Skip to content

Commit

Permalink
adding Persistable#save! tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaibel committed Feb 11, 2011
1 parent f0d9d13 commit e5c88e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
PATH
remote: .
specs:
gitmodel (0.0.0)
gitmodel (0.0.1)
activemodel (>= 3.0.1)
activesupport (>= 3.0.1)
grit (>= 2.3.0)
json
lockfile (>= 1.4.3)

GEM
Expand All @@ -25,6 +26,7 @@ GEM
diff-lcs (~> 1.1)
mime-types (~> 1.15)
i18n (0.4.1)
json (1.5.1)
lockfile (1.4.3)
mime-types (1.16)
rspec (2.0.1)
Expand All @@ -50,5 +52,6 @@ DEPENDENCIES
autotest-fsevent (>= 0.2.3)
gitmodel!
grit (>= 2.3.0)
json
lockfile (>= 1.4.3)
rspec (>= 2.0.1)
21 changes: 18 additions & 3 deletions spec/gitmodel/persistable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,26 @@ def setup

describe '#save!' do

it "calls save and returns the non-false and non-nil result"
it "calls save and returns the non-false and non-nil result" do
o = TestEntity.new
o.should_receive(:save).and_return(o)

o.save!.should == o
end

it "calls save and raises an exception if the result is nil" do
o = TestEntity.new
o.should_receive(:save).and_return(nil)

it "calls save and raises an exception if the result is nil"
expect { o.save! }.to raise_error
end

it "calls save and raises an exception if the result is false"
it "calls save and raises an exception if the result is false" do
o = TestEntity.new
o.should_receive(:save).and_return(false)

expect { o.save! }.to raise_error
end

end

Expand Down

0 comments on commit e5c88e6

Please sign in to comment.