class Capybara::Poltergeist::Client

Private Instance Methods

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

This is an extension of the 'abomination' written by the authors of poltergeist. They say its for JRuby, but the suppressor does not work without redirecting stderr in addition to stdout.

# File lib/workarea/testing/warning_suppressor.rb, line 10
def redirect_stdout
  prev = STDOUT.dup
  prev.autoclose = false
  $stdout = @write_io
  STDOUT.reopen(@write_io)

  prev = STDERR.dup
  prev.autoclose = false
  $stderr = @write_io
  STDERR.reopen(@write_io)
  yield
ensure
  STDOUT.reopen(prev)
  $stdout = STDOUT
  STDERR.reopen(prev)
  $stderr = STDERR
end