Class: RuboCop::Cop::RSpec::OverwritingSetup
- Defined in:
- lib/rubocop/cop/rspec/overwriting_setup.rb
Overview
Checks if there is a let/subject that overwrites an existing one.
Constant Summary collapse
- MSG =
'`%<name>s` is already defined.'
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_block(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/rspec/overwriting_setup.rb', line 30 def on_block(node) return unless example_group_with_body?(node) find_duplicates(node.body) do |duplicate, name| add_offense( duplicate, location: :expression, message: format(MSG, name: name) ) end end |