Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1131 from excentris/test-create-new-scope-controller
Browse files Browse the repository at this point in the history
fix(app): create new $scope for controller tests
  • Loading branch information
eddiemonge committed Jul 7, 2015
2 parents 3eb78fe + 76b213e commit 946bb1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions templates/coffeescript/spec/controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ describe 'Controller: <%= classedName %>Ctrl', ->

<%= classedName %>Ctrl = {}

scope = {}

# Initialize the controller and a mock scope
beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new()
<%= classedName %>Ctrl = $controller '<%= classedName %>Ctrl', {
# place here mocked dependencies
}
Expand Down
5 changes: 4 additions & 1 deletion templates/javascript/spec/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ describe('Controller: <%= classedName %>Ctrl', function () {
// load the controller's module
beforeEach(module('<%= scriptAppName %>'));

var <%= classedName %>Ctrl;
var <%= classedName %>Ctrl,
scope;

// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
<%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', {
$scope: scope
// place here mocked dependencies
});
}));
Expand Down

0 comments on commit 946bb1d

Please sign in to comment.