Created
October 18, 2015 00:37
-
-
Save pboling/e26aaa9a4357200eab7e to your computer and use it in GitHub Desktop.
Rspec support: Silnce the `puts`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some specs causes a lot of stuff to output to the console during the spec run which interrupts the flow of lovely green dots. | |
# We don't want to ignore stuff that we want to see, like rspec deprecation warnings, but for an otherwise clean spec, | |
# that is puts ing things, we can turn those off by tagging the spec as :noisy. | |
RSpec.configure do |config| | |
original_stderr = $stderr | |
original_stdout = $stdout | |
config.before(:each, :noisy) do | |
# Redirect stderr and stdout | |
$stderr = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3 | |
$stdout = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3 | |
end | |
config.after(:each, :noisy) do | |
$stderr = original_stderr | |
$stdout = original_stdout | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment