From 697e5f20634ba1408a41453d760d19381a519435 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 15 Sep 2010 16:11:09 +0200 Subject: tests use the mocker --- t/spore-middleware/format-json.t | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 't/spore-middleware/format-json.t') 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; -- cgit v1.2.3