Skip to content

Commit

Permalink
test for the any keyword in route handler defintions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Sukrieh committed Jan 5, 2010
1 parent 15c2b30 commit 526acfb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions t/03_route_handler/13_any_route_handler.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use Test::More import => ['!pass'];
use lib 't';
use TestUtils;

use Dancer;

ok( any(['get', 'delete'] => '/any_1' => sub {
"any_1"
}),
"route defined for 'get' and 'delete' methods" );

ok( any('/any_2' => sub {
"any_2"
}),
"route defined for 'get' and 'delete' methods" );

my @routes = (
{
methods => ['get', 'delete'],
path => '/any_1',
expected => 'any_1',
},
{
methods => ['get', 'delete', 'post', 'put'],
path => '/any_2',
expected => 'any_2',
}
);

foreach my $route (@routes) {
foreach my $method (@{ $route->{methods} }) {
my $cgi = TestUtils::fake_request($method => $route->{path});
Dancer::SharedData->cgi($cgi);
my $response = Dancer::Renderer::get_action_response();
ok(defined($response), "route handler found for method $method");
is $response->{content}, $route->{expected}, "response content is ok";
}
}

0 comments on commit 526acfb

Please sign in to comment.