From 57080b2666e528223676bd20d864a4a39f6f7076 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 20 Dec 2009 19:55:04 +0100 Subject: start to rewrite tests --- t/lib/FakeAPI.pm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 't/lib') 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/], -- cgit 1.4.1