diff options
author | Jeremy Evans <[email protected]> | 2019-08-17 22:49:04 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2019-08-30 12:39:31 -0700 |
commit | a810f6cbefb5726c626b0c490522865588f4480e (patch) | |
tree | 83bc883b724e75976a155578c667276d10220450 /spec/ruby/language/lambda_spec.rb | |
parent | 16cd0de6ec8464129041c52174f5608e32512ca1 (diff) |
Update specs to handle non-Symbols for keyword splats in 2.7
Also handle some warnings for behavior that will change in 3.0.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2395
Diffstat (limited to 'spec/ruby/language/lambda_spec.rb')
-rw-r--r-- | spec/ruby/language/lambda_spec.rb | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb index a4c265d80c..3b06a0d595 100644 --- a/spec/ruby/language/lambda_spec.rb +++ b/spec/ruby/language/lambda_spec.rb @@ -186,9 +186,19 @@ describe "A lambda literal -> () { }" do @a.().should == {} @a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5} - h = mock("keyword splat") - h.should_receive(:to_hash).and_return({a: 1}) - @a.(h).should == {a: 1} + def self.suppress_keyword_warning(&block) + if RUBY_VERSION > '2.7' + suppress_warning(&block) + else + yield + end + end + + suppress_keyword_warning do + h = mock("keyword splat") + h.should_receive(:to_hash).and_return({a: 1}) + @a.(h).should == {a: 1} + end end evaluate <<-ruby do @@ -520,9 +530,19 @@ describe "A lambda expression 'lambda { ... }'" do @a.().should == {} @a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5} - h = mock("keyword splat") - h.should_receive(:to_hash).and_return({a: 1}) - @a.(h).should == {a: 1} + def self.suppress_keyword_warning(&block) + if RUBY_VERSION > '2.7' + suppress_warning(&block) + else + yield + end + end + + suppress_keyword_warning do + h = mock("keyword splat") + h.should_receive(:to_hash).and_return({a: 1}) + @a.(h).should == {a: 1} + end end evaluate <<-ruby do |