From e5c88e6cfc3fb3d95425c8d0fbb281e8b43e0000 Mon Sep 17 00:00:00 2001 From: Betsy Haibel Date: Thu, 10 Feb 2011 22:28:18 -0500 Subject: [PATCH] adding Persistable#save! tests --- Gemfile.lock | 5 ++++- spec/gitmodel/persistable_spec.rb | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a87a6df..ed9d341 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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) @@ -50,5 +52,6 @@ DEPENDENCIES autotest-fsevent (>= 0.2.3) gitmodel! grit (>= 2.3.0) + json lockfile (>= 1.4.3) rspec (>= 2.0.1) diff --git a/spec/gitmodel/persistable_spec.rb b/spec/gitmodel/persistable_spec.rb index 0d34e70..cec1402 100644 --- a/spec/gitmodel/persistable_spec.rb +++ b/spec/gitmodel/persistable_spec.rb @@ -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