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
|
use strictures 1;
use Test::More 0.88;
use Plack::Test;
use HTTP::Request::Common qw(GET POST);
{
package t::Web::Simple::ResponseFilter;
use Web::Simple;
sub dispatch_request {
my $self = shift;
sub (.html) {
response_filter {
return [
200,
[ 'Content-Type' => 'text/html' ],
[ shift->{name} ],
];
}
},
sub (GET + /index) {
bless {name=>'john'}, 'CrazyHotWildWet';
},
}
}
ok my $app = t::Web::Simple::ResponseFilter->new->to_psgi_app,
'Got a plack app';
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->(GET "/index.html");
like $res->content, qr/john/,
'Got Expected Content';
};
done_testing;
|