# frozen_string_literal: true ############################################################################## # Capybara Plugin ############################################################################## # # This plugin does not attempt to require capybara. It assumes that if you're # using capybara, you're probably using something like Bundler which has already # required it for you. # # If this is not the case, you will need to require it prior to requiring # rspeckled. # # The same goes for capybara-webkit. It must be required before rspeckled. # begin require 'capybara/rspec' require 'capybara/rails' if defined?(Capybara::Driver::Base) Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end Capybara.register_driver :firefox do |app| Capybara::Selenium::Driver.new(app, :browser => :firefox) end if defined?(Selenium::WebDriver) Selenium::WebDriver.logger.output = 'log/selenium.log' end if defined?(Capybara::Webkit) Capybara.javascript_driver = :webkit Capybara::Webkit.configure do |config| config.block_unknown_urls config.skip_image_loading config.allow_url('*.lvh.me') config.allow_url('*.cloudfront.net') config.allow_url('*.s3.amazonaws.com') if defined?(Chamber) config.allow_url("*.#{Chamber.env.http.host}") config.allow_url("*.#{Chamber.env.http.web_client_domain}") end end else Capybara.javascript_driver = :selenium end RSpec.configure do |config| config.before(:each, :js => true) do page.driver.reset! end config.before(:each, :js => true, :autofocus => true) do Thread.new do sleep 1.5 ` osascript -e ' tell the application named "Firefox" activate set theWindow to the first item of windows if index of theWindow is not 1 then set index to 1 set visible to false set visible to true end if end tell ' > /dev/null ` end end config.after(:each, :js => true, :autofocus => true) do sleep 10 end config.before(:each, :js => true, :feature => true, :debug => true) do Selenium::WebDriver.logger.level = :debug if defined?(Selenium::WebDriver) end config.after(:each, :js => true, :feature => true, :debug => true) do Selenium::WebDriver.logger.level = :warn if defined?(Selenium::WebDriver) end end Capybara.configure do |config| config.exact = true config.match = :one config.ignore_hidden_elements = true config.visible_text_only = true end if defined?(Chamber) Capybara.default_host = Chamber.env.http.host_with_port Capybara.app_host = Chamber.env.http.base_url Capybara.server_port = Chamber.env.http.port end end rescue LoadError end # rubocop:enable Style/SymbolProc