From 17bf327a39bea0b4d9473cc718c369558f7dc3ba Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 5 Dec 2007 14:11:34 +0100 Subject: Add flunking darcs-hash:20071205131134-4fc50-f212f6e81f9439f8171234b379dbf4852f7ed9e2.gz --- lib/bacon.rb | 8 +++++--- 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 -- cgit 1.4.1