Move hook execution into Example#run

This commit is contained in:
Michael Miller 2018-09-12 20:42:39 -06:00
parent 5b275f3146
commit 77753ab974
2 changed files with 8 additions and 5 deletions

View file

@ -156,7 +156,14 @@ module Spectator
end
def run
Example%example.new.%run({% for v, i in var_names %}%var{i}{% if i < var_names.size - 1 %}, {% end %}{% end %})
context.run_before_all_hooks
context.run_before_each_hooks
begin
Example%example.new.%run({% for v, i in var_names %}%var{i}{% if i < var_names.size - 1 %}, {% end %}{% end %})
ensure
context.run_after_each_hooks
context.run_after_all_hooks
end
end
def description

View file

@ -24,8 +24,6 @@ module Spectator
private def run_example(example)
error = nil
example.context.run_before_all_hooks
example.context.run_before_each_hooks
elapsed = Time.measure do
begin
example.run
@ -33,8 +31,6 @@ module Spectator
error = ex
end
end
example.context.run_after_each_hooks
example.context.run_after_all_hooks
case error
when Nil
SuccessfulExampleResult.new(example, elapsed)