Sha256: 166fff53b30cb0fe37e953cda8d11df22febc6027ba15a8001c7d0842d66641b

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

require "billy/version"
require "billy/config"
require "billy/handlers/handler"
require "billy/handlers/request_handler"
require "billy/handlers/stub_handler"
require "billy/handlers/proxy_handler"
require "billy/handlers/cache_handler"
require "billy/proxy_request_stub"
require "billy/cache"
require "billy/proxy"
require "billy/proxy_connection"
require "billy/railtie" if defined?(Rails)

module Billy
  def self.proxy
    @billy_proxy ||= (
      proxy = Billy::Proxy.new
      proxy.start
      proxy
    )
  end

  def self.register_drivers
    ['capybara/poltergeist', 'capybara/webkit', 'selenium/webdriver'].each do |d|
      begin
        require d
      rescue LoadError
      end
    end

    if defined?(Capybara::Poltergeist)
      Capybara.register_driver :poltergeist_billy do |app|
        options = {
          phantomjs_options: [
            '--ignore-ssl-errors=yes',
            "--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
          ]
        }
        Capybara::Poltergeist::Driver.new(app, options)
      end
    end

    if defined?(Capybara::Webkit::Driver)
      Capybara.register_driver :webkit_billy do |app|
        driver = Capybara::Webkit::Driver.new(app)
        driver.browser.ignore_ssl_errors
        driver.browser.set_proxy(:host => Billy.proxy.host,
                                 :port => Billy.proxy.port)
        driver
      end
    end

    if defined?(Selenium::WebDriver)
      Capybara.register_driver :selenium_billy do |app|
        profile = Selenium::WebDriver::Firefox::Profile.new
        profile.assume_untrusted_certificate_issuer = false
        profile.proxy = Selenium::WebDriver::Proxy.new(
          :http => "#{Billy.proxy.host}:#{Billy.proxy.port}",
          :ssl => "#{Billy.proxy.host}:#{Billy.proxy.port}")
        Capybara::Selenium::Driver.new(app, :profile => profile)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puffing-billy-0.4.1 lib/billy.rb
puffing-billy-0.4.0 lib/billy.rb