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=048f45ee23401c9f2fbe241639f2687c1e79f990;hp=f67d0f9f1df1d40b0ca74eba2ef359cd561a2c6f;hpb=50cc3183118f1056427ab314b84b91fd0d9e1383;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_regexp.t b/t/live_component_controller_action_regexp.t index f67d0f9..4d4500e 100644 --- a/t/live_component_controller_action_regexp.t +++ b/t/live_component_controller_action_regexp.t @@ -4,15 +4,17 @@ use strict; use warnings; use FindBin; -use lib "$FindBin::Bin/../../../lib"; +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'; +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' ); + } }