Sha256: 49090887b229b847c497d42417df125701589faa9ad65ea714bf1f5c081f526b
Contents?: true
Size: 1.74 KB
Versions: 4
Compression:
Stored size: 1.74 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 'accepts multiline range literal with no space in it' do inspect_source(cop, ['x = 0..', ' 10']) expect(cop.offenses).to be_empty end it 'registers an offense in multiline range literal with space in it' do inspect_source(cop, ['x = 0 ..', ' 10']) expect(cop.offenses.size).to eq(1) 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
4 entries across 4 versions & 1 rubygems