X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fpsgi_utils.t;h=15afb9d11fd399170b8182bab03cc822a4f4fc19;hb=efa8265f59bbb8df5f80cc8ee54604acb72554be;hp=21f60046d728bd391ad4e3521f52a74f82f12dc4;hpb=9c7b676881de2255b45fdab5bfb71f58a5e6d236;p=catagits%2FCatalyst-Runtime.git diff --git a/t/psgi_utils.t b/t/psgi_utils.t index 21f6004..15afb9d 100644 --- a/t/psgi_utils.t +++ b/t/psgi_utils.t @@ -3,17 +3,40 @@ use strict; # Make it easier to mount PSGI apps under catalyst +my $psgi_app = sub { + my $req = Plack::Request->new(shift); + return [200,[],[$req->path]]; +}; + { - package MyApp::Controller::User; + package MyApp::Controller::Docs; + $INC{'MyApp/Controller/Docs.pm'} = __FILE__; use base 'Catalyst::Controller'; use Plack::Request; use Catalyst::Utils; - my $psgi_app = sub { - my $req = Plack::Request->new(shift); - return [200,[],[$req->path]]; - }; + sub name :Local { + my ($self, $c) = @_; + my $env = $c->Catalyst::Utils::env_at_action; + $c->res->from_psgi_response( + $psgi_app->($env)); + + } + + sub name_args :Local Args(1) { + my ($self, $c, $arg) = @_; + my $env = $c->Catalyst::Utils::env_at_action; + $c->res->from_psgi_response( + $psgi_app->($env)); + } + + package MyApp::Controller::User; + $INC{'MyApp/Controller/User.pm'} = __FILE__; + + use base 'Catalyst::Controller'; + use Plack::Request; + use Catalyst::Utils; sub local_example :Local { my ($self, $c) = @_; @@ -68,8 +91,6 @@ use strict; } } - $INC{'MyApp/Controller/User.pm'} = __FILE__; - package MyApp; use Catalyst; MyApp->setup; @@ -289,6 +310,26 @@ use Catalyst::Test 'MyApp'; is_deeply $c->req->args, [444]; } +{ + my ($res, $c) = ctx_request('/docs/name'); + is $c->action, 'docs/name'; + is $res->content, '/'; + is_deeply $c->req->args, []; +} + +{ + my ($res, $c) = ctx_request('/docs/name/111/222'); + is $c->action, 'docs/name'; + is $res->content, '/111/222'; + is_deeply $c->req->args, [111,222]; +} + +{ + my ($res, $c) = ctx_request('/docs/name_args/111'); + is $c->action, 'docs/name_args'; + is $res->content, '/111'; + is_deeply $c->req->args, [111]; +} done_testing();