summaryrefslogtreecommitdiff
path: root/t/02_error.t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-02 11:37:19 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-02 11:37:19 +0200
commitf92976bd47ad9ef1c54de83876db7dcc9843aafd (patch)
treec398c0f59acbe74178b94b113270a07fa6bf5e2f /t/02_error.t
parentrole to handle useragent (diff)
downloadmoosex-net-api-f92976bd47ad9ef1c54de83876db7dcc9843aafd.tar.gz
tests
Diffstat (limited to '')
-rw-r--r--t/02_error.t64
1 files changed, 7 insertions, 57 deletions
diff --git a/t/02_error.t b/t/02_error.t
index 332538a..a97158e 100644
--- a/t/02_error.t
+++ b/t/02_error.t
@@ -3,65 +3,15 @@ use warnings;
use Test::More;
use Test::Exception;
-BEGIN {
- dies_ok {
- {
+package test::api::missing_api_base_url;
+use MooseX::Net::API;
- package net_api_fail;
- use Moose;
- use MooseX::Net::API;
- net_api_declare foo => ();
- }
- }
- "... format is missing";
- like $@, qr/format is missing in your api declaration/,
- "... format is missing";
- dies_ok {
- {
+net_api_method user => (method => 'GET', path => '/user/');
- package net_api_fail;
- use Moose;
- use MooseX::Net::API;
- net_api_declare foo => ( format => 'foo' );
- }
- }
- "... no valid format";
- like $@, qr/format is not recognised/, "... no valid format";
- dies_ok {
- {
+package main;
- package net_api_fail;
- use Moose;
- use MooseX::Net::API;
- net_api_declare foo => ( format => 'json' );
- }
- }
- "... format mode is not set";
- like $@, qr/format_mode is not set/, "... format mode is not set";
- dies_ok {
- {
-
- package net_api_fail;
- use Moose;
- use MooseX::Net::API;
- net_api_declare foo => ( format => 'json', format_mode => 'bar' );
- }
- }
- "... format mode is unvalid";
- like $@, qr/must be append or content-type/, "... format mode is unvalid";
- #dies_ok {
- #{
- #package net_api_fail;
- #use Moose;
- #use MooseX::Net::API;
- #net_api_declare foo => (
- #format => 'json',
- #format_mode => 'content-type'
- #);
- #}
- #}
- #"... bad useragent";
- #warn $@;
-}
+ok my $t = test::api::missing_api_base_url->new;
+dies_ok { $t->user } 'die with missing url';
+like $@, qr/api_base_url is missing/, 'missing api_base_url';
done_testing;