mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use harness' cleanup instead of defer
This commit is contained in:
parent
5c910e5a85
commit
e9d3f31ac3
1 changed files with 10 additions and 14 deletions
|
@ -164,13 +164,11 @@ module Spectator
|
||||||
stubbable._spectator_define_stub(stub)
|
stubbable._spectator_define_stub(stub)
|
||||||
|
|
||||||
# Check if the stub was invoked after the test completes.
|
# Check if the stub was invoked after the test completes.
|
||||||
Harness.current.defer do
|
matcher = Matchers::ReceiveMatcher.new(stub)
|
||||||
matcher = Matchers::ReceiveMatcher.new(stub)
|
Harness.current.defer { to(matcher, message) }
|
||||||
to(matcher, message)
|
|
||||||
ensure
|
# Prevent leaking stubs between tests.
|
||||||
# Prevent leaking stubs between tests.
|
Harness.current.cleanup { stubbable._spectator_remove_stub(stub) }
|
||||||
stubbable._spectator_remove_stub(stub)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that some criteria defined by the matcher is eventually satisfied.
|
# Asserts that some criteria defined by the matcher is eventually satisfied.
|
||||||
|
@ -202,13 +200,11 @@ module Spectator
|
||||||
stubbable._spectator_define_stub(stub)
|
stubbable._spectator_define_stub(stub)
|
||||||
|
|
||||||
# Check if the stub was invoked after the test completes.
|
# Check if the stub was invoked after the test completes.
|
||||||
Harness.current.defer do
|
matcher = Matchers::ReceiveMatcher.new(stub)
|
||||||
matcher = Matchers::ReceiveMatcher.new(stub)
|
Harness.current.defer { to_not(matcher, message) }
|
||||||
to_not(matcher, message)
|
|
||||||
ensure
|
# Prevent leaking stubs between tests.
|
||||||
# Prevent leaking stubs between tests.
|
Harness.current.cleanup { stubbable._spectator_remove_stub(stub) }
|
||||||
stubbable._spectator_remove_stub(stub)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# :ditto:
|
# :ditto:
|
||||||
|
|
Loading…
Reference in a new issue