Sha256: d4b15c2714fcf9ddc930af7e3def4a70467b1be3de1ea5d53f952fec2a454ea7
Contents?: true
Size: 1.14 KB
Versions: 17
Compression:
Stored size: 1.14 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 Capybara.register_driver CAPYBARA_DRIVER_NAME do |app| Capybara::Poltergeist::Driver.new( app, ) 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) session.driver.headers = {"Host" => resource.uri.host} address, port = server.forward_port(resource.uri.port) Capybara.app_host = "http://#{address}:#{port}" 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
17 entries across 17 versions & 1 rubygems