Sha256: a0a7c166ac74220e526ac3a82fa160c5d16acce081d4ce4c10559e881f0daec8

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::SpaceInsideParens do
  subject(:cop) { described_class.new }

  it 'registers an offense for spaces inside parens' do
    inspect_source(cop, ['f( 3)',
                         'g(3 )'])
    expect(cop.messages).to eq(
      ['Space inside parentheses detected.',
       'Space inside parentheses detected.'])
  end

  it 'accepts parentheses in block parameter list' do
    inspect_source(cop,
                   ['list.inject(Tms.new) { |sum, (label, item)|',
                    '}'])
    expect(cop.messages).to be_empty
  end

  it 'accepts parentheses with no spaces' do
    inspect_source(cop, ['split("\n")'])
    expect(cop.messages).to be_empty
  end

  it 'accepts parentheses with line break' do
    inspect_source(cop, ['f(',
                         '  1)'])
    expect(cop.messages).to be_empty
  end

  it 'accepts parentheses with comment and line break' do
    inspect_source(cop, ['f( # Comment',
                         '  1)'])
    expect(cop.messages).to be_empty
  end

  it 'auto-corrects unwanted space' do
    new_source = autocorrect_source(cop, ['f( 3)',
                                          'g(3 )'])
    expect(new_source).to eq(['f(3)',
                              'g(3)'].join("\n"))
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/space_inside_parens_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/space_inside_parens_spec.rb