diff options
Diffstat (limited to 't/spore-method')
| -rw-r--r-- | t/spore-method/payload.t | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/t/spore-method/payload.t b/t/spore-method/payload.t new file mode 100644 index 0000000..483d9cc --- /dev/null +++ b/t/spore-method/payload.t @@ -0,0 +1,33 @@ +use strict; +use warnings; +use Test::More tests => 4; + +use Test::Exception; + +use JSON; +use Net::HTTP::Spore; + +my $api_with_payload = { + base_url => 'foo', + methods => { + create_user => { + method => 'POST', + path => '/user', + required_payload => 1, + }, + list_user => { + method => 'GET', + path => '/user', + } + }, +}; + +my $obj = + Net::HTTP::Spore->new_from_string( JSON::encode_json($api_with_payload), + base_url => 'http://localhost' ); + +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/; |
