Skip to content
Browse files

Makes collection resource #build accept attributes

  • Loading branch information...
1 parent 1b2c3ab commit 6af42a3df0ea5ad5e57344d3145eac77c530b101 @vesan committed Jul 19, 2012
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/kippt/collection_resource.rb
  2. +5 −0 spec/spec_helper.rb
View
4 lib/kippt/collection_resource.rb
@@ -5,8 +5,8 @@ def all(options = {})
collection_class.new(@client.get(base_uri, options).body, self)
end
- def build
- object_class.new({}, self)
+ def build(attributes = {})
+ object_class.new(attributes, self)
end
def [](resource_id)
View
5 spec/spec_helper.rb
@@ -87,6 +87,11 @@ def fixture(file)
it "returns new resource" do
subject.build.should be_a(resource_class)
end
+
+ it "accepts parameters" do
+ subject.object_class.should_receive(:new).with({an: "attribute"}, subject)
+ subject.build(an: "attribute")
+ end
end
end

0 comments on commit 6af42a3

Please sign in to comment.
Something went wrong with that request. Please try again.