Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for EOL Ruby 3.0 #2760

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
84 changes: 42 additions & 42 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", "3.3"]
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 @@ -90,45 +90,45 @@ jobs:
- name: Run tests
run: bundle exec rake ${{ matrix.task }}

remote_chrome:
runs-on: ubuntu-latest

strategy:
matrix:
ruby: ["3.0"]

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run remote Chrome
run: docker-compose up -d selenium_chrome
- name: Run specs
run: bundle exec rake spec_chrome_remote

remote_firefox:
runs-on: ubuntu-latest

strategy:
matrix:
ruby: ["3.1"]

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run remote Firefox
run: docker-compose up -d selenium_firefox
- name: Run specs
run: bundle exec rake spec_firefox_remote
# remote_chrome:
# runs-on: ubuntu-latest

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

# steps:
# - uses: actions/checkout@v4

# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: ${{ matrix.ruby }}
# bundler-cache: true
# - name: Run remote Chrome
# run: docker-compose up -d selenium_chrome
# - name: Run specs
# run: bundle exec rake spec_chrome_remote

# remote_firefox:
# runs-on: ubuntu-latest

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

# steps:
# - uses: actions/checkout@v4

# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: ${{ matrix.ruby }}
# bundler-cache: true
# - name: Run remote Firefox
# run: docker-compose up -d selenium_firefox
# - name: Run specs
# run: bundle exec rake spec_firefox_remote

non_headless:
runs-on: ubuntu-latest
Expand All @@ -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
6 changes: 5 additions & 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 Expand Up @@ -132,6 +132,10 @@ Naming/PredicateName:
Exclude:
- '**/*/*matchers.rb'

Naming/BlockForwarding:
Exclude:
- 'lib/capybara/node/matchers.rb'
- 'lib/capybara/node/finders.rb'
#################### Performance ####################

Performance/MethodObjectAsBlock:
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
4 changes: 2 additions & 2 deletions lib/capybara/rspec/matcher_proxies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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

Expand Down
28 changes: 14 additions & 14 deletions lib/capybara/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def match_selector(...)
end

%i[css xpath].each do |selector|
define_method "have_#{selector}" do |expr, **options, &optional_filter_block|
Matchers::HaveSelector.new(selector, expr, **options, &optional_filter_block)
define_method "have_#{selector}" do |expr, **options, &filter_block|
Matchers::HaveSelector.new(selector, expr, **options, &filter_block)
end

define_method "match_#{selector}" do |expr, **options, &optional_filter_block|
Matchers::MatchSelector.new(selector, expr, **options, &optional_filter_block)
define_method "match_#{selector}" do |expr, **options, &filter_block|
Matchers::MatchSelector.new(selector, expr, **options, &filter_block)
end
end

Expand All @@ -78,8 +78,8 @@ def match_selector(...)
# @see Capybara::Node::Matchers#matches_css?

%i[link button field select table element].each do |selector|
define_method "have_#{selector}" do |locator = nil, **options, &optional_filter_block|
Matchers::HaveSelector.new(selector, locator, **options, &optional_filter_block)
define_method "have_#{selector}" do |locator = nil, **options, &filter_block|
Matchers::HaveSelector.new(selector, locator, **options, &filter_block)
end
end

Expand Down Expand Up @@ -114,8 +114,8 @@ def match_selector(...)
# @see Capybara::Node::Matchers#has_table?

%i[checked unchecked].each do |state|
define_method "have_#{state}_field" do |locator = nil, **options, &optional_filter_block|
Matchers::HaveSelector.new(:field, locator, **options.merge(state => true), &optional_filter_block)
define_method "have_#{state}_field" do |locator = nil, **options, &filter_block|
Matchers::HaveSelector.new(:field, locator, **options.merge(state => true), &filter_block)
end
end

Expand Down Expand Up @@ -144,8 +144,8 @@ def have_title(title, **options)
# RSpec matcher for the current path.
#
# @see Capybara::SessionMatchers#assert_current_path
def have_current_path(path, **options, &optional_filter_block)
Matchers::HaveCurrentPath.new(path, **options, &optional_filter_block)
def have_current_path(path, **options, &)
Matchers::HaveCurrentPath.new(path, **options, &)
end

# RSpec matcher for element style.
Expand All @@ -167,15 +167,15 @@ def have_style(styles = nil, **options)
%w[selector css xpath text title current_path link button
field checked_field unchecked_field select table
sibling ancestor element].each do |matcher_type|
define_method "have_no_#{matcher_type}" do |*args, **kw_args, &optional_filter_block|
Matchers::NegatedMatcher.new(send("have_#{matcher_type}", *args, **kw_args, &optional_filter_block))
define_method "have_no_#{matcher_type}" do |*args, **kw_args, &filter_block|
Matchers::NegatedMatcher.new(send("have_#{matcher_type}", *args, **kw_args, &filter_block))
end
end
alias_method :have_no_content, :have_no_text

%w[selector css xpath].each do |matcher_type|
define_method "not_match_#{matcher_type}" do |*args, **kw_args, &optional_filter_block|
Matchers::NegatedMatcher.new(send("match_#{matcher_type}", *args, **kw_args, &optional_filter_block))
define_method "not_match_#{matcher_type}" do |*args, **kw_args, &filter_block|
Matchers::NegatedMatcher.new(send("match_#{matcher_type}", *args, **kw_args, &filter_block))
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/capybara/rspec/matchers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def initialize(matcher)
@matcher = matcher
end

def matches?(actual, &filter_block)
@matcher.does_not_match?(actual, &filter_block)
def matches?(actual, &)
@matcher.does_not_match?(actual, &)
end

def does_not_match?(actual, &filter_block)
@matcher.matches?(actual, &filter_block)
def does_not_match?(actual, &)
@matcher.matches?(actual, &)
end

def description
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/rspec/matchers/have_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Capybara
module RSpecMatchers
module Matchers
class HaveSelector < CountableWrappedElementMatcher
def initialize(*args, **kw_args, &filter_block)
def initialize(*args, **kw_args, &)
super
return unless (@args.size < 2) && @kw_args.keys.any?(String)

Expand Down