Skip to content

Commit e9f3da4

Browse files
committed
Add specs for IO#wait_readable and IO#wait_writable
1 parent 76cfbe8 commit e9f3da4

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require_relative '../../spec_helper'
2+
3+
require 'io/wait'
4+
5+
describe "IO#wait_readable" do
6+
before :each do
7+
@io = File.new(__FILE__ )
8+
end
9+
10+
after :each do
11+
@io.close
12+
end
13+
14+
it "waits for the IO to become readable with no timeout" do
15+
@io.wait_readable.should == @io
16+
end
17+
18+
it "waits for the IO to become readable with the given timeout" do
19+
@io.wait_readable(1).should == @io
20+
end
21+
22+
it "waits for the IO to become readable with the given large timeout" do
23+
@io.wait_readable(365 * 24 * 60 * 60).should == @io
24+
end
25+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require_relative '../../spec_helper'
2+
3+
require 'io/wait'
4+
5+
describe "IO#wait_writable" do
6+
it "waits for the IO to become writable with no timeout" do
7+
STDOUT.wait_writable.should == STDOUT
8+
end
9+
10+
it "waits for the IO to become writable with the given timeout" do
11+
STDOUT.wait_writable(1).should == STDOUT
12+
end
13+
14+
it "waits for the IO to become writable with the given large timeout" do
15+
# Represents one year and is larger than a 32-bit int
16+
STDOUT.wait_writable(365 * 24 * 60 * 60).should == STDOUT
17+
end
18+
end

0 commit comments

Comments
 (0)