Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit f2d40c1

Browse files
committed
Work around 1.8.7/JRuby weirdness.
1 parent a257d19 commit f2d40c1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/rspec/core/example.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def run(example_group_instance, reporter)
227227
rescue Pending::SkipDeclaredInExample
228228
# no-op, required metadata has already been set by the `skip`
229229
# method.
230-
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
230+
rescue AllExceptionsExcludingDangerousOnesOnRubiesThatAllowIt => e
231231
set_exception(e)
232232
ensure
233233
run_after_example
@@ -245,6 +245,20 @@ def run(example_group_instance, reporter)
245245
RSpec.current_example = nil
246246
end
247247

248+
if RSpec::Support::Ruby.jruby? || RUBY_VERSION.to_f < 1.9
249+
# :nocov:
250+
# For some reason, rescuing `Support::AllExceptionsExceptOnesWeMustNotRescue`
251+
# in place of `Exception` above can cause the exit status to be the wrong
252+
# thing. I have no idea why. See:
253+
# https://github.com/rspec/rspec-core/pull/2063#discussion_r38284978
254+
# @private
255+
AllExceptionsExcludingDangerousOnesOnRubiesThatAllowIt = Exception
256+
# :nocov:
257+
else
258+
# @private
259+
AllExceptionsExcludingDangerousOnesOnRubiesThatAllowIt = Support::AllExceptionsExceptOnesWeMustNotRescue
260+
end
261+
248262
# Wraps both a `Proc` and an {Example} for use in {Hooks#around
249263
# around} hooks. In around hooks we need to yield this special
250264
# kind of object (rather than the raw {Example}) because when

0 commit comments

Comments
 (0)