Permalink
Browse files

Adds error handling for empty collection URLs

  • Loading branch information...
1 parent accc323 commit 453cc38c9f75882e1f0a5275382ebb4bde065fa6 @vesan committed Jun 17, 2012
Showing with 13 additions and 0 deletions.
  1. +2 −0 lib/kippt/collection_resource.rb
  2. +11 −0 spec/spec_helper.rb
@@ -14,6 +14,8 @@ def [](resource_id)
end
def collection_from_url(url)
+ raise ArgumentError.new("The parameter URL can't be blank") if url.nil? || url == ""
+
collection_class.new(@client.get(url).body, self)
end
View
@@ -68,6 +68,17 @@ def fixture(file)
collection = subject.collection_from_url("/api/#{base_uri}/?limit=20&offset=20")
collection.should be_a(collection_class)
end
+
+ context "when passed URL is blank" do
+ it "raises ArgumentError" do
+ lambda {
+ subject.collection_from_url("")
+ }.should raise_error(ArgumentError, "The parameter URL can't be blank")
+ lambda {
+ subject.collection_from_url(nil)
+ }.should raise_error(ArgumentError, "The parameter URL can't be blank")
+ end
+ end
end
describe "#build" do

0 comments on commit 453cc38

Please sign in to comment.