Sha256: 69ca87f8e305250f5182570a4bcdba12637b732fb5dfe158a64366f38af98899

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for a line ending with space' do
    source = ['x = 0 ']
    inspect_source(cop, source)
    expect(cop.offenses.size).to eq(1)
  end

  it 'registers an offense for a line ending with tab' do
    inspect_source(cop, ["x = 0\t"])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts a line without trailing whitespace' do
    inspect_source(cop, ["x = 0\n"])
    expect(cop.offenses).to be_empty
  end

  it 'auto-corrects unwanted space' do
    new_source = autocorrect_source(cop, ['x = 0 ',
                                          "x = 0\t"])
    expect(new_source).to eq(['x = 0',
                              'x = 0'].join("\n"))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.25.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb