Sha256: 69677facaa549435e6323ba06a88653c3dbdd0c7cbd0092c8b1029366615d14e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe ExtraWhitespaceWarning do
  it 'is a line-based warning' do
    ExtraWhitespaceWarning.new('(stdin)', 'hello').should be_a(LineWarning)
  end

  it 'matches when there are spaces at the end of a line' do
    ExtraWhitespaceWarning.should warn('a + b  ')
    ExtraWhitespaceWarning.should warn('a + b ')
    ExtraWhitespaceWarning.should_not warn('a + b')
  end

  it 'matches when there are tabs at the end of a line' do
    ExtraWhitespaceWarning.should warn("a + b\t\t")
    ExtraWhitespaceWarning.should warn("a + b\t")
    ExtraWhitespaceWarning.should_not warn('a + b')
  end

  it 'has a remotely useful description' do
    ExtraWhitespaceWarning.new('(stdin)', 'hello  ').desc.should =~ /whitespace/
  end

  context 'when fixing' do
    it 'fixes by removing extra spaces' do
      ExtraWhitespaceWarning.should correct_to('a + b  ', 'a + b')
    end

    it 'fixes by removing extra tabs' do
      ExtraWhitespaceWarning.should correct_to("a + b\t\t", 'a + b')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wool-0.5.1 spec/warning_specs/extra_whitespace_spec.rb