From c1e6afca11061c5c5d7570a04825f98ce1994a88 Mon Sep 17 00:00:00 2001 From: DanS Date: Thu, 17 Oct 2013 07:05:28 -0700 Subject: docs(tutorial/step-2): add beforeEach to load module The non-global controller test throws an error because the test does not know about the module and so can not find the controller. This change tells the test about the module so the test can find the controller. Closes #4489 --- docs/content/tutorial/step_02.ngdoc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docs/content/tutorial/step_02.ngdoc') diff --git a/docs/content/tutorial/step_02.ngdoc b/docs/content/tutorial/step_02.ngdoc index cfa45ee2..d607ec76 100644 --- a/docs/content/tutorial/step_02.ngdoc +++ b/docs/content/tutorial/step_02.ngdoc @@ -151,13 +151,15 @@ Angular. Since testing is such a critical part of software development, we make tests in Angular so that developers are encouraged to write them. ### Testing non-Global Controllers -In practice, you will not want to have your controller functions in the global namespace. In this -case Angular provides a service, `$controller`, which will retrieve your controller by name. Here -is the same test using `$controller`: +In practice, you will not want to have your controller functions in the global namespace. Instead, +we have registered our controllers in the `phonecatApp` module. In this case Angular provides a +service, `$controller`, which will retrieve your controller by name. Here is the same test using +`$controller`: __`test/unit/controllersSpec.js`:__
describe('PhoneCat controllers', function() {
+ beforeEach(module('phonecatApp'));
describe('PhoneListCtrl', function(){
@@ -171,6 +173,9 @@ describe('PhoneCat controllers', function() {
});
+Don't forget that we need to load up the `phonecatApp` module into the test so that the controller
+is available to be injected.
+
### Writing and Running Tests
Angular developers prefer the syntax of Jasmine's Behavior-driven Development (BDD) framework when
writing tests. Although Angular does not require you to use Jasmine, we wrote all of the tests in
--
cgit v1.2.3