summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-07-11 15:34:57 +0200
committerfranck cuny <franck@lumberjaph.net>2011-07-26 13:21:01 +0200
commit3fb82b11673234448407be2d8b43bcb3d7bae9ef (patch)
treee9f3ab06933ddeb1e675163fc34f5c792270bb3e
parentadd debug while loading middlewares (diff)
downloadnet-http-spore-3fb82b11673234448407be2d8b43bcb3d7bae9ef.tar.gz
add a simple test for trace
Signed-off-by: franck cuny <franck@lumberjaph.net>
-rw-r--r--t/spore-response/debug.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/spore-response/debug.t b/t/spore-response/debug.t
new file mode 100644
index 0000000..261d5b0
--- /dev/null
+++ b/t/spore-response/debug.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use Test::More;
+use Net::HTTP::Spore;
+use File::Temp qw/ :seekable /;
+use Try::Tiny;
+
+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;