Permalink
Browse files

Add a Document#update!(params) method.

This method internally updates the object's attributes,
and saves the object, returning its id.

This completes the Update section.
  • Loading branch information...
1 parent f3563ab commit 3c67a0fb898ce864698005fff26ea7453e13cc8e @elliotcm committed Mar 27, 2010
Showing with 5 additions and 1 deletion.
  1. +4 −0 lib/document/persistence.rb
  2. +1 −1 spec/document/persistence_spec.rb
@@ -44,6 +44,10 @@ def update(params)
return self
end
+ def update!(params)
+ self.update(params).save
+ end
+
def id
@_id
end
@@ -52,6 +52,7 @@ class TestClass
describe "#update!(params)" do
before(:each) do
@test_object = TestClass.new(:name => 'Test object')
+ @test_object.stub!(:save => (@result = mock(:result)))
end
def update_object
@@ -69,7 +70,6 @@ def update_object
end
it "returns the result of the save" do
- @test_object.stub!(:save => (@result = mock(:result)))
update_object.should == @result
end
end

0 comments on commit 3c67a0f

Please sign in to comment.