Sha256: ce0573f6a7b4bcf833fbee2dc8042583f41bed835009c0d3d23b57be89c5c728

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe SpaceAroundEqualsInParameterDefault do
        let(:space) { SpaceAroundEqualsInParameterDefault.new }

        it 'registers an offence for default value assignment without space' do
          inspect_source(space, ['def f(x, y=0, z=1)', 'end'])
          expect(space.offences.map(&:message)).to eq(
            ['Surrounding space missing in default value assignment.'] * 2)
        end

        it 'registers an offence for assignment empty string without space' do
          inspect_source(space, ['def f(x, y="", z=1)', 'end'])
          expect(space.offences.size).to eq(2)
        end

        it 'registers an offence for assignment of empty list without space' do
          inspect_source(space, ['def f(x, y=[])', 'end'])
          expect(space.offences.size).to eq(1)
        end

        it 'accepts default value assignment with space' do
          inspect_source(space, ['def f(x, y = 0, z = {})', 'end'])
          expect(space.offences.map(&:message)).to be_empty
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rubocop-0.12.0 spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.11.1 spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.11.0 spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.10.0 spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.9.1 spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb