Created
December 1, 2023 11:16
-
-
Save semaperepelitsa/dc7288356fd6e23a93be90e22f91336b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rspec/core" | |
module RSpec | |
class << Core::Runner | |
# SIGINT callback (installed by trap_interrupt) | |
undef handle_interrupt | |
def handle_interrupt | |
if RSpec.world.wants_to_quit | |
# The default way Ruby handles an interrupt signal. | |
# Makes current example fail with this exception as a cause. | |
raise Interrupt, "" | |
else | |
RSpec.world.wants_to_quit = true | |
$stderr.puts "\nWaiting for the current example to finish. Interrupt again to abort it." | |
end | |
end | |
end | |
# Modified so that Interrupt is rescued as a regular error. | |
class << Support::AllExceptionsExceptOnesWeMustNotRescue | |
undef === | |
def ===(exception) | |
case exception | |
when Interrupt # subclass of SignalException | |
true | |
when NoMemoryError, SignalException, SystemExit | |
false | |
else | |
true | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment