diff options
Diffstat (limited to 'spec/ruby/core/io/shared/readlines.rb')
| -rw-r--r-- | spec/ruby/core/io/shared/readlines.rb | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index 479452b71c..f54fccc2e3 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -1,11 +1,11 @@ describe :io_readlines, shared: true do it "raises TypeError if the first parameter is nil" do - -> { IO.send(@method, nil, &@object) }.should raise_error(TypeError) + -> { IO.send(@method, nil, &@object) }.should.raise(TypeError) end it "raises an Errno::ENOENT if the file does not exist" do name = tmp("nonexistent.txt") - -> { IO.send(@method, name, &@object) }.should raise_error(Errno::ENOENT) + -> { IO.send(@method, name, &@object) }.should.raise(Errno::ENOENT) end it "yields a single string with entire content when the separator is nil" do @@ -79,11 +79,13 @@ describe :io_readlines_options_19, shared: true do (result ? result : ScratchPad.recorded).should == IOSpecs.lines end - ruby_bug "#18767", ""..."3.3" do - describe "when passed limit" do - it "raises ArgumentError when passed 0 as a limit" do - -> { IO.send(@method, @name, 0, &@object) }.should raise_error(ArgumentError) - end + it "does not accept Integers that don't fit in a C off_t" do + -> { IO.send(@method, @name, 2**128, &@object) }.should.raise(RangeError) + end + + describe "when passed limit" do + it "raises ArgumentError when passed 0 as a limit" do + -> { IO.send(@method, @name, 0, &@object) }.should.raise(ArgumentError) end end end @@ -95,18 +97,16 @@ describe :io_readlines_options_19, shared: true do end it "accepts non-ASCII data as separator" do - result = IO.send(@method, @name, "\303\250".force_encoding("utf-8"), &@object) + result = IO.send(@method, @name, "\303\250".dup.force_encoding("utf-8"), &@object) (result ? result : ScratchPad.recorded).should == IOSpecs.lines_arbitrary_separator end end describe "when the object is an options Hash" do - ruby_version_is "3.0" do - it "raises TypeError exception" do - -> { - IO.send(@method, @name, { chomp: true }, &@object) - }.should raise_error(TypeError) - end + it "raises TypeError exception" do + -> { + IO.send(@method, @name, { chomp: true }, &@object) + }.should.raise(TypeError) end end @@ -116,7 +116,7 @@ describe :io_readlines_options_19, shared: true do -> { IO.send(@method, @name, obj, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end @@ -170,17 +170,15 @@ describe :io_readlines_options_19, shared: true do -> { IO.send(@method, @name, " ", obj, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end describe "when the second object is an options Hash" do - ruby_version_is "3.0" do - it "raises TypeError exception" do - -> { - IO.send(@method, @name, "", { chomp: true }, &@object) - }.should raise_error(TypeError) - end + it "raises TypeError exception" do + -> { + IO.send(@method, @name, "", { chomp: true }, &@object) + }.should.raise(TypeError) end end end @@ -190,7 +188,7 @@ describe :io_readlines_options_19, shared: true do it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, 10, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -198,7 +196,7 @@ describe :io_readlines_options_19, shared: true do it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, " ", mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -209,7 +207,7 @@ describe :io_readlines_options_19, shared: true do -> do IO.send(@method, @filename, sep, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end end @@ -239,7 +237,7 @@ describe :io_readlines_options_19, shared: true do it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, " ", 10, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end describe "when passed chomp, nil as a separator, and a limit" do |
