mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add utility methods for setting count
This commit is contained in:
parent
dabd3a7658
commit
46aff9e11c
1 changed files with 37 additions and 0 deletions
|
@ -44,6 +44,34 @@ module Spectator::Matchers
|
|||
ReceiveMatcher.new(@expected, (2..2))
|
||||
end
|
||||
|
||||
def exactly(count)
|
||||
Count.new(@expected, (count..count))
|
||||
end
|
||||
|
||||
def at_least(count)
|
||||
Count.new(@expected, (count..))
|
||||
end
|
||||
|
||||
def at_most(count)
|
||||
Count.new(@expected, (..count))
|
||||
end
|
||||
|
||||
def at_least_once
|
||||
at_least(1).times
|
||||
end
|
||||
|
||||
def at_least_twice
|
||||
at_least(2).times
|
||||
end
|
||||
|
||||
def at_most_once
|
||||
at_most(1).times
|
||||
end
|
||||
|
||||
def at_most_twice
|
||||
at_most(2).times
|
||||
end
|
||||
|
||||
def humanize_range(range : Range)
|
||||
if (min = range.begin)
|
||||
if (max = range.end)
|
||||
|
@ -63,5 +91,14 @@ module Spectator::Matchers
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private struct Count
|
||||
def initialize(@expected : TestExpression(Symbol), @range : Range)
|
||||
end
|
||||
|
||||
def times
|
||||
ReceiveMatcher.new(@expected, @range)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue