Sha256: 80b98942fe1425e6672c6aa85cfc979379cd56f6be4311ac7d018a366912feee

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

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

  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(:blahblah) { baz }
        let(:blah) { thing }
                   ^ Align left let brace
        let(:a) { thing }
                ^ Align left let brace
      end
    RUBY
  end

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

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

  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_left_let_brace_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.18.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.17.1 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.17.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
rubocop-rspec-1.16.0 spec/rubocop/cop/rspec/align_left_let_brace_spec.rb