Convert from Ubuntu to Debian 5 live CD as the recommended way to do the tutorial...
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Tutorial / Testing.pod
index 92c6311..25acec4 100644 (file)
@@ -77,10 +77,10 @@ directory, enter:
 
     $ prove --lib lib t
 
-There will be a lot of output because we have the C<-Debug> flag enabled 
-in C<lib/MyApp.pm> (see the C<CATALYST_DEBUG=0> tip below for a quick 
-and easy way to reduce the clutter). Look for lines like this for 
-errors:
+There will be a lot of output because we have the C<-Debug> flag 
+enabled in C<lib/MyApp.pm> (see the C<CATALYST_DEBUG=0> tip below for 
+a quick and easy way to reduce the clutter).  Look for lines like this 
+for errors:
 
     #   Failed test 'Request should succeed'
     #   in t/controller_Books.t at line 8.
@@ -90,7 +90,7 @@ The redirection used by the Authentication plugins will cause several
 failures in the default tests.  You can fix this by making the following
 changes:
 
-1) Change the line in C<t/01app.t> that read:
+1) Change the line in C<t/01app.t> that reads:
 
     ok( request('/')->is_success, 'Request should succeed' );
 
@@ -98,11 +98,13 @@ to:
 
     ok( request('/login')->is_success, 'Request should succeed' );
 
-2) Change the C<request('/logout')-E<gt>is_success> to 
-C<request('/logout')-E<gt>is_redirect> in C<t/controller_Logout.t>.
+2) Change the "C<request('/logout')-E<gt>is_success>" to 
+"C<request('/logout')-E<gt>is_redirect>" in C<t/controller_Logout.t>.
 
-3) Change the C<request('/books')-E<gt>is_success> to 
-C<request('/books')-E<gt>is_redirect> in C<t/controller_Books.t>.
+3) Change the "C<request('/books')-E<gt>is_success>" to 
+"C<request('/books')-E<gt>is_redirect>" in C<t/controller_Books.t>.
+
+4) Add "C<use MyApp;>" to the top of C<t/view_TT.t>.
 
 As you can see in the C<prove> command line above, the C<--lib> option
 is used to set the location of the Catalyst C<lib> directory.  With this
@@ -210,7 +212,7 @@ editor and enter the following:
         "Check we ARE logged in" ) for $ua1, $ua2;
     
     # 'Click' the 'Logout' link (see also 'text_regex' and 'url_regex' options)
-    $_->follow_link_ok({n => 1}, "Logout via first link on page") for $ua1, $ua2;
+    $_->follow_link_ok({n => 4}, "Logout via first link on page") for $ua1, $ua2;
     $_->title_is("Login", "Check for login title") for $ua1, $ua2;
     $_->content_contains("You need to log in to use this application",
         "Check we are NOT logged in") for $ua1, $ua2;
@@ -227,7 +229,7 @@ editor and enter the following:
     
     $_->content_contains("Book List", "Check for book list title") for $ua1, $ua2;
     # Make sure the appropriate logout buttons are displayed
-    $_->content_contains("/logout\">Logout</a>",
+    $_->content_contains("/logout\">User Logout</a>",
         "Both users should have a 'User Logout'") for $ua1, $ua2;
     $ua1->content_contains("/books/form_create\">Create</a>",
         "Only 'test01' should have a create link");
@@ -319,6 +321,12 @@ failed test:
 
 This will cause the full HTML returned by the request to be displayed.
 
+Another approach to see the full HTML content at the failure point in 
+a series of tests would be to insert a "C<$DB::single=1;> right above 
+the location of the failure and run the test under the perl debugger 
+(with C<-d>) as shown above.  Then you can use the debugger to explore 
+the state of the application right before or after the failure.
+
 
 =head1 SUPPORTING BOTH PRODUCTION AND TEST DATABASES
 
@@ -357,7 +365,7 @@ Kennedy Clark, C<hkclark@gmail.com>
 
 Please report any errors, issues or suggestions to the author.  The
 most recent version of the Catalyst Tutorial can be found at
-L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
+L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/>.
 
 Copyright 2006-2008, Kennedy Clark, under Creative Commons License
 (L<http://creativecommons.org/licenses/by-sa/3.0/us/>).