File: 02_load_app.t

package info (click to toggle)
libdancer-perl 1.3202%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,408 kB
  • ctags: 638
  • sloc: perl: 7,215; xml: 1,977; sh: 51; makefile: 29; sql: 5
file content (42 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (3)
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
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";

my $main     = Dancer::App->get('main');
my $test_app = Dancer::App->get('TestApp');
my $forum    = Dancer::App->get('Forum');

ok defined($main), "app 'main' is defined";
ok defined($test_app), "app 'TestApp' is defined";
ok defined($forum), "app 'Forum' is defined";

is @{ $main->registry->routes->{'get'} }, 1, 
    "one route is defined in main app";

is @{ $test_app->registry->routes->{'get'} }, 15, 
    "15 routes are defined in test app";

is @{ $forum->registry->routes->{'get'} }, 5, 
    "5 routes are defined in forum app";

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";