Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/scientist/experiment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions test/scientist/experiment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down