X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_regexp.t;h=559167dbe5e158dce42ab807f96e9c329e1e8b14;hb=cccc8f68ace5d11c3fdcbfc4e353225b3b574255;hp=c50245688de732dd90931f995f2f744c2802ae8f;hpb=cb69249ef4c0f2c88ec4361b46be37d473402153;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_regexp.t b/t/live_component_controller_action_regexp.t index c502456..559167d 100644 --- a/t/live_component_controller_action_regexp.t +++ b/t/live_component_controller_action_regexp.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 12*$iters; +use Test::More tests => 28*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -61,4 +61,44 @@ sub run_tests { 'Content is a serialized Catalyst::Request' ); } + + { + ok( my $response = request('http://localhost/action/regexp/mandatory'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + '^action/regexp/(mandatory)(/optional)?$', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Regexp', + 'Test Class' + ); + my $content = $response->content; + my $req = eval $content; + + is( scalar @{ $req->captures }, 2, 'number of captures' ); + is( $req->captures->[ 0 ], 'mandatory', 'mandatory capture' ); + ok( !defined $req->captures->[ 1 ], 'optional capture' ); + } + + { + ok( my $response = request('http://localhost/action/regexp/mandatory/optional'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + '^action/regexp/(mandatory)(/optional)?$', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Regexp', + 'Test Class' + ); + my $content = $response->content; + my $req = eval $content; + + is( scalar @{ $req->captures }, 2, 'number of captures' ); + is( $req->captures->[ 0 ], 'mandatory', 'mandatory capture' ); + is( $req->captures->[ 1 ], '/optional', 'optional capture' ); + } }