| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
use Test::Fatal; |
| 5 |
use Plack::Test; |
| 6 |
use HTTP::Request::Common; |
| 7 |
|
| 8 |
{ |
| 9 |
## no critic |
| 10 |
package TestApp; |
| 11 |
use Dancer2; |
| 12 |
|
| 13 |
my $app = app; |
| 14 |
hook before_template => sub { |
| 15 |
1; |
| 16 |
}; |
| 17 |
|
| 18 |
set template => 'tiny'; |
| 19 |
|
| 20 |
get '/' => sub { |
| 21 |
template t => { hi => 'hello' }, |
| 22 |
}; |
| 23 |
}; |
| 24 |
|
| 25 |
my $test = Plack::Test->create( TestApp->to_app ); |
| 26 |
|
| 27 |
my $res; |
| 28 |
is( |
| 29 |
exception { $res = $test->request( GET '/' ); }, |
| 30 |
undef, |
| 31 |
'Request does not crash', |
| 32 |
); |
| 33 |
|
| 34 |
ok( $res->is_success, 'Request successful' ); |
| 35 |
|
| 36 |
chomp( my $content = $res->content ); |
| 37 |
is( $content, 'hello', 'Correct content' ); |
| 38 |
|
| 39 |
done_testing; |