Class: RuboCop::Cop::Vicenzo::RSpec::NestedSubjectRedefinition
- Inherits:
-
RSpec::Base
- Object
- RSpec::Base
- RuboCop::Cop::Vicenzo::RSpec::NestedSubjectRedefinition
- Defined in:
- lib/rubocop/cop/vicenzo/rspec/nested_subject_redefinition.rb
Overview
Do not define the same let in nested example groups.
It makes the tests more dificult to read and indicates that exists hidden scenarios (contexts)
Constant Summary collapse
- MSG =
'Subject `:%<name>s` is already defined in ancestor(s) block(s) at: %<definitions>s.'
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
-
#subject_name(node) {|Symbol| ... } ⇒ Object
Find a named or unnamed subject definition.
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
68 69 70 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_subject_redefinition.rb', line 68 def on_block(node) check_subject_redefinitions(node, {}) if example_group?(node) end |
#subject_name(node) {|Symbol| ... } ⇒ Object
Find a named or unnamed subject definition
61 62 63 64 65 66 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_subject_redefinition.rb', line 61 def_node_matcher :subject_name, <<-PATTERN (block (send nil? { #Subjects.all (sym $_) | $#Subjects.all } ) args ...) PATTERN |