diff options
author | franck cuny <franck@lumberjaph.net> | 2010-09-15 16:11:09 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-09-15 16:11:09 +0200 |
commit | 697e5f20634ba1408a41453d760d19381a519435 (patch) | |
tree | 1dc164944e4a0c86789358b932bc3a76ec64203f /t/spore-middleware/format-json.t | |
parent | rewrite test using mocker (diff) | |
download | net-http-spore-697e5f20634ba1408a41453d760d19381a519435.tar.gz |
tests use the mocker
Diffstat (limited to 't/spore-middleware/format-json.t')
-rw-r--r-- | t/spore-middleware/format-json.t | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/t/spore-middleware/format-json.t b/t/spore-middleware/format-json.t index 3e3b59b..61a557f 100644 --- a/t/spore-middleware/format-json.t +++ b/t/spore-middleware/format-json.t @@ -6,18 +6,25 @@ use JSON; use Net::HTTP::Spore; +my $content = { keys => [qw/1 2 3/] }; + +my $mock_server = { + '/test_spore/_all_docs' => sub { + my $req = shift; + $req->new_response( + 200, + [ 'Content-Type' => 'application/json' ], + JSON::encode_json( $content ) + ); + }, +}; + ok my $client = Net::HTTP::Spore->new_from_spec( 't/specs/couchdb.json', api_base_url => 'http://localhost:5984' ); -my $content = { keys => [qw/1 2 3/] }; - $client->enable('Format::JSON'); -$client->enable( - 'Test::Response', - body => JSON::encode_json($content), - headers => [ 'Content-Type' => 'application/json' ] -); +$client->enable('Mock', tests => $mock_server); my $res = $client->get_all_documents( database => 'test_spore' ); is $res->[0], 200; |