summary refs log tree commit diff
path: root/t/spore
diff options
context:
space:
mode:
authorBrian Phillips <bphillips@cpan.org>2012-12-04 22:27:23 -0600
committerAsh Berlin <ash_github@firemirror.com>2013-04-19 14:21:43 +0100
commit80232d581e7a82f0ec8bd85d269a1604fdbe58c7 (patch)
tree25e542e234b6e84980377f32e6bcb60fd9f6e29c /t/spore
parentsupport for anonymous middlewares (diff)
downloadnet-http-spore-80232d581e7a82f0ec8bd85d269a1604fdbe58c7.tar.gz
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)
Diffstat (limited to 't/spore')
-rw-r--r--t/spore/01_new_from_string.t10
1 files changed, 9 insertions, 1 deletions
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');
 };