Sha256: 1158b13762f00ee4c39a70cda6eac77e45409e56099b594cfba378c2a7effd42
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
# encoding: utf-8 require 'spec_helper' describe RuboCop::Cop::Style::SpaceInsideRangeLiteral do subject(:cop) { described_class.new } it 'registers an offense for space inside .. literal' do inspect_source(cop, ['1 .. 2', '1.. 2', '1 ..2']) expect(cop.offenses.size).to eq(3) expect(cop.messages) .to eq(['Space inside range literal.'] * 3) end it 'accepts no space inside .. literal' do inspect_source(cop, '1..2') expect(cop.offenses).to be_empty end it 'registers an offense for space inside ... literal' do inspect_source(cop, ['1 ... 2', '1... 2', '1 ...2']) expect(cop.offenses.size).to eq(3) expect(cop.messages) .to eq(['Space inside range literal.'] * 3) end it 'accepts no space inside ... literal' do inspect_source(cop, '1...2') expect(cop.offenses).to be_empty end it 'accepts complex range literal with space in it' do inspect_source(cop, '0...(line - 1)') expect(cop.offenses).to be_empty end it 'autocorrects space around .. literal' do corrected = autocorrect_source(cop, ['1 .. 2']) expect(corrected).to eq '1..2' end it 'autocorrects space around ... literal' do corrected = autocorrect_source(cop, ['1 ... 2']) expect(corrected).to eq '1...2' end end
Version data entries
5 entries across 5 versions & 2 rubygems