Skip to content

Instantly share code, notes, and snippets.

@semaperepelitsa
Created December 1, 2023 11:16
Show Gist options
  • Save semaperepelitsa/dc7288356fd6e23a93be90e22f91336b to your computer and use it in GitHub Desktop.
Save semaperepelitsa/dc7288356fd6e23a93be90e22f91336b to your computer and use it in GitHub Desktop.
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