Skip to content

Commit

Permalink
add tests to payload
Browse files Browse the repository at this point in the history
  • Loading branch information
fcuny committed Oct 26, 2010
1 parent 0e75416 commit d7ba148
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions t/spore-method/payload.t
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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/;

0 comments on commit d7ba148

Please sign in to comment.