forked from PerlDancer/Dancer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test for the any keyword in route handler defintions
- Loading branch information
Alexis Sukrieh
committed
Jan 5, 2010
1 parent
15c2b30
commit 526acfb
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |