mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add method to clear recorded calls
This commit is contained in:
parent
056d5892fa
commit
989086c4fc
4 changed files with 15 additions and 2 deletions
|
@ -121,6 +121,10 @@ module Spectator
|
|||
@calls
|
||||
end
|
||||
|
||||
def _spectator_clear_calls : Nil
|
||||
@calls.clear
|
||||
end
|
||||
|
||||
# Returns the double's name formatted for user output.
|
||||
private def _spectator_stubbed_name : String
|
||||
{% if anno = @type.annotation(StubbedName) %}
|
||||
|
|
|
@ -46,6 +46,10 @@ module Spectator
|
|||
_spectator_calls.select { |call| call.method == method }
|
||||
end
|
||||
|
||||
def _spectator_clear_calls : Nil
|
||||
_spectator_calls.clear
|
||||
end
|
||||
|
||||
# Method called when a stub isn't found.
|
||||
#
|
||||
# The received message is captured in *call*.
|
||||
|
|
|
@ -38,6 +38,9 @@ module Spectator
|
|||
# Retrieves all previously saved calls.
|
||||
abstract def _spectator_calls
|
||||
|
||||
# Clears all previously saved calls.
|
||||
abstract def _spectator_clear_calls : Nil
|
||||
|
||||
# Method called when a stub isn't found.
|
||||
#
|
||||
# The received message is captured in *call*.
|
||||
|
@ -387,6 +390,8 @@ module Spectator
|
|||
extend StubbedType
|
||||
|
||||
private class_getter _spectator_stubs : Array(::Spectator::Stub) = [] of ::Spectator::Stub
|
||||
|
||||
class_getter _spectator_calls : Array(::Spectator::MethodCall) = [] of ::Spectator::MethodCall
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,8 +28,8 @@ module Spectator
|
|||
_spectator_calls << call
|
||||
end
|
||||
|
||||
def _spectator_calls
|
||||
[] of MethodCall
|
||||
def _spectator_clear_calls : Nil
|
||||
_spectator_calls.clear
|
||||
end
|
||||
|
||||
def _spectator_stub_fallback(call : MethodCall, &)
|
||||
|
|
Loading…
Reference in a new issue