Skip to content

Commit

Permalink
fix nested failure messages
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy McAnally <jeremymcanally@gmail.com>
  • Loading branch information
technoweenie authored and jm committed Jan 31, 2009
1 parent d725734 commit 55e64c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/matchy/built_in/operator_expectations.rb
Expand Up @@ -82,7 +82,7 @@ def pass!
end

def fail!(operator)
flunk failure_message(@match ? failure_message(operator) : negative_failure_message(operator))
flunk @match ? failure_message(operator) : negative_failure_message(operator)
end

def failure_message(operator)
Expand Down
16 changes: 7 additions & 9 deletions test/test_operator_expectations.rb
Expand Up @@ -138,22 +138,20 @@ def test_negative_matches_fails
def test_fail_message
obj = Matchy::Expectations::OperatorExpectation.new(3, true)

def obj.fail!(fail)
def obj.flunk(msg)
msg
end

obj == 4

obj.send(:failure_message, "==").should =~ /Expected 3 to == 4./
(obj == 4).should == "Expected 3 to == 4."
end

def test_negative_fail_message
obj = Matchy::Expectations::OperatorExpectation.new(3, true)
obj = Matchy::Expectations::OperatorExpectation.new(3, false)

def obj.fail!(fail)
def obj.flunk(msg)
msg
end

obj == 3

obj.send(:negative_failure_message, "==").should =~ /Expected 3 to not == 3./
(obj == 3).should == "Expected 3 to not == 3."
end
end

0 comments on commit 55e64c1

Please sign in to comment.