Sha256: 3f56262bf7b25635e0b363ace23c1a539409c9aa816e93449a41fc48184197e7

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe 'blank?' do
  it 'is true for nil' do
    SmarterCSV.send(:blank?, nil).should eq true
  end

  it 'is true for empty string' do
    SmarterCSV.send(:blank?, '').should eq true
  end

  it 'is true for blank string' do
    SmarterCSV.send(:blank?, '   ').should eq true
  end

  it 'is true for tab string' do
    SmarterCSV.send(:blank?, " \t ").should eq true
  end

  it 'is false for string with content' do
    SmarterCSV.send(:blank?, " 1 ").should eq false
  end

  it 'is false for numeic values' do
    SmarterCSV.send(:blank?, 1).should eq false
  end

  describe 'arrays' do
    it 'is true for empty arrays' do
      SmarterCSV.send(:blank?, []).should eq true
    end

    it 'is true for blank arrays' do
      SmarterCSV.send(:blank?, [nil, '', '  ', " \t "]).should eq true
    end

    it 'is false for non-blank arrays' do
      SmarterCSV.send(:blank?, [nil, '', '  ', " 1 "]).should eq false
    end
  end

  describe 'hashes' do
    it 'is true for empty arrays' do
      SmarterCSV.send(:blank?, {}).should eq true
    end

    it 'is true for blank arrays' do
      SmarterCSV.send(:blank?, {a: nil, b: '', c: '  ', d: " \t "}).should eq true
    end

    it 'is false for non-blank arrays' do
      SmarterCSV.send(:blank?, {a: nil, b: '', c: '  ', d: " 1 "}).should eq false
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smarter_csv-1.6.1 spec/smarter_csv/blank_spec.rb
smarter_csv-1.6.0 spec/smarter_csv/blank_spec.rb
smarter_csv-1.5.2 spec/smarter_csv/blank_spec.rb
smarter_csv-1.5.1 spec/smarter_csv/blank_spec.rb
smarter_csv-1.5.0 spec/smarter_csv/blank_spec.rb
smarter_csv-1.4.2 spec/smarter_csv/blank_spec.rb
smarter_csv-1.4.0 spec/smarter_csv/blank_spec.rb