From d7ba14853fce25e4712474b40cd90393a860c377 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 26 Oct 2010 16:14:55 +0200 Subject: add tests to payload --- t/spore-method/payload.t | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 't/spore-method') 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/; -- cgit 1.4.1