Stringify respond_to bools

This commit is contained in:
Michael Miller 2019-08-10 09:55:26 -06:00
parent 39f253952d
commit 37c8dd0865

View file

@ -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.