class Capybara::Poltergeist::Inspector
Constants
- BROWSERS
- DEFAULT_PORT
Attributes
port[R]
Public Class Methods
browser_binary_exists?(browser)
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 37 def self.browser_binary_exists?(browser) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = "#{path}#{File::SEPARATOR}#{browser}#{ext}" return exe if File.executable? exe } end return nil end
detect_browser()
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 8 def self.detect_browser @browser ||= BROWSERS.find { |name| browser_binary_exists?(name) } end
new(browser = nil, port = DEFAULT_PORT)
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 14 def initialize(browser = nil, port = DEFAULT_PORT) @browser = browser.respond_to?(:to_str) ? browser : nil @port = port end
Public Instance Methods
browser()
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 19 def browser @browser ||= self.class.detect_browser end
open(scheme)
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 27 def open(scheme) if browser Process.spawn(browser, url(scheme)) else raise Error, "Could not find a browser executable to open #{url(scheme)}. " \ "You can specify one manually using e.g. `:inspector => 'chromium'` " \ "as a configuration option for Poltergeist." end end
url(scheme)
click to toggle source
# File lib/capybara/poltergeist/inspector.rb, line 23 def url(scheme) "#{scheme}://localhost:#{port}/" end