mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Require minimum of Ruby 2.3.0
This commit is contained in:
parent
bda90bb504
commit
baabfa5d67
22 changed files with 48 additions and 49 deletions
|
@ -3,7 +3,7 @@ require:
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
DisabledByDefault: false
|
DisabledByDefault: false
|
||||||
TargetRubyVersion: 2.2.2
|
TargetRubyVersion: 2.3.0
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'capybara.gemspec'
|
- 'capybara.gemspec'
|
||||||
|
|
||||||
|
|
11
.travis.yml
11
.travis.yml
|
@ -4,7 +4,7 @@ dist: trusty
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
rvm:
|
rvm:
|
||||||
- 2.5.0
|
- 2.5.1
|
||||||
- 2.3.6
|
- 2.3.6
|
||||||
- jruby-9.1.16.0
|
- jruby-9.1.16.0
|
||||||
gemfile:
|
gemfile:
|
||||||
|
@ -33,7 +33,7 @@ cache:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- gemfile: Gemfile
|
- gemfile: Gemfile
|
||||||
rvm: 2.5.0
|
rvm: 2.5.1
|
||||||
env: CAPYBARA_CHROME_REMOTE=true
|
env: CAPYBARA_CHROME_REMOTE=true
|
||||||
- gemfile: gemfiles/Gemfile.rspec-34
|
- gemfile: gemfiles/Gemfile.rspec-34
|
||||||
rvm: 2.3.6
|
rvm: 2.3.6
|
||||||
|
@ -44,10 +44,10 @@ matrix:
|
||||||
packages:
|
packages:
|
||||||
- awesome
|
- awesome
|
||||||
- gemfile: Gemfile
|
- gemfile: Gemfile
|
||||||
rvm: 2.2.2
|
rvm: 2.5.1
|
||||||
env: HEADLESS=true
|
env: HEADLESS=true
|
||||||
- gemfile: gemfiles/Gemfile.beta-versions
|
- gemfile: gemfiles/Gemfile.beta-versions
|
||||||
rvm: 2.5.0
|
rvm: 2.5.1
|
||||||
env: CAPYBARA_FF=true
|
env: CAPYBARA_FF=true
|
||||||
addons:
|
addons:
|
||||||
firefox: latest-beta
|
firefox: latest-beta
|
||||||
|
@ -70,11 +70,10 @@ matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- gemfile: gemfiles/Gemfile.beta-versions
|
- gemfile: gemfiles/Gemfile.beta-versions
|
||||||
- gemfile: gemfiles/Gemfile.edge-marionette
|
- gemfile: gemfiles/Gemfile.edge-marionette
|
||||||
- rvm: rbx-3
|
|
||||||
- env: CAPYBARA_CHROME_REMOTE=true
|
- env: CAPYBARA_CHROME_REMOTE=true
|
||||||
before_install:
|
before_install:
|
||||||
- gem update --system
|
- gem update --system
|
||||||
# - gem update bundler
|
- gem install bundler
|
||||||
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-marionette$ ]]; then
|
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-marionette$ ]]; then
|
||||||
pushd ..;
|
pushd ..;
|
||||||
git clone --depth 1 https://github.com/SeleniumHQ/selenium.git;
|
git clone --depth 1 https://github.com/SeleniumHQ/selenium.git;
|
||||||
|
|
|
@ -10,7 +10,7 @@ environment:
|
||||||
- RUBY_VERSION: 25
|
- RUBY_VERSION: 25
|
||||||
CAPYBARA_IE: true
|
CAPYBARA_IE: true
|
||||||
BUNDLE_GEMFILE: gemfiles/Gemfile.ie
|
BUNDLE_GEMFILE: gemfiles/Gemfile.ie
|
||||||
- RUBY_VERSION: 22
|
- RUBY_VERSION: 23
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 'capybara/version'
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "capybara"
|
s.name = "capybara"
|
||||||
s.version = Capybara::VERSION
|
s.version = Capybara::VERSION
|
||||||
s.required_ruby_version = ">= 2.2.2"
|
s.required_ruby_version = ">= 2.3.0"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
|
|
||||||
s.authors = ["Thomas Walpole", "Jonas Nicklas"]
|
s.authors = ["Thomas Walpole", "Jonas Nicklas"]
|
||||||
|
|
|
@ -155,6 +155,6 @@ class Capybara::Driver::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def session_options
|
def session_options
|
||||||
(@session && @session.config) || Capybara.session_options
|
@session&.config || Capybara.session_options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -307,7 +307,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
UPDATE_STYLE_SCRIPT = <<-'JS'.freeze
|
UPDATE_STYLE_SCRIPT = <<-'JS'
|
||||||
var el = arguments[0];
|
var el = arguments[0];
|
||||||
el.capybara_style_cache = el.style.cssText;
|
el.capybara_style_cache = el.style.cssText;
|
||||||
var css = arguments[1];
|
var css = arguments[1];
|
||||||
|
@ -318,7 +318,7 @@ module Capybara
|
||||||
}
|
}
|
||||||
JS
|
JS
|
||||||
|
|
||||||
RESET_STYLE_SCRIPT = <<-'JS'.freeze
|
RESET_STYLE_SCRIPT = <<-'JS'
|
||||||
var el = arguments[0];
|
var el = arguments[0];
|
||||||
if (el.hasOwnProperty('capybara_style_cache')) {
|
if (el.hasOwnProperty('capybara_style_cache')) {
|
||||||
el.style.cssText = el.capybara_style_cache;
|
el.style.cssText = el.capybara_style_cache;
|
||||||
|
@ -326,7 +326,7 @@ module Capybara
|
||||||
}
|
}
|
||||||
JS
|
JS
|
||||||
|
|
||||||
DATALIST_OPTIONS_SCRIPT = <<-'JS'.freeze
|
DATALIST_OPTIONS_SCRIPT = <<-'JS'
|
||||||
Array.prototype.slice.call((arguments[0].list||{}).options || []).
|
Array.prototype.slice.call((arguments[0].list||{}).options || []).
|
||||||
filter(function(el){ return !el.disabled }).
|
filter(function(el){ return !el.disabled }).
|
||||||
map(function(el){ return { "value": el.value, "label": el.label} })
|
map(function(el){ return { "value": el.value, "label": el.label} })
|
||||||
|
|
|
@ -596,7 +596,7 @@ module Capybara
|
||||||
#
|
#
|
||||||
def assert_text(*args)
|
def assert_text(*args)
|
||||||
_verify_text(args) do |count, query|
|
_verify_text(args) do |count, query|
|
||||||
unless query.matches_count?(count) && ((count > 0) || query.expects_none?)
|
unless query.matches_count?(count) && (count.positive? || query.expects_none?)
|
||||||
raise Capybara::ExpectationNotMet, query.failure_message
|
raise Capybara::ExpectationNotMet, query.failure_message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -612,7 +612,7 @@ module Capybara
|
||||||
#
|
#
|
||||||
def assert_no_text(*args)
|
def assert_no_text(*args)
|
||||||
_verify_text(args) do |count, query|
|
_verify_text(args) do |count, query|
|
||||||
if query.matches_count?(count) && ((count > 0) || query.expects_none?)
|
if query.matches_count?(count) && (count.positive? || query.expects_none?)
|
||||||
raise Capybara::ExpectationNotMet, query.negative_failure_message
|
raise Capybara::ExpectationNotMet, query.negative_failure_message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
child_query = @child_node && @child_node.instance_variable_get(:@query)
|
child_query = @child_node&.instance_variable_get(:@query)
|
||||||
desc = super
|
desc = super
|
||||||
desc += " that is an ancestor of #{child_query.description}" if child_query
|
desc += " that is an ancestor of #{child_query.description}" if child_query
|
||||||
desc
|
desc
|
||||||
|
|
|
@ -59,11 +59,11 @@ module Capybara
|
||||||
# Generates a failure message from the query description and count options.
|
# Generates a failure message from the query description and count options.
|
||||||
#
|
#
|
||||||
def failure_message
|
def failure_message
|
||||||
String.new("expected to find #{description}") << count_message
|
+"expected to find #{description}" << count_message
|
||||||
end
|
end
|
||||||
|
|
||||||
def negative_failure_message
|
def negative_failure_message
|
||||||
String.new("expected not to find #{description}") << count_message
|
+"expected not to find #{description}" << count_message
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -73,7 +73,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_message
|
def count_message
|
||||||
message = "".dup
|
message = +""
|
||||||
if options[:count]
|
if options[:count]
|
||||||
message << " #{options[:count]} #{Capybara::Helpers.declension('time', 'times', options[:count])}"
|
message << " #{options[:count]} #{Capybara::Helpers.declension('time', 'times', options[:count])}"
|
||||||
elsif options[:between]
|
elsif options[:between]
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Capybara
|
||||||
def resolves_for?(session)
|
def resolves_for?(session)
|
||||||
uri = ::Addressable::URI.parse(session.current_url)
|
uri = ::Addressable::URI.parse(session.current_url)
|
||||||
uri.query = nil if uri && options[:ignore_query]
|
uri.query = nil if uri && options[:ignore_query]
|
||||||
@actual_path = options[:url] ? uri.to_s : uri && uri.request_uri
|
@actual_path = options[:url] ? uri.to_s : uri&.request_uri
|
||||||
|
|
||||||
if @expected_path.is_a? Regexp
|
if @expected_path.is_a? Regexp
|
||||||
@actual_path.to_s.match(@expected_path)
|
@actual_path.to_s.match(@expected_path)
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Capybara
|
||||||
def label; selector.label || selector.name; end
|
def label; selector.label || selector.name; end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
@description = "".dup
|
@description = +""
|
||||||
@description << "visible " if visible == :visible
|
@description << "visible " if visible == :visible
|
||||||
@description << "non-visible " if visible == :hidden
|
@description << "non-visible " if visible == :hidden
|
||||||
@description << "#{label} #{locator.inspect}"
|
@description << "#{label} #{locator.inspect}"
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Capybara
|
||||||
|
|
||||||
def description
|
def description
|
||||||
desc = super
|
desc = super
|
||||||
sibling_query = @sibling_node && @sibling_node.instance_variable_get(:@query)
|
sibling_query = @sibling_node&.instance_variable_get(:@query)
|
||||||
desc += " that is a sibling of #{sibling_query.description}" if sibling_query
|
desc += " that is a sibling of #{sibling_query.description}" if sibling_query
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_message(report_on_invisible)
|
def build_message(report_on_invisible)
|
||||||
message = "".dup
|
message = +""
|
||||||
unless (COUNT_KEYS & @options.keys).empty?
|
unless (COUNT_KEYS & @options.keys).empty?
|
||||||
message << " but found #{@count} #{Capybara::Helpers.declension('time', 'times', @count)}"
|
message << " but found #{@count} #{Capybara::Helpers.declension('time', 'times', @count)}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Capybara
|
||||||
idx, length = args
|
idx, length = args
|
||||||
max_idx = case idx
|
max_idx = case idx
|
||||||
when Integer
|
when Integer
|
||||||
if idx >= 0
|
if !idx.negative?
|
||||||
length.nil? ? idx : idx + length - 1
|
length.nil? ? idx : idx + length - 1
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -11,7 +11,7 @@ Capybara::Selector::FilterSet.add(:_field) do
|
||||||
expression_filter(:placeholder) { |xpath, val| xpath[XPath.attr(:placeholder) == val] }
|
expression_filter(:placeholder) { |xpath, val| xpath[XPath.attr(:placeholder) == val] }
|
||||||
|
|
||||||
describe do |checked: nil, unchecked: nil, disabled: nil, multiple: nil, **_options|
|
describe do |checked: nil, unchecked: nil, disabled: nil, multiple: nil, **_options|
|
||||||
desc, states = "".dup, []
|
desc, states = +"", []
|
||||||
states << 'checked' if checked || (unchecked == false)
|
states << 'checked' if checked || (unchecked == false)
|
||||||
states << 'not checked' if unchecked || (checked == false)
|
states << 'not checked' if unchecked || (checked == false)
|
||||||
states << 'disabled' if disabled == true
|
states << 'disabled' if disabled == true
|
||||||
|
@ -94,7 +94,7 @@ Capybara.add_selector(:field) do
|
||||||
with.is_a?(Regexp) ? node.value =~ with : node.value == with.to_s
|
with.is_a?(Regexp) ? node.value =~ with : node.value == with.to_s
|
||||||
end
|
end
|
||||||
describe do |type: nil, **options|
|
describe do |type: nil, **options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
(expression_filters.keys - [:type]).each { |ef| desc << " with #{ef} #{options[ef]}" if options.key?(ef) }
|
(expression_filters.keys - [:type]).each { |ef| desc << " with #{ef} #{options[ef]}" if options.key?(ef) }
|
||||||
desc << " of type #{type.inspect}" if type
|
desc << " of type #{type.inspect}" if type
|
||||||
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
|
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
|
||||||
|
@ -170,7 +170,7 @@ Capybara.add_selector(:link) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |**options|
|
describe do |**options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with href #{options[:href].inspect}" if options[:href]
|
desc << " with href #{options[:href].inspect}" if options[:href]
|
||||||
desc << " with no href attribute" if options.fetch(:href, true).nil?
|
desc << " with no href attribute" if options.fetch(:href, true).nil?
|
||||||
end
|
end
|
||||||
|
@ -217,7 +217,7 @@ Capybara.add_selector(:button) do
|
||||||
filter(:disabled, :boolean, default: false, skip_if: :all) { |node, value| !(value ^ node.disabled?) }
|
filter(:disabled, :boolean, default: false, skip_if: :all) { |node, value| !(value ^ node.disabled?) }
|
||||||
|
|
||||||
describe do |disabled: nil, **options|
|
describe do |disabled: nil, **options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " that is disabled" if disabled == true
|
desc << " that is disabled" if disabled == true
|
||||||
desc << describe_all_expression_filters(options)
|
desc << describe_all_expression_filters(options)
|
||||||
desc
|
desc
|
||||||
|
@ -277,7 +277,7 @@ Capybara.add_selector(:fillable_field) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |options|
|
describe do |options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << describe_all_expression_filters(options)
|
desc << describe_all_expression_filters(options)
|
||||||
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
|
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
|
||||||
desc
|
desc
|
||||||
|
@ -310,7 +310,7 @@ Capybara.add_selector(:radio_button) do
|
||||||
filter(:option) { |node, value| node.value == value.to_s }
|
filter(:option) { |node, value| node.value == value.to_s }
|
||||||
|
|
||||||
describe do |option: nil, **options|
|
describe do |option: nil, **options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with value #{option.inspect}" if option
|
desc << " with value #{option.inspect}" if option
|
||||||
desc << describe_all_expression_filters(options)
|
desc << describe_all_expression_filters(options)
|
||||||
desc
|
desc
|
||||||
|
@ -341,7 +341,7 @@ Capybara.add_selector(:checkbox) do
|
||||||
filter(:option) { |node, value| node.value == value.to_s }
|
filter(:option) { |node, value| node.value == value.to_s }
|
||||||
|
|
||||||
describe do |option: nil, **options|
|
describe do |option: nil, **options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with value #{option.inspect}" if option
|
desc << " with value #{option.inspect}" if option
|
||||||
desc << describe_all_expression_filters(options)
|
desc << describe_all_expression_filters(options)
|
||||||
desc
|
desc
|
||||||
|
@ -401,7 +401,7 @@ Capybara.add_selector(:select) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |options: nil, with_options: nil, selected: nil, with_selected: nil, **opts|
|
describe do |options: nil, with_options: nil, selected: nil, with_selected: nil, **opts|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with options #{options.inspect}" if options
|
desc << " with options #{options.inspect}" if options
|
||||||
desc << " with at least options #{with_options.inspect}" if with_options
|
desc << " with at least options #{with_options.inspect}" if with_options
|
||||||
desc << " with #{selected.inspect} selected" if selected
|
desc << " with #{selected.inspect} selected" if selected
|
||||||
|
@ -434,7 +434,7 @@ Capybara.add_selector(:datalist_input) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |options: nil, with_options: nil, **opts|
|
describe do |options: nil, with_options: nil, **opts|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with options #{options.inspect}" if options
|
desc << " with options #{options.inspect}" if options
|
||||||
desc << " with at least options #{with_options.inspect}" if with_options
|
desc << " with at least options #{with_options.inspect}" if with_options
|
||||||
desc << describe_all_expression_filters(opts)
|
desc << describe_all_expression_filters(opts)
|
||||||
|
@ -461,7 +461,7 @@ Capybara.add_selector(:option) do
|
||||||
filter(:selected, :boolean) { |node, value| !(value ^ node.selected?) }
|
filter(:selected, :boolean) { |node, value| !(value ^ node.selected?) }
|
||||||
|
|
||||||
describe do |**options|
|
describe do |**options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " that is#{' not' unless options[:disabled]} disabled" if options.key?(:disabled)
|
desc << " that is#{' not' unless options[:disabled]} disabled" if options.key?(:disabled)
|
||||||
desc << " that is#{' not' unless options[:selected]} selected" if options.key?(:selected)
|
desc << " that is#{' not' unless options[:selected]} selected" if options.key?(:selected)
|
||||||
desc
|
desc
|
||||||
|
@ -481,7 +481,7 @@ Capybara.add_selector(:datalist_option) do
|
||||||
filter(:disabled, :boolean) { |node, value| !(value ^ node.disabled?) }
|
filter(:disabled, :boolean) { |node, value| !(value ^ node.disabled?) }
|
||||||
|
|
||||||
describe do |**options|
|
describe do |**options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " that is#{' not' unless options[:disabled]} disabled" if options.key?(:disabled)
|
desc << " that is#{' not' unless options[:disabled]} disabled" if options.key?(:disabled)
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
@ -508,7 +508,7 @@ Capybara.add_selector(:file_field) do
|
||||||
filter_set(:_field, %i[disabled multiple name])
|
filter_set(:_field, %i[disabled multiple name])
|
||||||
|
|
||||||
describe do |**options|
|
describe do |**options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << describe_all_expression_filters(options)
|
desc << describe_all_expression_filters(options)
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
@ -550,7 +550,7 @@ Capybara.add_selector(:label) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |**options|
|
describe do |**options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " for #{options[:for]}" if options[:for]
|
desc << " for #{options[:for]}" if options[:for]
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
@ -574,7 +574,7 @@ Capybara.add_selector(:table) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |caption: nil, **_options|
|
describe do |caption: nil, **_options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with caption #{caption}" if caption
|
desc << " with caption #{caption}" if caption
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
@ -598,7 +598,7 @@ Capybara.add_selector(:frame) do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe do |name: nil, **_options|
|
describe do |name: nil, **_options|
|
||||||
desc = "".dup
|
desc = +""
|
||||||
desc << " with name #{name}" if name
|
desc << " with name #{name}" if name
|
||||||
desc
|
desc
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Capybara
|
||||||
class CSS
|
class CSS
|
||||||
def self.escape(str)
|
def self.escape(str)
|
||||||
value = str.dup
|
value = str.dup
|
||||||
out = "".dup
|
out = +""
|
||||||
out << value.slice!(0...1) if value =~ /^[-_]/
|
out << value.slice!(0...1) if value =~ /^[-_]/
|
||||||
out << (value[0] =~ NMSTART ? value.slice!(0...1) : escape_char(value.slice!(0...1)))
|
out << (value[0] =~ NMSTART ? value.slice!(0...1) : escape_char(value.slice!(0...1)))
|
||||||
out << value.gsub(/[^a-zA-Z0-9_-]/) { |c| escape_char c }
|
out << value.gsub(/[^a-zA-Z0-9_-]/) { |c| escape_char c }
|
||||||
|
@ -16,7 +16,7 @@ module Capybara
|
||||||
c =~ %r{[ -/:-~]} ? "\\#{c}" : format("\\%06x", c.ord)
|
c =~ %r{[ -/:-~]} ? "\\#{c}" : format("\\%06x", c.ord)
|
||||||
end
|
end
|
||||||
|
|
||||||
S = '\u{80}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}'.freeze
|
S = '\u{80}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}'
|
||||||
H = /[0-9a-fA-F]/
|
H = /[0-9a-fA-F]/
|
||||||
UNICODE = /\\#{H}{1,6}[ \t\r\n\f]?/
|
UNICODE = /\\#{H}{1,6}[ \t\r\n\f]?/
|
||||||
NONASCII = /[#{S}]/
|
NONASCII = /[#{S}]/
|
||||||
|
|
|
@ -168,7 +168,7 @@ module Capybara
|
||||||
# @return [Boolean] Whether or not to use this selector
|
# @return [Boolean] Whether or not to use this selector
|
||||||
#
|
#
|
||||||
def match?(locator)
|
def match?(locator)
|
||||||
@match and @match.call(locator)
|
@match&.call(locator)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -263,7 +263,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def quit
|
def quit
|
||||||
@browser.quit if @browser
|
@browser&.quit
|
||||||
rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED
|
rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED
|
||||||
# Browser must have already gone
|
# Browser must have already gone
|
||||||
rescue Selenium::WebDriver::Error::UnknownError => e
|
rescue Selenium::WebDriver::Error::UnknownError => e
|
||||||
|
|
|
@ -33,7 +33,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_requests?
|
def pending_requests?
|
||||||
@counter.value > 0
|
@counter.value.positive?
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
@ -86,7 +86,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def responsive?
|
def responsive?
|
||||||
return false if @server_thread && @server_thread.join(0)
|
return false if @server_thread&.join(0)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
res = if !@using_ssl
|
res = if !@using_ssl
|
||||||
|
@ -162,7 +162,7 @@ module Capybara
|
||||||
server = TCPServer.new(host, 0)
|
server = TCPServer.new(host, 0)
|
||||||
server.addr[1]
|
server.addr[1]
|
||||||
ensure
|
ensure
|
||||||
server.close if server
|
server&.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -126,7 +126,7 @@ module Capybara
|
||||||
driver.reset!
|
driver.reset!
|
||||||
@touched = false
|
@touched = false
|
||||||
end
|
end
|
||||||
@server.wait_for_pending_requests if @server
|
@server&.wait_for_pending_requests
|
||||||
raise_server_error!
|
raise_server_error!
|
||||||
end
|
end
|
||||||
alias_method :cleanup!, :reset!
|
alias_method :cleanup!, :reset!
|
||||||
|
|
|
@ -86,7 +86,7 @@ module Capybara
|
||||||
Capybara::Session.class_variable_set(:@@instance_created, false) # Work around limit on when threadsafe can be changed
|
Capybara::Session.class_variable_set(:@@instance_created, false) # Work around limit on when threadsafe can be changed
|
||||||
Capybara.threadsafe = bool
|
Capybara.threadsafe = bool
|
||||||
session = session.current_session if session.respond_to?(:current_session)
|
session = session.current_session if session.respond_to?(:current_session)
|
||||||
session.instance_variable_set(:@config, nil) if session
|
session&.instance_variable_set(:@config, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Capybara
|
module Capybara
|
||||||
VERSION = '3.1.0'.freeze
|
VERSION = '3.1.0'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue