Sha256: ad17d93c0777f59bc5a6d838f662b77820d4d7f8b10c9be36578dd4196b68fe7

Contents?: true

Size: 674 Bytes

Versions: 11

Compression:

Stored size: 674 Bytes

Contents

require 'spec_helper'

describe Hashie::Extensions::DeepMerge do
  class DeepMergeHash < Hash
    include Hashie::Extensions::DeepMerge
  end

  subject { DeepMergeHash }

  let(:h1) { subject.new.merge(a: 'a', a1: 42, b: 'b', c: { c1: 'c1', c2: { a: 'b' }, c3: { d1: 'd1' } }) }
  let(:h2) { { a: 1, a1: 1, c: { c1: 2, c2: 'c2', c3: { d2: 'd2' } } } }
  let(:expected_hash) { { a: 1, a1: 1, b: 'b', c: { c1: 2, c2: 'c2', c3: { d1: 'd1', d2: 'd2' } } } }

  it 'deep merges two hashes' do
    expect(h1.deep_merge(h2)).to eq expected_hash
  end

  it 'deep merges another hash in place via bang method' do
    h1.deep_merge!(h2)
    expect(h1).to eq expected_hash
  end
end

Version data entries

11 entries across 10 versions & 3 rubygems

Version Path
hashie-3.3.2 spec/hashie/extensions/deep_merge_spec.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/hashie-3.3.1/spec/hashie/extensions/deep_merge_spec.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/hashie-3.3.1/spec/hashie/extensions/deep_merge_spec.rb
hashie-3.3.1 spec/hashie/extensions/deep_merge_spec.rb
hashie-3.2.0 spec/hashie/extensions/deep_merge_spec.rb
hashie-3.1.0 spec/hashie/extensions/deep_merge_spec.rb
whos_dated_who-0.1.0 vendor/bundle/gems/hashie-3.0.0/spec/hashie/extensions/deep_merge_spec.rb
whos_dated_who-0.0.1 vendor/bundle/gems/hashie-3.0.0/spec/hashie/extensions/deep_merge_spec.rb
hashie-2.1.2 spec/hashie/extensions/deep_merge_spec.rb
hashie-3.0.0 spec/hashie/extensions/deep_merge_spec.rb
hashie-2.1.1 spec/hashie/extensions/deep_merge_spec.rb