Fix methods not being stubbed with `expect().to receive` syntax

This commit is contained in:
Michael Miller 2021-07-02 21:45:16 -06:00
parent 83ab5f56f0
commit 1c865d1f4b
No known key found for this signature in database
GPG Key ID: FB9F12F7C646A4AD
1 changed files with 6 additions and 2 deletions

View File

@ -71,11 +71,15 @@ module Spectator::Mocks
end
def expect(object, stub : MethodStub) : Nil
fetch_instance(object).expected.add(stub)
entry = fetch_instance(object)
entry.expected.add(stub)
entry.stubs.unshift(stub)
end
def expect(type : T.class, stub : MethodStub) : Nil forall T
fetch_type(type).expected.add(stub)
entry = fetch_type(type)
entry.expected.add(stub)
entry.stubs.unshift(stub)
end
private def fetch_instance(object)