Skip to content

Instantly share code, notes, and snippets.

@pboling
Created October 18, 2015 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pboling/e26aaa9a4357200eab7e to your computer and use it in GitHub Desktop.
Save pboling/e26aaa9a4357200eab7e to your computer and use it in GitHub Desktop.
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 = 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