diff options
| author | Tom Black <[email protected]> | 2016-04-21 23:05:30 -0400 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2016-04-21 23:05:30 -0400 |
| commit | a3df22766dc5139e27024c96271aafb51ef1f316 (patch) | |
| tree | ec89b33a148dc9b177470ca789d2c950afeed840 | |
| parent | 417d76099d4979d6d98c796d5425776afdb73ef4 (diff) | |
| download | ruby2d-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.rb | 14 |
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 |
