From a3df22766dc5139e27024c96271aafb51ef1f316 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Thu, 21 Apr 2016 23:05:30 -0400 Subject: Silence lib output on RSpec tests Namely for testing when exceptions are thrown --- spec/spec_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 82b6100..d93bff8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,4 +6,18 @@ RSpec.configure do |config| config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end + + # Silence output when running tests + original_stderr = $stderr + original_stdout = $stdout + config.before(:all) do + # Redirect stderr and stdout + $stderr = File.open(File::NULL, "w") + $stdout = File.open(File::NULL, "w") + end + config.after(:all) do + # Restore + $stderr = original_stderr + $stdout = original_stdout + end end -- cgit v1.2.3