diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2007-12-05 14:11:34 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2007-12-05 14:11:34 +0100 |
commit | 17bf327a39bea0b4d9473cc718c369558f7dc3ba (patch) | |
tree | 092fddb654a19305b67016cc4f07bbef47ee1fbb | |
parent | 17c8a9c07eb67c60174c762a15f5aebe8ee902c7 (diff) | |
download | bacon-17bf327a39bea0b4d9473cc718c369558f7dc3ba.tar.gz bacon-17bf327a39bea0b4d9473cc718c369558f7dc3ba.tar.xz bacon-17bf327a39bea0b4d9473cc718c369558f7dc3ba.zip |
Add flunking
darcs-hash:20071205131134-4fc50-f212f6e81f9439f8171234b379dbf4852f7ed9e2.gz
-rw-r--r-- | lib/bacon.rb | 8 | ||||
-rw-r--r-- | test/spec_bacon.rb | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/bacon.rb b/lib/bacon.rb index 64e6504..b73bfe4 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -279,9 +279,7 @@ class Should r = yield(@object, *args) if Bacon::Counter[:depth] > 0 - unless @negated ^ r - raise Bacon::Error.new(:failed, description) - end + raise Bacon::Error.new(:failed, description) unless @negated ^ r Bacon::Counter[:requirements] += 1 end @negated ^ r ? r : false @@ -304,4 +302,8 @@ class Should def identical_to(value); self.equal? value; end alias same_as identical_to + + def flunk(reason="Flunked") + raise Bacon::Error.new(:failed, reason) + end end diff --git a/test/spec_bacon.rb b/test/spec_bacon.rb index 6847b9d..b0cb510 100644 --- a/test/spec_bacon.rb +++ b/test/spec_bacon.rb @@ -247,6 +247,11 @@ describe "Bacon" do lambda { (1+1).should.not.be equal_string("2") }.should fail lambda { (1+2).should.not.be equal_string("2") }.should succeed end + + it "should have should.flunk" do + lambda { should.flunk }.should fail + lambda { should.flunk "yikes" }.should fail + end end describe "before/after" do |