Added test for optional :Args when using :ChildOf
Matt S Trout [Thu, 22 Jun 2006 14:51:49 +0000 (14:51 +0000)]
r10064@cain (orig r4395):  phaylon | 2006-06-17 20:09:39 +0000

t/lib/TestApp/Controller/Action/ChildOf.pm
t/live_component_controller_action_childof.t

index 8370582..5f91d88 100644 (file)
@@ -73,6 +73,11 @@ sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { }
 sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { }
 sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { }
 
+#
+#   Optional specification of :Args in endpoint
+#
+sub opt_args :PathPart('childof/opt_args') :ChildOf('/') { }
+
 sub end :Private {
   my ($self, $c) = @_;
   my $out = join('; ', map { join(', ', @$_) }
index 4c32a15..8ae78d2 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
 
-use Test::More tests => 57*$iters;
+use Test::More tests => 60*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -405,4 +405,24 @@ sub run_tests {
             $expected, 'Executed actions' );
         is( $response->content, '1; 2; 3', 'Content OK' );
     }
+
+    #
+    #   The :Args attribute is optional, we check the action not specifying
+    #   it with these tests.
+    #
+    {
+        my @expected = qw[
+          TestApp::Controller::Action::ChildOf->begin
+          TestApp::Controller::Action::ChildOf->opt_args
+          TestApp::Controller::Action::ChildOf->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/childof/opt_args/1/2/3'),
+            'Optional :Args attribute working' );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+        is( $response->content, '; 1, 2, 3', 'Content OK' );
+    }
 }