Add checks for cause of hook error

Fix some tests that had copy/paste mistakes.
This commit is contained in:
Michael Miller 2018-12-07 23:07:04 -07:00
parent ef490c78b0
commit ef12e3967b

View file

@ -532,6 +532,16 @@ describe Spectator::RunnableExample do
end
end
it "passes along the original exception" do
error = Exception.new("oops")
hooks = new_hooks(before_all: ->{ raise error; nil })
begin
run_example(PassingExample, hooks)
rescue ex
ex.cause.should eq(error)
end
end
it "doesn't run the test code" do
called = false
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
@ -578,6 +588,16 @@ describe Spectator::RunnableExample do
end
end
it "passes along the original exception" do
error = Exception.new("oops")
hooks = new_hooks(before_each: ->{ raise error; nil })
begin
run_example(PassingExample, hooks)
rescue ex
ex.cause.should eq(error)
end
end
it "doesn't run the test code" do
called = false
hooks = new_hooks(before_each: ->{ raise "oops"; nil })
@ -617,15 +637,25 @@ describe Spectator::RunnableExample do
context "when an error is raised in an after_all hook" do
it "raises the exception" do
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
hooks = new_hooks(after_all: ->{ raise "oops"; nil })
expect_raises(Exception) do
run_example(PassingExample, hooks)
end
end
it "passes along the original exception" do
error = Exception.new("oops")
hooks = new_hooks(after_all: ->{ raise error; nil })
begin
run_example(PassingExample, hooks)
rescue ex
ex.cause.should eq(error)
end
end
it "doesn't run any additional after_all hooks" do
called = false
hooks = new_hooks(before_all: [
hooks = new_hooks(after_all: [
->{ raise "oops"; nil },
->{ called = true; nil },
])
@ -644,6 +674,16 @@ describe Spectator::RunnableExample do
end
end
it "passes along the original exception" do
error = Exception.new("oops")
hooks = new_hooks(after_each: ->{ raise error; nil })
begin
run_example(PassingExample, hooks)
rescue ex
ex.cause.should eq(error)
end
end
it "doesn't run any additional after_each hooks" do
called = false
hooks = new_hooks(after_each: [
@ -679,6 +719,16 @@ describe Spectator::RunnableExample do
end
end
it "passes along the original exception" do
error = Exception.new("oops")
hooks = new_hooks(around_each: ->(proc : ->) { raise error; proc.call })
begin
run_example(PassingExample, hooks)
rescue ex
ex.cause.should eq(error)
end
end
it "doesn't run the test code" do
called = false
hooks = new_hooks(around_each: ->(proc : ->) { raise "oops"; proc.call })