mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Remove support for Ruby 2.4
This commit is contained in:
parent
32c0d6cc2f
commit
79d5dcddbe
16 changed files with 115 additions and 134 deletions
|
@ -4,7 +4,7 @@ require:
|
|||
|
||||
AllCops:
|
||||
DisabledByDefault: false
|
||||
TargetRubyVersion: 2.4
|
||||
TargetRubyVersion: 2.5
|
||||
Exclude:
|
||||
- 'vendor/**/*'
|
||||
- 'gemfiles/vendor/**/*'
|
||||
|
|
12
.travis.yml
12
.travis.yml
|
@ -34,18 +34,18 @@ cache:
|
|||
matrix:
|
||||
include:
|
||||
- gemfile: gemfiles/Gemfile.gumbo
|
||||
rvm: 2.5
|
||||
rvm: 2.6
|
||||
script: bundle exec rake rack_smoke
|
||||
- gemfile: Gemfile
|
||||
rvm: 2.5
|
||||
rvm: 2.6
|
||||
env: CAPYBARA_REMOTE=true
|
||||
- gemfile: Gemfile
|
||||
rvm: 2.5
|
||||
rvm: 2.6
|
||||
env:
|
||||
- CAPYBARA_REMOTE=true
|
||||
- CAPYBARA_FF=true
|
||||
- gemfile: gemfiles/Gemfile.base-versions
|
||||
rvm: 2.4
|
||||
rvm: 2.5
|
||||
env: CAPYBARA_FF=true
|
||||
addons:
|
||||
firefox: latest
|
||||
|
@ -53,7 +53,7 @@ matrix:
|
|||
packages:
|
||||
- awesome
|
||||
- gemfile: gemfiles/Gemfile.base-versions
|
||||
rvm: 2.4
|
||||
rvm: 2.5
|
||||
- gemfile: Gemfile
|
||||
rvm: 2.6
|
||||
env: HEADLESS=true
|
||||
|
@ -102,7 +102,7 @@ matrix:
|
|||
addons:
|
||||
firefox: latest
|
||||
- gemfile: Gemfile
|
||||
rvm: 2.5
|
||||
rvm: 2.6
|
||||
env: CHROME_BETA=true HEADLESS=true
|
||||
addons:
|
||||
chrome: beta
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
# Version 3.33.0
|
||||
Release date: unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
* Ruby 2.5.0+ is now required
|
||||
|
||||
# Version 3.32.1
|
||||
Release date: 2020-04-05
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'capybara/version'
|
|||
Gem::Specification.new do |s|
|
||||
s.name = 'capybara'
|
||||
s.version = Capybara::VERSION
|
||||
s.required_ruby_version = '>= 2.4.0'
|
||||
s.required_ruby_version = '>= 2.5.0'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.authors = ['Thomas Walpole', 'Jonas Nicklas']
|
||||
|
|
|
@ -13,11 +13,9 @@ Then(/^Capybara should use the "([^"]*)" driver$/) do |driver|
|
|||
end
|
||||
|
||||
When(/^I use a matcher that fails$/) do
|
||||
begin
|
||||
expect(page).to have_css('h1#doesnotexist')
|
||||
rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e
|
||||
rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e
|
||||
@error_message = e.message
|
||||
end
|
||||
end
|
||||
|
||||
Then(/^the failing exception should be nice$/) do
|
||||
|
|
|
@ -308,7 +308,6 @@ module Capybara
|
|||
|
||||
def find_select_or_datalist_input(from, options)
|
||||
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
||||
begin
|
||||
find(:select, from, **options)
|
||||
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
||||
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
||||
|
@ -320,7 +319,6 @@ module Capybara
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def select_datalist_option(input, value)
|
||||
datalist_options = input.evaluate_script(DATALIST_OPTIONS_SCRIPT)
|
||||
|
@ -367,7 +365,6 @@ module Capybara
|
|||
options[:allow_self] = true if locator.nil?
|
||||
|
||||
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
||||
begin
|
||||
el = find(selector, locator, **options)
|
||||
el.set(checked)
|
||||
rescue StandardError => e
|
||||
|
@ -381,7 +378,6 @@ module Capybara
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
UPDATE_STYLE_SCRIPT = <<~'JS'
|
||||
this.capybara_style_cache = this.style.cssText;
|
||||
|
|
|
@ -201,13 +201,11 @@ module Capybara
|
|||
selector = extract_selector(args)
|
||||
synchronize(wait) do
|
||||
res = args.map do |locator|
|
||||
begin
|
||||
assert_selector(selector, locator, options, &optional_filter_block)
|
||||
break nil
|
||||
rescue Capybara::ExpectationNotMet => e
|
||||
e.message
|
||||
end
|
||||
end
|
||||
raise Capybara::ExpectationNotMet, res.join(' or ') if res
|
||||
|
||||
true
|
||||
|
|
|
@ -34,7 +34,7 @@ module Capybara
|
|||
private
|
||||
|
||||
def stringify_keys(hsh)
|
||||
hsh.each_with_object({}) { |(k, v), str_keys| str_keys[k.to_s] = v }
|
||||
hsh.transform_keys(&:to_s)
|
||||
end
|
||||
|
||||
def valid_keys
|
||||
|
|
|
@ -189,7 +189,7 @@ module Capybara
|
|||
def describe_all_expression_filters(**opts)
|
||||
expression_filters.map do |ef_name, ef|
|
||||
if ef.matcher?
|
||||
handled_custom_keys(ef, opts.keys).map { |key| " with #{ef_name}[#{key} => #{opts[key]}]" }.join
|
||||
handled_custom_options(ef, opts).map { |option, value| " with #{ef_name}[#{option} => #{value}]" }.join
|
||||
elsif opts.key?(ef_name)
|
||||
" with #{ef_name} #{opts[ef_name]}"
|
||||
end
|
||||
|
@ -251,9 +251,9 @@ module Capybara
|
|||
|
||||
private
|
||||
|
||||
def handled_custom_keys(filter, keys)
|
||||
keys.select do |key|
|
||||
filter.handles_option?(key) && !::Capybara::Queries::SelectorQuery::VALID_KEYS.include?(key)
|
||||
def handled_custom_options(filter, options)
|
||||
options.select do |option, _|
|
||||
filter.handles_option?(option) && !::Capybara::Queries::SelectorQuery::VALID_KEYS.include?(option)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ Capybara.add_selector(:table, locator_type: [String, Symbol]) do
|
|||
end
|
||||
|
||||
expression_filter(:cols, valid_values: [Array]) do |xpath, cols|
|
||||
raise ArgumentError, ':cols must be an Array of Arrays' unless cols.all? { |col| col.is_a? Array }
|
||||
raise ArgumentError, ':cols must be an Array of Arrays' unless cols.all?(Array)
|
||||
|
||||
rows = cols.transpose
|
||||
col_conditions = rows.map { |row| match_row(row, match_size: true) }.reduce(:&)
|
||||
|
|
|
@ -13,7 +13,6 @@ module Capybara::Selenium::Driver::ChromeDriver
|
|||
|
||||
def fullscreen_window(handle)
|
||||
within_given_window(handle) do
|
||||
begin
|
||||
super
|
||||
rescue NoMethodError => e
|
||||
raise unless e.message.match?(/full_screen_window/)
|
||||
|
@ -22,7 +21,6 @@ module Capybara::Selenium::Driver::ChromeDriver
|
|||
result['value']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def resize_window_to(handle, width, height)
|
||||
super
|
||||
|
@ -65,7 +63,7 @@ private
|
|||
end
|
||||
|
||||
def clear_all_storage?
|
||||
storage_clears.none? { |s| s == false }
|
||||
storage_clears.none? false
|
||||
end
|
||||
|
||||
def uniform_storage_clear?
|
||||
|
|
|
@ -13,7 +13,6 @@ module Capybara::Selenium::Driver::EdgeDriver
|
|||
return super if edgedriver_version < 75
|
||||
|
||||
within_given_window(handle) do
|
||||
begin
|
||||
super
|
||||
rescue NoMethodError => e
|
||||
raise unless e.message.match?(/full_screen_window/)
|
||||
|
@ -22,7 +21,6 @@ module Capybara::Selenium::Driver::EdgeDriver
|
|||
result['value']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def resize_window_to(handle, width, height)
|
||||
super
|
||||
|
@ -74,7 +72,7 @@ private
|
|||
end
|
||||
|
||||
def clear_all_storage?
|
||||
storage_clears.none? { |s| s == false }
|
||||
storage_clears.none? false
|
||||
end
|
||||
|
||||
def uniform_storage_clear?
|
||||
|
|
|
@ -42,7 +42,7 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
|
|||
|
||||
def send_keys(*args)
|
||||
# https://github.com/mozilla/geckodriver/issues/846
|
||||
return super(*args.map { |arg| arg == :space ? ' ' : arg }) if args.none? { |arg| arg.is_a? Array }
|
||||
return super(*args.map { |arg| arg == :space ? ' ' : arg }) if args.none?(Array)
|
||||
|
||||
native.click
|
||||
_send_keys(args).perform
|
||||
|
|
|
@ -33,12 +33,10 @@ module Capybara
|
|||
end
|
||||
|
||||
Array(data).map do |l|
|
||||
begin
|
||||
::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
|
||||
rescue KeyError
|
||||
next
|
||||
end
|
||||
end
|
||||
rescue ::Selenium::WebDriver::Error::UnknownCommandError
|
||||
raise NotImplementedError, LOG_MSG
|
||||
end
|
||||
|
|
|
@ -188,7 +188,6 @@ class TestApp < Sinatra::Base
|
|||
end
|
||||
|
||||
post '/upload' do
|
||||
begin
|
||||
buffer = []
|
||||
buffer << "Content-type: #{params.dig(:form, :document, :type)}"
|
||||
buffer << "File content: #{params.dig(:form, :document, :tempfile).read}"
|
||||
|
@ -196,10 +195,8 @@ class TestApp < Sinatra::Base
|
|||
rescue StandardError
|
||||
'No file uploaded'
|
||||
end
|
||||
end
|
||||
|
||||
post '/upload_multiple' do
|
||||
begin
|
||||
docs = params.dig(:form, :multiple_documents)
|
||||
buffer = [docs.size.to_s]
|
||||
docs.each do |doc|
|
||||
|
@ -210,7 +207,6 @@ class TestApp < Sinatra::Base
|
|||
rescue StandardError
|
||||
'No files uploaded'
|
||||
end
|
||||
end
|
||||
|
||||
get '/apple-touch-icon-precomposed.png' do
|
||||
halt(404)
|
||||
|
|
|
@ -75,26 +75,22 @@ RSpec.describe Capybara::Server do
|
|||
end
|
||||
|
||||
it 'should handle that getting available ports fails randomly' do
|
||||
begin
|
||||
# Use a port to force a EADDRINUSE error to be generated
|
||||
server = TCPServer.new('0.0.0.0', 0)
|
||||
server_port = server.addr[1]
|
||||
d_server = instance_double('TCPServer', addr: [nil, server_port, nil, nil], close: nil)
|
||||
call_count = 0
|
||||
allow(TCPServer).to receive(:new).and_wrap_original do |m, *args|
|
||||
begin
|
||||
call_count.zero? ? d_server : m.call(*args)
|
||||
ensure
|
||||
call_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
port = described_class.new(Object.new, host: '0.0.0.0').port
|
||||
expect(port).not_to eq(server_port)
|
||||
ensure
|
||||
server&.close
|
||||
end
|
||||
end
|
||||
|
||||
it 'should return its #base_url' do
|
||||
app = proc { |_env| [200, {}, ['Hello Server!']] }
|
||||
|
@ -104,7 +100,6 @@ RSpec.describe Capybara::Server do
|
|||
end
|
||||
|
||||
it 'should support SSL' do
|
||||
begin
|
||||
key = File.join(Dir.pwd, 'spec', 'fixtures', 'key.pem')
|
||||
cert = File.join(Dir.pwd, 'spec', 'fixtures', 'certificate.pem')
|
||||
Capybara.server = :puma, { Host: "ssl://#{Capybara.server_host}?key=#{key}&cert=#{cert}" }
|
||||
|
@ -127,7 +122,6 @@ RSpec.describe Capybara::Server do
|
|||
ensure
|
||||
Capybara.server = :default
|
||||
end
|
||||
end
|
||||
|
||||
context 'When Capybara.reuse_server is true' do
|
||||
let!(:old_reuse_server) { Capybara.reuse_server }
|
||||
|
@ -224,7 +218,6 @@ RSpec.describe Capybara::Server do
|
|||
end
|
||||
|
||||
it 'should raise server errors when the server errors before the timeout' do
|
||||
begin
|
||||
Capybara.register_server :kaboom do
|
||||
sleep 0.1
|
||||
raise 'kaboom'
|
||||
|
@ -237,7 +230,6 @@ RSpec.describe Capybara::Server do
|
|||
ensure
|
||||
Capybara.server = :default
|
||||
end
|
||||
end
|
||||
|
||||
it 'should raise an error when there are pending requests' do
|
||||
app = proc do |env|
|
||||
|
|
Loading…
Add table
Reference in a new issue