1
0
Fork 0
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:
Thomas Walpole 2018-05-10 13:20:23 -07:00
parent bda90bb504
commit baabfa5d67
22 changed files with 48 additions and 49 deletions

View file

@ -3,7 +3,7 @@ require:
AllCops:
DisabledByDefault: false
TargetRubyVersion: 2.2.2
TargetRubyVersion: 2.3.0
Exclude:
- 'capybara.gemspec'

View file

@ -4,7 +4,7 @@ dist: trusty
services:
- docker
rvm:
- 2.5.0
- 2.5.1
- 2.3.6
- jruby-9.1.16.0
gemfile:
@ -33,7 +33,7 @@ cache:
matrix:
include:
- gemfile: Gemfile
rvm: 2.5.0
rvm: 2.5.1
env: CAPYBARA_CHROME_REMOTE=true
- gemfile: gemfiles/Gemfile.rspec-34
rvm: 2.3.6
@ -44,10 +44,10 @@ matrix:
packages:
- awesome
- gemfile: Gemfile
rvm: 2.2.2
rvm: 2.5.1
env: HEADLESS=true
- gemfile: gemfiles/Gemfile.beta-versions
rvm: 2.5.0
rvm: 2.5.1
env: CAPYBARA_FF=true
addons:
firefox: latest-beta
@ -70,11 +70,10 @@ matrix:
allow_failures:
- gemfile: gemfiles/Gemfile.beta-versions
- gemfile: gemfiles/Gemfile.edge-marionette
- rvm: rbx-3
- env: CAPYBARA_CHROME_REMOTE=true
before_install:
- gem update --system
# - gem update bundler
- gem install bundler
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-marionette$ ]]; then
pushd ..;
git clone --depth 1 https://github.com/SeleniumHQ/selenium.git;

View file

@ -10,7 +10,7 @@ environment:
- RUBY_VERSION: 25
CAPYBARA_IE: true
BUNDLE_GEMFILE: gemfiles/Gemfile.ie
- RUBY_VERSION: 22
- RUBY_VERSION: 23
matrix:
allow_failures:

View file

@ -6,7 +6,7 @@ require 'capybara/version'
Gem::Specification.new do |s|
s.name = "capybara"
s.version = Capybara::VERSION
s.required_ruby_version = ">= 2.2.2"
s.required_ruby_version = ">= 2.3.0"
s.license = "MIT"
s.authors = ["Thomas Walpole", "Jonas Nicklas"]

View file

@ -155,6 +155,6 @@ class Capybara::Driver::Base
end
def session_options
(@session && @session.config) || Capybara.session_options
@session&.config || Capybara.session_options
end
end

View file

@ -307,7 +307,7 @@ module Capybara
end
end
UPDATE_STYLE_SCRIPT = <<-'JS'.freeze
UPDATE_STYLE_SCRIPT = <<-'JS'
var el = arguments[0];
el.capybara_style_cache = el.style.cssText;
var css = arguments[1];
@ -318,7 +318,7 @@ module Capybara
}
JS
RESET_STYLE_SCRIPT = <<-'JS'.freeze
RESET_STYLE_SCRIPT = <<-'JS'
var el = arguments[0];
if (el.hasOwnProperty('capybara_style_cache')) {
el.style.cssText = el.capybara_style_cache;
@ -326,7 +326,7 @@ module Capybara
}
JS
DATALIST_OPTIONS_SCRIPT = <<-'JS'.freeze
DATALIST_OPTIONS_SCRIPT = <<-'JS'
Array.prototype.slice.call((arguments[0].list||{}).options || []).
filter(function(el){ return !el.disabled }).
map(function(el){ return { "value": el.value, "label": el.label} })

View file

@ -596,7 +596,7 @@ module Capybara
#
def assert_text(*args)
_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
end
end
@ -612,7 +612,7 @@ module Capybara
#
def assert_no_text(*args)
_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
end
end

View file

