Skip to content

Instantly share code, notes, and snippets.

@hadees
Forked from ericboehs/gist:7125105
Last active December 27, 2015 10:09
Show Gist options
  • Save hadees/7308571 to your computer and use it in GitHub Desktop.
Save hadees/7308571 to your computer and use it in GitHub Desktop.
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
Copy link
Author

hadees commented Nov 4, 2013

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

@OpakAlex
Copy link

OpakAlex commented Nov 7, 2013

Thanks!

@carols10cents
Copy link

❤️ ❤️ ❤️ 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