summary refs log tree commit diff
path: root/t/spore-middleware/format-json.t
diff options
context:
space:
mode:
Diffstat (limited to 't/spore-middleware/format-json.t')
-rw-r--r--t/spore-middleware/format-json.t21
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;