fix environment changes within subdispatch and arrange for middleware to uplevel...
[catagits/Web-Simple.git] / t / sub-dispatch-env.t
diff --git a/t/sub-dispatch-env.t b/t/sub-dispatch-env.t
new file mode 100644 (file)
index 0000000..14a7a31
--- /dev/null
@@ -0,0 +1,26 @@
+use strictures 1;
+use Test::More;
+
+{
+  package TestApp;
+
+  use Web::Simple;
+
+  sub dispatch_request {
+    sub (/foo/...) {
+      sub (GET) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
+    },
+    sub (POST) { [ 200, [], [ $_[PSGI_ENV]->{PATH_INFO} ] ] }
+  }
+}
+
+my $app = TestApp->new->to_psgi_app;
+
+my $call = sub { $app->({
+  SCRIPT_NAME => '/base', PATH_INFO => '/foo/bar', REQUEST_METHOD => shift
+})->[2]->[0] };
+
+is($call->('GET'), '/bar', 'recursive strip ok');
+is($call->('POST'), '/foo/bar', 'later dispatchers unaffected');
+
+done_testing;