Force after_all hooks to run on fail-fast

Resolves issues #2.
This commit is contained in:
Michael Miller 2019-04-22 20:29:02 -06:00
parent 00045ba9be
commit 8480349ff0
3 changed files with 9 additions and 5 deletions

View file

@ -157,9 +157,10 @@ module Spectator
# The hooks will be run only once,
# and only after all examples in the group have finished.
# Subsequent calls after the hooks have been run will do nothing.
protected def run_after_all_hooks : Nil
protected def run_after_all_hooks(ignore_unfinished = false) : Nil
return if @after_all_hooks_run
return unless finished?
return unless ignore_unfinished || finished?
@hooks.run_after_all
@after_all_hooks_run = true
end

View file

@ -51,9 +51,9 @@ module Spectator
# and only after all examples in the group have finished.
# Subsequent calls after the hooks have been run will do nothing.
# Parent "after-all" hooks will be run last.
protected def run_after_all_hooks : Nil
protected def run_after_all_hooks(ignore_unfinished = false) : Nil
super
parent.run_after_all_hooks
parent.run_after_all_hooks(ignore_unfinished)
end
# Runs all of the "after-each" hooks.

View file

@ -34,7 +34,10 @@ module Spectator
example_order.each do |example|
result = run_example(example).as(Result)
results << result
break if @config.fail_fast? && result.is_a?(FailedResult)
if @config.fail_fast? && result.is_a?(FailedResult)
example.group.run_after_all_hooks(ignore_unfinished: true)
break
end
end
end