mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Implement remaining hook error tests
This commit is contained in:
parent
99de2335aa
commit
2aa7a75eea
1 changed files with 191 additions and 128 deletions
|
@ -179,134 +179,6 @@ describe Spectator::RunnableExample do
|
||||||
calls.should eq(%i[a b])
|
calls.should eq(%i[a b])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when an error is raised in a before_all hook" do
|
|
||||||
it "raises the exception" do
|
|
||||||
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(PassingExample, hooks)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't run the test code" do
|
|
||||||
called = false
|
|
||||||
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(hooks) do
|
|
||||||
called = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
called.should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't run any additional before_all hooks" do
|
|
||||||
called = false
|
|
||||||
hooks = new_hooks(before_all: [
|
|
||||||
->{ raise "oops"; nil },
|
|
||||||
->{ called = true; nil },
|
|
||||||
])
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(PassingExample, hooks)
|
|
||||||
end
|
|
||||||
called.should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't run any additional hooks" do
|
|
||||||
called = :none
|
|
||||||
hooks = new_hooks(
|
|
||||||
before_all: ->{ raise "oops"; nil },
|
|
||||||
before_each: ->{ called = :before_each; nil },
|
|
||||||
after_all: ->{ called = :after_all; nil },
|
|
||||||
after_each: ->{ called = :after_each; nil },
|
|
||||||
around_each: ->(proc : ->) { called = :around_each; proc.call })
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(PassingExample, hooks)
|
|
||||||
end
|
|
||||||
called.should eq(:none)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when an error is raised in a before_each hook" do
|
|
||||||
pending "returns an errored result" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "passes along the exception" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run the test code" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any additional before_each hooks" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any around_each or after_each hooks" do
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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 })
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(PassingExample, hooks)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't run any additional after_all hooks" do
|
|
||||||
called = false
|
|
||||||
hooks = new_hooks(before_all: [
|
|
||||||
->{ raise "oops"; nil },
|
|
||||||
->{ called = true; nil },
|
|
||||||
])
|
|
||||||
expect_raises(Exception) do
|
|
||||||
run_example(PassingExample, hooks)
|
|
||||||
end
|
|
||||||
called.should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when an error is raised in an after_each hook" do
|
|
||||||
pending "returns an errored result" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "passes along the exception" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any additional after_each hooks" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any after_all hooks" do
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with a failing result" do
|
|
||||||
pending "returns the original failure" do
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with an errored result" do
|
|
||||||
pending "returns the original error" do
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when an error is raised in an around_each hook" do
|
|
||||||
pending "raises the exception" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run the test code" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "returns an errored result" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "passes along the exception" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any additional around_each hooks" do
|
|
||||||
end
|
|
||||||
|
|
||||||
pending "doesn't run any after_each or after_all hooks" do
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a failing test" do
|
context "with a failing test" do
|
||||||
|
@ -628,6 +500,197 @@ describe Spectator::RunnableExample do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when an error is raised in a before_all hook" do
|
||||||
|
it "raises the exception" do
|
||||||
|
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run the test code" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(before_all: ->{ raise "oops"; nil })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(hooks) do
|
||||||
|
called = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional before_all hooks" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(before_all: [
|
||||||
|
->{ raise "oops"; nil },
|
||||||
|
->{ called = true; nil },
|
||||||
|
])
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional hooks" do
|
||||||
|
called = :none
|
||||||
|
hooks = new_hooks(
|
||||||
|
before_all: ->{ raise "oops"; nil },
|
||||||
|
before_each: ->{ called = :before_each; nil },
|
||||||
|
after_all: ->{ called = :after_all; nil },
|
||||||
|
after_each: ->{ called = :after_each; nil },
|
||||||
|
around_each: ->(proc : ->) { called = :around_each; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should eq(:none)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when an error is raised in a before_each hook" do
|
||||||
|
it "raises the exception" do
|
||||||
|
hooks = new_hooks(before_each: ->{ raise "oops"; nil })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run the test code" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(before_each: ->{ raise "oops"; nil })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(hooks) do
|
||||||
|
called = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional before_each hooks" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(before_each: [
|
||||||
|
->{ raise "oops"; nil },
|
||||||
|
->{ called = true; nil },
|
||||||
|
])
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional hooks" do
|
||||||
|
called = :none
|
||||||
|
hooks = new_hooks(
|
||||||
|
before_each: ->{ raise "oops"; nil },
|
||||||
|
after_all: ->{ called = :after_all; nil },
|
||||||
|
after_each: ->{ called = :after_each; nil },
|
||||||
|
around_each: ->(proc : ->) { called = :around_each; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should eq(:none)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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 })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional after_all hooks" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(before_all: [
|
||||||
|
->{ raise "oops"; nil },
|
||||||
|
->{ called = true; nil },
|
||||||
|
])
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when an error is raised in an after_each hook" do
|
||||||
|
it "raises the exception" do
|
||||||
|
hooks = new_hooks(after_each: ->{ raise "oops"; nil })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional after_each hooks" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(after_each: [
|
||||||
|
->{ raise "oops"; nil },
|
||||||
|
->{ called = true; nil },
|
||||||
|
])
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional hooks" do
|
||||||
|
called = :none
|
||||||
|
hooks = new_hooks(
|
||||||
|
before_all: ->{ nil },
|
||||||
|
before_each: ->{ nil },
|
||||||
|
after_all: ->{ called = :after_all; nil },
|
||||||
|
after_each: ->{ raise "oops"; nil },
|
||||||
|
around_each: ->(proc : ->) { called = :around_each; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should eq(:none)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when an error is raised in an around_each hook" do
|
||||||
|
it "raises the exception" do
|
||||||
|
hooks = new_hooks(around_each: ->(proc : ->) { raise "oops"; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run the test code" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(around_each: ->(proc : ->) { raise "oops"; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(hooks) do
|
||||||
|
called = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional around_each hooks" do
|
||||||
|
called = false
|
||||||
|
hooks = new_hooks(around_each: [
|
||||||
|
->(proc : ->) { raise "oops"; proc.call },
|
||||||
|
->(proc : ->) { called = true; proc.call },
|
||||||
|
])
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't run any additional hooks" do
|
||||||
|
called = :none
|
||||||
|
hooks = new_hooks(
|
||||||
|
after_all: ->{ called = :after_all; nil },
|
||||||
|
after_each: ->{ called = :after_each; nil },
|
||||||
|
around_each: ->(proc : ->) { raise "oops"; proc.call })
|
||||||
|
expect_raises(Exception) do
|
||||||
|
run_example(PassingExample, hooks)
|
||||||
|
end
|
||||||
|
called.should eq(:none)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#finished?" do
|
describe "#finished?" do
|
||||||
|
|
Loading…
Reference in a new issue