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
|
end
|
||||||
|
|
||||||
def match?(actual : TestExpression(T)) : Bool forall T
|
def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
double = actual.value.as(Mocks::Double)
|
calls = Mocks::Registry.calls_for(actual.value, @expected.value).select { |call| @args === call.args }
|
||||||
calls = double.spectator_stub_calls(@expected.value).select { |call| @args === call.args }
|
|
||||||
if (range = @range)
|
if (range = @range)
|
||||||
range.includes?(calls.size)
|
range.includes?(calls.size)
|
||||||
else
|
else
|
||||||
|
@ -29,8 +28,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
def values(actual : TestExpression(T)) forall T
|
def values(actual : TestExpression(T)) forall T
|
||||||
double = actual.value.as(Mocks::Double)
|
calls = Mocks::Registry.calls_for(actual.value, @expected.value).select { |call| @args === call.args }
|
||||||
calls = double.spectator_stub_calls(@expected.value)
|
|
||||||
range = @range
|
range = @range
|
||||||
{
|
{
|
||||||
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with #{@args}",
|
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with #{@args}",
|
||||||
|
|
|
@ -14,8 +14,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
def match?(actual : TestExpression(T)) : Bool forall T
|
def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
double = actual.value.as(Mocks::Double)
|
calls = Mocks::Registry.calls_for(actual.value, @expected.value)
|
||||||
calls = double.spectator_stub_calls(@expected.value)
|
|
||||||
if (range = @range)
|
if (range = @range)
|
||||||
range.includes?(calls.size)
|
range.includes?(calls.size)
|
||||||
else
|
else
|
||||||
|
@ -29,8 +28,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
def values(actual : TestExpression(T)) forall T
|
def values(actual : TestExpression(T)) forall T
|
||||||
double = actual.value.as(Mocks::Double)
|
calls = Mocks::Registry.calls_for(actual.value, @expected.value)
|
||||||
calls = double.spectator_stub_calls(@expected.value)
|
|
||||||
range = @range
|
range = @range
|
||||||
{
|
{
|
||||||
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with any arguments",
|
expected: "#{range ? "#{humanize_range(range)} time(s)" : "At least once"} with any arguments",
|
||||||
|
|
|
@ -27,6 +27,10 @@ module Spectator::Mocks
|
||||||
fetch(object).calls << call
|
fetch(object).calls << call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def calls_for(object, method_name : Symbol)
|
||||||
|
fetch(object).calls.select { |call| call.name == method_name }
|
||||||
|
end
|
||||||
|
|
||||||
private def fetch(object)
|
private def fetch(object)
|
||||||
key = unique_key(object)
|
key = unique_key(object)
|
||||||
if @@entries.has_key?(key)
|
if @@entries.has_key?(key)
|
||||||
|
|
Loading…
Reference in a new issue