Sha256: 7f62e4f24323d7b8366dc66ea710e700849e56ec7848c71ddf45c7f2b723cda3

Contents?: true

Size: 844 Bytes

Versions: 7

Compression:

Stored size: 844 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',
                         ''])
    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

7 entries across 7 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/trailing_whitespace_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/trailing_whitespace_spec.rb