mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix value negation of attribute matcher
This commit is contained in:
parent
00d1cd9ea3
commit
3a6fcb9b0d
1 changed files with 13 additions and 1 deletions
|
@ -39,7 +39,7 @@ module Spectator::Matchers
|
||||||
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} has attributes #{expected.label}", **values(snapshot))
|
FailedMatchData.new("#{actual.label} has attributes #{expected.label}", **negated_values(snapshot))
|
||||||
else
|
else
|
||||||
SuccessfulMatchData.new
|
SuccessfulMatchData.new
|
||||||
end
|
end
|
||||||
|
@ -79,5 +79,17 @@ module Spectator::Matchers
|
||||||
}
|
}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Produces the tuple for the failed negated match data from a snapshot of the attributes.
|
||||||
|
private def negated_values(snapshot)
|
||||||
|
{% begin %}
|
||||||
|
{
|
||||||
|
{% for attribute in ExpectedType.keys %}
|
||||||
|
{{"expected " + attribute.stringify}}: "Not #{expected.value[{{attribute.symbolize}}].inspect}",
|
||||||
|
{{"actual " + attribute.stringify}}: snapshot[{{attribute.symbolize}}].inspect,
|
||||||
|
{% end %}
|
||||||
|
}
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue