Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
Signed-off-by: franck cuny <[email protected]>
  • Loading branch information
fcuny committed Jul 26, 2011
1 parent 36f54fd commit 48466e5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions t/spore-role/basic.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,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';

0 comments on commit 48466e5

Please sign in to comment.