Commit | Line | Data |
787cf3ef |
1 | use Web::Simple 'TestApp'; |
2 | use Test::More; |
3 | { |
4 | package TestApp; |
5 | use JSON; |
6 | |
7 | sub dispatch_request { |
8 | sub () { |
9 | response_filter { |
10 | [200, ['Content-Type', 'application/json'], [encode_json {%{$_[0]}}]]; |
11 | } |
12 | }, |
13 | sub (GET) { |
14 | { hash => 'boo' } |
15 | }, |
16 | sub (POST) { |
17 | bless { hash => 'what' }, 'what'; |
18 | } |
19 | } |
20 | } |
21 | |
22 | my $res = TestApp->new->run_test_request(GET => '/?foo=bar'); |
23 | is($res->content, '{"hash":"boo"}', 'raw hashref passed to response_filter'); |
24 | |
25 | my $res2 = TestApp->new->run_test_request(POST => '/?foo=bar'); |
26 | is($res2->content, '{"hash":"what"}', 'blessed hash gets passed to response_filter'); |
27 | |
28 | done_testing; |