summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTom Black <[email protected]>2016-04-21 23:05:30 -0400
committerTom Black <[email protected]>2016-04-21 23:05:30 -0400
commita3df22766dc5139e27024c96271aafb51ef1f316 (patch)
treeec89b33a148dc9b177470ca789d2c950afeed840
parent417d76099d4979d6d98c796d5425776afdb73ef4 (diff)
downloadruby2d-a3df22766dc5139e27024c96271aafb51ef1f316.tar.gz
ruby2d-a3df22766dc5139e27024c96271aafb51ef1f316.zip
Silence lib output on RSpec tests
Namely for testing when exceptions are thrown
-rw-r--r--spec/spec_helper.rb14
1 files changed, 14 insertions, 0 deletions
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