Skip to content

Commit ff678eb

Browse files
committed
Share a Hash#merge! spec with Hash#update
1 parent ad62b51 commit ff678eb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

core/hash/merge_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,4 @@
9999

100100
describe "Hash#merge!" do
101101
it_behaves_like :hash_update, :merge!
102-
103-
it "does not raise an exception if changing the value of an existing key during iteration" do
104-
hash = {1 => 2, 3 => 4, 5 => 6}
105-
hash2 = {1 => :foo, 3 => :bar}
106-
hash.each { hash.merge!(hash2) }
107-
hash.should == {1 => :foo, 3 => :bar, 5 => 6}
108-
end
109102
end

core/hash/shared/update.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def obj.to_hash() raise Exception, "should not receive #to_hash" end
5757
end.should raise_error(frozen_error_class)
5858
end
5959

60+
it "does not raise an exception if changing the value of an existing key during iteration" do
61+
hash = {1 => 2, 3 => 4, 5 => 6}
62+
hash2 = {1 => :foo, 3 => :bar}
63+
hash.each { hash.send(@method, hash2) }
64+
hash.should == {1 => :foo, 3 => :bar, 5 => 6}
65+
end
66+
6067
ruby_version_is "2.6" do
6168
it "accepts multiple hashes" do
6269
result = { a: 1 }.send(@method, { b: 2 }, { c: 3 }, { d: 4 })

0 commit comments

Comments
 (0)