From 00f7e424516a6c5ea58ddb3cc821d3cabe9c496c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 23 May 2019 01:46:21 +0900 Subject: spec/ruby/core/hash/constructor_spec.rb: add "ruby_version_is" guard follow up for d3f1c615c5 --- spec/ruby/core/hash/constructor_spec.rb | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'spec/ruby') 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 -- cgit v1.2.3