From: Thomas Sibley Date: Mon, 7 Apr 2014 19:38:50 +0000 (-0700) Subject: Test that (GET+/foo)|(POST+/foo) works X-Git-Tag: v0.021~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=965732b4ae93d6ba933d867d5329d7694ec91596 Test that (GET+/foo)|(POST+/foo) works Currently the dispatch parser throws an error about not finding a closing paren. --- diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index b63dac2..b6e0317 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -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 },