X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=2f91020494c15f48f94a36db77f4178278f6a5e7;hb=386777dc6439f150392cbca5da094803296d3640;hp=5fe2a0ca0d010b3b15ad81f900d74fa3a298438a;hpb=523d44ecdd184a0a56c8094c60fe545098e06cff;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index 5fe2a0c..2f91020 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -27,12 +27,12 @@ Catalyst::Test - Test Catalyst applications use Catalyst qw[-Engine=Test]; - __PACKAGE__->action( - foo => sub { + sub foo : Global { my ( $self, $c ) = @_; $c->res->output('bar'); - } - ); + } + + __PACKAGE__->setup(); package main; @@ -47,13 +47,15 @@ Test Catalyst applications. =head2 METHODS -=head3 get +=over 4 + +=item get Returns the content. my $content = get('foo/bar?test=1'); -=head3 request +=item request Returns a C object. @@ -74,10 +76,8 @@ sub import { else { $class->require; - - unless ( $INC{'Test/Builder.pm'} ) { - die qq/Couldn't load "$class", "$@"/ if $@; - } + my $error = $UNIVERSAL::require::ERROR; + die qq/Couldn't load "$class", "$error"/ if $@; $class->import; @@ -93,6 +93,12 @@ sub import { my $agent; +=item remote_request + +Do an actual remote rquest using LWP. + +=cut + sub remote_request { my $request = shift; @@ -100,7 +106,8 @@ sub remote_request { unless ( ref $request ) { - my $uri = ( $request =~ m/http/i ) + my $uri = + ( $request =~ m/http/i ) ? URI->new($request) : URI->new( 'http://localhost' . $request ); @@ -114,7 +121,7 @@ sub remote_request { my $server = URI->new( $ENV{CATALYST_SERVER} ); if ( $server->path =~ m|^(.+)?/$| ) { - $server->path("$1"); # need to be quoted + $server->path("$1"); # need to be quoted } $request->uri->scheme( $server->scheme ); @@ -124,7 +131,8 @@ sub remote_request { unless ($agent) { $agent = LWP::UserAgent->new( - # cookie_jar => {}, + + # cookie_jar => {}, keep_alive => 1, max_redirect => 0, timeout => 60, @@ -135,6 +143,8 @@ sub remote_request { return $agent->request($request); } +=back + =head1 SEE ALSO L.