File: 02_flash.t

package info (click to toggle)
libdancer-plugin-flashmessage-perl 0.314-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: perl: 129; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (4)
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
use Test::More tests => 10, import => ['!pass'];
use Dancer ':syntax';
use Dancer::Test;

use_ok 'Dancer::Plugin::FlashMessage';

setting views => path('t', 'views');

ok(
    get '/nothing' => sub {
        template 'index', { };
    });
ok(
    get '/' => sub {
        flash(error => 'plop');
        template 'index', { foo => 'bar' };
    });
ok(
    get '/different' => sub {
        template 'index', { foo => 'bar' };
    }
);

# empty route
route_exists [ GET => '/nothing' ];
response_content_like( [ GET => '/nothing' ], qr/foo :\s*, message :\s*$/ );

# first time we get the error message
route_exists [ GET => '/' ];
response_content_like( [ GET => '/' ], qr/foo : bar, message : plop$/ );
# second time the error has disappeared
route_exists [ GET => '/different' ];
response_content_like( [ GET => '/different' ], qr/foo : bar, message : \s*$/ );