diff options
author | Jerry Cheung <jch@whatcodecraves.com> | 2013-02-12 10:58:32 -0800 |
---|---|---|
committer | Jerry Cheung <jch@whatcodecraves.com> | 2013-02-12 10:58:32 -0800 |
commit | 90b3f89d0cabcb56f0d28536754982b00eeed1eb (patch) | |
tree | aaf127543f8be67a63dd6aca4118b22833eb49b0 /spec | |
parent | 52bf2872eaaaffb174b9ba707f1d4396d81ca444 (diff) | |
parent | e94b70f20600d460c5123f5f9324fa36822ea69a (diff) | |
download | hashie-90b3f89d0cabcb56f0d28536754982b00eeed1eb.tar.gz |
Merge pull request #41 from nashby/deep-merge
add DeepMerge extension
Diffstat (limited to 'spec')
-rw-r--r-- | spec/hashie/extensions/deep_merge_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/hashie/extensions/deep_merge_spec.rb b/spec/hashie/extensions/deep_merge_spec.rb new file mode 100644 index 0000000..d835381 --- /dev/null +++ b/spec/hashie/extensions/deep_merge_spec.rb @@ -0,0 +1,20 @@ +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", :b => "b", :c => { :c1 => "c1", :c2 => "c2", :c3 => { :d1 => "d1" } }) } + let(:h2) { { :a => 1, :c => { :c1 => 2, :c3 => { :d2 => "d2" } } } } + let(:expected_hash) { { :a => 1, :b => "b", :c => { :c1 => 2, :c2 => "c2", :c3 => { :d1 => "d1", :d2 => "d2" } } } } + + it 'should deep merge two hashes' do + h1.deep_merge(h2).should == expected_hash + end + + it 'should deep merge two hashes with bang method' do + h1.deep_merge!(h2) + h1.should == expected_hash + end +end |