Sha256: 88b428cf50ae9c81dfb0ea4496cc83d544cf2c15031c5ed70488b85b2215b2a2

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

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

  # rubocop:disable RSpec/ExampleLength
  it 'registers offense for unaligned braces' do
    expect_offense(<<-RUBY)
      let(:foo) { bar }
                ^ Align left let brace
      let(:hi) { baz }
               ^ Align left let brace
      let(:blahblah) { baz }

      let(:thing) { ignore_this }
      let(:other) {
        ignore_this_too
      }

      describe 'blah' do
        let(:long_name) { thing }
        let(:blah) { thing }
                   ^ Align left let brace
        let(:a) { thing }
                ^ Align left let brace
      end
    RUBY

    expect_correction(<<-RUBY)
      let(:foo)      { bar }
      let(:hi)       { baz }
      let(:blahblah) { baz }

      let(:thing) { ignore_this }
      let(:other) {
        ignore_this_too
      }

      describe 'blah' do
        let(:long_name) { thing }
        let(:blah)      { thing }
        let(:a)         { thing }
      end
    RUBY
  end
  # rubocop:enable RSpec/ExampleLength

  it 'works with empty file' do
    expect_no_offenses('')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.35.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb