Sha256: 30018f13ee92d6bd148fa877b92dcd2b8293cfd8068b2958c416ea77601816a5
Contents?: true
Size: 1.03 KB
Versions: 13
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' describe "BlacklightAdvancedSearch#deep_merge!" do before do @ahash = {"a" => "a", "b" => "b", "array1" => [1,2], "array2" => [3,4], "hash1" => {"a" => "a", "array" => [1], "b" => "b"}, "hash2" => {"a2" => "a2", "array2" => [12], "b2" => "b2"} } BlacklightAdvancedSearch.deep_merge!(@ahash, { "a" => "NEW A", "array1" => [3, 4], "hash1" => { "array" => [2], "b" => "NEW B" }, "c" => "NEW C" }) end it "leaves un-collided content alone" do expect(@ahash["b"]).to eq("b") expect(@ahash["array2"]).to eq([3,4]) expect(@ahash["hash2"]).to eq({"a2" => "a2", "array2" => [12], "b2" => "b2"}) end it "adds new content" do expect(@ahash["c"]).to eq("NEW C") end it "merges an array" do expect(@ahash["array1"]).to eq([1,2,3,4]) end it "merges a hash, recursive like" do expect(@ahash["hash1"]).to eq({ "a" => "a", "array" => [1,2], "b" => "NEW B" }) end end
Version data entries
13 entries across 13 versions & 1 rubygems