Ensure stubs defined with allow syntax are cleared

This commit is contained in:
Michael Miller 2022-10-09 15:48:00 -06:00
parent 2516803b0d
commit 090c95b162
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
3 changed files with 29 additions and 0 deletions

View file

@ -1,3 +1,4 @@
require "../harness"
require "./stub"
require "./stubbable"
require "./stubbed_type"
@ -21,6 +22,7 @@ module Spectator
# Applies a stub to the targeted stubbable object.
def to(stub : Stub) : Nil
@target._spectator_define_stub(stub)
Harness.current?.try &.cleanup { @target._spectator_remove_stub(stub) }
end
end
end