状況
Rubocopを実行すると以下のエラーを吐かれた。
spec/rails_helper.rb:65:23: W: Lint/ShadowingOuterLocalVariable: Shadowing outer local variable - config.
RSpec.configure do |config|
^^^^^^
108 files inspected, 1 offense detected
Exited with code exit status 1
原因
FactoryBotのcreateメソッドを有効にするためにspec/rails_helperにいくつかコードを追記したが、よく見たらconfigというブロック変数の中にさらにconfigというブロック変数を追記していた。
(これはこれで見てて面白いのでここに残しておきます。)
rails_helper.rb
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
end