Add method to check for stub

This commit is contained in:
Michael Miller 2019-11-16 10:06:11 -07:00
parent 8dbfb2d6ec
commit 186fa15a1a

View file

@ -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))