diff options
author | Ash Berlin <ash_github@firemirror.com> | 2013-04-18 14:09:55 +0100 |
---|---|---|
committer | Ash Berlin <ash_github@firemirror.com> | 2013-04-18 14:09:55 +0100 |
commit | e0ad6bfc02f7d69d14fc78fff25031dd44f7f583 (patch) | |
tree | 5c2c61f9b21e386ed758c8b9ce9d6d830c1b8126 | |
parent | Clarifies that new_from_string expects a string in JSON format. (diff) | |
parent | Fix an error string, add a crude test (diff) | |
download | net-http-spore-e0ad6bfc02f7d69d14fc78fff25031dd44f7f583.tar.gz |
Merge branch 'method-patch' of git://github.com/omega/net-http-spore into omega-method-patch
-rw-r--r-- | lib/Net/HTTP/Spore/Meta/Method.pm | 6 | ||||
-rw-r--r-- | t/spore-method/payload.t | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/Net/HTTP/Spore/Meta/Method.pm b/lib/Net/HTTP/Spore/Meta/Method.pm index b3a0c6a..1a04eca 100644 --- a/lib/Net/HTTP/Spore/Meta/Method.pm +++ b/lib/Net/HTTP/Spore/Meta/Method.pm @@ -17,7 +17,7 @@ subtype UriPath => where { $_ =~ m!^/! } => message {"path must start with /"}; -enum Method => qw(OPTIONS HEAD GET POST PUT DELETE TRACE); +enum Method => qw(OPTIONS HEAD GET POST PUT DELETE TRACE PATCH); subtype 'JSON::XS::Boolean' => as 'JSON::XS::Boolean'; subtype 'JSON::PP::Boolean' => as 'JSON::PP::Boolean'; @@ -145,10 +145,10 @@ sub wrap { : delete $method_args{payload}; if ( $payload - && ( $method->method !~ /^P(?:OS|U)T$/i ) ) + && ( $method->method !~ /^(?:POST|PUT|PATCH)$/i ) ) { die Net::HTTP::Spore::Response->new( 599, [], - { error => "payload requires a PUT or POST method" }, + { error => "payload requires a PUT, PATCH or POST method" }, ); } diff --git a/t/spore-method/payload.t b/t/spore-method/payload.t index 483d9cc..369ec22 100644 --- a/t/spore-method/payload.t +++ b/t/spore-method/payload.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 6; use Test::Exception; @@ -15,6 +15,11 @@ my $api_with_payload = { path => '/user', required_payload => 1, }, + update_user => { + method => 'PATCH', + path => '/user', + required_payload => 1, + }, list_user => { method => 'GET', path => '/user', @@ -30,4 +35,7 @@ dies_ok { $obj->create_user(); }; like $@->body->{error}, qr/this method require a payload/; dies_ok { $obj->list_user( payload => {} ) }; -like $@->body->{error}, qr/payload requires a PUT or POST method/; +like $@->body->{error}, qr/payload requires a PUT, PATCH or POST method/; + +dies_ok { $obj->update_user(); }; +like $@->body->{error}, qr/this method require a payload/; |