File: 02_load_app.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 (43 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download
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
use Test::More tests => 12, import => ['!pass'];
use strict;
use warnings;

use Dancer::Test;
use File::Spec;
use lib File::Spec->catdir( 't', 'lib' );

{
    use Dancer;

    load_app 'TestApp';
    load_app 'Forum', prefix => '/forum';

    get '/' => sub { "home" };
}

my $apps = [ Dancer::App->applications ];
is scalar(@$apps), 3, "3 applications exist";

for (
    { name => "main",    routes => 1  },
    { name => "TestApp", routes => 22 },
    { name => "Forum",   routes => 5  },
)
{
    my $app = Dancer::App->get($_->{name});
    ok(
        defined($app)
        , "app $_->{name} is defined",
    );
    is(
        @{ $app->registry->routes('get') },
        $_->{routes},
        "Expected number of get routes defined for " . $_->{name},
    );
}

response_content_is [GET => "/forum/index"], "forum index"; 
response_content_is [GET => "/forum/admin/index"], "admin index"; 
response_content_is [GET => "/forum/users/list"], "users list"; 
response_content_is [GET => "/forum/users/mods/list"], "mods list"; 
response_content_is [GET => "/forum/"], "root";