Skip to content

Commit 7705019

Browse files
authored
RuboCop: target the current Ruby version rather than old 2.7 (rails#54692)
1 parent d8f68f9 commit 7705019

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* RuboCop targets the Ruby version you're using rather than the 2.7 default.
2+
3+
*Jeremy Daer*
4+
15
* Add a `SessionTestHelper` module with `sign_in_as(user)` and `sign_out` test helpers when
26
running `rails g authentication`. Simplifies authentication in integration tests.
37

railties/lib/rails/generators/rails/app/templates/rubocop.yml.tt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Omakase Ruby styling for Rails
22
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
33

4+
AllCops:
5+
TargetRubyVersion: <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || RUBY_ENGINE_VERSION %>
6+
47
# Overwrite or add rules to create your own house style
58
#
69
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`

railties/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Omakase Ruby styling for Rails
22
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
33

4+
AllCops:
5+
TargetRubyVersion: <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || RUBY_ENGINE_VERSION %>
6+
47
# Overwrite or add rules to create your own house style
58
#
69
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`

railties/test/generators/app_generator_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ def test_inclusion_of_rubocop
614614
run_generator
615615
assert_gem "rubocop-rails-omakase"
616616
assert_file "config/environments/development.rb", %r|# Apply autocorrection by RuboCop to files generated by `bin/rails generate`\.|
617+
assert_file ".rubocop.yml" do |content|
618+
assert_match "TargetRubyVersion: #{ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || RUBY_ENGINE_VERSION}", content
619+
end
617620
end
618621

619622
def test_quiet_assets_in_development

0 commit comments

Comments
 (0)