aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language/hash_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/hash_spec.rb')
-rw-r--r--spec/ruby/language/hash_spec.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb
index 4bce241e76..79131e9da6 100644
--- a/spec/ruby/language/hash_spec.rb
+++ b/spec/ruby/language/hash_spec.rb
@@ -128,9 +128,18 @@ describe "Hash literal" do
{a: 1, **obj, c: 3}.should == {a:1, b: 2, c: 3, d: 4}
end
- it "raises a TypeError if any splatted elements keys are not symbols" do
- h = {1 => 2, b: 3}
- -> { {a: 1, **h} }.should raise_error(TypeError)
+ ruby_version_is "0"..."2.7" do
+ it "raises a TypeError if any splatted elements keys are not symbols" do
+ h = {1 => 2, b: 3}
+ -> { {a: 1, **h} }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "2.7" do
+ it "allows splatted elements keys that are not symbols" do
+ h = {1 => 2, b: 3}
+ {a: 1, **h}.should == {a: 1, 1 => 2, b: 3}
+ end
end
it "raises a TypeError if #to_hash does not return a Hash" do