Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0e5c53
commit 9b8b1de
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "./spec_helper" | ||
|
||
POLLER_ENDPOINT = "inproc://poll_test" | ||
|
||
describe ZMQ::Poller do | ||
context "#register" do | ||
it "returns false when given a nil pollable" do | ||
poller = ZMQ::Poller.new | ||
ZMQ::Context.create(ZMQ::DEALER) do |ctx, (pollable)| | ||
orig = poller.poll_items.size | ||
poller.register(pollable, ZMQ::POLLIN) | ||
poller.poll_items.size.should eq(orig + 1) | ||
end | ||
end | ||
end | ||
|
||
context "#poll" do | ||
it "returns 0 when there are no sockets to poll" do | ||
poller = ZMQ::Poller.new | ||
poller.poll(1).should eq(0) | ||
end | ||
|
||
it "returns 0 when there is a single socket to poll and no events" do | ||
poller = ZMQ::Poller.new | ||
ZMQ::Context.create(ZMQ::DEALER) do |ctx, (first)| | ||
poller.register(first, ZMQ::POLLIN) | ||
poller.poll(1).should eq(0) | ||
end | ||
end | ||
|
||
it "returns 1 when there is a read event on a socket" do | ||
poller = ZMQ::Poller.new | ||
ZMQ::Context.create(ZMQ::DEALER, ZMQ::ROUTER) do |ctx, (first, last)| | ||
first.bind POLLER_ENDPOINT | ||
APIHelper.connect_to_inproc last, POLLER_ENDPOINT | ||
|
||
poller.register_readable last | ||
first.send_string "test" | ||
|
||
poller.poll(1).should eq(1) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters