diff options
Diffstat (limited to 'spec/ruby/core/hash/transform_keys_spec.rb')
-rw-r--r-- | spec/ruby/core/hash/transform_keys_spec.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb index 2c5d4124e0..63403a25b0 100644 --- a/spec/ruby/core/hash/transform_keys_spec.rb +++ b/spec/ruby/core/hash/transform_keys_spec.rb @@ -84,7 +84,7 @@ describe "Hash#transform_keys!" do end end - ruby_version_is "2.5.1" do + ruby_version_is "2.5.1"..."3.1" do it "returns the processed keys if we broke from the block" do @hash.transform_keys! do |v| break if v == :c @@ -94,6 +94,16 @@ describe "Hash#transform_keys!" do end end + ruby_version_is "3.1" do + it "returns the processed keys and non evaluated keys if we broke from the block" do + @hash.transform_keys! do |v| + break if v == :c + v.succ + end + @hash.should == { b: 1, c: 2, d: 4 } + end + end + it "keeps later pair if new keys conflict" do @hash.transform_keys! { |_| :a }.should == { a: 4 } end |