Convert bools to strings for output

This commit is contained in:
Michael Miller 2019-08-09 11:20:29 -06:00
parent 3d86893f44
commit 5a1dea8f72

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} is not #{expected.label}", **snapshot) FailedMatchData.new("#{actual.label} is not #{expected.label}", **values(snapshot))
end end
end end
def negated_match(actual) def negated_match(actual)
snapshot = snapshot_values(actual.value) snapshot = snapshot_values(actual.value)
if match?(snapshot) if match?(snapshot)
FailedMatchData.new("#{actual.label} is #{expected.label}", **snapshot) FailedMatchData.new("#{actual.label} is #{expected.label}", **values(snapshot))
else else
SuccessfulMatchData.new SuccessfulMatchData.new
end end
@ -53,6 +53,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)
# Test each predicate and immediately return false if one is false. # Test each predicate and immediately return false if one is false.
{% for attribute in ExpectedType.keys %} {% for attribute in ExpectedType.keys %}