mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add cover
matcher
Works the same as `contain` but is for ranges.
This commit is contained in:
parent
8143229fdb
commit
b7c686e836
1 changed files with 21 additions and 0 deletions
|
@ -454,6 +454,27 @@ module Spectator
|
|||
::Spectator::Matchers::ContainMatcher.new(%test_value)
|
||||
end
|
||||
|
||||
# Indicates that some range (or collection) should contain another value.
|
||||
# This is typically used on a `Range` (although any `Enumerable` works).
|
||||
# The `includes?` method is used.
|
||||
#
|
||||
# Examples:
|
||||
# ```
|
||||
# expect(1..10).to contain(5)
|
||||
# expect((1..)).to contain(100)
|
||||
# expect(..100).to contain(50)
|
||||
# ```
|
||||
#
|
||||
# Additionally, multiple arguments can be specified.
|
||||
# ```
|
||||
# expect(1..10).to contain(2, 3)
|
||||
# expect(..100).to contain(0, 50)
|
||||
# ```
|
||||
macro cover(*expected)
|
||||
%test_value = ::Spectator::TestValue.new({{expected}}, {{expected.splat.stringify}})
|
||||
::Spectator::Matchers::ContainMatcher.new(%test_value)
|
||||
end
|
||||
|
||||
# Indicates that some value or set should contain another value.
|
||||
# This is similar to `#contain`, but uses a different method for matching.
|
||||
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
|
||||
|
|
Loading…
Reference in a new issue