Debian Codegraph @

t/vars.t

raw
1 use strict;
2 use warnings;
3 use Test::More import => ['!pass'];
4 use Plack::Test;
5 use HTTP::Request::Common;
6 use Ref::Util qw<is_coderef>;
7
8 plan tests => 3;
9
10 {
11 use Dancer2;
12
13 hook before => sub {
14 var( "xpto" => "foo" );
15 vars->{zbr} = 'ugh';
16 };
17
18 get '/bar' => sub {
19 var("xpto");
20 };
21
22 get '/baz' => sub {
23 vars->{zbr};
24 };
25 }
26
27 my $app = __PACKAGE__->to_app;
28 ok( is_coderef($app), 'Got app' );
29
30 test_psgi $app, sub {
31 my $cb = shift;
32
33 is( $cb->( GET '/bar' )->content, 'foo', 'foo' );
34 is( $cb->( GET '/baz' )->content, 'ugh', 'ugh' );
35 };