Skip to content

Commit

Permalink
Add Rails 8 compatibility
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tagliala committed Nov 13, 2024
1 parent 11897e8 commit b750833
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ jobs:
- { ruby: '3.0', gemfile: 'rails_7_0' }
# Ruby 3.1+ has issues with Rails 6.1 https://github.com/rails/rails/issues/46883#issuecomment-1371325906
# 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
- { ruby: '3.3', gemfile: 'rails_7_0' }
- { ruby: '3.3', gemfile: 'rails_7_1' }
- { ruby: '3.3', gemfile: 'rails_7_2' }
- { ruby: '3.3', gemfile: 'rails_8_0' }
# Supported rubies will test all permissible supported rails versions
ruby: ['3.1', '3.2']
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0', 'rails_7_1', 'rails_7_2']
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0', 'rails_7_1', 'rails_7_2', 'rails_8_0']
exclude:
# Ruby 3.0+ doesn't work with Rails 5.2: https://github.com/rails/rails/issues/40938
# 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
- { ruby: '3.1', gemfile: 'rails_5_2' }
- { ruby: '3.1', gemfile: 'rails_6_0' }
- { ruby: '3.1', gemfile: 'rails_6_1' }
- { ruby: '3.1', gemfile: 'rails_8_0' }
- { ruby: '3.2', gemfile: 'rails_5_2' }
- { ruby: '3.2', gemfile: 'rails_6_0' }
- { ruby: '3.2', gemfile: 'rails_6_1' }
Expand Down
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ appraise 'rails_7_2' do
gem 'railties', '~> 7.2.2'
gem 'sqlite3', '~> 2.2'
end

appraise 'rails_8_0' do
gem 'activerecord'
gem 'railties', '~> 8.0.0'
gem 'sqlite3', '~> 2.2'
end
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This file is intended to be modified using the [`changelog`](https://github.com/

## [Unreleased]

- Add support for Rails 8.0 (No code changes required) [#590](https://github.com/cucumber/cucumber-rails/pull/590)

## [3.0.1] - 2024-11-05
### Changed
- 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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Code Climate](https://codeclimate.com/github/cucumber/cucumber-rails.svg)](https://codeclimate.com/github/cucumber/cucumber-rails)
[![Open Source Helpers](https://www.codetriage.com/cucumber/cucumber-rails/badges/users.svg)](https://www.codetriage.com/cucumber/cucumber-rails)

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

## Installation

Expand Down
4 changes: 2 additions & 2 deletions cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Gem::Specification.new do |s|

s.add_runtime_dependency('capybara', '>= 3.11', '< 4')
s.add_runtime_dependency('cucumber', '>= 5', '< 10')
s.add_runtime_dependency('railties', '>= 5.2', '< 8')
s.add_runtime_dependency('railties', '>= 5.2', '< 8.1')

# Main development dependencies
s.add_development_dependency('ammeter', '>= 1.1.5')
s.add_development_dependency('appraisal', '>= 2.4.1', '< 3')
s.add_development_dependency('aruba', '>= 1.1.2', '< 3')
s.add_development_dependency('database_cleaner', '>= 1.8', '< 3.0')
s.add_development_dependency('rails', '>= 5.2', '< 8')
s.add_development_dependency('rails', '>= 5.2', '< 8.1')
s.add_development_dependency('rake', '>= 13.0')
s.add_development_dependency('rspec', '~> 3.12')
s.add_development_dependency('rubocop', '~> 1.45.0')
Expand Down
2 changes: 1 addition & 1 deletion features/allow_rescue.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: Allow Cucumber to rescue exceptions
end
Then('I should see the public error page') do
expect(page).to have_content "We're sorry, but something went wrong."
expect(page).to have_content "sorry, but something went wrong."
end
"""
And I run `bundle exec rake db:migrate`
Expand Down
19 changes: 15 additions & 4 deletions features/support/cucumber_rails_gem_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module CucumberRailsGemHelper
def install_cucumber_rails(*options)
configure_rails_gems
add_cucumber_rails(options)
add_rails_conditional_gems
add_sqlite3_gem
add_selenium_webdriver_gem
add_remaining_gems(options)
bundle_install
run_command_and_stop 'bundle exec rails generate cucumber:install'
Expand All @@ -29,13 +30,23 @@ def add_cucumber_rails(options)
end
end

def add_rails_conditional_gems
if rails_equal_or_higher_than?('6.0')
def add_sqlite3_gem
if rails_equal_or_higher_than?('7.1')
add_gem 'sqlite3', '~> 2.0'
elsif rails_equal_or_higher_than?('6.0')
add_gem 'sqlite3', '~> 1.4'
else
add_gem 'sqlite3', '~> 1.3.13'
end
end

def add_selenium_webdriver_gem
if rails_equal_or_higher_than?('7.0')
add_gem 'selenium-webdriver', '~> 4.22', group: :test
elsif rails_equal_or_higher_than?('6.0')
add_gem 'selenium-webdriver', '~> 4.0', group: :test
add_gem 'webdrivers', '~> 5.0', group: :test
else
add_gem 'sqlite3', '~> 1.3.13'
add_gem 'selenium-webdriver', '< 4', group: :test
add_gem 'webdrivers', '~> 4.0', group: :test
remove_gem 'chromedriver-helper'
Expand Down
9 changes: 9 additions & 0 deletions gemfiles/rails_8_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord"
gem "railties", "~> 8.0.0"
gem "sqlite3", "~> 2.2"

gemspec path: "../"

0 comments on commit b750833

Please sign in to comment.