Skip to content

Commit 6d01925

Browse files
committed
Fix a wrong AllowedPatterns example in Rails/FindEach
This PR is fix a wrong AllowedPatterns example in `Rails/FindEach` When specifying in the .rubocop.yml file, it is necessary to specify `AllowedPatterns: ['foo']` instead of `AllowedPatterns: [/foo/]`. Follow up: rubocop/rubocop-rspec#1395 The test code was also modified to match the actual behavior as mentioned in rubocop/rubocop-rspec#1396 (comment) .
1 parent 80c0902 commit 6d01925

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rubocop/cop/rails/find_each.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Rails
1717
# # good
1818
# User.order(:foo).each
1919
#
20-
# @example AllowedPattern: [/order/]
20+
# @example AllowedPattern: ['order']
2121
# # good
2222
# User.order(:foo).each
2323
class FindEach < Base

spec/rubocop/cop/rails/find_each_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class C < ActiveRecord::Base
142142
end
143143

144144
context 'allowed patterns' do
145-
let(:cop_config) { { 'AllowedMethods' => [], 'AllowedPatterns' => [/order/, /lock/], 'IgnoredMethods' => [] } }
145+
let(:cop_config) { { 'AllowedMethods' => [], 'AllowedPatterns' => %w[order lock], 'IgnoredMethods' => [] } }
146146

147147
it 'does not register an offense when using order(...) earlier' do
148148
expect_no_offenses('User.order(:name).each { |u| u.something }')

0 commit comments

Comments
 (0)