X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=911878299bbb171cf46889788cf8686a10d523f4;hp=b8855d60f430bd1701e587b743be20d47e0f7eb1;hb=85f0a66f2b5de7a028ed0e4960435784baff4a37;hpb=51a75afc729b5071433eb7dbfd511854a160c45e diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index b8855d6..9118782 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -38,19 +38,24 @@ my $build_exports = sub { Catalyst::Exception->throw("$me only works with local requests, not remote") if $ENV{CATALYST_SERVER}; + ### check explicitly for the class here, or the Cat->meta call will blow + ### up in our face + Catalyst::Exception->throw("Must specify a test app: use Catalyst::Test 'TestApp'") unless $class; + ### place holder for $c after the request finishes; reset every time ### requests are done. my $c; ### hook into 'dispatch' -- the function gets called after all plugins ### have done their work, and it's an easy place to capture $c. - no warnings 'redefine'; - my $dispatch = Catalyst->can('dispatch'); - local *Catalyst::dispatch = sub { - $c = shift; - $dispatch->( $c, @_ ); - }; + my $meta = Catalyst->meta; + $meta->make_mutable; + $meta->add_after_method_modifier( "dispatch", sub { + $c = shift; + }); + $meta->make_immutable; + ### do the request; C::T::request will know about the class name, and ### we've already stopped it from doing remote requests above. my $res = $request->( @_ ); @@ -168,7 +173,7 @@ specific testing methods as displayed in the method section. The L and L functions take either a URI or an L object. -=head2 METHODS +=head1 METHODS =head2 $content = get( ... )