diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-09-29 16:03:58 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-09-29 16:03:58 +0200 |
commit | 1c938a72aa9378f982dbc55327e86150c47b8707 (patch) | |
tree | 34a0bb0a45396c26eed111877a810c3aa793bff5 /spec/ruby/core/io/shared | |
parent | 31bb66a19df26409c9d47afcf37919c9a065516a (diff) |
Update to ruby/spec@519df35
Diffstat (limited to 'spec/ruby/core/io/shared')
-rw-r--r-- | spec/ruby/core/io/shared/binwrite.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/new.rb | 44 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/readlines.rb | 8 |
3 files changed, 30 insertions, 26 deletions
diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb index 17682a1a93..29310e1eaf 100644 --- a/spec/ruby/core/io/shared/binwrite.rb +++ b/spec/ruby/core/io/shared/binwrite.rb @@ -56,7 +56,7 @@ describe :io_binwrite, shared: true do end it "doesn't truncate and writes at the given offset after passing empty opts" do - IO.send(@method, @filename, "hello world!", 1, {}) + IO.send(@method, @filename, "hello world!", 1, **{}) File.read(@filename).should == "0hello world!34567890123456789" end @@ -72,7 +72,7 @@ describe :io_binwrite, shared: true do end it "truncates if empty :opts provided and offset skipped" do - IO.send(@method, @filename, "hello, world!", {}) + IO.send(@method, @filename, "hello, world!", **{}) File.read(@filename).should == "hello, world!" end end diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index 2101958170..cc76955784 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -89,59 +89,59 @@ describe :io_new, shared: true do end it "uses the external encoding specified via the :external_encoding option" do - @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8'}) + @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8') @io.external_encoding.to_s.should == 'UTF-8' end it "uses the internal encoding specified via the :internal_encoding option" do - @io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866'}) + @io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866') @io.internal_encoding.to_s.should == 'IBM866' end it "uses the colon-separated encodings specified via the :encoding option" do - @io = IO.send(@method, @fd, 'w', {encoding: 'utf-8:ISO-8859-1'}) + @io = IO.send(@method, @fd, 'w', encoding: 'utf-8:ISO-8859-1') @io.external_encoding.to_s.should == 'UTF-8' @io.internal_encoding.to_s.should == 'ISO-8859-1' end it "uses the :encoding option as the external encoding when only one is given" do - @io = IO.send(@method, @fd, 'w', {encoding: 'ISO-8859-1'}) + @io = IO.send(@method, @fd, 'w', encoding: 'ISO-8859-1') @io.external_encoding.to_s.should == 'ISO-8859-1' end it "uses the :encoding options as the external encoding when it's an Encoding object" do - @io = IO.send(@method, @fd, 'w', {encoding: Encoding::ISO_8859_1}) + @io = IO.send(@method, @fd, 'w', encoding: Encoding::ISO_8859_1) @io.external_encoding.should == Encoding::ISO_8859_1 end it "ignores the :encoding option when the :external_encoding option is present" do -> { - @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1'}) + @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1') }.should complain(/Ignoring encoding parameter/) @io.external_encoding.to_s.should == 'UTF-8' end it "ignores the :encoding option when the :internal_encoding option is present" do -> { - @io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1'}) + @io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1') }.should complain(/Ignoring encoding parameter/) @io.internal_encoding.to_s.should == 'IBM866' end it "uses the encoding specified via the :mode option hash" do - @io = IO.send(@method, @fd, {mode: 'w:utf-8:ISO-8859-1'}) + @io = IO.send(@method, @fd, mode: 'w:utf-8:ISO-8859-1') @io.external_encoding.to_s.should == 'UTF-8' @io.internal_encoding.to_s.should == 'ISO-8859-1' end it "ignores the :internal_encoding option when the same as the external encoding" do - @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: 'utf-8'}) + @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: 'utf-8') @io.external_encoding.to_s.should == 'UTF-8' @io.internal_encoding.to_s.should == '' end it "sets internal encoding to nil when passed '-'" do - @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: '-'}) + @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: '-') @io.external_encoding.to_s.should == 'UTF-8' @io.internal_encoding.to_s.should == '' end @@ -157,12 +157,12 @@ describe :io_new, shared: true do end it "sets binmode from :binmode option" do - @io = IO.send(@method, @fd, 'w', {binmode: true}) + @io = IO.send(@method, @fd, 'w', binmode: true) @io.binmode?.should == true end it "does not set binmode from false :binmode" do - @io = IO.send(@method, @fd, 'w', {binmode: false}) + @io = IO.send(@method, @fd, 'w', binmode: false) @io.binmode?.should == false end @@ -173,7 +173,7 @@ describe :io_new, shared: true do # #5917 it "sets external encoding to binary with :binmode option" do - @io = IO.send(@method, @fd, 'w', {binmode: true}) + @io = IO.send(@method, @fd, 'w', binmode: true) @io.external_encoding.should == Encoding::BINARY end @@ -198,7 +198,9 @@ describe :io_new, shared: true do end it "accepts nil options" do - @io = IO.send(@method, @fd, 'w', nil) + @io = suppress_keyword_warning do + IO.send(@method, @fd, 'w', nil) + end @io.write("foo").should == 3 end @@ -247,13 +249,13 @@ describe :io_new, shared: true do it "coerces options as third argument with #to_hash" do options = mock("options") options.should_receive(:to_hash).and_return({}) - @io = IO.send(@method, @fd, 'w', options) + @io = IO.send(@method, @fd, 'w', **options) end it "coerces options as second argument with #to_hash" do options = mock("options") options.should_receive(:to_hash).and_return({}) - @io = IO.send(@method, @fd, options) + @io = IO.send(@method, @fd, **options) end it "accepts an :autoclose option" do @@ -307,13 +309,13 @@ describe :io_new_errors, shared: true do it "raises an error if passed encodings two ways" do -> { - @io = IO.send(@method, @fd, 'w:ISO-8859-1', {encoding: 'ISO-8859-1'}) + @io = IO.send(@method, @fd, 'w:ISO-8859-1', encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) -> { - @io = IO.send(@method, @fd, 'w:ISO-8859-1', {external_encoding: 'ISO-8859-1'}) + @io = IO.send(@method, @fd, 'w:ISO-8859-1', external_encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) -> { - @io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', {internal_encoding: 'ISO-8859-1'}) + @io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) end @@ -372,7 +374,9 @@ describe :io_new_errors, shared: true do it "raises TypeError if passed a hash for mode and nil for options" do -> { - @io = IO.send(@method, @fd, {mode: 'w'}, nil) + suppress_keyword_warning do + @io = IO.send(@method, @fd, {mode: 'w'}, nil) + end }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index 9bc02da0bd..de803f42e5 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -107,7 +107,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, 10, options, &@object) + IO.send(@method, @filename, 10, **options, &@object) end.should raise_error(IOError) end end @@ -135,7 +135,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", options, &@object) + IO.send(@method, @filename, " ", **options, &@object) end.should raise_error(IOError) end end @@ -170,7 +170,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", options, &@object) + IO.send(@method, @filename, " ", **options, &@object) end.should raise_error(IOError) end end @@ -202,7 +202,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", 10, options, &@object) + IO.send(@method, @filename, " ", 10, **options, &@object) end.should raise_error(IOError) end end |