Sha256: 6f9170a76bac90fb144364cc3e31de8a8e7f3f978e3a2555eef77e8ed85082a4

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

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

  it 'flags `let` after the first different node ' do
    expect_violation(<<-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_violations(<<-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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rspec-1.15.1 spec/rubocop/cop/rspec/scattered_let_spec.rb
rubocop-rspec-1.15.0 spec/rubocop/cop/rspec/scattered_let_spec.rb