summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-03-24 15:35:29 +0100
committerfranck cuny <franck@lumberjaph.net>2011-07-26 13:19:59 +0200
commit48466e51f7aa1d659f339be9741fb419a321f18c (patch)
tree7a87101d3439ec4722678861c64a926ae4c4fa41
parentmultiple clients (diff)
downloadnet-http-spore-48466e51f7aa1d659f339be9741fb419a321f18c.tar.gz
add some tests
Signed-off-by: franck cuny <franck@lumberjaph.net>
-rw-r--r--t/spore-role/basic.t46
1 files changed, 46 insertions, 0 deletions
diff --git a/t/spore-role/basic.t b/t/spore-role/basic.t
new file mode 100644
index 0000000..7b73875
--- /dev/null
+++ b/t/spore-role/basic.t
@@ -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';