summary refs log tree commit diff
path: root/t/spore-middleware
diff options
context:
space:
mode:
Diffstat (limited to 't/spore-middleware')
-rw-r--r--t/spore-middleware/format-auto.t38
1 files changed, 38 insertions, 0 deletions
diff --git a/t/spore-middleware/format-auto.t b/t/spore-middleware/format-auto.t
new file mode 100644
index 0000000..e90e16b
--- /dev/null
+++ b/t/spore-middleware/format-auto.t
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+use Test::More;
+
+plan tests => 1;
+
+use JSON;
+
+use Net::HTTP::Spore;
+
+my $content = { keys => [qw/1 2 3/] };
+
+my $mock_server = {
+    '/api/show' => sub {
+        my $req = shift;
+        $req->new_response(
+            200,
+            [ 'Content-Type' => 'application/json' ],
+            JSON::encode_json($content),
+        );
+    },
+};
+
+my $api = {
+    api_base_url => 'http://services.org/api',
+    methods      => {
+        'show' => {
+            path   => '/show',
+            method => 'GET',
+        }
+    }
+};
+
+ok my $client = Net::HTTP::Spore->new_from_string( JSON::encode_json($api) );
+
+$client->enable('Format::Auto');
+$client->enable( 'Mock', tests => $mock_server );
+