blob: 7b738759720a532f0c2cf8b96467a5b38acded54 (
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
39
40
41
42
43
44
45
46
|
use strict;
use warnings;
use Test::More;
use JSON;
plan tests => 5;
my $conf = {
'twitter' => {
spec => 't/specs/api.json',
options => { base_url => 'http://localhost/', },
middlewares => [ { name => 'Format::JSON' } ],
}
};
{
package my::app;
use Moose;
with 'Net::HTTP::Spore::Role' => {
spore_clients => [
{ name => 'twitter', config => 'twitter_config' }
]
};
}
my $mock_server = {
'/show' => sub {
my $req = shift;
$req->new_response(
200,
[ 'Content-Type' => 'application/json' ],
JSON::encode_json({status => 'ok'})
);
},
};
ok my $app = my::app->new( twitter_config => $conf->{twitter} );
is_deeply $app->twitter_config, $conf->{twitter};
$app->twitter->enable('Mock', tests => $mock_server);
my $res = $app->twitter->get_info();
is $res->[0], 200;
is_deeply $res->[2], {status => 'ok'};
is $res->header('Content-Type'), 'application/json';
|