Sha256: 26788bd19c2056185453dee7b9e6c6e6c40c279933e7270764d25f87f5145335

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 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

  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

15 entries across 15 versions & 1 rubygems

Version Path
rubocop-rspec-1.25.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.18.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.17.1 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.17.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
rubocop-rspec-1.16.0 spec/rubocop/cop/rspec/align_right_let_brace_spec.rb