Sha256: b70ba162a0e00c56fa66aea895b03de5f9453088eacbe37f023b4614889cd94f

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

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

      it 'registers an offence for block argument commas' do
        space.inspect_source('file.rb', ['each { |s,t| }'])
        space.offences.map(&:message).should ==
          ['Space missing after comma.']
      end

      it 'registers an offence for colon without space after it' do
        space.inspect_source('file.rb', ['x = w ? {a:3}:4'])
        space.offences.map(&:message).should ==
          ['Space missing after colon.'] * 2
      end

      it 'registers an offence for semicolon without space after it' do
        space.inspect_source('file.rb', ['x = 1;y = 2'])
        space.offences.map(&:message).should ==
          ['Space missing after semicolon.']
      end

      it 'allows the colons in symbols' do
        space.inspect_source('file.rb', ['x = :a'])
        space.offences.map(&:message).should == []
      end

      it 'allows colons in strings' do
        space.inspect_source('file.rb', ["str << ':'"])
        space.offences.map(&:message).should == []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.1.0 spec/rubocop/cops/space_after_comma_etc_spec.rb