From: Christian Hansen Date: Wed, 23 Mar 2005 03:49:40 +0000 (+0000) Subject: updated C::Test and documented changes X-Git-Tag: 5.7099_04~1720 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b6898a9f489a6e5946a4640ec049ada70f47a48a updated C::Test and documented changes --- diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index ff4437c..97de28f 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -22,8 +22,25 @@ Catalyst::Test - Test Catalyst applications request('index.html'); get('index.html'); - # Request - perl -MCatalyst::Test=MyApp -e1 index.html + # Tests with inline apps need to use Catalyst::Engine::Test + package TestApp; + + use Catalyst qw[-Engine=Test]; + + __PACKAGE__->action( + foo => sub { + my ( $self, $c ) = @_; + $c->res->output('bar'); + } + ); + + package main; + + use Test::More tests => 1; + use Catalyst::Test 'TestApp'; + + ok( get('/foo') =~ /bar/ ); + =head1 DESCRIPTION @@ -45,15 +62,6 @@ Returns a C object. =cut -{ - no warnings; - CHECK { - if ( ( caller(0) )[1] eq '-e' ) { - print request( $ARGV[0] || 'http://localhost' )->content; - } - } -} - sub import { my $self = shift; if ( $class = shift ) { @@ -63,13 +71,6 @@ sub import { } no strict 'refs'; - - unless ( $class->engine->isa('Catalyst::Engine::Test') ) { - require Catalyst::Engine::Test; - splice( @{"$class\::ISA"}, @{"$class\::ISA"} - 1, - 0, 'Catalyst::Engine::Test' ); - } - my $caller = caller(0); *{"$caller\::request"} = sub { $class->run(@_) }; *{"$caller\::get"} = sub { $class->run(@_)->content };