Sha256: c84c2b30bbf13f57b641cb5e2e067e228af6bfa3393b2c600b859f631f54d8a7

Contents?: true

Size: 974 Bytes

Versions: 6

Compression:

Stored size: 974 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offence 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 '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

6 entries across 6 versions & 2 rubygems

Version Path
ridecharge-rubocop-0.0.1 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.18.1 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.18.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.17.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.16.0 spec/rubocop/cop/style/space_inside_parens_spec.rb
rubocop-0.15.0 spec/rubocop/cop/style/space_inside_parens_spec.rb