mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix string usage with contain matcher
This commit is contained in:
parent
f6fc36f60a
commit
de1af7178c
1 changed files with 6 additions and 8 deletions
|
@ -8,7 +8,7 @@ module Spectator::Matchers
|
|||
private getter expected
|
||||
|
||||
# Creates the matcher with an expected value.
|
||||
def initialize(@expected : TestValue(Array(ExpectedType)))
|
||||
def initialize(@expected : TestValue(ExpectedType))
|
||||
end
|
||||
|
||||
# Short text about the matcher's purpose.
|
||||
|
@ -23,9 +23,8 @@ module Spectator::Matchers
|
|||
actual_value = actual.value
|
||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:includes?)
|
||||
|
||||
actual_elements = actual_value.to_a
|
||||
missing = expected.value.reject do |item|
|
||||
actual_elements.includes?(item)
|
||||
actual_value.includes?(item)
|
||||
end
|
||||
|
||||
if missing.empty?
|
||||
|
@ -35,7 +34,7 @@ module Spectator::Matchers
|
|||
# Content is missing.
|
||||
FailedMatchData.new(description, "#{actual.label} does not contain #{expected.label}",
|
||||
expected: expected.value.inspect,
|
||||
actual: actual_elements.inspect,
|
||||
actual: actual_value.inspect,
|
||||
missing: missing.inspect,
|
||||
)
|
||||
end
|
||||
|
@ -47,16 +46,15 @@ module Spectator::Matchers
|
|||
actual_value = actual.value
|
||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:includes?)
|
||||
|
||||
actual_elements = actual_value.to_a
|
||||
missing = expected.value.reject do |item|
|
||||
actual_elements.includes?(item)
|
||||
actual_value.includes?(item)
|
||||
end
|
||||
|
||||
if missing.empty?
|
||||
# Contents are identical.
|
||||
FailedMatchData.new(description, "#{actual.label} contains #{expected.label}",
|
||||
expected: "Not #{expected_elements.inspect}",
|
||||
actual: actual_elements.inspect
|
||||
expected: "Not #{expected.value.inspect}",
|
||||
actual: actual_value.inspect
|
||||
)
|
||||
else
|
||||
# Content differs.
|
||||
|
|
Loading…
Reference in a new issue