Skip to content

Commit

Permalink
Remove support for EOL Ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Apr 13, 2024
1 parent ae0203c commit bfac6db
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 113 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["3.0", "3.1", "3.2"]
ruby: ["3.1", "3.2"]
task: ["rack_smoke", "cucumber"]

steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
# Ensure all jobs are run to completion
fail-fast: false
matrix:
ruby: ["3.0"]
ruby: ["3.1"]
task: ["spec_chrome", "spec_firefox"]

steps:
Expand All @@ -95,7 +95,7 @@ jobs:

strategy:
matrix:
ruby: ["3.0"]
ruby: ["3.1"]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
# Ensure all jobs are run to completion
fail-fast: false
matrix:
ruby: ["3.0"]
ruby: ["3.1"]
task: ["spec_chrome", "spec_firefox"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require:
AllCops:
NewCops: enable
DisabledByDefault: false
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
Exclude:
- 'vendor/**/*'
- 'gemfiles/vendor/**/*'
Expand Down
2 changes: 1 addition & 1 deletion capybara.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require 'capybara/version'
Gem::Specification.new do |s|
s.name = 'capybara'
s.version = Capybara::VERSION
s.required_ruby_version = '>= 3.0.0'
s.required_ruby_version = '>= 3.1.0'
s.license = 'MIT'

s.authors = ['Thomas Walpole', 'Jonas Nicklas']
Expand Down
16 changes: 8 additions & 8 deletions lib/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def register_server(name, &block)
# @param [Symbol] name The name of the selector to add
# @yield A block executed in the context of the new {Capybara::Selector}
#
def add_selector(name, **options, &block)
Capybara::Selector.add(name, **options, &block)
def add_selector(name, **options, &)
Capybara::Selector.add(name, **options, &)
end

##
Expand All @@ -197,8 +197,8 @@ def add_selector(name, **options, &block)
# @param [Symbol] name The name of the selector to modify
# @yield A block executed in the context of the existing {Capybara::Selector}
#
def modify_selector(name, &block)
Capybara::Selector.update(name, &block)
def modify_selector(name, &)
Capybara::Selector.update(name, &)
end

def drivers
Expand Down Expand Up @@ -358,10 +358,10 @@ def session_name=(name)
def using_session(name_or_session, &block)
previous_session = current_session
previous_session_info = {
specified_session: specified_session,
session_name: session_name,
current_driver: current_driver,
app: app
specified_session:,
session_name:,
current_driver:,
app:
}
self.specified_session = self.session_name = nil
if name_or_session.is_a? Capybara::Session
Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def no_such_window_error
# @return [String] the message shown in the modal
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
#
def accept_modal(type, **options, &blk)
def accept_modal(type, **options, &)
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#accept_modal'
end

Expand All @@ -148,7 +148,7 @@ def accept_modal(type, **options, &blk)
# @return [String] the message shown in the modal
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
#
def dismiss_modal(type, **options, &blk)
def dismiss_modal(type, **options, &)
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#dismiss_modal'
end

Expand Down
8 changes: 4 additions & 4 deletions lib/capybara/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def self.extended(base)
#
# Shortcut to working in a different session.
#
def using_session(name_or_session, &block)
Capybara.using_session(name_or_session, &block)
def using_session(name_or_session, &)
Capybara.using_session(name_or_session, &)
end

# Shortcut to using a different wait time.
#
def using_wait_time(seconds, &block)
page.using_wait_time(seconds, &block)
def using_wait_time(seconds, &)
page.using_wait_time(seconds, &)
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def filter_backtrace(trace)
end

def warn(message, uplevel: 1)
Kernel.warn(message, uplevel: uplevel)
Kernel.warn(message, uplevel:)
end

if defined?(Process::CLOCK_MONOTONIC_RAW)
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/node/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def inspect
# @return [String] The text of the document
#
def text(type = nil, normalize_ws: false)
find(:xpath, '/html').text(type, normalize_ws: normalize_ws)
find(:xpath, '/html').text(type, normalize_ws:)
end

##
Expand Down
8 changes: 4 additions & 4 deletions lib/capybara/queries/selector_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def initialize(*args,
@selector = Selector.new(
find_selector(args[0].is_a?(Symbol) ? args.shift : args[0]),
config: {
enable_aria_label: enable_aria_label,
enable_aria_role: enable_aria_role,
test_id: test_id
enable_aria_label:,
enable_aria_role:,
test_id:
},
format: selector_format
)
Expand Down Expand Up @@ -600,7 +600,7 @@ def normalize_ws
def matches_text_regexp(node, regexp)
text_visible = visible
text_visible = :all if text_visible == :hidden
node.text(text_visible, normalize_ws: normalize_ws).match(regexp)
node.text(text_visible, normalize_ws:).match(regexp)
end

def matches_text_regexp?(node, regexp)
Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/queries/text_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def exact?

def build_message(report_on_invisible)
message = +''
unless (COUNT_KEYS & @options.keys).empty?
if COUNT_KEYS.intersect?(@options.keys)
message << " but found #{@count} #{Capybara::Helpers.declension('time', 'times', @count)}"
end
message << " in #{@actual_text.inspect}"
Expand Down Expand Up @@ -105,7 +105,7 @@ def check_case_insensitive?

def text(node: @node, query_type: @type)
normalize_ws = options.fetch(:normalize_ws, session_options.default_normalize_ws)
node.text(query_type, normalize_ws: normalize_ws)
node.text(query_type, normalize_ws:)
end

def default_type
Expand Down
8 changes: 4 additions & 4 deletions lib/capybara/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ def rest
# while JRuby >= 9.2.8.0 leaks threads when using lazy enumerators
# https://github.com/teamcapybara/capybara/issues/2349
# so disable the use and JRuby users will need to pay a performance penalty
def lazy_select_elements(&block)
@elements.select(&block).to_enum # non-lazy evaluation
def lazy_select_elements(&)
@elements.select(&).to_enum # non-lazy evaluation
end
else
def lazy_select_elements(&block)
@elements.lazy.select(&block)
def lazy_select_elements(&)
@elements.lazy.select(&)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/capybara/rspec/matcher_proxies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

module Capybara
module RSpecMatcherProxies
def all(*args, **kwargs, &block)
def all(*args, **kwargs, &)
if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
::RSpec::Matchers::BuiltIn::All.new(*args)
else
find_all(*args, **kwargs, &block)
find_all(*args, **kwargs, &)
end
end

def within(*args, **kwargs, &block)
def within(*args, **kwargs, &)
if block
within_element(*args, **kwargs, &block)
within_element(*args, **kwargs, &)
else
be_within(*args)
end
Expand Down
16 changes: 8 additions & 8 deletions lib/capybara/selector/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Definition

extend Forwardable

def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &block)
def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &)
@name = name
@filter_set = Capybara::Selector::FilterSet.add(name)
@match = nil
Expand All @@ -26,7 +26,7 @@ def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil,
@locator_type = locator_type
@raw_locator = raw_locator
@supports_exact = supports_exact
instance_eval(&block)
instance_eval(&)
end

