class Gitlab::Styles::Rubocop::Cop::RSpec::EmptyLineAfterSharedExample

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

@example

# bad
RSpec.describe Foo do
  it_behaves_like 'do this first'
  it_behaves_like 'does this' do
  end
  it_behaves_like 'does that' do
  end
  it_behaves_like 'do some more'
end

# good
RSpec.describe Foo do
  it_behaves_like 'do this first'
  it_behaves_like 'does this' do
  end

  it_behaves_like 'does that' do
  end

  it_behaves_like 'do some more'
end

# fair - it's ok to have non-separated without blocks
RSpec.describe Foo do
  it_behaves_like 'do this first'
  it_behaves_like 'does this'
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb, line 51
def on_block(node)
  shared_examples(node) do
    break if last_child?(node)

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