diff options
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c9d653adea..01ff1d3c47 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -103,6 +103,12 @@ resource_priority_map ||= nil provider_handler_map ||= nil resource_handler_map ||= nil +class UnexpectedSystemExit < RuntimeError + def self.from(system_exit) + new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) } + end +end + RSpec.configure do |config| config.include(Matchers) config.include(MockShellout::RSpec) @@ -282,6 +288,15 @@ RSpec.configure do |config| config.before(:suite) do ARGV.clear end + + # Protect Rspec from accidental exit(0) causing rspec to terminate without error + config.around(:example) do |ex| + begin + ex.run + rescue SystemExit => e + raise UnexpectedSystemExit.from(e) + end + end end require "webrick/utils" |