Added index tests, 2 are failing
Andy Grundman [Sat, 22 Oct 2005 13:49:06 +0000 (13:49 +0000)]
t/live/component/controller/action/index.t [new file with mode: 0644]
t/live/lib/TestApp.pm
t/live/lib/TestApp/Controller/Action/Index.pm [new file with mode: 0644]

diff --git a/t/live/component/controller/action/index.t b/t/live/component/controller/action/index.t
new file mode 100644 (file)
index 0000000..738e422
--- /dev/null
@@ -0,0 +1,36 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../../../lib";
+
+use Test::More tests => 10;
+use Catalyst::Test 'TestApp';
+    
+for ( 1 .. 1 ) {
+    # test root index
+    {
+        ok( my $response = request('http://localhost/'), 'root index' );
+        is( $response->content, 'root index', 'root index ok' );
+        
+        ok( $response = request('http://localhost'), 'root index no slash' );
+        is( $response->content, 'root index', 'root index no slash ok' );
+    }
+    
+    # test controller index
+    {
+        ok( my $response = request('http://localhost/action/index/'), 'controller index' );
+        is( $response->content, 'Action::Index index', 'controller index ok' );
+        
+        ok( $response = request('http://localhost/action/index'), 'controller index no slash' );
+        is( $response->content, 'Action::Index index', 'controller index no slash ok' );        
+    }
+    
+    # test controller default when index is present
+    {
+        ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
+        is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );
+    }
+}
index 8227622..95d77e2 100644 (file)
@@ -10,6 +10,11 @@ TestApp->config( name => 'TestApp', root => '/some/dir' );
 
 TestApp->setup;
 
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->body( 'root index' );
+}
+
 sub global_action : Private {
     my ( $self, $c ) = @_;
     $c->forward('TestApp::View::Dump::Request');
diff --git a/t/live/lib/TestApp/Controller/Action/Index.pm b/t/live/lib/TestApp/Controller/Action/Index.pm
new file mode 100644 (file)
index 0000000..d6b2ada
--- /dev/null
@@ -0,0 +1,11 @@
+package TestApp::Controller::Action::Index;
+
+use strict;
+use base 'TestApp::Controller::Action';
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->body( 'Action::Index index' );
+}
+
+1;