From 80232d581e7a82f0ec8bd85d269a1604fdbe58c7 Mon Sep 17 00:00:00 2001 From: Brian Phillips Date: Tue, 4 Dec 2012 22:27:23 -0600 Subject: clean up types - Split out type declarations into separate class - Use namespaced types instead of global types (via MooseX::Types) - use declared types where possible, instead of quoted type names (i.e. isa => Str, instead of isa => 'Str') - Allow "authentication" attribute to coerce from a JSON::is_bool() value (instead of expecting it to be a 1 or a 0 all the time) --- t/spore/01_new_from_string.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 't/spore') diff --git a/t/spore/01_new_from_string.t b/t/spore/01_new_from_string.t index 6a21994..834baa3 100644 --- a/t/spore/01_new_from_string.t +++ b/t/spore/01_new_from_string.t @@ -3,7 +3,7 @@ use warnings; use Test::More; use Test::Exception; -plan tests => 27; +plan tests => 28; use JSON; use IO::All; @@ -37,6 +37,12 @@ my $api_without_method = { methods => { get_info => { method => 'PET', path => '/show' } }, }; +my $api_with_authentication = { + base_url => "http://services.org/restapi", + authentication => JSON::true(), + methods => { get_info => { method => 'GET', path => '/show' } }, +}; + dies_ok { Net::HTTP::Spore->new_from_spec }; like $@, qr/specification file is missing/; @@ -70,6 +76,8 @@ like $@, qr/Attribute \(method\) does not pass the type constraint/; ok $client = Net::HTTP::Spore->new_from_string(JSON::encode_json($api_ok)); ok $client->meta->_find_spore_method_by_name(sub{/^get_info$/}); +ok $client = Net::HTTP::Spore->new_from_string(JSON::encode_json($api_with_authentication)); + dies_ok { Net::HTTP::Spore->new_from_strings('/a/b/c', '/a/b/c'); }; -- cgit 1.4.1