mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Update receive matchers to use registry
This commit is contained in:
parent
9e8286f892
commit
48363951c2
3 changed files with 8 additions and 8 deletions
|
@ -14,8 +14,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
def match?(actual : TestExpression(T)) : Bool forall T
|
||||
double = actual.value.as(Mocks::Double)
|
||||
calls = double.spectator_stub_calls(@expected.value).select { |call| @args === call.args }
|
||||
calls = Mocks::Registry.calls_for(actual.value, @expected.value).select { |call| @args === call.args }
|
||||
if (range = @range)
|
||||
range.includes?(calls.size)
|
||||
else
|
||||
|
@ -29,8 +28,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
def values(actual : TestExpression(T)) forall T
|
||||
double = actual.value.as(Mocks::Double)
|
||||
calls = double.spectator_stub_calls(@expected.value)
|
||||
calls = Mocks::Registry.calls_for(actual.value, @expected.value).select { |call| @args === call.args }
|
||||
range = @range
|
||||
{
|
||||
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with #{@args}",
|
||||
|
|
|
@ -14,8 +14,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
def match?(actual : TestExpression(T)) : Bool forall T
|
||||
double = actual.value.as(Mocks::Double)
|
||||
calls = double.spectator_stub_calls(@expected.value)
|
||||
calls = Mocks::Registry.calls_for(actual.value, @expected.value)
|
||||
if (range = @range)
|
||||
range.includes?(calls.size)
|
||||
else
|
||||
|
@ -29,8 +28,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
def values(actual : TestExpression(T)) forall T
|
||||
double = actual.value.as(Mocks::Double)
|
||||
calls = double.spectator_stub_calls(@expected.value)
|
||||
calls = Mocks::Registry.calls_for(actual.value, @expected.value)
|
||||
range = @range
|
||||
{
|
||||
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with any arguments",
|
||||
|
|
|
@ -27,6 +27,10 @@ module Spectator::Mocks
|
|||
fetch(object).calls << call
|
||||
end
|
||||
|
||||
def calls_for(object, method_name : Symbol)
|
||||
fetch(object).calls.select { |call| call.name == method_name }
|
||||
end
|
||||
|
||||
private def fetch(object)
|
||||
key = unique_key(object)
|
||||
if @@entries.has_key?(key)
|
||||
|
|
Loading…
Reference in a new issue