mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add functionality to clear stubs
This commit is contained in:
parent
fdac99d122
commit
c98442e0ed
7 changed files with 99 additions and 12 deletions
|
@ -95,6 +95,11 @@ module Spectator
|
|||
@stubs.unshift(stub)
|
||||
end
|
||||
|
||||
protected def _spectator_clear_stubs : Nil
|
||||
Log.debug { "Clearing stubs for #{_spectator_stubbed_name}" }
|
||||
@stubs.clear
|
||||
end
|
||||
|
||||
private def _spectator_find_stub(call : MethodCall) : Stub?
|
||||
Log.debug { "Finding stub for #{call}" }
|
||||
stub = @stubs.find &.===(call)
|
||||
|
|
|
@ -12,6 +12,10 @@ module Spectator
|
|||
_spectator_stubs.unshift(stub)
|
||||
end
|
||||
|
||||
def _spectator_clear_stubs : Nil
|
||||
_spectator_stubs.clear
|
||||
end
|
||||
|
||||
private def _spectator_find_stub(call : ::Spectator::MethodCall) : ::Spectator::Stub?
|
||||
_spectator_stubs.find &.===(call)
|
||||
end
|
||||
|
|
|
@ -28,6 +28,9 @@ module Spectator
|
|||
# Defines a stub to change the behavior of a method.
|
||||
abstract def _spectator_define_stub(stub : Stub) : Nil
|
||||
|
||||
# Clears all previously defined stubs.
|
||||
abstract def _spectator_clear_stubs : Nil
|
||||
|
||||
# Method called when a stub isn't found.
|
||||
#
|
||||
# The received message is captured in *call*.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue