diff options
Diffstat (limited to 'spec/ruby/core/io/shared')
-rw-r--r-- | spec/ruby/core/io/shared/binwrite.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/each.rb | 20 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/new.rb | 55 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/readlines.rb | 22 |
4 files changed, 36 insertions, 73 deletions
diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb index 950a6f51ab..e51093329b 100644 --- a/spec/ruby/core/io/shared/binwrite.rb +++ b/spec/ruby/core/io/shared/binwrite.rb @@ -21,14 +21,12 @@ describe :io_binwrite, shared: true do IO.send(@method, @filename, "abcde").should == 5 end - ruby_version_is "3.0" do - it "accepts options as a keyword argument" do - IO.send(@method, @filename, "hi", 0, flags: File::CREAT).should == 2 + it "accepts options as a keyword argument" do + IO.send(@method, @filename, "hi", 0, flags: File::CREAT).should == 2 - -> { - IO.send(@method, @filename, "hi", 0, {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)") - end + -> { + IO.send(@method, @filename, "hi", 0, {flags: File::CREAT}) + }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)") end it "creates a file if missing" do diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb index 02bbe19c1a..aca622834f 100644 --- a/spec/ruby/core/io/shared/each.rb +++ b/spec/ruby/core/io/shared/each.rb @@ -33,10 +33,6 @@ describe :io_each, shared: true do $_.should == "test" end - it "returns self" do - @io.send(@method) { |l| l }.should equal(@io) - end - it "raises an IOError when self is not readable" do -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError) end @@ -180,16 +176,14 @@ describe :io_each, shared: true do ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters end - ruby_version_is "3.0" do - it "raises exception when options passed as Hash" do - -> { - @io.send(@method, { chomp: true }) { |s| } - }.should raise_error(TypeError) + it "raises exception when options passed as Hash" do + -> { + @io.send(@method, { chomp: true }) { |s| } + }.should raise_error(TypeError) - -> { - @io.send(@method, "\n", 1, { chomp: true }) { |s| } - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") - end + -> { + @io.send(@method, "\n", 1, { chomp: true }) { |s| } + }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") end end diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index da4c0af7a9..cba5f33ebf 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -1,6 +1,6 @@ require_relative '../fixtures/classes' -# NOTE: should be syncronized with library/stringio/initialize_spec.rb +# NOTE: should be synchronized with library/stringio/initialize_spec.rb # This group of specs may ONLY contain specs that do successfully create # an IO instance from the file descriptor returned by #new_fd helper. @@ -64,15 +64,13 @@ describe :io_new, shared: true do @io.should be_an_instance_of(IO) end - ruby_version_is "3.0" do - it "accepts options as keyword arguments" do - @io = IO.send(@method, @fd, "w", flags: File::CREAT) - @io.write("foo").should == 3 + it "accepts options as keyword arguments" do + @io = IO.send(@method, @fd, "w", flags: File::CREAT) + @io.write("foo").should == 3 - -> { - IO.send(@method, @fd, "w", {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") - end + -> { + IO.send(@method, @fd, "w", {flags: File::CREAT}) + }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") end it "accepts a :mode option" do @@ -210,21 +208,10 @@ describe :io_new, shared: true do @io.internal_encoding.to_s.should == 'IBM866' end - ruby_version_is ''...'3.0' 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 '3.0' do - it "raises ArgumentError for nil options" do - -> { - IO.send(@method, @fd, 'w', nil) - }.should raise_error(ArgumentError) - end + it "raises ArgumentError for nil options" do + -> { + IO.send(@method, @fd, 'w', nil) + }.should raise_error(ArgumentError) end it "coerces mode with #to_str" do @@ -395,21 +382,9 @@ describe :io_new_errors, shared: true do }.should raise_error(ArgumentError) end - ruby_version_is ''...'3.0' 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 '3.0' do - it "raises ArgumentError if passed a hash for mode and nil for options" do - -> { - @io = IO.send(@method, @fd, {mode: 'w'}, nil) - }.should raise_error(ArgumentError) - end + it "raises ArgumentError if passed a hash for mode and nil for options" do + -> { + @io = IO.send(@method, @fd, {mode: 'w'}, nil) + }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index 7681e1b5c1..6c1fa11a59 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -99,18 +99,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_error(TypeError) end end @@ -179,12 +177,10 @@ describe :io_readlines_options_19, shared: true do 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_error(TypeError) end end end |