Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Poltergeist hack to silence CoreText performance notes from phantomjs that works with billy.
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
@hadees

This comment has been minimized.

Copy link
Owner Author

@hadees hadees commented Nov 4, 2013

You'll need to change the driver to :poltergeist_billy_quite.

@OpakAlex

This comment has been minimized.

Copy link

@OpakAlex OpakAlex commented Nov 7, 2013

Thanks!

@carols10cents

This comment has been minimized.

Copy link

@carols10cents carols10cents commented Dec 1, 2013

❤️ ❤️ ❤️ Thank you for figuring this out and sharing! It's such a little thing but not having to see those warning messages is sooo much nicer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment