Sha256: bf3fd0a14d63f09c3ab148632ca060d81e392e55d7277ba44f7a9978208a9ff3

Contents?: true

Size: 931 Bytes

Versions: 47

Compression:

Stored size: 931 Bytes

Contents

require "spec_helper"

describe ApiClient::Utils do

  describe '.deep_merge' do

    it "merges two hashes updating the first one" do
      hash_a = { :a => 1, :b => 2  }
      hash_b = { :b => 3, :c => 45 }
      ApiClient::Utils.deep_merge hash_a, hash_b
      hash_a.should == { :a => 1, :b => 3, :c=>45 }
      hash_b.should == { :b => 3, :c => 45 }
    end

    it "deeply merges two hashes recursively" do
      hash_a = { :a => { :foo => 2, :boo => { :wat => 'wat' } }, :b => 2  }
      hash_b = { :b => 3, :c => 45, :a => { :boo => { :wat => "WAT????" } } }
      ApiClient::Utils.deep_merge hash_a, hash_b
      hash_a.should == { :a => { :foo => 2, :boo => { :wat => 'WAT????' } }, :b => 3, :c => 45  }
    end

    it "require correct key type" do
      hash_a = { :a  => 1 }
      hash_b = { 'a' => 2 }
      ApiClient::Utils.deep_merge hash_a, hash_b
      hash_a.should == { :a => 1, 'a' => 2 }

    end

  end

end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
api_client-0.6.0-java spec/api_client/utils_spec.rb
api_client-0.6.0 spec/api_client/utils_spec.rb
api_client-0.5.26-java spec/api_client/utils_spec.rb
api_client-0.5.26 spec/api_client/utils_spec.rb
api_client-0.5.25-java spec/api_client/utils_spec.rb
api_client-0.5.25 spec/api_client/utils_spec.rb
api_client-0.5.24 spec/api_client/utils_spec.rb
api_client-0.5.22 spec/api_client/utils_spec.rb
api_client-0.5.21 spec/api_client/utils_spec.rb
api_client-0.5.20 spec/api_client/utils_spec.rb
api_client-0.5.19 spec/api_client/utils_spec.rb
api_client-0.5.18 spec/api_client/utils_spec.rb
api_client-0.5.17 spec/api_client/utils_spec.rb
api_client-0.5.16 spec/api_client/utils_spec.rb
api_client-0.5.15 spec/api_client/utils_spec.rb
api_client-0.5.14 spec/api_client/utils_spec.rb
api_client-0.5.13 spec/api_client/utils_spec.rb
api_client-0.5.12 spec/api_client/utils_spec.rb
api_client-0.5.11 spec/api_client/utils_spec.rb
api_client-0.5.9 spec/api_client/utils_spec.rb