Skip to content

Commit 1cf4099

Browse files
authored
Support rails 7.1 (#575)
* add rails 7.1 gemfile * add rails 7.1 to test workflow * use symbols to show exceptions Removes ``` DEPRECATION WARNING: Setting action_dispatch.show_exceptions to false is deprecated. Set to :none instead. (called from call at /home/runner/work/cucumber-rails/cucumber-rails/lib/cucumber/rails/action_dispatch.rb:14) ``` * deal with new raise_on_missing_callback_conditionals rails feature Rails 7.1 introduces a new "Raise error on missing only unless" feature (see rails/rails#43487). The new feature is enabled by default. I rewrote the auto-generated code in feature specs to comply to the new rule.
1 parent 48d9f16 commit 1cf4099

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

.github/workflows/test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
20-
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0']
20+
gemfile: ['rails_5_2', 'rails_6_0', 'rails_6_1', 'rails_7_0', 'rails_7_1']
2121
exclude:
2222
# Latest ruby will test
2323
# - all rails versions in current major
@@ -34,7 +34,9 @@ jobs:
3434
- { ruby: '2.6', gemfile: 'rails_6_0' }
3535
- { ruby: '2.6', gemfile: 'rails_6_1' }
3636
- { ruby: '2.6', gemfile: 'rails_7_0' }
37+
- { ruby: '2.6', gemfile: 'rails_7_1' }
3738
- { ruby: '2.7', gemfile: 'rails_7_0' }
39+
- { ruby: '2.7', gemfile: 'rails_7_1' }
3840
# Ruby 3+ won't work with Rails 5.2: https://github.com/rails/rails/issues/40938
3941
- { ruby: '3.0', gemfile: 'rails_5_2' }
4042
- { ruby: '3.1', gemfile: 'rails_5_2' }

Appraisals

+6
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ appraise 'rails_7_0' do
3232
gem 'railties', '~> 7.0.0'
3333
gem 'sqlite3', '~> 1.4'
3434
end
35+
36+
appraise 'rails_7_1' do
37+
gem 'activerecord'
38+
gem 'railties', '~> 7.1.0'
39+
gem 'sqlite3', '~> 1.4'
40+
end

features/emulate_javascript.feature

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ Feature: Emulate Javascript
6464
before_action except: :establish do
6565
render text: 'denied', status: :forbidden and return false unless session[:verified]
6666
end
67+
68+
# Rails 7.1 introduces raise_on_missing_callback_conditionals and it's on by default
69+
def establish
70+
raise "This action must be implemented in child controllers"
71+
end
6772
end
6873
"""
6974
And I write to "features/widgets.feature" with:

gemfiles/rails_7_1.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", "~> 7.1.0"
7+
gem "sqlite3", "~> 1.4"
8+
9+
gemspec path: "../"

lib/cucumber/rails/action_dispatch.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ module ActionDispatch
1010
module ShowExceptions
1111
def call(env)
1212
env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
13-
env['action_dispatch.show_exceptions'] = !env['action_dispatch.show_detailed_exceptions']
13+
14+
show_exceptions = !env['action_dispatch.show_detailed_exceptions']
15+
if ::Rails.gem_version >= Gem::Version.new('7.1.0')
16+
# Rails 7.1 deprecated `show_exceptions` boolean in in favor of symbols
17+
show_exceptions = show_exceptions ? :all : :none
18+
end
19+
20+
env['action_dispatch.show_exceptions'] = show_exceptions
1421
super(env)
1522
end
1623
end

0 commit comments

Comments
 (0)