mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Improve failure messages for #fail_with_message_including
This improves our internal matcher so that it mirrors #fail_with_message. In other words, when it fails it will now say: Expectation should have failed with: Some message goes here Actually failed with: Some other message goes here However, the expectation did not fail.
This commit is contained in:
parent
b3113117bd
commit
ea50a9ffaf
1 changed files with 9 additions and 8 deletions
|
@ -20,15 +20,17 @@ module UnitTests
|
|||
end
|
||||
|
||||
def failure_message
|
||||
msg = "Expectation should have failed with message including '#{expected}'"
|
||||
lines = ['Expectation should have failed with message including:']
|
||||
lines << Shoulda::Matchers::Util.indent(expected, 2)
|
||||
|
||||
if @actual
|
||||
msg << ",\nactually failed with '#{@actual}'"
|
||||
lines << 'Actually failed with:'
|
||||
lines << Shoulda::Matchers::Util.indent(@actual, 2)
|
||||
else
|
||||
msg << ", but did not fail."
|
||||
lines << 'However, the expectation did not fail.'
|
||||
end
|
||||
|
||||
msg
|
||||
lines.join("\n")
|
||||
end
|
||||
|
||||
def failure_message_for_should
|
||||
|
@ -36,10 +38,9 @@ module UnitTests
|
|||
end
|
||||
|
||||
def failure_message_when_negated
|
||||
msg = "Expectation should not have failed with message including '#{expected}'"
|
||||
msg << ", but did."
|
||||
|
||||
msg
|
||||
lines = ['Expectation should not have failed with message including:']
|
||||
lines << Shoulda::Matchers::Util.indent(expected, 2)
|
||||
lines.join("\n")
|
||||
end
|
||||
|
||||
def failure_message_for_should_not
|
||||
|
|
Loading…
Add table
Reference in a new issue