summaryrefslogtreecommitdiff
path: root/spec/ruby/core/io
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-08 19:43:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-01 15:36:20 +0900
commit826f44834fe11f3f9c52343443a15b6c83466889 (patch)
treef2c2abed62db1c750515cd8b0fbac6442b6d4200 /spec/ruby/core/io
parent3a2073e61b6ccce6d07d31ebd89d4c385b9a55f2 (diff)
Drop support for ruby 2.4 from ruby/spec
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2892
Diffstat (limited to 'spec/ruby/core/io')
-rw-r--r--spec/ruby/core/io/close_spec.rb28
-rw-r--r--spec/ruby/core/io/pread_spec.rb74
-rw-r--r--spec/ruby/core/io/pwrite_spec.rb62
-rw-r--r--spec/ruby/core/io/write_spec.rb12
4 files changed, 84 insertions, 92 deletions
diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb
index 21bba32cd8..37c8ab5a12 100644
--- a/spec/ruby/core/io/close_spec.rb
+++ b/spec/ruby/core/io/close_spec.rb
@@ -44,22 +44,20 @@ describe "IO#close" do
@io.close.should be_nil
end
- ruby_version_is '2.5' do
- it 'raises an IOError with a clear message' do
- read_io, write_io = IO.pipe
- going_to_read = false
- thread = Thread.new do
- -> do
- going_to_read = true
- read_io.read
- end.should raise_error(IOError, 'stream closed in another thread')
- end
-
- Thread.pass until going_to_read && thread.stop?
- read_io.close
- thread.join
- write_io.close
+ it 'raises an IOError with a clear message' do
+ read_io, write_io = IO.pipe
+ going_to_read = false
+ thread = Thread.new do
+ -> do
+ going_to_read = true
+ read_io.read
+ end.should raise_error(IOError, 'stream closed in another thread')
end
+
+ Thread.pass until going_to_read && thread.stop?
+ read_io.close
+ thread.join
+ write_io.close
end
end
diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb
index bfe6472fef..43071d6a31 100644
--- a/spec/ruby/core/io/pread_spec.rb
+++ b/spec/ruby/core/io/pread_spec.rb
@@ -1,52 +1,50 @@
# -*- encoding: utf-8 -*-
require_relative '../../spec_helper'
-ruby_version_is "2.5" do
- platform_is_not :windows do
- describe "IO#pread" do
- before :each do
- @fname = tmp("io_pread.txt")
- @contents = "1234567890"
- touch(@fname) { |f| f.write @contents }
- @file = File.open(@fname, "r+")
- end
-
- after :each do
- @file.close
- rm_r @fname
- end
+platform_is_not :windows do
+ describe "IO#pread" do
+ before :each do
+ @fname = tmp("io_pread.txt")
+ @contents = "1234567890"
+ touch(@fname) { |f| f.write @contents }
+ @file = File.open(@fname, "r+")
+ end
- it "accepts a length, and an offset" do
- @file.pread(4, 0).should == "1234"
- @file.pread(3, 4).should == "567"
- end
+ after :each do
+ @file.close
+ rm_r @fname
+ end
- it "accepts a length, an offset, and an output buffer" do
- buffer = "foo"
- @file.pread(3, 4, buffer)
- buffer.should == "567"
- end
+ it "accepts a length, and an offset" do
+ @file.pread(4, 0).should == "1234"
+ @file.pread(3, 4).should == "567"
+ end
- it "does not advance the file pointer" do
- @file.pread(4, 0).should == "1234"
- @file.read.should == "1234567890"
- end
+ it "accepts a length, an offset, and an output buffer" do
+ buffer = "foo"
+ @file.pread(3, 4, buffer)
+ buffer.should == "567"
+ end
- it "raises EOFError if end-of-file is reached" do
- -> { @file.pread(1, 10) }.should raise_error(EOFError)
- end
+ it "does not advance the file pointer" do
+ @file.pread(4, 0).should == "1234"
+ @file.read.should == "1234567890"
+ end
- it "raises IOError when file is not open in read mode" do
- File.open(@fname, "w") do |file|
- -> { file.pread(1, 1) }.should raise_error(IOError)
- end
- end
+ it "raises EOFError if end-of-file is reached" do
+ -> { @file.pread(1, 10) }.should raise_error(EOFError)
+ end
- it "raises IOError when file is closed" do
- file = File.open(@fname, "r+")
- file.close
+ it "raises IOError when file is not open in read mode" do
+ File.open(@fname, "w") do |file|
-> { file.pread(1, 1) }.should raise_error(IOError)
end
end
+
+ it "raises IOError when file is closed" do
+ file = File.open(@fname, "r+")
+ file.close
+ -> { file.pread(1, 1) }.should raise_error(IOError)
+ end
end
end
diff --git a/spec/ruby/core/io/pwrite_spec.rb b/spec/ruby/core/io/pwrite_spec.rb
index 929ed08698..fe29d1e1f6 100644
--- a/spec/ruby/core/io/pwrite_spec.rb
+++ b/spec/ruby/core/io/pwrite_spec.rb
@@ -1,45 +1,43 @@
# -*- encoding: utf-8 -*-
require_relative '../../spec_helper'
-ruby_version_is "2.5" do
- platform_is_not :windows do
- describe "IO#pwrite" do
- before :each do
- @fname = tmp("io_pwrite.txt")
- @file = File.open(@fname, "w+")
- end
-
- after :each do
- @file.close
- rm_r @fname
- end
+platform_is_not :windows do
+ describe "IO#pwrite" do
+ before :each do
+ @fname = tmp("io_pwrite.txt")
+ @file = File.open(@fname, "w+")
+ end
- it "returns the number of bytes written" do
- @file.pwrite("foo", 0).should == 3
- end
+ after :each do
+ @file.close
+ rm_r @fname
+ end
- it "accepts a string and an offset" do
- @file.pwrite("foo", 2)
- @file.pread(3, 2).should == "foo"
- end
+ it "returns the number of bytes written" do
+ @file.pwrite("foo", 0).should == 3
+ end
- it "does not advance the pointer in the file" do
- @file.pwrite("bar", 3)
- @file.write("foo")
- @file.pread(6, 0).should == "foobar"
- end
+ it "accepts a string and an offset" do
+ @file.pwrite("foo", 2)
+ @file.pread(3, 2).should == "foo"
+ end
- it "raises IOError when file is not open in write mode" do
- File.open(@fname, "r") do |file|
- -> { file.pwrite("foo", 1) }.should raise_error(IOError)
- end
- end
+ it "does not advance the pointer in the file" do
+ @file.pwrite("bar", 3)
+ @file.write("foo")
+ @file.pread(6, 0).should == "foobar"
+ end
- it "raises IOError when file is closed" do
- file = File.open(@fname, "w+")
- file.close
+ it "raises IOError when file is not open in write mode" do
+ File.open(@fname, "r") do |file|
-> { file.pwrite("foo", 1) }.should raise_error(IOError)
end
end
+
+ it "raises IOError when file is closed" do
+ file = File.open(@fname, "w+")
+ file.close
+ -> { file.pwrite("foo", 1) }.should raise_error(IOError)
+ end
end
end
diff --git a/spec/ruby/core/io/write_spec.rb b/spec/ruby/core/io/write_spec.rb
index b28b582019..9c9b8b254b 100644
--- a/spec/ruby/core/io/write_spec.rb
+++ b/spec/ruby/core/io/write_spec.rb
@@ -126,14 +126,12 @@ end
describe "IO#write" do
it_behaves_like :io_write, :write
- ruby_version_is "2.5" do
- it "accepts multiple arguments" do
- IO.pipe do |r, w|
- w.write("foo", "bar")
- w.close
+ it "accepts multiple arguments" do
+ IO.pipe do |r, w|
+ w.write("foo", "bar")
+ w.close
- r.read.should == "foobar"
- end
+ r.read.should == "foobar"
end
end
end