Sha256: 88d1d31258a5914135aef31daea690dfbcf53c1a92f5a7bf25a2dfe6b580d8bf
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require 'capybara' require 'capybara/rspec/matchers' require 'capybara/poltergeist' module Infrataster module Contexts class CapybaraContext < BaseContext CAPYBARA_DRIVER_NAME = :infrataster_driver def self.session @session ||= prepare_session end def self.prepare_session proxy = BrowsermobProxy.proxy Capybara.register_driver CAPYBARA_DRIVER_NAME do |app| Capybara::Poltergeist::Driver.new( app, phantomjs_options: ["--proxy=http://#{proxy.host}:#{proxy.port}"], ) end Capybara::Session.new(CAPYBARA_DRIVER_NAME) end def initialize(*args) super(*args) end def session self.class.session end def page session end def before_each(example) example.example_group_instance.extend(Capybara::RSpecMatchers) proxy = BrowsermobProxy.proxy proxy.header({"Host" => resource.uri.host}) address, port, @gateway_finalize_proc = server.open_gateway_on_from_server(resource.uri.port) Capybara.app_host = "http://#{address}:#{port}" end def after_each(example) @gateway_finalize_proc.call if @gateway_finalize_proc end Capybara::Session::DSL_METHODS.each do |method| define_method method do |*args, &block| page.send method, *args, &block end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
infrataster-0.1.7 | lib/infrataster/contexts/capybara_context.rb |