diff --git a/src/spectator/matchers/respond_matcher.cr b/src/spectator/matchers/respond_matcher.cr index dbecaa0..00d63bb 100644 --- a/src/spectator/matchers/respond_matcher.cr +++ b/src/spectator/matchers/respond_matcher.cr @@ -20,14 +20,14 @@ module Spectator::Matchers if match?(snapshot) SuccessfulMatchData.new else - FailedMatchData.new("#{actual.label} does not respond to #{label}", **snapshot) + FailedMatchData.new("#{actual.label} does not respond to #{label}", **values(snapshot)) end end def negated_match(actual : TestExpression(T)) : MatchData forall T snapshot = snapshot_values(actual.value) if match?(snapshot) - FailedMatchData.new("#{actual.label} responds to #{label}", **snapshot) + FailedMatchData.new("#{actual.label} responds to #{label}", **values(snapshot)) else SuccessfulMatchData.new end @@ -45,6 +45,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) # The snapshot did the hard work. # Here just check if all values are true.