Reduce nesting of conditionals

This commit is contained in:
Michael Miller 2018-11-19 23:46:14 -07:00
parent 101489ea19
commit f3feabb6e0

View file

@ -127,11 +127,10 @@ module Spectator
# The hooks will be run only once.
# Subsequent calls to this method will do nothing.
def run_before_all_hooks : Nil
unless @before_all_hooks_run
return if @before_all_hooks_run
@hooks.run_before_all
@before_all_hooks_run = true
end
end
# Runs all of the `before_each` hooks.
# This method should run prior to every example in the group.
@ -145,13 +144,11 @@ module Spectator
# and only after all examples in the group have finished.
# Subsequent calls after the hooks have been run will do nothing.
def run_after_all_hooks : Nil
unless @after_all_hooks_run
if finished?
return if @after_all_hooks_run
return unless finished?
@hooks.run_after_all
@after_all_hooks_run = true
end
end
end
# Runs all of the `after_each` hooks.
# This method should run following every example in the group.