spec/rubocop/cops/align_parameters_spec.rb in rubocop-0.4.2 vs spec/rubocop/cops/align_parameters_spec.rb in rubocop-0.4.3

- old
+ new

@@ -7,29 +7,29 @@ describe AlignParameters do let(:align) { AlignParameters.new } it 'registers an offence for parameters with single indent' do inspect_source(align, 'file.rb', ['function(a,', - ' if b then c else d end)']) + ' if b then c else d end)']) expect(align.offences.map(&:message)).to eq( ['Align the parameters of a method call if they span more than ' + 'one line.']) end it 'registers an offence for parameters with double indent' do inspect_source(align, 'file.rb', ['function(a,', - ' if b then c else d end)']) + ' if b then c else d end)']) expect(align.offences.map(&:message)).to eq( ['Align the parameters of a method call if they span more than ' + 'one line.']) end it 'accepts correctly aligned parameters' do inspect_source(align, 'file.rb', ['function(a,', - ' 0, 1,', - ' (x + y),', - ' if b then c else d end)']) + ' 0, 1,', + ' (x + y),', + ' if b then c else d end)']) expect(align.offences.map(&:message)).to be_empty end it 'accepts calls that only span one line' do inspect_source(align, 'file.rb', ['find(path, s, @special[sexp[0]])']) @@ -53,9 +53,18 @@ ' c)', 'func3(*a)', ]) expect(align.offences.map(&:to_s)).to eq( ['C: 5: Align the parameters of a method call if they span ' + + 'more than one line.']) + end + + it "doesn't get confused by extra comma at the end" do + inspect_source(align, '', + ['func1(a,', + ' b,)']) + expect(align.offences.map(&:to_s)).to eq( + ['C: 2: Align the parameters of a method call if they span ' + 'more than one line.']) end it 'can handle a correctly aligned string literal as first argument' do inspect_source(align, '',