From 371fe680c23986d7a299d28fec36e827de0bff8d Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 24 Sep 2018 22:57:37 -0600 Subject: [PATCH] Pass matcher messages to failure results --- src/spectator/expectation.cr | 4 ++-- src/spectator/formatters/default_formatter.cr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/spectator/expectation.cr b/src/spectator/expectation.cr index 4bec79d..1f72bb0 100644 --- a/src/spectator/expectation.cr +++ b/src/spectator/expectation.cr @@ -10,13 +10,13 @@ module Spectator def to(matcher : Matchers::Matcher) unless matcher.match?(self) - raise ExpectationFailed.new + raise ExpectationFailed.new(matcher.message(self)) end end def to_not(matcher : Matchers::Matcher) if matcher.match?(self) - raise ExpectationFailed.new + raise ExpectationFailed.new(matcher.negated_message(self)) end end diff --git a/src/spectator/formatters/default_formatter.cr b/src/spectator/formatters/default_formatter.cr index 370d569..7fbacdd 100644 --- a/src/spectator/formatters/default_formatter.cr +++ b/src/spectator/formatters/default_formatter.cr @@ -31,7 +31,7 @@ module Spectator puts "Failures:" puts failures.each_with_index do |failure, index| - display_failure(failure, index + 1) + display_failure(failure.as(FailedResult), index + 1) end end end @@ -40,7 +40,7 @@ module Spectator expected = "TODO" actual = "TODO" puts " #{number}) #{failure.example}" - puts " Failure: " + puts " Failure: #{failure.error.message}" puts puts " Expected: #{expected}" puts " got: #{actual}"