Sha256: d78661c857a7f4c147e708f321df4bb3e2acd9236095b99d07d600374941ab75

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
  subject(:cop) { described_class.new }

  it 'flags `let` after the first different node ' do
    expect_offense(<<-RUBY)
      RSpec.describe User do
        let(:a) { a }
        subject { User }
        let(:b) { b }
        ^^^^^^^^^^^^^ Group all let/let! blocks in the example group together.
      end
    RUBY
  end

  it 'doesnt flag `let!` in the middle of multiple `let`s' do
    expect_no_offenses(<<-RUBY)
      RSpec.describe User do
        subject { User }

        let(:a) { a }
        let!(:b) { b }
        let(:c) { c }
      end
    RUBY
  end

  it 'does not encounter an error when handling an empty describe' do
    expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
      .not_to raise_error
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-rspec-1.16.0 spec/rubocop/cop/rspec/scattered_let_spec.rb