Improve spec helper.

This commit is contained in:
Markus Reiter 2020-04-07 08:32:30 +02:00
parent 740e0242fa
commit a6be0e62af

View File

@ -173,24 +173,25 @@ RSpec.configure do |config|
@__argv = ARGV.dup @__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV @__env = ENV.to_hash # dup doesn't work on ENV
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
@__stdout = $stdout.clone @__stdout = $stdout.clone
@__stderr = $stderr.clone @__stderr = $stderr.clone
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
$stdout.reopen(File::NULL) $stdout.reopen(File::NULL)
$stderr.reopen(File::NULL) $stderr.reopen(File::NULL)
end end
example.run example.run
rescue SystemExit => e
raise "Unexpected exit with status #{e.status}."
ensure ensure
ARGV.replace(@__argv) ARGV.replace(@__argv)
ENV.replace(@__env) ENV.replace(@__env)
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
$stdout.reopen(@__stdout) $stdout.reopen(@__stdout)
$stderr.reopen(@__stderr) $stderr.reopen(@__stderr)
@__stdout.close @__stdout.close
@__stderr.close @__stderr.close
end
Formulary.clear_cache Formulary.clear_cache
Tap.clear_cache Tap.clear_cache