Sha256: e0f0f5fbd1d8f98656585723a7687ebde5b8b73b5ec645c8e994faea49663fe9

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks if there is an empty line after example group blocks.
      #
      # @example
      #   # 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
      #
      class EmptyLineAfterExampleGroup < Cop
        include RuboCop::RSpec::BlankLineSeparation

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

        def_node_matcher :example_group, ExampleGroups::ALL.block_pattern

        def on_block(node)
          return unless example_group(node)
          return if node.parent && node.equal?(node.parent.children.last)

          missing_separating_line(node) do |location|
            add_offense(
              node,
              location: location,
              message: format(MSG, example_group: node.method_name)
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-rspec-1.27.0 lib/rubocop/cop/rspec/empty_line_after_example_group.rb