Match hook ordering of RSpec

Addresses https://github.com/icy-arctic-fox/spectator/issues/12
This commit is contained in:
Michael Miller 2021-01-16 17:04:42 -07:00
parent cd519178ac
commit 57c9333c1f
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -54,11 +54,15 @@ module Spectator
begin
@result = Harness.run do
group?.try(&.call_once_before_all)
if (parent = group?)
parent.call_around_each(self) { run_internal }
else
run_internal
end
if (parent = group?)
parent.call_once_after_all if parent.finished?
end
end
ensure
@@current = previous_example
@ -67,9 +71,9 @@ module Spectator
end
private def run_internal
run_before_hooks
group?.try(&.call_before_each(self))
run_test
run_after_hooks
group?.try(&.call_after_each(self))
end
private def run_before_hooks : Nil