Skip to content

Instantly share code, notes, and snippets.

@j-manu

j-manu/gist:7376425

Forked from hadees/gist:7308571
Created Nov 8, 2013
Embed
What would you like to do?
module Capybara::Poltergeist
class Client
private
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
end
end
class WarningSuppressor
class << self
def write(message)
if message =~ /QFont::setPixelSize: Pixel size <= 0/ || message =~/CoreText performance note:/ then 0 else puts(message);1;end
end
end
end
Capybara.register_driver :poltergeist_billy_quite do |app|
options = {
phantomjs_options: [
'--ignore-ssl-errors=yes',
"--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
],
phantomjs_logger: WarningSuppressor
}
Capybara::Poltergeist::Driver.new(app, options)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment