summary refs log tree commit diff
path: root/t/spore-middleware/format-auto.t
blob: 857d65dac6f5a31ba586520e1aa97472dd6c834c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 = {
    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 );