def custom_filters
Expand Down Expand Up @@ -56,8 +56,8 @@ def expression_filters
# @overload xpath()
# @return [#call] The block that will be called to generate the XPath expression
#
def xpath(*allowed_filters, &block)
expression(:xpath, allowed_filters, &block)
def xpath(*allowed_filters, &)
expression(:xpath, allowed_filters, &)
end

##
Expand All @@ -74,8 +74,8 @@ def xpath(*allowed_filters, &block)
# @overload css()
# @return [#call] The block that will be called to generate the CSS selector
#
def css(*allowed_filters, &block)
expression(:css, allowed_filters, &block)
def css(*allowed_filters, &)
expression(:css, allowed_filters, &)
end

##
Expand Down Expand Up @@ -197,8 +197,8 @@ def describe_all_expression_filters(**opts)
end.join
end

def describe_node_filters(&block)
describe(:node_filters, &block)
def describe_node_filters(&)
describe(:node_filters, &)
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector/definition/id.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Capybara.add_selector(:id, locator_type: [String, Symbol, Regexp]) do
xpath { |id| builder(XPath.descendant).add_attribute_conditions(id: id) }
xpath { |id| builder(XPath.descendant).add_attribute_conditions(id:) }
locator_filter { |node, id| id.is_a?(Regexp) ? id.match?(node[:id]) : true }
end
6 changes: 3 additions & 3 deletions lib/capybara/selector/definition/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Capybara.add_selector(:link, locator_type: [String, Symbol]) do
xpath do |locator, href: true, alt: nil, title: nil, target: nil, **|
xpath = XPath.descendant(:a)
xpath = builder(xpath).add_attribute_conditions(href: href) unless href == false
xpath = builder(xpath).add_attribute_conditions(href:) unless href == false

