diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-10-06 09:26:58 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-01-02 18:40:45 -0800 |
commit | e014e6bf6685f681998238ff005f6d161d43ce51 (patch) | |
tree | 1c373d95cdb9280ca051e9e66876ba6adc133f91 /spec/ruby/core | |
parent | ff96565686c05919bcae3ea77831879e95f67457 (diff) | |
download | ruby-e014e6bf6685f681998238ff005f6d161d43ce51.tar.gz |
Update specs for keyword argument separation
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/io/shared/new.rb | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index a7b4fc1cbe..27d32f97ed 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -197,11 +197,21 @@ describe :io_new, shared: true do @io.internal_encoding.to_s.should == 'IBM866' end - it "accepts nil options" do - @io = suppress_keyword_warning do - IO.send(@method, @fd, 'w', nil) + ruby_version_is ''...'2.8' do + it "accepts nil options" do + @io = suppress_keyword_warning do + IO.send(@method, @fd, 'w', nil) + end + @io.write("foo").should == 3 + end + end + + ruby_version_is '2.8' do + it "raises ArgumentError for nil options" do + -> { + IO.send(@method, @fd, 'w', nil) + }.should raise_error(ArgumentError) end - @io.write("foo").should == 3 end it "coerces mode with #to_str" do @@ -372,11 +382,21 @@ describe :io_new_errors, shared: true do }.should raise_error(ArgumentError) end - it "raises TypeError if passed a hash for mode and nil for options" do - -> { - suppress_keyword_warning do + ruby_version_is ''...'2.8' do + it "raises TypeError if passed a hash for mode and nil for options" do + -> { + suppress_keyword_warning do + @io = IO.send(@method, @fd, {mode: 'w'}, nil) + end + }.should raise_error(TypeError) + end + end + + ruby_version_is '2.8' do + it "raises ArgumentError if passed a hash for mode and nil for options" do + -> { @io = IO.send(@method, @fd, {mode: 'w'}, nil) - end - }.should raise_error(TypeError) + }.should raise_error(ArgumentError) + end end end |