summaryrefslogtreecommitdiff
path: root/spec/ruby/library/io-wait
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/io-wait')
-rw-r--r--spec/ruby/library/io-wait/wait_readable_spec.rb4
-rw-r--r--spec/ruby/library/io-wait/wait_spec.rb65
-rw-r--r--spec/ruby/library/io-wait/wait_writable_spec.rb4
3 files changed, 19 insertions, 54 deletions
diff --git a/spec/ruby/library/io-wait/wait_readable_spec.rb b/spec/ruby/library/io-wait/wait_readable_spec.rb
index df25fdb931..d7473f029f 100644
--- a/spec/ruby/library/io-wait/wait_readable_spec.rb
+++ b/spec/ruby/library/io-wait/wait_readable_spec.rb
@@ -1,9 +1,5 @@
require_relative '../../spec_helper'
-ruby_version_is ''...'3.2' do
- require 'io/wait'
-end
-
describe "IO#wait_readable" do
before :each do
@io = File.new(__FILE__ )
diff --git a/spec/ruby/library/io-wait/wait_spec.rb b/spec/ruby/library/io-wait/wait_spec.rb
index 6ab41e9f08..1d784e7aa4 100644
--- a/spec/ruby/library/io-wait/wait_spec.rb
+++ b/spec/ruby/library/io-wait/wait_spec.rb
@@ -1,10 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../fixtures/io'
-ruby_version_is ''...'3.2' do
- require 'io/wait'
-end
-
describe "IO#wait" do
before :each do
@io = File.new(__FILE__ )
@@ -25,26 +21,13 @@ describe "IO#wait" do
end
context "[events, timeout] passed" do
- ruby_version_is ""..."3.2" do
- it "returns self when the READABLE event is ready during the timeout" do
- @w.write('data to read')
- @r.wait(IO::READABLE, 2).should.equal?(@r)
- end
-
- it "returns self when the WRITABLE event is ready during the timeout" do
- @w.wait(IO::WRITABLE, 0).should.equal?(@w)
- end
+ it "returns events mask when the READABLE event is ready during the timeout" do
+ @w.write('data to read')
+ @r.wait(IO::READABLE, 2).should == IO::READABLE
end
- ruby_version_is "3.2" do
- it "returns events mask when the READABLE event is ready during the timeout" do
- @w.write('data to read')
- @r.wait(IO::READABLE, 2).should == IO::READABLE
- end
-
- it "returns events mask when the WRITABLE event is ready during the timeout" do
- @w.wait(IO::WRITABLE, 0).should == IO::WRITABLE
- end
+ it "returns events mask when the WRITABLE event is ready during the timeout" do
+ @w.wait(IO::WRITABLE, 0).should == IO::WRITABLE
end
it "waits for the READABLE event to be ready" do
@@ -73,14 +56,12 @@ describe "IO#wait" do
it "raises IOError when io is closed (closed stream (IOError))" do
@io.close
- -> { @io.wait(IO::READABLE, 0) }.should raise_error(IOError, "closed stream")
+ -> { @io.wait(IO::READABLE, 0) }.should.raise(IOError, "closed stream")
end
- ruby_version_is "3.2" do
- it "raises ArgumentError when events is not positive" do
- -> { @w.wait(0, 0) }.should raise_error(ArgumentError, "Events must be positive integer!")
- -> { @w.wait(-1, 0) }.should raise_error(ArgumentError, "Events must be positive integer!")
- end
+ it "raises ArgumentError when events is not positive" do
+ -> { @w.wait(0, 0) }.should.raise(ArgumentError, "Events must be positive integer!")
+ -> { @w.wait(-1, 0) }.should.raise(ArgumentError, "Events must be positive integer!")
end
it "changes thread status to 'sleep' when waits for READABLE event" do
@@ -159,31 +140,23 @@ describe "IO#wait" do
@io.wait(0, :r, :w, :rw).should == @io
end
- # It works at least since 2.7 but by some reason may fail on 3.1
- ruby_version_is "3.2" do
- it "accepts timeout and mode in any order" do
- @io.wait(0, :r).should == @io
- @io.wait(:r, 0).should == @io
- @io.wait(:r, 0, :w).should == @io
- end
+ it "accepts timeout and mode in any order" do
+ @io.wait(0, :r).should == @io
+ @io.wait(:r, 0).should == @io
+ @io.wait(:r, 0, :w).should == @io
end
it "raises ArgumentError when passed wrong Symbol value as mode argument" do
- -> { @io.wait(0, :wrong) }.should raise_error(ArgumentError, "unsupported mode: wrong")
+ -> { @io.wait(0, :wrong) }.should.raise(ArgumentError, "unsupported mode: wrong")
end
- # It works since 3.0 but by some reason may fail on 3.1
- ruby_version_is "3.2" do
- it "raises ArgumentError when several Integer arguments passed" do
- -> { @w.wait(0, 10, :r) }.should raise_error(ArgumentError, "timeout given more than once")
- end
+ it "raises ArgumentError when several Integer arguments passed" do
+ -> { @w.wait(0, 10, :r) }.should.raise(ArgumentError, "timeout given more than once")
end
- ruby_version_is "3.2" do
- it "raises IOError when io is closed (closed stream (IOError))" do
- @io.close
- -> { @io.wait(0, :r) }.should raise_error(IOError, "closed stream")
- end
+ it "raises IOError when io is closed (closed stream (IOError))" do
+ @io.close
+ -> { @io.wait(0, :r) }.should.raise(IOError, "closed stream")
end
end
end
diff --git a/spec/ruby/library/io-wait/wait_writable_spec.rb b/spec/ruby/library/io-wait/wait_writable_spec.rb
index 8639dd717b..2017817caa 100644
--- a/spec/ruby/library/io-wait/wait_writable_spec.rb
+++ b/spec/ruby/library/io-wait/wait_writable_spec.rb
@@ -1,10 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../fixtures/io'
-ruby_version_is ''...'3.2' do
- require 'io/wait'
-end
-
describe "IO#wait_writable" do
it "waits for the IO to become writable with no timeout" do
STDOUT.wait_writable.should == STDOUT