mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Detect errors in around_each
hooks
This commit is contained in:
parent
ef12e3967b
commit
56e8f8978b
1 changed files with 10 additions and 2 deletions
|
@ -41,18 +41,26 @@ module Spectator
|
|||
wrapper = wrap_run_example(result)
|
||||
|
||||
run_before_hooks
|
||||
wrapper.call
|
||||
run_wrapper(wrapper)
|
||||
run_after_hooks
|
||||
end
|
||||
end
|
||||
|
||||
private def run_wrapper(wrapper)
|
||||
wrapper.call
|
||||
rescue ex
|
||||
# If an error occurs calling the wrapper,
|
||||
# it means it came from the `around_each` hooks.
|
||||
# This is because the test code is completely wrapped with a begin/rescue block.
|
||||
raise Exception.new("Error encountered while running around hooks", ex)
|
||||
end
|
||||
|
||||
# Creates a proc that runs the test code
|
||||
# and captures the result.
|
||||
private def wrap_run_example(result) : ->
|
||||
# Wrap the method that runs and captures
|
||||
# the test code with the around-each hooks.
|
||||
group.wrap_around_each_hooks do
|
||||
# Pass along the result capture utility.
|
||||
run_example(result)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue