Sha256: e95310bbc377318f020cd9b784b77836152e7fc7022f597ffd8bccf030fe4baa

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

require 'spec_helper'

describe "Hash" do
  describe "#deep_merge" do
    it "should do a deep merge for new keys and deep override for existing keys" do
      hash1 = {
        'key1' => 'value1',
        'key2' => {
          'inner_key1' =>'inner_value1',
          'inner_key2' =>'inner_value2'
        }
      }
      hash2 = {
        'key_to_merge' => 'value_to_merge',
        'key2' => {
          'inner_key_to_be_merged' =>'inner_value_to_be_merged',
          'inner_key2' =>'inner_value_to_override'
        }
      }
      hash1.deep_merge(hash2).should == {
        "key1"=>"value1",
        "key2"=>{
          "inner_key1"=>"inner_value1",
          "inner_key2"=>"inner_value_to_override",
          "inner_key_to_be_merged"=>"inner_value_to_be_merged"
        },
        "key_to_merge"=>"value_to_merge"
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cloudster-2.19.6 spec/deep_merge_spec.rb
cloudster-2.19.5 spec/deep_merge_spec.rb
cloudster-2.19.4 spec/deep_merge_spec.rb
cloudster-2.19.3 spec/deep_merge_spec.rb
cloudster-2.19.2 spec/deep_merge_spec.rb
cloudster-2.19.1 spec/deep_merge_spec.rb
cloudster-2.19.0 spec/deep_merge_spec.rb
cloudster-2.18.0 spec/deep_merge_spec.rb