@ -13,7 +13,7 @@ module Capybara
end
def description
child_query = @child_node && @child_node.instance_variable_get(:@query)
child_query = @child_node&.instance_variable_get(:@query)
desc = super
desc += " that is an ancestor of #{child_query.description}" if child_query
desc

View file

@ -59,11 +59,11 @@ module Capybara
# Generates a failure message from the query description and count options.
#
def failure_message
String.new("expected to find #{description}") << count_message
+"expected to find #{description}" << count_message
end
def negative_failure_message
String.new("expected not to find #{description}") << count_message
+"expected not to find #{description}" << count_message
end
private
@ -73,7 +73,7 @@ module Capybara
end
def count_message
message = "".dup
message = +""
if options[:count]
message << " #{options[:count]} #{Capybara::Helpers.declension('time', 'times', options[:count])}"
elsif options[:between]

View file

@ -19,7 +19,7 @@ module Capybara
def resolves_for?(session)
uri = ::Addressable::URI.parse(session.current_url)
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
@actual_path.to_s.match(@expected_path)

View file

@ -31,7 +31,7 @@ module Capybara
def label; selector.label || selector.name; end
def description
@description = "".dup
@description = +""
@description << "visible " if visible == :visible
@description << "non-visible " if visible == :hidden
@description << "#{label} #{locator.inspect}"

View file

@ -16,7 +16,7 @@ module Capybara
def description
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
end

View file

@ -50,7 +50,7 @@ module Capybara
end
def build_message(report_on_invisible)
message = "".dup
message = +""
unless (COUNT_KEYS & @options.keys).empty?
message << " but found #{@count} #{Capybara::Helpers.declension('time', 'times', @count)}"
end

View file

@ -50,7 +50,7 @@ module Capybara
idx, length = args
max_idx = case idx
when Integer
if idx >= 0
if !idx.negative?
length.nil? ? idx : idx + length - 1
else
nil

View file

@ -11,7 +11,7 @@ Capybara::Selector::FilterSet.add(:_field) do
expression_filter(:placeholder) { |xpath, val| xpath[XPath.attr(:placeholder) == val] }
describe do |checked: nil, unchecked: nil, disabled: nil, multiple: nil, **_options|
desc, states = "".dup, []
desc, states = +"", []
states << 'checked' if checked || (unchecked == false)
states << 'not checked' if unchecked || (checked == false)
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
end
describe do |type: nil, **options|
desc = "".dup
desc = +""
(expression_filters.keys - [:type]).each { |ef| desc << " with #{ef} #{options[ef]}" if options.key?(ef) }
desc << " of type #{type.inspect}" if type
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
@ -170,7 +170,7 @@ Capybara.add_selector(:link) do
end
describe do |**options|
desc = "".dup
desc = +""
desc << " with href #{options[:href].inspect}" if options[:href]
desc << " with no href attribute" if options.fetch(:href, true).nil?
end
@ -217,7 +217,7 @@ Capybara.add_selector(:button) do
filter(:disabled, :boolean, default: false, skip_if: :all) { |node, value| !(value ^ node.disabled?) }
describe do |disabled: nil, **options|
desc = "".dup
desc = +""
desc << " that is disabled" if disabled == true
desc << describe_all_expression_filters(options)
desc
@ -277,7 +277,7 @@ Capybara.add_selector(:fillable_field) do
end
describe do |options|
desc = "".dup
desc = +""
desc << describe_all_expression_filters(options)
desc << " with value #{options[:with].to_s.inspect}" if options.key?(:with)
desc
@ -310,7 +310,7 @@ Capybara.add_selector(:radio_button) do
filter(:option) { |node, value| node.value == value.to_s }
describe do |option: nil, **options|
desc = "".dup
desc = +""
desc << " with value #{option.inspect}" if option
desc << describe_all_expression_filters(options)
desc
@ -341,7 +341,7 @@ Capybara.add_selector(:checkbox) do
filter(:option) { |node, value| node.value == value.to_s }
describe do |option: nil, **options|
desc = "".dup
desc = +""
desc << " with value #{option.inspect}" if option
desc << describe_all_expression_filters(options)
desc
@ -401,7 +401,7 @@ Capybara.add_selector(:select) do
end
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 at least options #{with_options.inspect}" if with_options
desc << " with #{selected.inspect} selected" if selected
@ -434,7 +434,7 @@ Capybara.add_selector(:datalist_input) do
end
describe do |options: nil, with_options: nil, **opts|
desc = "".dup
desc = +""
desc << " with options #{options.inspect}" if options
desc << " with at least options #{with_options.inspect}" if with_options
desc << describe_all_expression_filters(opts)
@ -461,7 +461,7 @@ Capybara.add_selector(:option) do
filter(:selected, :boolean) { |node, value| !(value ^ node.selected?) }
describe do |**options|
desc = "".dup
desc = +""
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
@ -481,7 +481,7 @@ Capybara.add_selector(:datalist_option) do
filter(:disabled, :boolean) { |node, value| !(value ^ node.disabled?) }
describe do |**options|
desc = "".dup
desc = +""
desc << " that is#{' not' unless options[:disabled]} disabled" if options.key?(:disabled)
desc
end
@ -508,7 +508,7 @@ Capybara.add_selector(:file_field) do
filter_set(:_field, %i[disabled multiple name])
describe do |**options|
desc = "".dup
desc = +""
desc << describe_all_expression_filters(options)
desc
end
@ -550,7 +550,7 @@ Capybara.add_selector(:label) do
end
describe do |**options|
desc = "".dup
desc = +""
desc << " for #{options[:for]}" if options[:for]
desc
end
@ -574,7 +574,7 @@ Capybara.add_selector(:table) do
end
describe do |caption: nil, **_options|
desc = "".dup
desc = +""
desc << " with caption #{caption}" if caption
desc
end
@ -598,7 +598,7 @@ Capybara.add_selector(:frame) do
end
describe do |name: nil, **_options|
desc = "".dup
desc = +""
desc << " with name #{name}" if name
desc
end

