File: 18_auto_page.t

package info (click to toggle)
libdancer-perl 1.3521%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,460 kB
  • sloc: perl: 7,436; xml: 2,211; sh: 54; makefile: 32; sql: 5
file content (33 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (6)
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
# this test makes sure the auto_page feature works as expected
# whenever a template matches a requested path, a default route handler 
# takes care of rendering it.
use strict;
use warnings;
use Test::More import => ['!pass'], tests => 8;
use Dancer::Test;

{
    package Foo;
    use Dancer;

    hook before_template => sub {
        my $tokens = shift;
        $tokens->{title} = "Dancer";
    };

    set auto_page => true, views => path(dirname(__FILE__), 'views');

    get '/' => sub { 1 };
}

response_status_is  [GET => '/hello'] => 200, "response found for /hello";
response_content_is [GET => '/hello'] => "Hello\n", "content looks good";

response_status_is  [GET => '/foo/bar' ], 200, "response found for /foo/bar";
response_content_is [GET => '/foo/bar' ], "foo/bar\n", "content looks good";

response_status_is  [GET => '/foo/' ], 200, "response found for /foo/";
response_content_is [GET => '/foo/' ], "foo/index\n", "content looks good";

response_status_is  [GET => '/falsepage'] => 404;
response_content_like [GET => '/error'] => qr/ERROR: Dancer\n/, "error page looks OK";