-
-
Save zetter/7133549 to your computer and use it in GitHub Desktop.
Fix to work with current version of poltergeist. Don't recommend using.
This file contains 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 | |
def redirect_stdout | |
prev_stdout = STDOUT.dup | |
prev_stderror = STDERR.dup | |
prev_stdout.autoclose = false | |
$stdout = @write_io | |
STDOUT.reopen(@write_io) | |
prev_stderror.autoclose = false | |
$stderr = @write_io | |
STDERR.reopen(@write_io) | |
yield | |
ensure | |
STDOUT.reopen(prev_stdout) | |
$stdout = STDOUT | |
STDERR.reopen(prev_stderror) | |
$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 do |app| | |
Capybara::Poltergeist::Driver.new(app, phantomjs_logger: WarningSuppressor) | |
end | |
Capybara.javascript_driver = :poltergeist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment