diff --git a/lib/scientist/experiment.rb b/lib/scientist/experiment.rb index 53f2ae0..e824268 100644 --- a/lib/scientist/experiment.rb +++ b/lib/scientist/experiment.rb @@ -18,7 +18,7 @@ def self.new(name) end # A mismatch, raised when raise_on_mismatches is enabled. - class MismatchError < StandardError + class MismatchError < Exception attr_reader :name, :result def initialize(name, result) diff --git a/test/scientist/experiment_test.rb b/test/scientist/experiment_test.rb index e12ef37..7588286 100644 --- a/test/scientist/experiment_test.rb +++ b/test/scientist/experiment_test.rb @@ -444,6 +444,20 @@ def @ex.raised(op, exception) assert_raises(Scientist::Experiment::MismatchError) { @ex.run } end + it "allows MismatchError to bubble up through bare rescues" do + Fake.raise_on_mismatches = true + @ex.use { "control" } + @ex.try { "candidate" } + runner = -> { + begin + @ex.run + rescue + # StandardError handled + end + } + assert_raises(Scientist::Experiment::MismatchError) { runner.call } + end + describe "#raise_on_mismatches?" do it "raises when there is a mismatch if the experiment instance's raise on mismatches is enabled" do Fake.raise_on_mismatches = false