Class: RuboCop::Cop::RSpec::EmptyLineAfterExampleGroup

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
EmptyLineSeparation
Defined in:
lib/rubocop/cop/rspec/empty_line_after_example_group.rb

Overview

Checks if there is an empty line after example group blocks.

Examples:

# bad
RSpec.describe Foo do
  describe '#bar' do
  end
  describe '#baz' do
  end
end

# good
RSpec.describe Foo do
  describe '#bar' do
  end

  describe '#baz' do
  end
end

Constant Summary collapse

MSG =
'Add an empty line after `%<example_group>s`.'

Instance Method Summary collapse

Methods included from EmptyLineSeparation

#last_child?, #missing_separating_line, #missing_separating_line_offense, #offending_loc

Methods included from FinalEndLocation

#final_end_location

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language::NodePattern

#block_pattern, #send_pattern

Instance Method Details

#on_block(node) ⇒ Object


32
33
34
35
36
37
38
# File 'lib/rubocop/cop/rspec/empty_line_after_example_group.rb', line 32

def on_block(node)
  return unless example_group?(node)

  missing_separating_line_offense(node) do |method|
    format(MSG, example_group: method)
  end
end