Sha256: 562cd38e0809dc980a4540541d5dfddc46eefcb1eccf2bd78b12559edde4b386

Contents?: true

Size: 951 Bytes

Versions: 6

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks if there is an empty line after the last let block.
      #
      # @example
      #   # bad
      #   let(:foo) { bar }
      #   let(:something) { other }
      #   it { does_something }
      #
      #   # good
      #   let(:foo) { bar }
      #   let(:something) { other }
      #
      #   it { does_something }
      class EmptyLineAfterFinalLet < Base
        extend AutoCorrector
        include RuboCop::RSpec::EmptyLineSeparation

        MSG = 'Add an empty line after the last `%<let>s`.'

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

          final_let = node.body.child_nodes.reverse.find { |child| let?(child) }

          return if final_let.nil?

          missing_separating_line_offense(final_let) do |method|
            format(MSG, let: method)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-2.0.0.pre lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.44.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.44.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.43.2 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.43.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.43.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb