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)
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 %}