summary refs log tree commit diff
path: root/t/lib
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-12-20 19:55:04 +0100
committerfranck cuny <franck@lumberjaph.net>2009-12-20 19:55:04 +0100
commit57080b2666e528223676bd20d864a4a39f6f7076 (patch)
tree8b67a68c92782d4dae7ac51bac809c4e064133d7 /t/lib
parentChecking in changes prior to tagging of version 0.06. Changelog diff is: (diff)
downloadmoosex-net-api-57080b2666e528223676bd20d864a4a39f6f7076.tar.gz
start to rewrite tests
Diffstat (limited to '')
-rw-r--r--t/lib/FakeAPI.pm22
1 files changed, 20 insertions, 2 deletions
diff --git a/t/lib/FakeAPI.pm b/t/lib/FakeAPI.pm
index d51a469..0f53157 100644
--- a/t/lib/FakeAPI.pm
+++ b/t/lib/FakeAPI.pm
@@ -1,14 +1,31 @@
 package FakeAPI;
 use Moose;
 use MooseX::Net::API;
+use LWP::UserAgent;
+use HTTP::Response;
+use JSON::XS;
 
 net_api_declare demorest => (
-    base_url       => 'http://lumberjaph.net/demorest/rest',
+    base_url => "http://example.com/",
     format         => 'json',
     format_mode    => 'content-type',
     authentication => 0,
     username       => 'foo',
     password       => 'bar',
+    useragent      => sub {
+        my ($self) = @_;
+        my $ua = LWP::UserAgent->new();
+        $ua->add_handler(
+            request_send => sub {
+                my $request = shift;
+                my $res = HTTP::Response->new(200, 'OK');
+                $res->header('content-type' => 'application/json');
+                $res->content(encode_json {status => 1});
+                return $res;
+            }
+        );
+        return $ua;
+    },
 );
 
 net_api_method users => (
@@ -52,7 +69,8 @@ net_api_method delete_user => (
 );
 
 net_api_method auth_get_user => (
-    description => 'fetch information about a specific user with authentication',
+    description =>
+        'fetch information about a specific user with authentication',
     method         => 'GET',
     path           => '/auth_user/$id',
     params         => [qw/id/],