From aabf3d9b711f66fe4195a8c850856826c7ad5580 Mon Sep 17 00:00:00 2001 From: icebaker Date: Wed, 10 Jan 2024 21:31:42 -0300 Subject: improving merging approach --- spec/logic/helpers/hash_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'spec/logic/helpers') diff --git a/spec/logic/helpers/hash_spec.rb b/spec/logic/helpers/hash_spec.rb index 7c8ff58..0da92fb 100644 --- a/spec/logic/helpers/hash_spec.rb +++ b/spec/logic/helpers/hash_spec.rb @@ -9,6 +9,15 @@ RSpec.describe NanoBot::Logic::Helpers::Hash do ) end + it 'deep merges' do + expect(described_class.deep_merge( + { a: { x: 1, y: 2 }, b: 3 }, + { a: { y: 99, z: 4 }, c: 5 } + )).to eq( + { a: { x: 1, y: 99, z: 4 }, b: 3, c: 5 } + ) + end + it 'stringify keys' do expect(described_class.stringify_keys({ a: 'b', c: { d: [:e] } })).to eq( { 'a' => 'b', 'c' => { 'd' => [:e] } } -- cgit v1.2.3