Sha256: 2196dfef1b42b3eac9643c8ffa09ab2d0dc05a26b2a1adaac98cc7d05ddbde0d
Contents?: true
Size: 1.49 KB
Versions: 16
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' describe NIO::Monitor do let(:pipes) { IO.pipe } let(:reader) { pipes.first } let(:writer) { pipes.last } let(:selector) { NIO::Selector.new } subject { selector.register(reader, :rw) } let(:peer) { selector.register(writer, :rw) } after { selector.close } it "knows its interests" do subject.interests.should == :rw peer.interests.should == :rw end it "knows its IO object" do subject.io.should == reader end it "knows its selector" do subject.selector.should == selector end it "stores arbitrary values" do subject.value = 42 subject.value.should == 42 end it "knows what operations IO objects are ready for" do # For whatever odd reason this breaks unless we eagerly evaluate subject reader_monitor, writer_monitor = subject, peer selected = selector.select(0) selected.should_not include(reader_monitor) selected.should include(writer_monitor) writer_monitor.readiness.should == :w writer_monitor.should_not be_readable writer_monitor.should be_writable writer << "loldata" selected = selector.select(0) selected.should include(reader_monitor) reader_monitor.readiness.should == :r reader_monitor.should be_readable reader_monitor.should_not be_writable end it "closes" do subject.should_not be_closed selector.registered?(reader).should be_true subject.close subject.should be_closed selector.registered?(reader).should be_false end end
Version data entries
16 entries across 16 versions & 1 rubygems