Sha256: bac9333f02b7b0fd4ee6f0d77222e32095dfbc2caa76ba2e46bb87917204e202
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::LineEndConcatenation do subject(:cop) { described_class.new } it 'registers an offense for string concat at line end' do inspect_source(cop, ['top = "test" +', '"top"']) expect(cop.offenses.size).to eq(1) end it 'registers an offense for string concat with << at line end' do inspect_source(cop, ['top = "test" <<', '"top"']) expect(cop.offenses.size).to eq(1) end it 'registers an offense for dynamic string concat at line end' do inspect_source(cop, ['top = "test#{x}" +', '"top"']) expect(cop.offenses.size).to eq(1) end it 'registers an offense for dynamic string concat with << at line end' do inspect_source(cop, ['top = "test#{x}" <<', '"top"']) expect(cop.offenses.size).to eq(1) end it 'accepts string concat on the same line' do inspect_source(cop, ['top = "test" + "top"']) expect(cop.offenses).to be_empty end it 'accepts string concat at line end when followed by comment' do inspect_source(cop, ['top = "test" + # something', '"top"']) expect(cop.offenses).to be_empty end it 'accepts string concat at line end when % literals are involved' do inspect_source(cop, ['top = %(test) +', '"top"']) expect(cop.offenses).to be_empty end it 'autocorrects by replacing + with \\' do corrected = autocorrect_source(cop, ['top = "test" +', '"top"']) expect(corrected).to eq ['top = "test" \\', '"top"'].join("\n") end end
Version data entries
3 entries across 3 versions & 1 rubygems