fix for response_filter regression and matching test
[catagits/Web-Simple.git] / t / response-filter.t
CommitLineData
16c72d23 1use strict;
2use warnings FATAL => 'all';
3
4use Test::More;
5use Plack::Test;
6use HTTP::Request::Common qw(GET POST);
7
8{
9 package t::Web::Simple::ResponseFilter;
10 use Web::Simple;
11 sub dispatch_request {
12 my $self = shift;
13 sub (.html) {
14 response_filter {
15 return [
16 200,
17 [ 'Content-Type' => 'text/html' ],
18 [ shift->{name} ],
19 ];
20 };
21 },
22 sub (GET + /index) {
23 bless {name=>'john'}, 'CrazyHotWildWet';
24 },
25 }
26}
27
28ok my $app = t::Web::Simple::ResponseFilter->new->to_psgi_app,
29 'Got a plack app';
30
31test_psgi $app, sub {
32 my $cb = shift;
33 my $res = $cb->(GET "/index.html");
34 like $res->content, qr/john/,
35 'Got Expected Content';
36};
37
38done_testing;