Sha256: e9567399a2c446e90514c318b718f4587e05a2995bcc5a113d95ef4108374488

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

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

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

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

      describe 'blah' do
        let(:blahblah) { a }
                           ^ Align right let brace
        let(:blah)     { bc }
                            ^ Align right let brace
        let(:a)        { abc }
      end
    RUBY

    expect_correction(<<-RUBY)
      let(:foo)      { a    }
      let(:hi)       { ab   }
      let(:blahblah) { abcd }

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

      describe 'blah' do
        let(:blahblah) { a   }
        let(:blah)     { bc  }
        let(:a)        { abc }
      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_right_let_brace_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb