Skip to content

Commit

Permalink
Test empty selector timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 28, 2019
1 parent 56167ca commit 97ecd04
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/nio/selector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@

context "timeouts" do
let(:select_precision) {0.2}
let(:timeout) {2.0}
let(:payload) {"hi there"}

it "waits for a timeout when selecting" do
it "waits for timeout when selecting from empty selector" do
started_at = Time.now
expect(subject.select(timeout)).to be_nil
expect(Time.now - started_at).to be_within(select_precision).of(timeout)
end

it "waits for a timeout when selecting with reader" do
monitor = subject.register(reader, :r)

writer << payload

timeout = 0.5
started_at = Time.now
expect(subject.select(timeout)).to include monitor
expect(Time.now - started_at).to be_within(select_precision).of(0)
Expand Down

0 comments on commit 97ecd04

Please sign in to comment.