Skip to content

Commit b750833

Browse files
committed
Add Rails 8 compatibility
In specific: - Do not test Rails 7.0 against 3.3 - Allow 8.0 in gemspec, by relaxing the upper constraint to `< 8.1`. Rails uses shifted SemVer, so `8.1` is considered a Major. - Conditionally load the sqlite3 gem based on the Rails version. - Conditionally load selenium webdriver gem based on the Rails version. - Simplify error page assertions to account for variations in apostrophes, as "We're sorry" changed to "We`re sorry" in Rails 8. References: - https://guides.rubyonrails.org/maintenance_policy.html#versioning - rails/rails#53045 Close #589
1 parent 11897e8 commit b750833

8 files changed

+39
-10
lines changed

.github/workflows/test.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ jobs:
3636
- { ruby: '3.0', gemfile: 'rails_7_0' }
3737
# Ruby 3.1+ has issues with Rails 6.1 https://github.com/rails/rails/issues/46883#issuecomment-1371325906
3838
# It (Rails 6.1.x), has been marked as a won't fix and as such it's likely this will need to just be excluded until out of support window
39-
- { ruby: '3.3', gemfile: 'rails_7_0' }
4039
- { ruby: '3.3', gemfile: 'rails_7_1' }
4140
- { ruby: '3.3', gemfile: 'rails_7_2' }
41+
- { ruby: '3.3', gemfile: 'rails_8_0' }
4242
# Supported rubies will test all permissible supported rails versions
4343
ruby: ['3.1', '3.2']
44-
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0', 'rails_7_1', 'rails_7_2']
44+
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0', 'rails_7_1', 'rails_7_2', 'rails_8_0']
4545
exclude:
4646
# Ruby 3.0+ doesn't work with Rails 5.2: https://github.com/rails/rails/issues/40938
4747
# Ruby 3.1+ has a conflicting Psych version with Rails 6.x: https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias
4848
- { ruby: '3.1', gemfile: 'rails_5_2' }
4949
- { ruby: '3.1', gemfile: 'rails_6_0' }
5050
- { ruby: '3.1', gemfile: 'rails_6_1' }
51+
- { ruby: '3.1', gemfile: 'rails_8_0' }
5152
- { ruby: '3.2', gemfile: 'rails_5_2' }
5253
- { ruby: '3.2', gemfile: 'rails_6_0' }
5354
- { ruby: '3.2', gemfile: 'rails_6_1' }

Appraisals

+6
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ appraise 'rails_7_2' do
5151
gem 'railties', '~> 7.2.2'
5252
gem 'sqlite3', '~> 2.2'
5353
end
54+
55+
appraise 'rails_8_0' do
56+
gem 'activerecord'
57+
gem 'railties', '~> 8.0.0'
58+
gem 'sqlite3', '~> 2.2'
59+
end

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This file is intended to be modified using the [`changelog`](https://github.com/
99

1010
## [Unreleased]
1111

12+
- Add support for Rails 8.0 (No code changes required) [#590](https://github.com/cucumber/cucumber-rails/pull/590)
13+
1214
## [3.0.1] - 2024-11-05
1315
### Changed
1416
- Add support for Rails 7.2 / Ruby 3.3 (No code changes required) [#586](https://github.com/cucumber/cucumber-rails/pull/586) [#588](https://github.com/cucumber/cucumber-rails/pull/588)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Code Climate](https://codeclimate.com/github/cucumber/cucumber-rails.svg)](https://codeclimate.com/github/cucumber/cucumber-rails)
66
[![Open Source Helpers](https://www.codetriage.com/cucumber/cucumber-rails/badges/users.svg)](https://www.codetriage.com/cucumber/cucumber-rails)
77

8-
Cucumber-Rails brings Cucumber to Rails 5.2, 6.x and 7.x.
8+
Cucumber-Rails brings Cucumber to Rails 5.2, 6.x, 7.x, and 8.0.
99

1010
## Installation
1111

cucumber-rails.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Gem::Specification.new do |s|
2626

2727
s.add_runtime_dependency('capybara', '>= 3.11', '< 4')
2828
s.add_runtime_dependency('cucumber', '>= 5', '< 10')
29-
s.add_runtime_dependency('railties', '>= 5.2', '< 8')
29+
s.add_runtime_dependency('railties', '>= 5.2', '< 8.1')
3030

3131
# Main development dependencies
3232
s.add_development_dependency('ammeter', '>= 1.1.5')
3333
s.add_development_dependency('appraisal', '>= 2.4.1', '< 3')
3434
s.add_development_dependency('aruba', '>= 1.1.2', '< 3')
3535
s.add_development_dependency('database_cleaner', '>= 1.8', '< 3.0')
36-
s.add_development_dependency('rails', '>= 5.2', '< 8')
36+
s.add_development_dependency('rails', '>= 5.2', '< 8.1')
3737
s.add_development_dependency('rake', '>= 13.0')
3838
s.add_development_dependency('rspec', '~> 3.12')
3939
s.add_development_dependency('rubocop', '~> 1.45.0')

features/allow_rescue.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Feature: Allow Cucumber to rescue exceptions
3333
end
3434
3535
Then('I should see the public error page') do
36-
expect(page).to have_content "We're sorry, but something went wrong."
36+
expect(page).to have_content "sorry, but something went wrong."
3737
end
3838
"""
3939
And I run `bundle exec rake db:migrate`

features/support/cucumber_rails_gem_helper.rb

+15-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module CucumberRailsGemHelper
88
def install_cucumber_rails(*options)
99
configure_rails_gems
1010
add_cucumber_rails(options)
11-
add_rails_conditional_gems
11+
add_sqlite3_gem
12+
add_selenium_webdriver_gem
1213
add_remaining_gems(options)
1314
bundle_install
1415
run_command_and_stop 'bundle exec rails generate cucumber:install'
@@ -29,13 +30,23 @@ def add_cucumber_rails(options)
2930
end
3031
end
3132

32-
def add_rails_conditional_gems
33-
if rails_equal_or_higher_than?('6.0')
33+
def add_sqlite3_gem
34+
if rails_equal_or_higher_than?('7.1')
35+
add_gem 'sqlite3', '~> 2.0'
36+
elsif rails_equal_or_higher_than?('6.0')
3437
add_gem 'sqlite3', '~> 1.4'
38+
else
39+
add_gem 'sqlite3', '~> 1.3.13'
40+
end
41+
end
42+
43+
def add_selenium_webdriver_gem
44+
if rails_equal_or_higher_than?('7.0')
45+
add_gem 'selenium-webdriver', '~> 4.22', group: :test
46+
elsif rails_equal_or_higher_than?('6.0')
3547
add_gem 'selenium-webdriver', '~> 4.0', group: :test
3648
add_gem 'webdrivers', '~> 5.0', group: :test
3749
else
38-
add_gem 'sqlite3', '~> 1.3.13'
3950
add_gem 'selenium-webdriver', '< 4', group: :test
4051
add_gem 'webdrivers', '~> 4.0', group: :test
4152
remove_gem 'chromedriver-helper'

gemfiles/rails_8_0.gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "activerecord"
6+
gem "railties", "~> 8.0.0"
7+
gem "sqlite3", "~> 2.2"
8+
9+
gemspec path: "../"

0 commit comments

Comments
 (0)