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.5.7 spec/api_client/utils_spec.rb
api_client-0.5.6 spec/api_client/utils_spec.rb
api_client-0.5.5 spec/api_client/utils_spec.rb
api_client-0.5.4 spec/api_client/utils_spec.rb
api_client-0.5.3 spec/api_client/utils_spec.rb
api_client-0.5.2 spec/api_client/utils_spec.rb
api_client-0.5.1 spec/api_client/utils_spec.rb
api_client-0.5.0 spec/api_client/utils_spec.rb
api_client-0.4.3 spec/api_client/utils_spec.rb
api_client-0.4.2 spec/api_client/utils_spec.rb
api_client-0.4.1 spec/api_client/utils_spec.rb
api_client-0.3.3 spec/api_client/utils_spec.rb
api_client-0.4.0 spec/api_client/utils_spec.rb
api_client-0.3.2 spec/api_client/utils_spec.rb
api_client-0.3.1 spec/api_client/utils_spec.rb
api_client-0.3.0 spec/api_client/utils_spec.rb
api_client-0.2.0 spec/api_client/utils_spec.rb
api_client-0.1.9 spec/api_client/utils_spec.rb
api_client-0.1.8 spec/api_client/utils_spec.rb
api_client-0.1.7 spec/api_client/utils_spec.rb