Sha256: e5fdaa0c3f827955f9d977f17ba6e4acf1ce22613bc278eed7d36c77cf449ac6
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require File.expand_path('../spec_helper', File.dirname(__FILE__)) require 'gorillib/hash/deep_compact' require 'gorillib/array/deep_compact' describe Hash do describe 'array/deep_compact and hash/deep_compact' do it "should respond to the method deep_compact!" do { }.should respond_to :deep_compact! end it "should return nil if all values evaluate as blank" do { :a => nil, :b => "", :c => [], :d => {} }.deep_compact!.should == {} end it "should return a hash with all blank values removed recursively" do @test_hash = {:e=>["", nil, [], {}, "foo", { :a=> [nil, {}, { :c=> ["","",[]] } ], :b => nil }]} @test_hash.deep_compact!.should == {:e=>["foo"]} end end end describe Array do describe 'array/deep_compact and hash/deep_compact' do it "should respond to the method deep_compact!" do [ ].should respond_to :deep_compact! end it "should return nil if all values evaluate as blank" do [nil, '', { }, []].deep_compact!.should == [] end it "should return a hash with all blank values removed recursively" do @test_arr = ["", nil, [], {}, "foo", { :a=> [nil, {}, { :c=> ["","",[]] } ], :b => nil }] @test_arr.deep_compact!.should == ["foo"] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.1.11 | spec/hash/deep_compact_spec.rb |
gorillib-0.1.9 | spec/hash/deep_compact_spec.rb |
gorillib-0.1.8 | spec/hash/deep_compact_spec.rb |