mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add method to check for stub
This commit is contained in:
parent
8dbfb2d6ec
commit
186fa15a1a
1 changed files with 5 additions and 0 deletions
|
@ -41,6 +41,11 @@ module Spectator::Mocks
|
|||
fetch_type(type).stubs.unshift(stub)
|
||||
end
|
||||
|
||||
def stubbed?(object, method_name : Symbol) : Bool
|
||||
fetch_instance(object).stubs.any? { |stub| stub.name == method_name } ||
|
||||
fetch_type(object.class).stubs.any? { |stub| stub.name == method_name }
|
||||
end
|
||||
|
||||
def find_stub(object, call : GenericMethodCall(T, NT)) forall T, NT
|
||||
fetch_instance(object).stubs.find(&.callable?(call)) ||
|
||||
fetch_type(object.class).stubs.find(&.callable?(call))
|
||||
|
|
Loading…
Reference in a new issue