mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Negation for receive matchers
This commit is contained in:
parent
5da231a5e8
commit
a63d3d05a5
2 changed files with 30 additions and 0 deletions
|
@ -28,6 +28,11 @@ module Spectator::Matchers
|
||||||
"#{actual.label} did not receive #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
"#{actual.label} did not receive #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def failure_message_when_negated(actual) : String
|
||||||
|
range = @range
|
||||||
|
"#{actual.label} received #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
||||||
|
end
|
||||||
|
|
||||||
def values(actual : TestExpression(T)) forall T
|
def values(actual : TestExpression(T)) forall T
|
||||||
calls = Harness.current.mocks.calls_for(actual.value, @expected.value)
|
calls = Harness.current.mocks.calls_for(actual.value, @expected.value)
|
||||||
calls.select! { |call| @args === call.args } if @args
|
calls.select! { |call| @args === call.args } if @args
|
||||||
|
@ -38,6 +43,16 @@ module Spectator::Matchers
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def negated_values(actual : TestExpression(T)) forall T
|
||||||
|
calls = Harness.current.mocks.calls_for(actual.value, @expected.value)
|
||||||
|
calls.select! { |call| @args === call.args } if @args
|
||||||
|
range = @range
|
||||||
|
{
|
||||||
|
expected: "#{range ? "Not #{humanize_range(range)} time(s)" : "Never"} with #{@args || "any arguments"}",
|
||||||
|
received: "#{calls.size} time(s)",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def with(*args, **opts)
|
def with(*args, **opts)
|
||||||
args = Mocks::GenericArguments.new(args, opts)
|
args = Mocks::GenericArguments.new(args, opts)
|
||||||
ReceiveMatcher.new(@expected, args, @range)
|
ReceiveMatcher.new(@expected, args, @range)
|
||||||
|
|
|
@ -28,6 +28,11 @@ module Spectator::Matchers
|
||||||
"#{actual.label} did not receive #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
"#{actual.label} did not receive #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def failure_message_when_negated(actual : TestExpression(T)) : String forall T
|
||||||
|
range = @range
|
||||||
|
"#{actual.label} received #{@expected.label} #{range ? "#{humanize_range(range)} time(s)" : "at least once"} with #{@args || "any arguments"}"
|
||||||
|
end
|
||||||
|
|
||||||
def values(actual : TestExpression(T)) forall T
|
def values(actual : TestExpression(T)) forall T
|
||||||
calls = Harness.current.mocks.calls_for_type(T, @expected.value)
|
calls = Harness.current.mocks.calls_for_type(T, @expected.value)
|
||||||
calls.select! { |call| @args === call.args } if @args
|
calls.select! { |call| @args === call.args } if @args
|
||||||
|
@ -38,6 +43,16 @@ module Spectator::Matchers
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def negated_values(actual : TestExpression(T)) forall T
|
||||||
|
calls = Harness.current.mocks.calls_for_type(T, @expected.value)
|
||||||
|
calls.select! { |call| @args === call.args } if @args
|
||||||
|
range = @range
|
||||||
|
{
|
||||||
|
expected: "#{range ? "Not #{humanize_range(range)} time(s)" : "Never"} with #{@args || "any arguments"}",
|
||||||
|
received: "#{calls.size} time(s)",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def with(*args, **opts)
|
def with(*args, **opts)
|
||||||
args = Mocks::GenericArguments.new(args, opts)
|
args = Mocks::GenericArguments.new(args, opts)
|
||||||
ReceiveTypeMatcher.new(@expected, args, @range)
|
ReceiveTypeMatcher.new(@expected, args, @range)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue