Sha256: 5d69eef14d6efbf355886c4d45cb481bd9ce36f0c141d5deef41601abf8ef0e1

Contents?: true

Size: 693 Bytes

Versions: 9

Compression:

Stored size: 693 Bytes

Contents

describe "hash" do
  before do
    @hash = { :a => 1, :b => [ { :c => 2, :d => 3 }, :b ], :d => { :f => 4 } }
  end

  describe "deep_delete_if" do
    it "should delete a top level key recursively" do
      @hash.deep_delete_if { |k,v| k == :a }.should == { :b => [ { :c => 2, :d => 3 }, :b ], :d => { :f => 4 } }
    end

    it "should delete a key within an array recursively" do
      @hash.deep_delete_if { |k,v| v == 2 }.should == { :a => 1, :b => [ { :d => 3 }, :b ], :d => { :f => 4 } }
    end

    it "should delete a key within a hash recursively" do
      @hash.deep_delete_if { |k,v| v == 4 }.should == { :a => 1, :b => [ { :c => 2, :d => 3 }, :b ], :d => {} }
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
motion-support-1.2.1 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-1.1.1 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-1.2.0 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-1.1.0 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-1.0.0 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-0.3.0 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion_blender-support-0.2.8 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion_blender-support-0.2.7 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb
motion-support-0.2.6 spec/motion-support/core_ext/hash/deep_delete_if_spec.rb