View file

@ -5,7 +5,7 @@ module Capybara
class CSS
def self.escape(str)
value = str.dup
out = "".dup
out = +""
out << value.slice!(0...1) if value =~ /^[-_]/
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 }
@ -16,7 +16,7 @@ module Capybara
c =~ %r{[ -/:-~]} ? "\\#{c}" : format("\\%06x", c.ord)
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]/
UNICODE = /\\#{H}{1,6}[ \t\r\n\f]?/
NONASCII = /[#{S}]/

View file

@ -168,7 +168,7 @@ module Capybara
# @return [Boolean] Whether or not to use this selector
#
def match?(locator)
@match and @match.call(locator)
@match&.call(locator)
end
##

View file

@ -263,7 +263,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
end
def quit
@browser.quit if @browser
@browser&.quit
rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED
# Browser must have already gone
rescue Selenium::WebDriver::Error::UnknownError => e

View file

@ -33,7 +33,7 @@ module Capybara
end
def pending_requests?
@counter.value > 0
@counter.value.positive?
end
def call(env)
@ -86,7 +86,7 @@ module Capybara
end
def responsive?
return false if @server_thread && @server_thread.join(0)
return false if @server_thread&.join(0)
begin
res = if !@using_ssl
@ -162,7 +162,7 @@ module Capybara
server = TCPServer.new(host, 0)
server.addr[1]
ensure
server.close if server
server&.close
end
end
end

View file

@ -126,7 +126,7 @@ module Capybara
driver.reset!
@touched = false
end
@server.wait_for_pending_requests if @server
@server&.wait_for_pending_requests
raise_server_error!
end
alias_method :cleanup!, :reset!

View file

@ -86,7 +86,7 @@ module Capybara
Capybara::Session.class_variable_set(:@@instance_created, false) # Work around limit on when threadsafe can be changed
Capybara.threadsafe = bool
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

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Capybara
VERSION = '3.1.0'.freeze
VERSION = '3.1.0'
end