14a7a3122b9220b9643313c0d71b6017c34e752e
[catagits/Web-Simple.git] / t / sub-dispatch-env.t
1 use strictures 1;
2 use Test::More;
3
4 {
5   package TestApp;
6
7   use Web::Simple;
8
9   sub dispatch_request {
10     sub (/foo/...) {
11       sub (GET) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
12     },
13     sub (POST) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
14   }
15 }
16
17 my $app = TestApp->new->to_psgi_app;
18
19 my $call = sub { $app->({
20   SCRIPT_NAME => '/base', PATH_INFO => '/foo/bar', REQUEST_METHOD => shift
21 })->[2]->[0] };
22
23 is($call->('GET'), '/bar', 'recursive strip ok');
24 is($call->('POST'), '/foo/bar', 'later dispatchers unaffected');
25
26 done_testing;