Class: RuboCop::Cop::Obsession::Rspec::EmptyLineAfterFinalLet

Inherits:
RSpec::EmptyLineAfterFinalLet
  • Object
show all
Defined in:
lib/rubocop/cop/obsession/rspec/empty_line_after_final_let.rb

Overview

Same as RSpec/EmptyLineAfterFinalLet, but allows ‘let` to be followed by `it` with no new line, to allow for this style of spec:

Examples:


describe Url do
  describe '#domain' do
    context do
      let(:url) { Url.new('http://www.some-site.com/some-page') }
      it { expect(url.domain).to eq 'some-site.com' }
    end

    context do
      let(:url) { Url.new('some-site.com') }
      it { expect(url.domain).to eq 'some-site.com' }
    end
  end
end

Instance Method Summary collapse

Instance Method Details

#missing_separating_line(node) {|offending_loc(line)| ... } ⇒ Object

Yields:

  • (offending_loc(line))


25
26
27
28
29
30
31
32
# File 'lib/rubocop/cop/obsession/rspec/empty_line_after_final_let.rb', line 25

def missing_separating_line(node)
  line = final_end_location(node).line
  line += 1 while comment_line?(processed_source[line])
  return if processed_source[line].blank?
  return if processed_source[line].match?(/\s*it /)

  yield offending_loc(line)
end