Sha256: cfae6b9c71539541e2716d2cc48eb36f807dde6d51a0b6d735b4ac038f3b5a91
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
describe Skala::I18n::DeepMerger do describe ".deep_merge!" do describe "merges arrays into arrays" do it "merges two arrays of literals" do source = [1,"2",:f] destination = [:"3", 5, "foo"] described_class.deep_merge!(destination, source) expect(destination).to eq([:"3", 5, "foo", 1, "2", :f]) end it "merges two arrays of hashes" do source = [{c:3}] destination = [{a: 1}, {b:2}] described_class.deep_merge!(destination, source) expect(destination).to eq([{:a=>1}, {:b=>2}, {:c=>3}]) end end describe "merges hashes into hashes" do it "merges two simple hashes" do source = { c: 3 } destination = { a: 1, b: 2 } described_class.deep_merge!(destination, source) expect(destination).to eq({:a=>1, :b=>2, :c=>3}) end it "merges two nested hashes" do source = { a: { type: "multi_value", values: [2,3] }, b: { value: "123" } } destination = { a: { values: [1]}, b: { type: "id" } } described_class.deep_merge!(destination, source) expect(destination).to eq({:a=>{:values=>[1, 2, 3], :type=>"multi_value"}, :b=>{:type=>"id", :value=>"123"}}) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skala-0.2.0 | spec/skala/i18n/deep_merger_spec.rb |