summary refs log tree commit diff
path: root/t/spore-response/debug.t
blob: 9bf92ef5cebf5909fb8e8946cb401dd4cd56940b (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;
use Net::HTTP::Spore;
use File::Temp;

my $mock_server = {
    '/show' => sub {
        my $req = shift;
        $req->new_response( 200, [ 'Content-Type' => 'text/plan' ], 'ok');
    }
};

my $fh = File::Temp->new();
my $filename = $fh->filename;

ok my $client = Net::HTTP::Spore->new_from_spec(
    't/specs/api.json',
    base_url => 'http://localhost',
    trace    => "1=$filename"
  ),
  "client created";

$client->enable( 'Mock', tests => $mock_server );

my $res = $client->get_info();

ok -f $filename;

close $fh;

open $fh, '<', $filename;
my $out = <$fh>;
close $fh;

like $out, qr/enabling middleware Net::HTTP::Spore::Middleware::Mock/;

done_testing;