1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
use strict;
use warnings;
use Test::More import => ['!pass'];
use Dancer ':syntax';
use Dancer::Test;
use lib 't/lib';
use FindBin qw($Bin);
use lib "$Bin/../../";
plan tests => 6;
use LinkBlocker;
ok(
get(
'/test' => sub {
return 'index';
}
),
'index route is defined'
);
route_exists [ GET => '/test' ];
response_content_is( [ GET => '/test' ], 'no content' );
response_status_is( [ GET => '/test' ], 202 );
# home-made hooks (test taken from Dancer 2)
my $counter = 0;
{
use Dancer;
use t::lib::Hookee;
hook 'start_hookee' => sub {
'hook for plugin';
};
get '/hooks_plugin' => sub {
$counter++;
some_keyword();
};
}
is $counter, 0, "the hook has not been executed";
my $r = dancer_response(GET => '/hooks_plugin');
is $counter, 1, "the hook has been executed exactly once";
|