Skip to content

Instantly share code, notes, and snippets.

Created Oct 18, 2015
What would you like to do?
Rspec support: Silnce the `puts`
# 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 =, "w") # to /dev/null, since Ruby 1.9.3
$stdout =, "w") # to /dev/null, since Ruby 1.9.3
config.after(:each, :noisy) do
$stderr = original_stderr
$stdout = original_stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment