Stringify respond_to bools

This commit is contained in:
Michael Miller 2019-08-10 09:55:26 -06:00
parent 39f253952d
commit 37c8dd0865
1 changed files with 12 additions and 2 deletions

View File

@ -20,14 +20,14 @@ module Spectator::Matchers
if match?(snapshot) if match?(snapshot)
SuccessfulMatchData.new SuccessfulMatchData.new
else else
FailedMatchData.new("#{actual.label} does not respond to #{label}", **snapshot) FailedMatchData.new("#{actual.label} does not respond to #{label}", **values(snapshot))
end end
end end
def negated_match(actual : TestExpression(T)) : MatchData forall T def negated_match(actual : TestExpression(T)) : MatchData forall T
snapshot = snapshot_values(actual.value) snapshot = snapshot_values(actual.value)
if match?(snapshot) if match?(snapshot)
FailedMatchData.new("#{actual.label} responds to #{label}", **snapshot) FailedMatchData.new("#{actual.label} responds to #{label}", **values(snapshot))
else else
SuccessfulMatchData.new SuccessfulMatchData.new
end end
@ -45,6 +45,16 @@ module Spectator::Matchers
{% end %} {% end %}
end end
private def values(snapshot)
{% begin %}
{
{% for attribute in ExpectedType.keys %}
{{attribute}}: snapshot[{{attribute.symbolize}}].inspect,
{% end %}
}
{% end %}
end
private def match?(snapshot) private def match?(snapshot)
# The snapshot did the hard work. # The snapshot did the hard work.
# Here just check if all values are true. # Here just check if all values are true.