Sha256: cd43e5dec0a915697d435d7ebd3aa7af31e8598c765f6cc5aa94945daa4fff0a

Contents?: true

Size: 928 Bytes

Versions: 3

Compression:

Stored size: 928 Bytes

Contents

require 'capybara'
require 'capybara/webmock/version'
require 'capybara/webmock/proxy'

module Capybara
  module Webmock

    class << self

      def start
        log_file   = File.join('log', 'test.log')
        gem_path   = File.dirname(__FILE__)
        proxy_file = File.join(gem_path, 'webmock', 'config.ru')
        IO.popen("rackup #{proxy_file} >> #{log_file} 2>&1")
      end

      def stop
        if File.exists?(Capybara::Webmock::Proxy::PID_FILE)
          rack_pid = File.read(Capybara::Webmock::Proxy::PID_FILE).to_i
          Process.kill('HUP', rack_pid)
        end
      end

    end
  end
end

Capybara.register_driver :capybara_webmock do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile["network.proxy.type"] = 1
  profile["network.proxy.http"] = '127.0.0.1'
  profile["network.proxy.http_port"] = 9292
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capybara-webmock-0.2.2 lib/capybara/webmock.rb
capybara-webmock-0.2.1 lib/capybara/webmock.rb
capybara-webmock-0.2.0 lib/capybara/webmock.rb