Skip to content

Commit

Permalink
Drop support for Ruby 2.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Mar 27, 2021
1 parent d8ceecb commit 9ca027a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ require:
- rubocop-performance
- rubocop-minitest
- rubocop-rake

AllCops:
NewCops: enable
DisabledByDefault: false
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
Exclude:
- 'vendor/**/*'
- 'gemfiles/vendor/**/*'

#################### Lint ################################

Layout/LineLength:
Description: 'Limit lines to 80 characters.'
Description: 'Limit lines to 120 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Exclude:
- 'spec/**/*'
Expand Down Expand Up @@ -246,7 +246,7 @@ Performance/StringInclude:

Performance/MethodObjectAsBlock:
Enabled: false

Performance/BlockGivenWithExplicitBlock:
Enabled: false

Expand Down
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Version 3.36.0
Release date: unreleased

### Changed

* Ruby 2.6.0+ is now required

### Fixed

* Sibling and ancestor queries now work with Simple::Node - Issue #2452
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ GitHub): http://groups.google.com/group/ruby-capybara

## <a name="setup"></a>Setup

Capybara requires Ruby 2.5.0 or later. To install, add this line to your
Capybara requires Ruby 2.6.0 or later. To install, add this line to your
`Gemfile` and run `bundle install`:

```ruby
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 = '>= 2.5.0'
s.required_ruby_version = '>= 2.6.0'
s.license = 'MIT'

s.authors = ['Thomas Walpole', 'Jonas Nicklas']
Expand Down
11 changes: 1 addition & 10 deletions lib/capybara/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,7 @@ def filter_backtrace(trace)
end

def warn(message, uplevel: 1)
return Kernel.warn(message, uplevel: uplevel) if RUBY_VERSION >= '2.6'

# TODO: Remove when we drop support for Ruby 2.5
# Workaround for emulating `warn '...', uplevel: n` in Ruby 2.5 or lower.
if (match = /^(?<file>.+?):(?<line>\d+)(?::in `.*')?/.match(caller[uplevel]))
location = [match[:file], match[:line]].join(':')
Kernel.warn "#{location}: #{message}"
else
Kernel.warn message
end
Kernel.warn(message, uplevel: uplevel)
end

if defined?(Process::CLOCK_MONOTONIC)
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selenium/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def set_text(value, clear: nil, rapid: nil, **_unused)
if rapid == true || ((value.length > auto_rapid_set_length) && rapid != false)
send_keys(value[0..3])
driver.execute_script RAPID_APPEND_TEXT, self, value[4...-3]
send_keys(value[-3..-1])
send_keys(value[-3..])
else
send_keys(value)
end
Expand Down
10 changes: 4 additions & 6 deletions lib/capybara/spec/session/all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@
expect { @session.all(:css, 'h1, p', between: 0..3) }.to raise_error(Capybara::ExpectationNotMet)
end

eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.5
it'treats an endless range as minimum' do
expect { @session.all(:css, 'h1, p', between: 2..) }.not_to raise_error
expect { @session.all(:css, 'h1, p', between: 5..) }.to raise_error(Capybara::ExpectationNotMet)
end
TEST
it 'treats an endless range as minimum' do
expect { @session.all(:css, 'h1, p', between: 2..) }.not_to raise_error
expect { @session.all(:css, 'h1, p', between: 5..) }.to raise_error(Capybara::ExpectationNotMet)
end

eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
it'treats a beginless range as maximum' do
Expand Down
11 changes: 5 additions & 6 deletions spec/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ def recalc_result
expect(recalc_result[1...3].map(&:text)).to eq %w[Beta Gamma]
expect(recalc_result[1..7].map(&:text)).to eq %w[Beta Gamma Delta]
expect(recalc_result[2...-1].map(&:text)).to eq %w[Gamma]
expect(recalc_result[2..-1].map(&:text)).to eq %w[Gamma Delta]
expect(recalc_result[2..-1].map(&:text)).to eq %w[Gamma Delta] # rubocop:disable Style/SlicingWithRange
expect(recalc_result[2..].map(&:text)).to eq %w[Gamma Delta]
end

eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.5
it 'supports endless ranges' do
expect(result[2..].map(&:text)).to eq %w[Gamma Delta]
end
TEST
it 'supports endless ranges' do
expect(result[2..].map(&:text)).to eq %w[Gamma Delta]
end

eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
it 'supports inclusive positive beginless ranges' do
Expand Down

0 comments on commit 9ca027a

Please sign in to comment.