Skip to content

Commit 3463724

Browse files
committed
Add failing example illustrating behavior of MismatchError in bare rescue
1 parent 1105e41 commit 3463724

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/scientist/experiment_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,18 @@ def @ex.raised(op, exception)
444444
assert_raises(Scientist::Experiment::MismatchError) { @ex.run }
445445
end
446446

447+
it "allows MismatchError to bubble up through bare rescues" do
448+
Fake.raise_on_mismatches = true
449+
@ex.use { "control" }
450+
@ex.try { "candidate" }
451+
runner = -> do
452+
@ex.run
453+
rescue
454+
# StandardError handled
455+
end
456+
assert_raises(Scientist::Experiment::MismatchError) { runner.call }
457+
end
458+
447459
describe "#raise_on_mismatches?" do
448460
it "raises when there is a mismatch if the experiment instance's raise on mismatches is enabled" do
449461
Fake.raise_on_mismatches = false

0 commit comments

Comments
 (0)