Pass matcher messages to failure results

This commit is contained in:
Michael Miller 2018-09-24 22:57:37 -06:00
parent 8fb051d61e
commit 371fe680c2
2 changed files with 4 additions and 4 deletions

View file

@ -10,13 +10,13 @@ module Spectator
def to(matcher : Matchers::Matcher) def to(matcher : Matchers::Matcher)
unless matcher.match?(self) unless matcher.match?(self)
raise ExpectationFailed.new raise ExpectationFailed.new(matcher.message(self))
end end
end end
def to_not(matcher : Matchers::Matcher) def to_not(matcher : Matchers::Matcher)
if matcher.match?(self) if matcher.match?(self)
raise ExpectationFailed.new raise ExpectationFailed.new(matcher.negated_message(self))
end end
end end

View file

@ -31,7 +31,7 @@ module Spectator
puts "Failures:" puts "Failures:"
puts puts
failures.each_with_index do |failure, index| failures.each_with_index do |failure, index|
display_failure(failure, index + 1) display_failure(failure.as(FailedResult), index + 1)
end end
end end
end end
@ -40,7 +40,7 @@ module Spectator
expected = "TODO" expected = "TODO"
actual = "TODO" actual = "TODO"
puts " #{number}) #{failure.example}" puts " #{number}) #{failure.example}"
puts " Failure: <INSERT EXPECTATION HERE>" puts " Failure: #{failure.error.message}"
puts puts
puts " Expected: #{expected}" puts " Expected: #{expected}"
puts " got: #{actual}" puts " got: #{actual}"