0
0

More than 1 year has passed since last update.

【Rubocop】W: Lint/ShadowingOuterLocalVariable: Shadowing outer local variableについて

Last updated at Posted at 2022-01-30

状況

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

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0