Class: RuboCop::Cop::Vicenzo::RSpec::NestedLetRedefinition
- Inherits:
-
RSpec::Base
- Object
- RSpec::Base
- RuboCop::Cop::Vicenzo::RSpec::NestedLetRedefinition
- Defined in:
- lib/rubocop/cop/vicenzo/rspec/nested_let_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 =
'Let `:%<name>s` is already defined in ancestor(s) block(s) at: %<definitions>s.'
Instance Method Summary collapse
- #let_it_be?(node) ⇒ Object
- #let_it_be_name(node) ⇒ Object
- #let_name(node) ⇒ Object
- #on_block(node) ⇒ Object (also: #on_numblock)
Instance Method Details
#let_it_be?(node) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_let_redefinition.rb', line 65 def_node_matcher :let_it_be?, <<~PATTERN { (block (send nil? {:let_it_be :let_it_be!} ...) ...) (send nil? {:let_it_be :let_it_be!} _ block_pass) } PATTERN |
#let_it_be_name(node) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_let_redefinition.rb', line 57 def_node_matcher :let_it_be_name, <<~PATTERN { (block (send nil? {:let_it_be :let_it_be!} ({str sym} $_) ...) ...) (send nil? {:let_it_be :let_it_be!} ({str sym} $_) block_pass) } PATTERN |
#let_name(node) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_let_redefinition.rb', line 49 def_node_matcher :let_name, <<~PATTERN { (block (send nil? #Helpers.all ({str sym} $_) ...) ...) (send nil? #Helpers.all ({str sym} $_) block_pass) } PATTERN |
#on_block(node) ⇒ Object Also known as: on_numblock
72 73 74 |
# File 'lib/rubocop/cop/vicenzo/rspec/nested_let_redefinition.rb', line 72 def on_block(node) check_let_redefinitions(node, {}) if example_group?(node) end |