-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Thanks!
❤️ ❤️ ❤️ 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
You'll need to change the driver to
:poltergeist_billy_quite
.