summaryrefslogtreecommitdiff
path: root/spec/ruby/core/io/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/io/shared')
-rw-r--r--spec/ruby/core/io/shared/binwrite.rb4
-rw-r--r--spec/ruby/core/io/shared/chars.rb73
-rw-r--r--spec/ruby/core/io/shared/codepoints.rb54
-rw-r--r--spec/ruby/core/io/shared/each.rb251
-rw-r--r--spec/ruby/core/io/shared/new.rb79
-rw-r--r--spec/ruby/core/io/shared/pos.rb40
-rw-r--r--spec/ruby/core/io/shared/readlines.rb30
-rw-r--r--spec/ruby/core/io/shared/tty.rb24
-rw-r--r--spec/ruby/core/io/shared/write.rb8
9 files changed, 74 insertions, 489 deletions
diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb
index e51093329b..64793b1936 100644
--- a/spec/ruby/core/io/shared/binwrite.rb
+++ b/spec/ruby/core/io/shared/binwrite.rb
@@ -26,7 +26,7 @@ describe :io_binwrite, shared: true do
-> {
IO.send(@method, @filename, "hi", 0, {flags: File::CREAT})
- }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)")
+ }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 2..3)")
end
it "creates a file if missing" do
@@ -81,7 +81,7 @@ describe :io_binwrite, shared: true do
end
it "raises an error if readonly mode is specified" do
- -> { IO.send(@method, @filename, "abcde", mode: "r") }.should raise_error(IOError)
+ -> { IO.send(@method, @filename, "abcde", mode: "r") }.should.raise(IOError)
end
it "truncates if empty :opts provided and offset skipped" do
diff --git a/spec/ruby/core/io/shared/chars.rb b/spec/ruby/core/io/shared/chars.rb
deleted file mode 100644
index 266566f221..0000000000
--- a/spec/ruby/core/io/shared/chars.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- encoding: utf-8 -*-
-describe :io_chars, shared: true do
- before :each do
- @io = IOSpecs.io_fixture "lines.txt"
- ScratchPad.record []
- end
-
- after :each do
- @io.close unless @io.closed?
- end
-
- it "yields each character" do
- @io.readline.should == "Voici la ligne une.\n"
-
- count = 0
- @io.send(@method) do |c|
- ScratchPad << c
- break if 4 < count += 1
- end
-
- ScratchPad.recorded.should == ["Q", "u", "i", " ", "è"]
- end
-
- describe "when no block is given" do
- it "returns an Enumerator" do
- enum = @io.send(@method)
- enum.should be_an_instance_of(Enumerator)
- enum.first(5).should == ["V", "o", "i", "c", "i"]
- end
-
- describe "returned Enumerator" do
- describe "size" do
- it "should return nil" do
- @io.send(@method).size.should == nil
- end
- end
- end
- end
-
- it "returns itself" do
- @io.send(@method) { |c| }.should equal(@io)
- end
-
- it "returns an enumerator for a closed stream" do
- IOSpecs.closed_io.send(@method).should be_an_instance_of(Enumerator)
- end
-
- it "raises an IOError when an enumerator created on a closed stream is accessed" do
- -> { IOSpecs.closed_io.send(@method).first }.should raise_error(IOError)
- end
-
- it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
- end
-end
-
-describe :io_chars_empty, shared: true do
- before :each do
- @name = tmp("io_each_char")
- @io = new_io @name, "w+:utf-8"
- ScratchPad.record []
- end
-
- after :each do
- @io.close unless @io.closed?
- rm_r @name
- end
-
- it "does not yield any characters on an empty stream" do
- @io.send(@method) { |c| ScratchPad << c }
- ScratchPad.recorded.should == []
- end
-end
diff --git a/spec/ruby/core/io/shared/codepoints.rb b/spec/ruby/core/io/shared/codepoints.rb
deleted file mode 100644
index 6872846c1a..0000000000
--- a/spec/ruby/core/io/shared/codepoints.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- encoding: utf-8 -*-
-require_relative '../fixtures/classes'
-
-describe :io_codepoints, shared: true do
- before :each do
- @io = IOSpecs.io_fixture "lines.txt"
- @enum = @io.send(@method)
- end
-
- after :each do
- @io.close
- end
-
- describe "when no block is given" do
- it "returns an Enumerator" do
- @enum.should be_an_instance_of(Enumerator)
- end
-
- describe "returned Enumerator" do
- describe "size" do
- it "should return nil" do
- @enum.size.should == nil
- end
- end
- end
- end
-
- it "yields each codepoint" do
- @enum.first(25).should == [
- 86, 111, 105, 99, 105, 32, 108, 97, 32, 108, 105, 103, 110,
- 101, 32, 117, 110, 101, 46, 10, 81, 117, 105, 32, 232
- ]
- end
-
- it "yields each codepoint starting from the current position" do
- @io.pos = 130
- @enum.to_a.should == [101, 32, 115, 105, 120, 46, 10]
- end
-
- it "raises an error if reading invalid sequence" do
- @io.pos = 60 # inside of a multibyte sequence
- -> { @enum.first }.should raise_error(ArgumentError)
- end
-
- it "does not change $_" do
- $_ = "test"
- @enum.to_a
- $_.should == "test"
- end
-
- it "raises an IOError when self is not readable" do
- -> { IOSpecs.closed_io.send(@method).to_a }.should raise_error(IOError)
- end
-end
diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb
deleted file mode 100644
index 0747f31b8a..0000000000
--- a/spec/ruby/core/io/shared/each.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-# -*- encoding: utf-8 -*-
-require_relative '../fixtures/classes'
-
-describe :io_each, shared: true do
- before :each do
- @io = IOSpecs.io_fixture "lines.txt"
- ScratchPad.record []
- end
-
- after :each do
- @io.close if @io
- end
-
- describe "with no separator" do
- it "yields each line to the passed block" do
- @io.send(@method) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines
- end
-
- it "yields each line starting from the current position" do
- @io.pos = 41
- @io.send(@method) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines[2..-1]
- end
-
- it "returns self" do
- @io.send(@method) { |l| l }.should equal(@io)
- end
-
- it "does not change $_" do
- $_ = "test"
- @io.send(@method) { |s| s }
- $_.should == "test"
- end
-
- it "raises an IOError when self is not readable" do
- -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
- end
-
- it "makes line count accessible via lineno" do
- @io.send(@method) { ScratchPad << @io.lineno }
- ScratchPad.recorded.should == [ 1,2,3,4,5,6,7,8,9 ]
- end
-
- it "makes line count accessible via $." do
- @io.send(@method) { ScratchPad << $. }
- ScratchPad.recorded.should == [ 1,2,3,4,5,6,7,8,9 ]
- end
-
- describe "when no block is given" do
- it "returns an Enumerator" do
- enum = @io.send(@method)
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |l| ScratchPad << l }
- ScratchPad.recorded.should == IOSpecs.lines
- end
-
- describe "returned Enumerator" do
- describe "size" do
- it "should return nil" do
- @io.send(@method).size.should == nil
- end
- end
- end
- end
- end
-
- describe "with limit" do
- describe "when limit is 0" do
- it "raises an ArgumentError" do
- # must pass block so Enumerator is evaluated and raises
- -> { @io.send(@method, 0){} }.should raise_error(ArgumentError)
- end
- end
-
- it "does not accept Integers that don't fit in a C off_t" do
- -> { @io.send(@method, 2**128){} }.should raise_error(RangeError)
- end
- end
-
- describe "when passed a String containing one space as a separator" do
- it "uses the passed argument as the line separator" do
- @io.send(@method, " ") { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines_space_separator
- end
-
- it "does not change $_" do
- $_ = "test"
- @io.send(@method, " ") { |s| }
- $_.should == "test"
- end
-
- it "tries to convert the passed separator to a String using #to_str" do
- obj = mock("to_str")
- obj.stub!(:to_str).and_return(" ")
-
- @io.send(@method, obj) { |l| ScratchPad << l }
- ScratchPad.recorded.should == IOSpecs.lines_space_separator
- end
- end
-
- describe "when passed nil as a separator" do
- it "yields self's content starting from the current position when the passed separator is nil" do
- @io.pos = 100
- @io.send(@method, nil) { |s| ScratchPad << s }
- ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
- end
- end
-
- describe "when passed an empty String as a separator" do
- it "yields each paragraph" do
- @io.send(@method, "") { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.paragraphs
- end
-
- it "discards leading newlines" do
- @io.readline
- @io.readline
- @io.send(@method, "") { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.paragraphs[1..-1]
- end
- end
-
- describe "with both separator and limit" do
- describe "when no block is given" do
- it "returns an Enumerator" do
- enum = @io.send(@method, nil, 1024)
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |l| ScratchPad << l }
- ScratchPad.recorded.should == [IOSpecs.lines.join]
- end
-
- describe "returned Enumerator" do
- describe "size" do
- it "should return nil" do
- @io.send(@method, nil, 1024).size.should == nil
- end
- end
- end
- end
-
- describe "when a block is given" do
- it "accepts an empty block" do
- @io.send(@method, nil, 1024) {}.should equal(@io)
- end
-
- describe "when passed nil as a separator" do
- it "yields self's content starting from the current position when the passed separator is nil" do
- @io.pos = 100
- @io.send(@method, nil, 1024) { |s| ScratchPad << s }
- ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
- end
- end
-
- describe "when passed an empty String as a separator" do
- it "yields each paragraph" do
- @io.send(@method, "", 1024) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.paragraphs
- end
-
- it "discards leading newlines" do
- @io.readline
- @io.readline
- @io.send(@method, "", 1024) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.paragraphs[1..-1]
- end
- end
- end
- end
-
- describe "when passed chomp" do
- it "yields each line without trailing newline characters to the passed block" do
- @io.send(@method, chomp: true) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters
- end
-
- 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
- end
-
- describe "when passed chomp and a separator" do
- it "yields each line without separator to the passed block" do
- @io.send(@method, " ", chomp: true) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines_space_separator_without_trailing_spaces
- end
- end
-
- describe "when passed chomp and empty line as a separator" do
- it "yields each paragraph without trailing new line characters" do
- @io.send(@method, "", 1024, chomp: true) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.paragraphs_without_trailing_new_line_characters
- end
- end
-
- describe "when passed chomp and nil as a separator" do
- it "yields self's content" do
- @io.pos = 100
- @io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
- ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
- end
- end
-
- describe "when passed chomp, nil as a separator, and a limit" do
- it "yields each line of limit size without truncating trailing new line character" do
- # 43 - is a size of the 1st paragraph in the file
- @io.send(@method, nil, 43, chomp: true) { |s| ScratchPad << s }
-
- ScratchPad.recorded.should == [
- "Voici la ligne une.\nQui è la linea due.\n\n\n",
- "Aquí está la línea tres.\n" + "Hier ist Zeile ",
- "vier.\n\nEstá aqui a linha cinco.\nHere is li",
- "ne six.\n"
- ]
- end
- end
-
- describe "when passed too many arguments" do
- it "raises ArgumentError" do
- -> {
- @io.send(@method, "", 1, "excess argument", chomp: true) {}
- }.should raise_error(ArgumentError)
- end
- end
-end
-
-describe :io_each_default_separator, shared: true do
- before :each do
- @io = IOSpecs.io_fixture "lines.txt"
- ScratchPad.record []
- suppress_warning {@sep, $/ = $/, " "}
- end
-
- after :each do
- @io.close if @io
- suppress_warning {$/ = @sep}
- end
-
- it "uses $/ as the default line separator" do
- @io.send(@method) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines_space_separator
- end
-end
diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb
index cba5f33ebf..6f318ddee5 100644
--- a/spec/ruby/core/io/shared/new.rb
+++ b/spec/ruby/core/io/shared/new.rb
@@ -22,7 +22,7 @@ describe :io_new, shared: true do
it "creates an IO instance from an Integer argument" do
@io = IO.send(@method, @fd, "w")
- @io.should be_an_instance_of(IO)
+ @io.should.instance_of?(IO)
end
it "creates an IO instance when STDOUT is closed" do
@@ -32,7 +32,7 @@ describe :io_new, shared: true do
begin
@io = IO.send(@method, @fd, "w")
- @io.should be_an_instance_of(IO)
+ @io.should.instance_of?(IO)
ensure
STDOUT = stdout
rm_r stdout_file
@@ -49,7 +49,7 @@ describe :io_new, shared: true do
begin
@io = IO.send(@method, @fd, "w")
- @io.should be_an_instance_of(IO)
+ @io.should.instance_of?(IO)
ensure
STDERR = stderr
rm_r stderr_file
@@ -61,7 +61,7 @@ describe :io_new, shared: true do
obj = mock("file descriptor")
obj.should_receive(:to_int).and_return(@fd)
@io = IO.send(@method, obj, "w")
- @io.should be_an_instance_of(IO)
+ @io.should.instance_of?(IO)
end
it "accepts options as keyword arguments" do
@@ -70,7 +70,7 @@ describe :io_new, shared: true do
-> {
IO.send(@method, @fd, "w", {flags: File::CREAT})
- }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)")
+ }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 1..2)")
end
it "accepts a :mode option" do
@@ -208,10 +208,30 @@ describe :io_new, shared: true do
@io.internal_encoding.to_s.should == 'IBM866'
end
+ it "does not use binary encoding when mode encoding is specified along with binmode: true option" do
+ @io = IO.send(@method, @fd, 'w:iso-8859-1', binmode: true)
+ @io.external_encoding.to_s.should == 'ISO-8859-1'
+ end
+
+ it "does not use textmode argument when mode encoding is specified" do
+ @io = IO.send(@method, @fd, 'w:ascii-8bit', textmode: true)
+ @io.external_encoding.to_s.should == 'ASCII-8BIT'
+ end
+
+ it "does not use binmode argument when external encoding is specified via the :external_encoding option" do
+ @io = IO.send(@method, @fd, 'w', binmode: true, external_encoding: 'iso-8859-1')
+ @io.external_encoding.to_s.should == 'ISO-8859-1'
+ end
+
+ it "does not use textmode argument when external encoding is specified via the :external_encoding option" do
+ @io = IO.send(@method, @fd, 'w', textmode: true, external_encoding: 'ascii-8bit')
+ @io.external_encoding.to_s.should == 'ASCII-8BIT'
+ end
+
it "raises ArgumentError for nil options" do
-> {
IO.send(@method, @fd, 'w', nil)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "coerces mode with #to_str" do
@@ -294,97 +314,100 @@ describe :io_new_errors, shared: true do
end
it "raises an Errno::EBADF if the file descriptor is not valid" do
- -> { IO.send(@method, -1, "w") }.should raise_error(Errno::EBADF)
+ -> { IO.send(@method, -1, "w") }.should.raise(Errno::EBADF)
end
it "raises an IOError if passed a closed stream" do
- -> { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should raise_error(IOError)
+ -> { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should.raise(IOError)
end
platform_is_not :windows do
it "raises an Errno::EINVAL if the new mode is not compatible with the descriptor's current mode" do
- -> { IO.send(@method, @fd, "r") }.should raise_error(Errno::EINVAL)
+ -> { IO.send(@method, @fd, "r") }.should.raise(Errno::EINVAL)
end
end
it "raises ArgumentError if passed an empty mode string" do
- -> { IO.send(@method, @fd, "") }.should raise_error(ArgumentError)
+ -> { IO.send(@method, @fd, "") }.should.raise(ArgumentError)
end
it "raises an error if passed modes two ways" do
-> {
IO.send(@method, @fd, "w", mode: "w")
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error if passed encodings two ways" do
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1', encoding: 'ISO-8859-1')
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1', external_encoding: 'ISO-8859-1')
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
+ -> {
+ @io = IO.send(@method, @fd, 'w:ISO-8859-1', internal_encoding: 'ISO-8859-1')
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1')
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error if passed matching binary/text mode two ways" do
-> {
@io = IO.send(@method, @fd, "wb", binmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wt", textmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wb", textmode: false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wt", binmode: false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error if passed conflicting binary/text mode two ways" do
-> {
@io = IO.send(@method, @fd, "wb", binmode: false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wt", textmode: false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wb", textmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, "wt", binmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error when trying to set both binmode and textmode" do
-> {
@io = IO.send(@method, @fd, "w", textmode: true, binmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, File::Constants::WRONLY, textmode: true, binmode: true)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises ArgumentError if not passed a hash or nil for options" do
-> {
@io = IO.send(@method, @fd, 'w', false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, false, false)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
-> {
@io = IO.send(@method, @fd, nil, false)
- }.should raise_error(ArgumentError)
+ }.should.raise(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)
+ }.should.raise(ArgumentError)
end
end
diff --git a/spec/ruby/core/io/shared/pos.rb b/spec/ruby/core/io/shared/pos.rb
index 3fdd3eb2b3..450058e159 100644
--- a/spec/ruby/core/io/shared/pos.rb
+++ b/spec/ruby/core/io/shared/pos.rb
@@ -1,37 +1,3 @@
-describe :io_pos, shared: true do
- before :each do
- @fname = tmp('test.txt')
- File.open(@fname, 'w') { |f| f.write "123" }
- end
-
- after :each do
- rm_r @fname
- end
-
- it "gets the offset" do
- File.open @fname do |f|
- f.send(@method).should == 0
- f.read 1
- f.send(@method).should == 1
- f.read 2
- f.send(@method).should == 3
- end
- end
-
- it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method) }.should raise_error(IOError)
- end
-
- it "resets #eof?" do
- open @fname do |io|
- io.read 1
- io.read 1
- io.send(@method)
- io.should_not.eof?
- end
- end
-end
-
describe :io_set_pos, shared: true do
before :each do
@fname = tmp('test.txt')
@@ -62,17 +28,17 @@ describe :io_set_pos, shared: true do
it "raises TypeError when cannot convert implicitly argument to Integer" do
File.open @fname do |io|
- -> { io.send @method, Object.new }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ -> { io.send @method, Object.new }.should.raise(TypeError, "no implicit conversion of Object into Integer")
end
end
it "does not accept Integers that don't fit in a C off_t" do
File.open @fname do |io|
- -> { io.send @method, 2**128 }.should raise_error(RangeError)
+ -> { io.send @method, 2**128 }.should.raise(RangeError)
end
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send @method, 0 }.should raise_error(IOError)
+ -> { IOSpecs.closed_io.send @method, 0 }.should.raise(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb
index 6c1fa11a59..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
@@ -80,14 +80,12 @@ describe :io_readlines_options_19, shared: true do
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_error(RangeError)
+ -> { IO.send(@method, @name, 2**128, &@object) }.should.raise(RangeError)
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
+ 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
@@ -108,7 +106,7 @@ describe :io_readlines_options_19, shared: true do
it "raises TypeError exception" do
-> {
IO.send(@method, @name, { chomp: true }, &@object)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
end
@@ -118,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
@@ -172,7 +170,7 @@ describe :io_readlines_options_19, shared: true do
-> {
IO.send(@method, @name, " ", obj, &@object)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
end
@@ -180,7 +178,7 @@ describe :io_readlines_options_19, shared: true do
it "raises TypeError exception" do
-> {
IO.send(@method, @name, "", { chomp: true }, &@object)
- }.should raise_error(TypeError)
+ }.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
diff --git a/spec/ruby/core/io/shared/tty.rb b/spec/ruby/core/io/shared/tty.rb
deleted file mode 100644
index 89ac08ec86..0000000000
--- a/spec/ruby/core/io/shared/tty.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :io_tty, shared: true do
- platform_is_not :windows do
- it "returns true if this stream is a terminal device (TTY)" do
- begin
- # check to enabled tty
- File.open('/dev/tty') {}
- rescue Errno::ENXIO
- skip "workaround for not configured environment like OS X"
- else
- File.open('/dev/tty') { |f| f.send(@method) }.should == true
- end
- end
- end
-
- it "returns false if this stream is not a terminal device (TTY)" do
- File.open(__FILE__) { |f| f.send(@method) }.should == false
- end
-
- it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send @method }.should raise_error(IOError)
- end
-end
diff --git a/spec/ruby/core/io/shared/write.rb b/spec/ruby/core/io/shared/write.rb
index 964064746a..5de9fe4335 100644
--- a/spec/ruby/core/io/shared/write.rb
+++ b/spec/ruby/core/io/shared/write.rb
@@ -23,7 +23,7 @@ describe :io_write, shared: true do
end
it "checks if the file is writable if writing more than zero bytes" do
- -> { @readonly_file.send(@method, "abcde") }.should raise_error(IOError)
+ -> { @readonly_file.send(@method, "abcde") }.should.raise(IOError)
end
it "returns the number of bytes written" do
@@ -66,7 +66,7 @@ describe :io_write, shared: true do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError)
+ -> { IOSpecs.closed_io.send(@method, "hello") }.should.raise(IOError)
end
describe "on a pipe" do
@@ -92,7 +92,7 @@ describe :io_write, shared: true do
guard_not -> { defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? } do
it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do
@r.close
- -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/)
+ -> { @w.send(@method, "foo") }.should.raise(Errno::EPIPE, /Broken pipe/)
end
end
end
@@ -126,7 +126,7 @@ describe :io_write_transcode, shared: true do
File.open(@transcode_filename, "w", external_encoding: Encoding::UTF_16BE) do |file|
file.external_encoding.should == Encoding::UTF_16BE
- -> { file.send(@method, str) }.should raise_error(Encoding::UndefinedConversionError)
+ -> { file.send(@method, str) }.should.raise(Encoding::UndefinedConversionError)
end
end
end