Class: Rubocop::Cop::RSpec::EmptyLineAfterSharedExample
- Inherits:
-
Base
- Object
- RuboCop::Cop::RSpec::Base
- Base
- Rubocop::Cop::RSpec::EmptyLineAfterSharedExample
- Extended by:
- RuboCop::Cop::AutoCorrector
- Includes:
- RuboCop::Cop::RSpec::EmptyLineSeparation
- Defined in:
- lib/rubocop/cop/rspec/empty_line_after_shared_example.rb
Overview
Checks if there is an empty line after shared example blocks.
Constant Summary collapse
- MSG =
'Add an empty line after `%<example>s` block.'
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
- #shared_examples(node) ⇒ Object
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
57 58 59 60 61 62 63 64 65 |
# File 'lib/rubocop/cop/rspec/empty_line_after_shared_example.rb', line 57 def on_block(node) shared_examples(node) do break if last_child?(node) (node) do |method| format(MSG, example: method) end end end |
#shared_examples(node) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/rubocop/cop/rspec/empty_line_after_shared_example.rb', line 47 def_node_matcher :shared_examples, <<~PATTERN { (block (send #rspec? #SharedGroups.all ...) ...) { (block (send nil? #Includes.all ...) ...) (send nil? #Includes.all ...) } } PATTERN |