module Spout::Helpers::Quietly

Silences output for tests

Public Instance Methods

quietly() { || ... } click to toggle source

From Rails: apidock.com/rails/v3.2.13/Kernel/quietly

# File lib/spout/helpers/quietly.rb, line 18
def quietly
  silence_stream(STDOUT) do
    silence_stream(STDERR) do
      yield
    end
  end
end
silence_stream(stream) { || ... } click to toggle source

From Rails: apidock.com/rails/v3.2.13/Kernel/silence_stream

# File lib/spout/helpers/quietly.rb, line 8
def silence_stream(stream)
  old_stream = stream.dup
  stream.reopen(/mswin|mingw/ =~ RbConfig::CONFIG["host_os"] ? "NUL:" : "/dev/null")
  stream.sync = true
  yield
ensure
  stream.reopen(old_stream)
end