Skip to content

Commit

Permalink
Specs for fixing arrow_alignment issues where multiple params are on …
Browse files Browse the repository at this point in the history
…the same line
  • Loading branch information
rodjek committed Sep 21, 2014
1 parent 7026a07 commit 2d79fb8
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,5 +445,66 @@ class { 'lvs::base':
expect(manifest).to eq(fixed)
end
end

context 'multiline resource with multiple params on a line' do
let(:code) { "
user { 'test':
a => 'foo', bb => 'bar',
ccc => 'baz',
}
" }

let(:fixed) { "
user { 'test':
a => 'foo',
bb => 'bar',
ccc => 'baz',
}
" }

it 'should detect 2 problems' do
expect(problems).to have(2).problems
end

it 'should fix 2 problems' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(13)
expect(problems).to contain_fixed(msg).on_line(3).in_column(26)
end

it 'should move the extra param onto its own line and realign' do
expect(manifest).to eq(fixed)
end
end

context 'multiline resource with multiple params on a line, extra one longer' do
let(:code) { "
user { 'test':
a => 'foo', bbccc => 'bar',
ccc => 'baz',
}
" }

let(:fixed) { "
user { 'test':
a => 'foo',
bbccc => 'bar',
ccc => 'baz',
}
" }

it 'should detect 2 problems' do
expect(problems).to have(3).problems
end

it 'should fix 2 problems' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(13)
expect(problems).to contain_fixed(msg).on_line(3).in_column(29)
expect(problems).to contain_fixed(msg).on_line(4).in_column(15)
end

it 'should move the extra param onto its own line and realign' do
expect(manifest).to eq(fixed)
end
end
end
end

0 comments on commit 2d79fb8

Please sign in to comment.