diff --git a/core/hash/transform_keys_spec.rb b/core/hash/transform_keys_spec.rb index 70a4cdde36..9efb01064c 100644 --- a/core/hash/transform_keys_spec.rb +++ b/core/hash/transform_keys_spec.rb @@ -42,6 +42,12 @@ r.keys.should == [:xfoo] r.class.should == Hash end + + ruby_version_is "3.0.1" do + it "allows a hash argument" do + @hash.transform_keys({ a: :A, b: :B, c: :C }).should == { A: 1, B: 2, C: 3 } + end + end end describe "Hash#transform_keys!" do @@ -98,6 +104,13 @@ end end + ruby_version_is "3.0.1" do + it "allows a hash argument" do + @hash.transform_keys!({ a: :A, b: :B, c: :C, d: :D }) + @hash.should == { A: 1, B: 2, C: 3, D: 4 } + end + end + describe "on frozen instance" do before :each do @hash.freeze @@ -112,6 +125,12 @@ @hash.should == @initial_pairs end + ruby_version_is "3.0.1" do + it "raises a FrozenError on hash argument" do + ->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError) + end + end + context "when no block is given" do it "does not raise an exception" do @hash.transform_keys!.should be_an_instance_of(Enumerator)