summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-05-23 01:46:21 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-05-23 01:46:21 +0900
commit00f7e424516a6c5ea58ddb3cc821d3cabe9c496c (patch)
tree5ec0f26aaa0676137ea016f8ad34a79af5d9fac0 /spec
parenta093c98ddc92d8b0a341233630aea8f778188c7e (diff)
spec/ruby/core/hash/constructor_spec.rb: add "ruby_version_is" guard
follow up for d3f1c615c5
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/hash/constructor_spec.rb27
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/ruby/core/hash/constructor_spec.rb b/spec/ruby/core/hash/constructor_spec.rb
index 4e02a955bd..d32117b5a1 100644
--- a/spec/ruby/core/hash/constructor_spec.rb
+++ b/spec/ruby/core/hash/constructor_spec.rb
@@ -42,13 +42,26 @@ describe "Hash.[]" do
Hash[ary].should == { a: :b }
end
- it "ignores elements that are not arrays" do
- -> {
- Hash[[:a]].should == {}
- }.should raise_error(ArgumentError)
- -> {
- Hash[[:nil]].should == {}
- }.should raise_error(ArgumentError)
+ ruby_version_is "" ... "2.7" do
+ it "ignores elements that are not arrays" do
+ -> {
+ Hash[[:a]].should == {}
+ }.should complain(/ignoring wrong elements/)
+ -> {
+ Hash[[:nil]].should == {}
+ }.should complain(/ignoring wrong elements/)
+ end
+ end
+
+ ruby_version_is "2.7" do
+ it "ignores elements that are not arrays" do
+ -> {
+ Hash[[:a]].should == {}
+ }.should raise_error(ArgumentError)
+ -> {
+ Hash[[:nil]].should == {}
+ }.should raise_error(ArgumentError)
+ end
end
it "raises an ArgumentError for arrays of more than 2 elements" do