From a68a663e948d11301cf1d48c8099ed9aad0274fa Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Mon, 25 Mar 2019 09:37:25 -0700 Subject: [PATCH] Remove support for ruby 2.3 --- .rubocop.yml | 2 +- .travis.yml | 2 +- capybara.gemspec | 2 +- lib/capybara/rack_test/form.rb | 2 +- lib/capybara/selector/css.rb | 4 ++-- lib/capybara/selenium/driver.rb | 4 ++-- lib/capybara/selenium/nodes/chrome_node.rb | 4 +--- lib/capybara/session.rb | 4 ++-- lib/capybara/spec/spec_helper.rb | 2 +- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ea82602e..31706438 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: AllCops: DisabledByDefault: false - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.4 Exclude: - 'capybara.gemspec' diff --git a/.travis.yml b/.travis.yml index 892e2449..0d66ff1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/capybara.gemspec b/capybara.gemspec index 91f25a2e..10886035 100644 --- a/capybara.gemspec +++ b/capybara.gemspec @@ -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'] diff --git a/lib/capybara/rack_test/form.rb b/lib/capybara/rack_test/form.rb index 53bde425..ad3d1102 100644 --- a/lib/capybara/rack_test/form.rb +++ b/lib/capybara/rack_test/form.rb @@ -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) diff --git a/lib/capybara/selector/css.rb b/lib/capybara/selector/css.rb index 58a57476..842893c0 100644 --- a/lib/capybara/selector/css.rb +++ b/lib/capybara/selector/css.rb @@ -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) diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index 65c11d08..7e92a645 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -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 diff --git a/lib/capybara/selenium/nodes/chrome_node.rb b/lib/capybara/selenium/nodes/chrome_node.rb index 35404ad8..21061368 100644 --- a/lib/capybara/selenium/nodes/chrome_node.rb +++ b/lib/capybara/selenium/nodes/chrome_node.rb @@ -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 diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 63436530..2fa43cff 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -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 diff --git a/lib/capybara/spec/spec_helper.rb b/lib/capybara/spec/spec_helper.rb index 122c5b3e..479143de 100644 --- a/lib/capybara/spec/spec_helper.rb +++ b/lib/capybara/spec/spec_helper.rb @@ -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