failing test for hashref bubbling to response_filter filter_hashref
Matt Phillips [Fri, 20 Sep 2013 21:43:24 +0000 (17:43 -0400)]
t/hashref_bubbling.t [new file with mode: 0644]

diff --git a/t/hashref_bubbling.t b/t/hashref_bubbling.t
new file mode 100644 (file)
index 0000000..ad3ff60
--- /dev/null
@@ -0,0 +1,28 @@
+use Web::Simple 'TestApp';
+use Test::More;
+{
+  package TestApp;
+  use JSON;
+
+    sub dispatch_request {
+    sub () {
+      response_filter {
+        [200, ['Content-Type', 'application/json'], [encode_json {%{$_[0]}}]];
+      }
+    },
+    sub (GET) {
+      { hash => 'boo' }
+    },
+    sub (POST) {
+      bless { hash => 'what' }, 'what';
+    }
+  }
+}
+
+my $res = TestApp->new->run_test_request(GET => '/?foo=bar');
+is($res->content, '{"hash":"boo"}', 'raw hashref passed to response_filter');
+
+my $res2 = TestApp->new->run_test_request(POST => '/?foo=bar');
+is($res2->content, '{"hash":"what"}', 'blessed hash gets passed to response_filter');
+
+done_testing;