mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add method to define stubs
This commit is contained in:
parent
123dd0efca
commit
ea46af00a6
3 changed files with 42 additions and 1 deletions
|
@ -9,6 +9,6 @@ module Spectator
|
|||
module DSL
|
||||
# Keywords that cannot be used in specs using the DSL.
|
||||
# These are either problematic or reserved for internal use.
|
||||
RESERVED_KEYWORDS = %i[initialize _spectator_stubbed_name _spectator_find_stub]
|
||||
RESERVED_KEYWORDS = %i[initialize _spectator_stubbed_name _spectator_find_stub _spectator_define_stub]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,10 @@ module Spectator
|
|||
def initialize(@stubs : Array(Stub) = [] of Stub)
|
||||
end
|
||||
|
||||
protected def _spectator_define_stub(stub : Stub) : Nil
|
||||
@stubs.unshift(stub)
|
||||
end
|
||||
|
||||
private def _spectator_find_stub(call) : Stub?
|
||||
Log.debug { "Finding stub for #{call}" }
|
||||
stub = @stubs.find &.===(call)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue