Sha256: 1dc94fb5b84bcbb11fadde0681ba9e22d4a765da3c5b345f24ec3dc893ed5243

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

require File.expand_path('../spec_helper', File.dirname(__FILE__))
require 'gorillib/array/compact_blank'

describe Array do

  describe '#compact_blank' do
    it 'with empty' do
      [ [nil], [nil, false, {}, ""] ].each do |arr|
        arr.compact_blank.should == []
        arr.length.should_not    == 0
      end
    end

    it 'with full' do
      [ [nil, 1, nil, 2], [nil, 1, false, 2, {}, ""] ].each do |arr|
        arr.compact_blank.should == [1, 2]
      end
    end
  end

  describe '#compact_blank!' do
    it 'with empty' do
      [].compact_blank!.should == []
      [ [nil], [nil, false, {}, ""] ].each do |arr|
        arr.compact_blank!.should == []
        arr.length.should         == 0
      end
    end

    it 'with full' do
      [ [nil, 1, nil, 2], [nil, 1, false, 2, {}, ""] ].each do |arr|
        arr.compact_blank!.should == [1, 2]
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gorillib-0.1.11 spec/array/compact_blank_spec.rb
gorillib-0.1.9 spec/array/compact_blank_spec.rb
gorillib-0.1.8 spec/array/compact_blank_spec.rb