Sha256: 66ac985161e9a31fd81000da82cd1083a57aa97a85107785e84c3efffa0fbc63

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

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

  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
  end

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

  offensive_source = <<-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

  corrected_source = <<-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

  include_examples 'autocorrect', offensive_source, corrected_source
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubocop-rspec-1.32.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.31.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.30.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.30.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.29.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.29.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.28.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.27.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.26.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb