Dancer-Plugin-BeforeRoute
view release on metacpan or search on metacpan
t/dancer2/02-check-method-and_path.t view on Meta::CPAN
use strict;
use warnings;
use lib "t/dancer2/lib";
use HTTP::Request::Common;
use Plack::Test;
use TestApp;
use Test::More;
my $app = Plack::Test->create( TestApp->to_app );
is $app->request( GET '/' )->content, "homepage";
is $app->request( GET '/foo' )->content, "foo", "Test string path";
is $app->request( GET "/foo/baz" )->content, "baz", "Test token path";
is $app->request( POST "/bar" )->content, "bar", "Test regexp";
is $app->request( POST "/baz" )->code, 404, "Not found";
t/dancer2/04-any.t view on Meta::CPAN
use strict;
use warnings;
## Test Frameworks
use Test::More import => ["!pass"]; # last test to print
use Plack::Test;
use HTTP::Request::Common;
## Setup Dancer2 Testing Routes
{
package MyApp;
use Dancer2;
set logger => "console";
set log => "error";
set show_errors => 1;
t/dancer2/04-any.t view on Meta::CPAN
return var "here";
};
}
## Start test
my $app = Plack::Test->create( MyApp->to_app );
my @testing_methods = map { uc } qw( get post put delete);
METHOD: foreach my $method (@testing_methods) {
is $app->request( HTTP::Request::Common->can($method)->('/here') )->content,
1, "set var in before route with $method method";
is $app->request( HTTP::Request::Common->can($method)->('/there') )->content,
q{},
"try to access other route to access /here before route set var with $method method";
}
done_testing;
t/dancer2/05-head.t view on Meta::CPAN
use strict;
use warnings;
## Test Frameworks
use Test::More import => ["!pass"], tests => 2; # last test to print
use HTTP::Request::Common;
use Plack::Test;
## Setup dancer routes
{
package MyApp;
use Dancer2 qw(:syntax);
## Module to be tested
use Dancer2::Plugin::BeforeRoute;
( run in 0.320 second using v1.01-cache-2.11-cpan-de7293f3b23 )