if enable_aria_role
role_path = XPath.descendant[XPath.attr(:role).equals('link')]
role_path = builder(role_path).add_attribute_conditions(href: href) unless [true, false].include? href
role_path = builder(role_path).add_attribute_conditions(href:) unless [true, false].include? href

xpath += role_path
end
Expand Down Expand Up @@ -38,7 +38,7 @@
end

expression_filter(:download, valid_values: [true, false, String]) do |expr, download|
builder(expr).add_attribute_conditions(download: download)
builder(expr).add_attribute_conditions(download:)
end

describe_expression_filters do |download: nil, **options|
Expand Down
12 changes: 6 additions & 6 deletions lib/capybara/selector/filter_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def initialize(name, &block)
instance_eval(&block) if block
end

def node_filter(names, *types, **options, &block)
def node_filter(names, *types, **options, &)
Array(names).each do |name|
add_filter(name, Filters::NodeFilter, *types, **options, &block)
add_filter(name, Filters::NodeFilter, *types, **options, &)
end
end
alias_method :filter, :node_filter

def expression_filter(name, *types, **options, &block)
add_filter(name, Filters::ExpressionFilter, *types, **options, &block)
def expression_filter(name, *types, **options, &)
add_filter(name, Filters::ExpressionFilter, *types, **options, &)
end

def describe(what = nil, &block)
Expand Down Expand Up @@ -75,8 +75,8 @@ def [](name)
all.fetch(name.to_sym) { |set_name| raise ArgumentError, "Unknown filter set (:#{set_name})" }
end

def add(name, &block)
all[name.to_sym] = FilterSet.new(name.to_sym, &block)
def add(name, &)
all[name.to_sym] = FilterSet.new(name.to_sym, &)
end

def remove(name)
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector/filters/locator_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(block, **options)
end

def matches?(node, value, context = nil, exact:)
apply(node, value, true, context, exact: exact, format: context&.default_format)
apply(node, value, true, context, exact:, format: context&.default_format)
rescue Capybara::ElementNotFound
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector/regexp_disassembler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def remove_or_covered(or_series)
end

def process(alternation:)
strs = extract_strings(Regexp::Parser.parse(@regexp), alternation: alternation)
strs = extract_strings(Regexp::Parser.parse(@regexp), alternation:)
strs = collapse(combine(strs).map(&:flatten))
strs.each { |str| str.map!(&:upcase) } if @regexp.casefold?
strs
Expand Down
10 changes: 5 additions & 5 deletions lib/capybara/selector/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def [](name)
all.fetch(name.to_sym) { |sel_type| raise ArgumentError, "Unknown selector type (:#{sel_type})" }
end

def add(name, **options, &block)
all[name.to_sym] = Definition.new(name.to_sym, **options, &block)
def add(name, **options, &)
all[name.to_sym] = Definition.new(name.to_sym, **options, &)
end

def update(name, &block)
self[name].instance_eval(&block)
def update(name, &)
self[name].instance_eval(&)
end

def remove(name)
Expand Down Expand Up @@ -79,7 +79,7 @@ def add_error(error_msg)
end

def expression_for(name, locator, config: @config, format: current_format, **options)
Selector.new(name, config: config, format: format).call(locator, **options)
Selector.new(name, config:, format:).call(locator, **options)
end

# @api private
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def frame_obscured_at?(x:, y:)

switch_to_frame(:parent)
begin
frame.base.obscured?(x: x, y: y)
frame.base.obscured?(x:, y:)
ensure
switch_to_frame(frame)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def execute_cdp(cmd, params = {})
if browser.respond_to? :execute_cdp
browser.execute_cdp(cmd, **params)
else
args = { cmd: cmd, params: params }
args = { cmd:, params: }
result = bridge.http.call(:post, "session/#{bridge.session_id}/goog/cdp/execute", args)
result['value']
end
Expand Down
Loading

0 comments on commit bfac6db

Please sign in to comment.