1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/spec/spec_helper.rb

84 lines
2.4 KiB
Ruby
Raw Normal View History

2016-03-07 19:52:19 -05:00
# frozen_string_literal: true
2018-02-28 19:11:41 -05:00
require 'rspec/expectations'
2018-03-16 14:10:31 -04:00
require 'webdrivers' if ENV['CI']
require 'selenium_statistics'
2019-04-27 13:00:00 -04:00
if ENV['TRAVIS']
2019-04-25 03:39:37 -04:00
require 'coveralls'
Coveralls.wear! do
add_filter '/lib/capybara/driver/'
add_filter '/lib/capybara/registrations/'
end
end
require 'capybara/spec/spec_helper'
module Capybara
module SpecHelper
def firefox?(session)
browser_name(session) == :firefox &&
2019-04-18 03:28:05 -04:00
((defined?(::Selenium::WebDriver::VERSION) && (::Selenium::WebDriver::VERSION.to_f >= 4)) ||
session.driver.browser.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities))
end
def firefox_lt?(version, session)
firefox?(session) && (session.driver.browser.capabilities[:browser_version].to_f < version)
end
def firefox_gte?(version, session)
firefox?(session) && (session.driver.browser.capabilities[:browser_version].to_f >= version)
end
def chrome?(session)
browser_name(session) == :chrome
end
def chrome_lt?(version, session)
chrome?(session) && (session.driver.browser.capabilities[:version].to_f < version)
end
def chrome_gte?(version, session)
chrome?(session) && (session.driver.browser.capabilities[:version].to_f >= version)
end
def edge?(session)
browser_name(session) == :edge
end
def ie?(session)
%i[internet_explorer ie].include?(browser_name(session))
end
def safari?(session)
%i[safari Safari Safari_Technology_Preview].include?(browser_name(session))
end
def browser_name(session)
session.driver.browser.browser if session.respond_to?(:driver)
end
2018-09-24 12:41:47 -04:00
def remote?(session)
session.driver.browser.is_a? ::Selenium::WebDriver::Remote::Driver
end
def self.log_selenium_driver_version(mod)
mod = mod::Service if ::Selenium::WebDriver::Service.respond_to? :driver_path
path = mod.driver_path
path = path.call if path.respond_to? :call
$stdout.puts `#{path.gsub(' ', '\ ')} --version`
end
end
end
RSpec.configure do |config|
Capybara::SpecHelper.configure(config)
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.filter_run_including focus_: true unless ENV['CI']
2017-01-13 14:59:38 -05:00
config.run_all_when_everything_filtered = true
config.after(:suite) { SeleniumStatistics.print_results }
end