Subject: | ctx_request |
I encounter the bug...
t/01app-fail.t
------------
use strict;
use Test::More 'no_plan';
BEGIN { use_ok 'Catalyst::Test', 'TestApp' }
ok( get('/') );
my ($res, $c) = ctx_request('/');
isa_ok($res, "HTTP::Response");
isa_ok($c, "Catalyst"); # fail!
t/01app-success.t
------------
use strict;
use Test::More 'no_plan';
BEGIN { use_ok 'Catalyst::Test', 'TestApp' }
my ($res, $c) = ctx_request('/');
isa_ok($res, "HTTP::Response");
isa_ok($c, "Catalyst"); # success!
ok( get('/') );
I traced with cluck().
Catalyst::dispatch('TestApp=HASH(0xd15284)') called at
/Library/Perl/5.8.8/Catalyst/Plugin/Static/Simple.pm line 68
Catalyst::Plugin::Static::Simple::dispatch('TestApp=HASH(0xd15284)')
called at
/Users/bokutin/scribble/Catalyst-Runtime-5.80004/lib/Catalyst.pm line 1804
eval {...} called at
/Users/bokutin/scribble/Catalyst-Runtime-5.80004/lib/Catalyst.pm line 1795
Catalyst::handle_request('TestApp') called at
/Users/bokutin/scribble/Catalyst-Runtime-5.80004/lib/Catalyst/Test.pm
line 229
Catalyst::Test::local_request('TestApp', '/') called at
/Users/bokutin/scribble/Catalyst-Runtime-5.80004/lib/Catalyst/Test.pm
line 28
Catalyst::Test::__ANON__('/') called at
/Users/bokutin/scribble/Catalyst-Runtime-5.80004/lib/Catalyst/Test.pm
line 61
Catalyst::Test::__ANON__('/') called at t/subsession/01app.t line 23
mbp bokutin % diff -C 10 lib/Catalyst/Test.pm.orig lib/Catalyst/Test.pm
*** lib/Catalyst/Test.pm.orig 2009-05-29 19:04:01.000000000 +0900
--- lib/Catalyst/Test.pm 2009-05-29 19:03:40.000000000 +0900
***************
*** 48,67 ****
--- 48,68 ----
### hook into 'dispatch' -- the function gets called after all
plugins
### have done their work, and it's an easy place to capture $c.
my $meta = Catalyst->meta;
$meta->make_mutable;
$meta->add_after_method_modifier( "dispatch", sub {
$c = shift;
});
$meta->make_immutable;
+ Class::C3::reinitialize();
### 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->( @_ );
### return both values
return ( $res, $c );
};
return {