diff options
author | franck cuny <franck@lumberjaph.net> | 2010-10-26 16:14:55 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-10-26 16:14:55 +0200 |
commit | d7ba14853fce25e4712474b40cd90393a860c377 (patch) | |
tree | 3773dbddf04c791bdba664078355665f7e3be5da /t/spore-method | |
parent | add payload and form-data to the method object (diff) | |
download | net-http-spore-d7ba14853fce25e4712474b40cd90393a860c377.tar.gz |
add tests to payload
Diffstat (limited to 't/spore-method')
-rw-r--r-- | t/spore-method/payload.t | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/t/spore-method/payload.t b/t/spore-method/payload.t index 07691dc..483d9cc 100644 --- a/t/spore-method/payload.t +++ b/t/spore-method/payload.t @@ -1,7 +1,10 @@ use strict; use warnings; -use Test::More; +use Test::More tests => 4; +use Test::Exception; + +use JSON; use Net::HTTP::Spore; my $api_with_payload = { @@ -10,8 +13,21 @@ my $api_with_payload = { create_user => { method => 'POST', path => '/user', - payload_required => 1, + 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/; |