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