File: basic.t

package info (click to toggle)
libplack-perl 0.9989-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,556 kB
  • sloc: perl: 6,890; python: 6; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (8)
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 Plack::Test;
use Test::More;

use Plack::App::Cascade;
use Plack::App::File;
use HTTP::Request::Common;

my $cascade = Plack::App::Cascade->new;

test_psgi $cascade, sub {
    my $cb = shift;
    $res = $cb->(GET "http://localhost/");
    is $res->code, 404;
};

$cascade->add( Plack::App::File->new(root => "t/Plack-Middleware")->to_app );
$cascade->add( Plack::App::File->new(root => "t/Plack-Util")->to_app );
$cascade->add( sub { [ 404, [], [ 'Custom 404 Page' ] ] } );

test_psgi $cascade, sub {
    my $cb = shift;

    my $res = $cb->(GET "http://localhost/access_log.t");
    is $res->code, 200;

    $res = $cb->(GET "http://localhost/foo");
    is $res->code, 404;
    is $res->content, 'Custom 404 Page';

    $res = $cb->(GET "http://localhost/foreach.t");
    is $res->code, 200;
};

done_testing;