Sha256: 79d5ccbca61ed9f2422f9a5e28df23d61594dadd9f91f2f272bb947eb976c30b

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::EmptyLines do
  subject(:cop) { described_class.new }

  it 'registers an offence for consecutive empty lines' do
    inspect_source(cop,
                   ['test = 5', '', '', '', 'top'])
    expect(cop.offences.size).to eq(2)
  end

  it 'auto-corrects consecutive empty lines' do
    corrected = autocorrect_source(cop,
                                   ['test = 5', '', '', '', 'top'])
    expect(corrected).to eq ['test = 5', '', 'top'].join("\n")
  end

  it 'works when there are no tokens' do
    inspect_source(cop,
                   ['#comment'])
    expect(cop.offences).to be_empty
  end

  it 'handles comments' do
    inspect_source(cop,
                   ['test', '', '#comment', 'top'])
    expect(cop.offences).to be_empty
  end

  it 'does not register an offence for empty lines in a string' do
    inspect_source(cop, ['result = "test



                                  string"'])
    expect(cop.offences).to be_empty
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ridecharge-rubocop-0.0.1 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.18.1 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.18.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.17.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.16.0 spec/rubocop/cop/style/empty_lines_spec.rb