summaryrefslogtreecommitdiff
path: root/spec/hashie/mash_spec.rb
diff options
context:
space:
mode:
authorAmy Sutedja <asutedja@biaprotect.com>2014-09-04 16:31:48 -0700
committerAmy Sutedja <asutedja@biaprotect.com>2014-09-05 14:06:11 -0700
commitcebfebb8012520c4ab89d4c368983c28bdfcbe9b (patch)
tree1de0dd7e4d3d092a852477166f1ae727f617b61c /spec/hashie/mash_spec.rb
parentcdf6c832c067112ef95fbe0dd0c5b65cf9101eae (diff)
downloadhashie-cebfebb8012520c4ab89d4c368983c28bdfcbe9b.tar.gz
Merging Hashie::Mash now correctly only calls the block on duplicate values
Diffstat (limited to 'spec/hashie/mash_spec.rb')
-rw-r--r--spec/hashie/mash_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb
index 4f80a51..77adc25 100644
--- a/spec/hashie/mash_spec.rb
+++ b/spec/hashie/mash_spec.rb
@@ -189,6 +189,12 @@ describe Hashie::Mash do
duped = subject.merge(details: { address: 'Pasadena CA' }) { |_, oldv, newv| [oldv, newv].join(', ') }
expect(duped.details.address).to eq 'Nowhere road, Pasadena CA'
end
+
+ it 'copies values for non-duplicate keys when a block is supplied' do
+ duped = subject.merge(details: { address: 'Pasadena CA', state: 'West Thoughtleby' }) { |_, oldv, _| oldv }
+ expect(duped.details.address).to eq 'Nowhere road'
+ expect(duped.details.state).to eq 'West Thoughtleby'
+ end
end
describe 'shallow update' do