Remove support for ruby 2.3

This commit is contained in:
Thomas Walpole 2019-03-25 09:37:25 -07:00
parent 5e133126c3
commit a68a663e94
9 changed files with 12 additions and 14 deletions

View File

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

View File

@ -42,7 +42,7 @@ matrix:
- CAPYBARA_REMOTE=true
- CAPYBARA_FF=true
- gemfile: gemfiles/Gemfile.base-versions
rvm: 2.3.8
rvm: 2.4
env: CAPYBARA_FF=true
addons:
firefox: latest

View File

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

View File

@ -56,7 +56,7 @@ private
end
def request_method
self[:method] =~ /post/i ? :post : :get
self[:method].to_s.match?(/post/i) ? :post : :get
end
def merge_param!(params, key, value)

View File

@ -7,13 +7,13 @@ module Capybara
value = str.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[0].match?(NMSTART) ? value.slice!(0...1) : escape_char(value.slice!(0...1)))
out << value.gsub(/[^a-zA-Z0-9_-]/) { |char| escape_char char }
out
end
def self.escape_char(char)
char =~ %r{[ -/:-~]} ? "\\#{char}" : format('\\%06x', char.ord)
char.match?(%r{[ -/:-~]}) ? "\\#{char}" : format('\\%06x', char.ord)
end
def self.split(css)

View File

@ -322,7 +322,7 @@ private
wait.until do
alert = @browser.switch_to.alert
regexp = text.is_a?(Regexp) ? text : Regexp.escape(text.to_s)
alert.text.match(regexp) ? alert : nil
alert.text.match?(regexp) ? alert : nil
end
rescue Selenium::WebDriver::Error::TimeOutError
raise Capybara::ModalNotFound, "Unable to find modal dialog#{" with #{text}" if text}"
@ -342,7 +342,7 @@ private
when Array
arg.map { |arr| unwrap_script_result(arr) }
when Hash
arg.each { |key, value| arg[key] = unwrap_script_result(value) }
arg.transform_values! { |value| unwrap_script_result(value) }
when Selenium::WebDriver::Element
build_node(arg)
else

View File

@ -15,9 +15,7 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
def set_file(value) # rubocop:disable Naming/AccessorMethodName
super(value)
rescue ::Selenium::WebDriver::Error::ExpectedError => err
if err.message =~ /File not found : .+\n.+/m
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload"
end
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if err.message.match?(/File not found : .+\n.+/m)
raise
end

View File

@ -263,7 +263,7 @@ module Capybara
if base_uri && [nil, 'http', 'https'].include?(visit_uri.scheme)
if visit_uri.relative?
visit_uri_parts = visit_uri.to_hash.delete_if { |_k, value| value.nil? }
visit_uri_parts = visit_uri.to_hash.compact
# Useful to people deploying to a subdirectory
# and/or single page apps where only the url fragment changes
@ -850,7 +850,7 @@ module Capybara
when Array
arg.map { |subarg| element_script_result(subarg) }
when Hash
arg.each { |key, value| arg[key] = element_script_result(value) }
arg.transform_values! { |value| element_script_result(value) }
when Capybara::Driver::Node
Capybara::Node::Element.new(self, arg, nil, nil)
else

View File

@ -100,7 +100,7 @@ module Capybara
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RbConfig::CONFIG['host_os'] =~ /rmswin|mingw/ ? 'NUL:' : '/dev/null')
stream.reopen(RbConfig::CONFIG['host_os'].match?(/rmswin|mingw/) ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure