X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdispatch_parser.t;h=0e6a732795292b1b709d5d7558275b2c3f5cef80;hb=c6ea9542edce47dd994df1e1243056d7a1c2e19c;hp=0a8b0cfd8b1d8d14b455b1034363421fd74c8f1a;hpb=44db8e762b9dc73b4938910a146327d79aa0a786;p=catagits%2FWeb-Simple.git diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index 0a8b0cf..0e6a732 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -40,6 +40,21 @@ is_deeply( '.xml does not match .html' ); +my $any_ext = $dp->parse_dispatch_specification('.*'); + +is_deeply( + [ $any_ext->({ PATH_INFO => '/foo/bar.html' }) ], + [ { PATH_INFO => '/foo/bar' }, 'html' ], + '.html matches .* and extension returned' +); + +is_deeply( + [ $any_ext->({ PATH_INFO => '/foo/bar' }) ], + [], + 'no extension does not match .*' +); + + my $slash = $dp->parse_dispatch_specification('/'); is_deeply( @@ -87,3 +102,20 @@ is_deeply( [], 'POST /post/one does not match' ); + +my $or = $dp->parse_dispatch_specification('GET|POST'); + +foreach my $meth (qw(GET POST)) { + + is_deeply( + [ $or->({ REQUEST_METHOD => $meth }) ], + [ {} ], + 'GET|POST matches method '.$meth + ); +} + +is_deeply( + [ $or->({ REQUEST_METHOD => 'PUT' }) ], + [], + 'GET|POST does not match PUT' +);