Sha256: d973d90814205566a6aefe3ec812fdf1bb015408813cce36c29e3635739484d0
Contents?: true
Size: 1005 Bytes
Versions: 2
Compression:
Stored size: 1005 Bytes
Contents
require 'spec_helper' require 'gorillib/hash/deep_compact' require 'gorillib/array/deep_compact' describe Hash 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=>[] }.deep_compact!.should be nil 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 describe Array 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 be nil end it "should return a hash with all blank values removed recursively" do @test_hash = ["",nil,[],{},"foo",{:a=>[nil,{:c=>["","",[]]}],:b=>nil }] @test_hash.deep_compact!.should == ["foo"] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.0.7 | spec/deep_compact_spec.rb |
gorillib-0.0.6 | spec/deep_compact_spec.rb |