X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdispatch_parser.t;h=b6e03172b520b77c77e322d446b201533ef4455c;hb=0bcd037f283addf0a239eb2b5d456e403682027b;hp=b63dac293a9f068bcc918569c8c0783fe9ead135;hpb=b54172e8e85b09c0de0b167f1b682af54f4d8379;p=catagits%2FWeb-Simple.git 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 },