Sha256: bbfc53ce6308cd4d6cb7d447ace038cbe0f6ebc567361bee7eb92c66e6723c84

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for consecutive empty lines' do
    inspect_source(cop,
                   ['test = 5', '', '', '', 'top'])
    expect(cop.offenses.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.offenses).to be_empty
  end

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

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



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

  it 'does not register an offense for heredocs with empty lines inside' do
    inspect_source(cop, ['str = <<-TEXT',
                         'line 1',
                         '',
                         '',
                         'line 2',
                         'TEXT',
                         'puts str'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/empty_lines_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/empty_lines_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/empty_lines_spec.rb