X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_regexp.t;h=4d4500e22ea13811a57be8e5ec8b42537161671a;hb=f3414019f472b55682ef3af53f761b6db7955887;hp=c50245688de732dd90931f995f2f744c2802ae8f;hpb=6b25e5554ead493893b5bf164bfde1f58f0730e5;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..4d4500e 100644 --- a/t/live_component_controller_action_regexp.t +++ b/t/live_component_controller_action_regexp.t @@ -10,9 +10,11 @@ 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'; +use Catalyst::Request; + if ( $ENV{CAT_BENCHMARK} ) { require Benchmark; Benchmark::timethis( $iters, \&run_tests ); @@ -61,4 +63,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' ); + } }