summary refs log tree commit diff
path: root/t/spore-middleware
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-11-24 11:18:53 +0100
committerfranck cuny <franck@lumberjaph.net>2010-11-24 11:19:15 +0100
commitcc9ba73cdd6e17495a263c874c22d0d7592be6d2 (patch)
tree496db8a8c8278af23b11ded492410b435eae4475 /t/spore-middleware
parentadd new method in test description file (diff)
downloadnet-http-spore-cc9ba73cdd6e17495a263c874c22d0d7592be6d2.tar.gz
add new tests to check content-type value
Diffstat (limited to 't/spore-middleware')
-rw-r--r--t/spore-middleware/format-json.t17
1 files changed, 16 insertions, 1 deletions
diff --git a/t/spore-middleware/format-json.t b/t/spore-middleware/format-json.t
index 95d84c3..20dd1e9 100644
--- a/t/spore-middleware/format-json.t
+++ b/t/spore-middleware/format-json.t
@@ -7,14 +7,26 @@ use JSON;
 use Net::HTTP::Spore;
 
 my $content = { keys => [qw/1 2 3/] };
+my $payload = {user => 'foo'};
 
 my $mock_server = {
     '/show' => sub {
         my $req = shift;
+        is( $req->header('Accept'), 'application/json' );
         $req->new_response(
             200,
             [ 'Content-Type' => 'application/json' ],
-            JSON::encode_json( $content )
+            JSON::encode_json($content)
+        );
+    },
+    '/add' => sub {
+        my $req = shift;
+        is( $req->header('Content-Type'), 'application/json;' );
+        is_deeply( JSON::decode_json( $req->body ), $payload );
+        $req->new_response(
+            200,
+            [ 'Content-Type' => 'application/json' ],
+            JSON::encode_json($content)
         );
     },
 };
@@ -34,4 +46,7 @@ is $res->header('Content-Type'), 'application/json';
 my $req = $res->request;
 is $req->header('Accept'), 'application/json';
 
+$res = $client->add_user(payload => $payload);
+is $res->[0], 200;
+
 done_testing;