Test that (GET+/foo)|(POST+/foo) works
Thomas Sibley [Mon, 7 Apr 2014 19:38:50 +0000 (12:38 -0700)]
Currently the dispatch parser throws an error about not finding a
closing paren.

t/dispatch_parser.t

index b63dac2..b6e0317 100644 (file)
@@ -214,6 +214,30 @@ my $dp = Web::Dispatch::Parser->new;
 }
 
 {
+  my $spec = '(GET+/foo)|(POST+/foo)';
+  my $nest = $dp->parse($spec);
+
+  for my $method (qw( GET POST )) {
+      is_deeply(
+        [ $nest->({ PATH_INFO => '/foo', REQUEST_METHOD => $method }) ],
+        [ {} ],
+        "$spec matches $method /foo"
+      );
+      is_deeply(
+        [ $nest->({ PATH_INFO => '/bar', REQUEST_METHOD => $method }) ],
+        [],
+        "$spec does not match $method /bar"
+      );
+  }
+
+  is_deeply(
+    [ $nest->({ PATH_INFO => '/foo', REQUEST_METHOD => 'PUT' }) ],
+    [],
+    "$spec does not match PUT /foo"
+  );
+}
+
+{
   local $@;
   ok(
     !eval { $dp->parse('/foo+(GET'); 1 },