summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-08-31 15:45:25 +0200
committerfranck cuny <franck@lumberjaph.net>2010-08-31 15:45:25 +0200
commit3579912d0fbf05fc0a945ef3c7b08497b0aabe4e (patch)
treea56642c0abd42361dc039c95316d48a15d4d831e
parents/load/new/ (diff)
downloadnet-http-api-spec-3579912d0fbf05fc0a945ef3c7b08497b0aabe4e.tar.gz
check path for file
-rw-r--r--lib/Net/HTTP/API/Spec.pm5
-rw-r--r--t/01_basic.t7
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Net/HTTP/API/Spec.pm b/lib/Net/HTTP/API/Spec.pm
index 6fcd6d4..39f9680 100644
--- a/lib/Net/HTTP/API/Spec.pm
+++ b/lib/Net/HTTP/API/Spec.pm
@@ -3,12 +3,17 @@ package Net::HTTP::API::Spec;
 use JSON;
 use Moose;
 use IO::All;
+use Carp;
 
 use Net::HTTP::API::Core;
 
 sub new_from_spec {
     my ($class, $spec_file) = @_;
 
+    if (! -f $spec_file) {
+        Carp::confess ("$spec_file does not exists");
+    }
+
     my $content < io($spec_file);
     my $spec = JSON::decode_json($content);
 
diff --git a/t/01_basic.t b/t/01_basic.t
index 64983c1..5f1c9b9 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -1,11 +1,18 @@
 use strict;
 use warnings;
 use Test::More;
+use Test::Exception;
 
 use Net::HTTP::API::Spec;
 
 ok my $client = Net::HTTP::API::Spec->new_from_spec('t/spec/test1.json');
 
+dies_ok {
+    $client = Net::HTTP::API::Spec->new_from_spec('foobarbaz');
+};
+
+like $@, qr/does not exists/;
+
 my @methods = $client->meta->get_all_net_api_methods();
 is scalar @methods, 2;