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=3b4d12511c59793e85feca1ac1b4a8c2c5f1a6ae;hp=49f7460e218368829083636faff4dd559f809fe2;hpb=a2e038a1e9cbc0f1ea32b7087e6b47efe3af082f;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_regexp.t b/t/live_component_controller_action_regexp.t index 49f7460..559167d 100644 --- a/t/live_component_controller_action_regexp.t +++ b/t/live_component_controller_action_regexp.t @@ -8,9 +8,9 @@ use lib "$FindBin::Bin/lib"; our $iters; -BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } +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' ); + } }