mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Implement defer logic in harness
This commit is contained in:
parent
173f7bfa13
commit
2128184659
1 changed files with 12 additions and 0 deletions
|
@ -51,10 +51,22 @@ module Spectator
|
|||
@reporter.expectations
|
||||
end
|
||||
|
||||
# Marks a block of code to run later.
|
||||
def defer(&block : ->) : Nil
|
||||
@deferred << block
|
||||
end
|
||||
|
||||
# Runs all deferred blocks.
|
||||
def run_deferred : Nil
|
||||
@deferred.each(&.call)
|
||||
@deferred.clear
|
||||
end
|
||||
|
||||
# Creates a new harness.
|
||||
# The example the harness is for should be passed in.
|
||||
private def initialize(@example)
|
||||
@reporter = Expectations::ExpectationReporter.new
|
||||
@deferred = Deque(->).new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue