Sha256: b4d41fc205a45ad555c377a639a881eedf8509abd29a9f685930b3f11087d9b4

Contents?: true

Size: 817 Bytes

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.21.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.20.1 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.20.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.19.1 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.19.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb