Module: Kernel
- Defined in:
- lib/tork/master.rb
Overview
monkeypatch at_exit to fix RSpec and MiniTest github.com/rspec/rspec-core/pull/720 github.com/seattlerb/minitest/pull/183
Instance Method Summary collapse
Instance Method Details
#_d20922b4_a7b3_48d6_ad66_3d23e7310cf0 ⇒ Object
93 |
# File 'lib/tork/master.rb', line 93 alias _d20922b4_a7b3_48d6_ad66_3d23e7310cf0 at_exit |
#at_exit(&block) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/tork/master.rb', line 94 def at_exit &block _d20922b4_a7b3_48d6_ad66_3d23e7310cf0 do # prevent SystemExit from inhibiting testing libraries' autorun helpers: # RSpec and MiniTest don't run any tests if $! is present during at_exit if $! and $!.kind_of? SystemExit begin cleared_exit = $! $! = nil # works in Ruby 1.8; raises NameError in Ruby 1.9 rescue NameError # $! becomes nil after this rescue block ends in Ruby 1.9 end raise NotImplementedError, 'tork/master: could not clear $!' if $! end block.call # if calling the block didn't raise any exceptions, then restore the # SystemExit exception that we cleared away above (if there was any) raise cleared_exit if cleared_exit end end |