Sha256: ce24f71eb0ac0d6232f55f2f5a154041aa59d0c8e113cee71d0f101bd320cbae
Contents?: true
Size: 1.48 KB
Versions: 10
Compression:
Stored size: 1.48 KB
Contents
# encoding: utf-8 require 'spec_helper' describe RuboCop::Cop::Style::SpaceAfterColon do subject(:cop) { described_class.new } it 'registers an offense for colon without space after it' do # TODO: There is double reporting of the last colon (also from # SpaceAroundOperators). inspect_source(cop, ['x = w ? {a:3}:4']) expect(cop.messages).to eq(['Space missing after colon.'] * 2) expect(cop.highlights).to eq([':'] * 2) end it 'accepts colons in symbols' do inspect_source(cop, ['x = :a']) expect(cop.messages).to be_empty end it 'accepts colon in ternary followed by space' do inspect_source(cop, ['x = w ? a : b']) expect(cop.messages).to be_empty end it 'accepts hash rockets' do inspect_source(cop, ['x = {"a"=>1}']) expect(cop.messages).to be_empty end it 'accepts if' do inspect_source(cop, ['x = if w', ' a', ' end']) expect(cop.messages).to be_empty end if RUBY_VERSION >= '2.1' it 'accepts colons denoting required keyword argument' do inspect_source(cop, ['def initialize(table:, nodes:)', 'end']) expect(cop.messages).to be_empty end end it 'accepts colons in strings' do inspect_source(cop, ["str << ':'"]) expect(cop.messages).to be_empty end it 'auto-corrects missing space' do new_source = autocorrect_source(cop, 'x = w ? {a:3}:4') expect(new_source).to eq('x = w ? {a: 3}: 4') end end
Version data entries
10 entries across 10 versions & 2 rubygems