X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fresponse-filter.t;fp=t%2Fresponse-filter.t;h=c03ccd369621220281f9b725f6bd7387d1d4e12d;hb=16c72d232d9b3bf1b55cbb944aa1e97e383360df;hp=0000000000000000000000000000000000000000;hpb=b6bf9ed3faa4fead683ce3c301a4342cd0930fda;p=catagits%2FWeb-Simple.git diff --git a/t/response-filter.t b/t/response-filter.t new file mode 100644 index 0000000..c03ccd3 --- /dev/null +++ b/t/response-filter.t @@ -0,0 +1,38 @@ +use strict; +use warnings FATAL => 'all'; + +use Test::More; +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;