diff --git a/src/spectator/matchers/predicate_matcher.cr b/src/spectator/matchers/predicate_matcher.cr index 93ce33b..f8cb737 100644 --- a/src/spectator/matchers/predicate_matcher.cr +++ b/src/spectator/matchers/predicate_matcher.cr @@ -20,14 +20,14 @@ module Spectator::Matchers if match?(snapshot) SuccessfulMatchData.new else - FailedMatchData.new("#{actual.label} is not #{expected.label}", **snapshot) + FailedMatchData.new("#{actual.label} is not #{expected.label}", **values(snapshot)) end end def negated_match(actual) snapshot = snapshot_values(actual.value) if match?(snapshot) - FailedMatchData.new("#{actual.label} is #{expected.label}", **snapshot) + FailedMatchData.new("#{actual.label} is #{expected.label}", **values(snapshot)) else SuccessfulMatchData.new end @@ -53,6 +53,16 @@ module Spectator::Matchers {% end %} end + private def values(snapshot) + {% begin %} + { + {% for attribute in ExpectedType.keys %} + {{attribute}}: snapshot[{{attribute.symbolize}}].inspect, + {% end %} + } + {% end %} + end + private def match?(snapshot) # Test each predicate and immediately return false if one is false. {% for attribute in ExpectedType.keys %}