diff options
author | Andreas Marienborg <andreas.marienborg@gmail.com> | 2012-02-06 16:30:01 +0100 |
---|---|---|
committer | Andreas Marienborg <andreas.marienborg@gmail.com> | 2012-02-06 16:30:01 +0100 |
commit | 1c10f35f99c10f6f2e04b8826234e2585f6d9c22 (patch) | |
tree | c6f63ca1ee9d43652cfeb94a6afcc7237a583f56 | |
parent | Support PATCH method (that github uses) (diff) | |
download | net-http-spore-1c10f35f99c10f6f2e04b8826234e2585f6d9c22.tar.gz |
Fix an error string, add a crude test
-rw-r--r-- | lib/Net/HTTP/Spore/Meta/Method.pm | 2 | ||||
-rw-r--r-- | t/spore-method/payload.t | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/Net/HTTP/Spore/Meta/Method.pm b/lib/Net/HTTP/Spore/Meta/Method.pm index f3d440f..9f95c48 100644 --- a/lib/Net/HTTP/Spore/Meta/Method.pm +++ b/lib/Net/HTTP/Spore/Meta/Method.pm @@ -147,7 +147,7 @@ sub wrap { && ( $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/; |