mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow contain
matcher to take multiple values
This commit is contained in:
parent
7c8239e55b
commit
85b4e6894b
2 changed files with 11 additions and 3 deletions
|
@ -356,8 +356,14 @@ module Spectator::DSL
|
|||
# expect("foobar").to contain('o')
|
||||
# expect(%i[a b c]).to contain(:b)
|
||||
# ```
|
||||
macro contain(expected)
|
||||
::Spectator::Matchers::ContainMatcher.new({{expected.stringify}}, {{expected}})
|
||||
#
|
||||
# Additionally, multiple arguments can be specified.
|
||||
# ```
|
||||
# expect("foobarbaz").to contain("foo", "bar")
|
||||
# expect(%i[a b c]).to contain(:a, :b)
|
||||
# ```
|
||||
macro contain(*expected)
|
||||
::Spectator::Matchers::ContainMatcher.new({{expected.splat.stringify}}, {{expected}})
|
||||
end
|
||||
|
||||
# Indicates that some value or set should contain another value.
|
||||
|
|
|
@ -7,7 +7,9 @@ module Spectator::Matchers
|
|||
# Determines whether the matcher is satisfied with the value given to it.
|
||||
# True is returned if the match was successful, false otherwise.
|
||||
def match?(partial)
|
||||
partial.actual.includes?(expected)
|
||||
expected.all? do |item|
|
||||
partial.actual.includes?(item)
|
||||
end
|
||||
end
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
|
|
Loading…
Reference in a new issue