Sha256: 3dc935a9c85abe9c4b036bcf2e7a22c9fd2cccefa2c0175c47c21dd4687e1a09

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe String do
  it 'should not do anything when there is no leading whitespace' do
    "abc\ndef\nhij".unindent.should == "abc\ndef\nhij"
  end

  it 'should remove leading whitespace consistently' do
    "  abc\n  def\n  hij".unindent.should == "abc\ndef\nhij"
  end

  it 'should remove no whitespace when one line has none' do
    "  abc\ndef\n  hij".unindent.should == "  abc\ndef\n  hij"
  end

  it 'should ignore blank lines' do
    "  abc\n  def\n\n  hij".unindent.should == "abc\ndef\n\nhij"
  end

  it 'should remove no more whitespace than required' do
    # Left-most at beginning.
    unindented = "  abc\n    def\n    hij\n    lmn".unindent
    unindented.should == "abc\n  def\n  hij\n  lmn"

    # Left-most in middle.
    unindented = "    abc\n    def\n  hij\n    lmn".unindent
    unindented.should == "  abc\n  def\nhij\n  lmn"

    # Left-most at end.
    unindented = "    abc\n    def\n    hij\n  lmn".unindent
    unindented.should == "  abc\n  def\n  hij\nlmn"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
montage-0.4.0 spec/montage/core_ext_spec.rb
montage-0.3.0 spec/montage/core_ext_spec.rb
montage-0.2.1 spec/montage/core_ext_spec.rb