Commit | Line | Data |
16c72d23 |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | |
4 | use Test::More; |
5 | use Plack::Test; |
6 | use 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 | |
28 | ok my $app = t::Web::Simple::ResponseFilter->new->to_psgi_app, |
29 | 'Got a plack app'; |
30 | |
31 | test_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 | |
38 | done_testing; |