diff options
author | franck cuny <franck@lumberjaph.net> | 2010-11-24 11:18:53 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-11-24 11:19:15 +0100 |
commit | cc9ba73cdd6e17495a263c874c22d0d7592be6d2 (patch) | |
tree | 496db8a8c8278af23b11ded492410b435eae4475 | |
parent | add new method in test description file (diff) | |
download | net-http-spore-cc9ba73cdd6e17495a263c874c22d0d7592be6d2.tar.gz |
add new tests to check content-type value
-rw-r--r-- | t/spore-middleware/format-json.t | 17 |
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; |