mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add MatchData for EqualityMatcher
crystal spec runs, but fails for this commit.
This commit is contained in:
parent
94cbb9860a
commit
b4502711cd
1 changed files with 31 additions and 1 deletions
|
@ -13,7 +13,9 @@ module Spectator::Matchers
|
|||
# Determines whether the matcher is satisfied with the partial given to it.
|
||||
# `MatchData` is returned that contains information about the match.
|
||||
def match(partial) : MatchData
|
||||
raise NotImplementedError.new("#match")
|
||||
actual = partial.actual
|
||||
matched = actual == expected
|
||||
MatchData.new(matched, expected, actual, partial.label, label)
|
||||
end
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
|
@ -27,5 +29,33 @@ module Spectator::Matchers
|
|||
def negated_message(partial)
|
||||
"Expected #{partial.label} to not equal #{label} (using ==)"
|
||||
end
|
||||
|
||||
# Match data specific to this matcher.
|
||||
private struct MatchData(ExpectedType, ActualType) < MatchData
|
||||
# Creates the match data.
|
||||
def initialize(matched, @expected : ExpectedType, @actual : ActualType, @expected_label : String, @actual_label : String)
|
||||
super(matched)
|
||||
end
|
||||
|
||||
# Information about the match.
|
||||
def values
|
||||
{
|
||||
expected: @expected,
|
||||
actual: @actual,
|
||||
}
|
||||
end
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
def message
|
||||
"#{@expected_label} is #{@actual_label} (using ==)"
|
||||
end
|
||||
|
||||
# Describes the condition that won't satsify the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
def negated_message
|
||||
"#{@expected_label} is not #{@actual_label} (using ==)"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue