Created
June 3, 2017 03:56
-
-
Save westonplatter/a2ec2018f7ee6511171f5fedbd4bd694 to your computer and use it in GitHub Desktop.
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
| # https://github.com/teampoltergeist/poltergeist/issues/419 | |
| class RandomController < ApplicationController | |
| before_filter :check_initialized | |
| require 'capybara/rails' | |
| require 'capybara/poltergeist' | |
| def check_initialized | |
| unless initialized? | |
| new_session | |
| end | |
| end | |
| def initialized? | |
| @initialized | |
| end | |
| def new_session | |
| Capybara.register_driver :poltergeist do |app| | |
| Capybara::Poltergeist::Driver.new(app, :debug => true) | |
| end | |
| Capybara.javascript_driver = :poltergeist | |
| Capybara.current_driver = :poltergeist | |
| Capybara.app_host = 'derp.random.com' | |
| @session = Capybara::Session.new(:poltergeist) | |
| @initialized = true | |
| trap("SIGINT") { puts 'Ctrl+C pressed. Check for zombie phantomjs procs!'; exit! } # this is where the magic happens | |
| # Return the driver's session | |
| @session | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment