Sha256: a84902ebf1423aca5fb7d05e59af01d67dbaaeb8a43d856b5579ca2653c012f9

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe SpaceAroundEqualsInParameterDefault do
        subject(: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.messages).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.messages).to be_empty
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb