Class: RuboCop::Cop::RSpec::LetBeforeExamples
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/let_before_examples.rb
Overview
Checks for `let` definitions that come after an example.
Constant Summary collapse
- MSG =
'Move `let` before the examples in the group.'
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#example_or_group?(node) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/rubocop/cop/rspec/let_before_examples.rb', line 39 def_node_matcher :example_or_group?, <<-PATTERN { #{block_pattern('{#ExampleGroups.all #Examples.all}')} #{send_pattern('#Includes.examples')} } PATTERN |
#on_block(node) ⇒ Object
46 47 48 49 50 |
# File 'lib/rubocop/cop/rspec/let_before_examples.rb', line 46 def on_block(node) return unless example_group_with_body?(node) check_let_declarations(node.body) if multiline_block?(node.body) end |