diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 471cd39..f21f3cd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,6 +22,9 @@ RSpec.configure do |config| config.include LoadFixtureHelper + config.before(:all) { silence_stdout } + config.after(:all){ enable_stdout } + # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. @@ -106,3 +109,15 @@ Kernel.srand config.seed =end end + +# Redirects stdout to /dev/null. +def silence_stdout + @orig_stdout = $stdout + $stdout = File.new('/dev/null', 'w') +end + +# Replace stdout so anything else is output correctly. +def enable_stdout + $stdout = @orig_stdout + @orig_stdout = nil +end