aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/tutorial
diff options
context:
space:
mode:
authorDanS2013-10-17 07:05:28 -0700
committerPete Bacon Darwin2013-10-25 22:03:10 +0100
commitc1e6afca11061c5c5d7570a04825f98ce1994a88 (patch)
tree4c2e0e5eb00e6855d098b1aedc20a84532ead585 /docs/content/tutorial
parent280354c3f948b77a116225d9b5099dadaeaf75b3 (diff)
downloadangular.js-c1e6afca11061c5c5d7570a04825f98ce1994a88.tar.bz2
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
Diffstat (limited to 'docs/content/tutorial')
-rw-r--r--docs/content/tutorial/step_02.ngdoc11
1 files changed, 8 insertions, 3 deletions
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`:__
<pre>
describe('PhoneCat controllers', function() {
+ beforeEach(module('phonecatApp'));
describe('PhoneListCtrl', function(){
@@ -171,6 +173,9 @@ describe('PhoneCat controllers', function() {
});
</pre>
+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