diff --git a/core/hash/replace_spec.rb b/core/hash/replace_spec.rb index 182c7977d..a26a31f5f 100644 --- a/core/hash/replace_spec.rb +++ b/core/hash/replace_spec.rb @@ -23,6 +23,22 @@ h.should == { 1 => 2 } end + it "transfers the compare_by_identity flag" do + hash_a = { a: 1 } + hash_b = { b: 2 } + hash_b.compare_by_identity + hash_a.should_not.compare_by_identity? + hash_a.replace(hash_b) + hash_a.should.compare_by_identity? + + hash_a = { a: 1 } + hash_b = { b: 2 } + hash_a.compare_by_identity + hash_a.should.compare_by_identity? + hash_a.replace(hash_b) + hash_a.should_not.compare_by_identity? + end + it "does not transfer default values" do hash_a = {} hash_b = Hash.new(5)