File: tt2.t

package info (click to toggle)
libmagpie-perl 1.141660-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 3,524 kB
  • ctags: 337
  • sloc: perl: 4,081; xml: 405; makefile: 26
file content (58 lines) | stat: -rw-r--r-- 1,359 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use strict;
use warnings;
use Test::More;
use Test::Requires qw{
    Template
};

use FindBin;
use lib "$FindBin::Bin/../lib";
use Plack::Test;
use Plack::Builder;
use Plack::Middleware::Magpie;
use HTTP::Request::Common;

my @params = my %params = (
    last_hotel        => 'Marriot',
    last_street       => 'Via Zapata',
    last_maiden       => 'Cook',
    first_middle_name => 'Curtis',
    first_pet         => 'Sasha',
    first_car         => 'Wrangler',
    appstate          => 'complete',
);

my $handler = builder {
    enable "Magpie",
        context  => {},
        pipeline => [
        'Magpie::Pipeline::TT2::Base',
        'Magpie::Pipeline::TT2::Output' =>
            { template_path => './t/htdocs/templates/moviename' }
        ];
};

test_psgi
    app    => $handler,
    client => sub {
    my $cb = shift;
    {
        my $res = $cb->( GET "http://localhost/" );
        like $res->content, qr/fabulous/;
        like $res->content, qr/input/;
        like $res->content, qr/submit/;
    }
    {
        my $res
            = $cb->( POST "http://localhost/?appstate=complete", \%params );
        my $body = $res->content;
        like $body, qr/Congratulations/;
        foreach my $key ( keys(%params) ) {
            next if $key eq 'appstate';
            like $body, qr/$params{$key}/;
        }
    }

    };

done_testing;