failing test for hashref bubbling to response_filter
[catagits/Web-Simple.git] / t / hashref_bubbling.t
CommitLineData
787cf3ef 1use Web::Simple 'TestApp';
2use 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
22my $res = TestApp->new->run_test_request(GET => '/?foo=bar');
23is($res->content, '{"hash":"boo"}', 'raw hashref passed to response_filter');
24
25my $res2 = TestApp->new->run_test_request(POST => '/?foo=bar');
26is($res2->content, '{"hash":"what"}', 'blessed hash gets passed to response_filter');
27
28done_testing;