1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
require 'spec_helper'
describe Celluloid::IO::UDPSocket do
let(:payload) { 'ohai' }
subject do
Celluloid::IO::UDPSocket.new.tap do |sock|
sock.bind example_addr, example_port
end
end
after { subject.close }
context "inside Celluloid::IO" do
it "should be evented" do
within_io_actor { Celluloid::IO.evented? }.should be_truthy
end
it "sends and receives packets" do
within_io_actor do
subject.send payload, 0, example_addr, example_port
subject.recvfrom(payload.size).first.should == payload
end
end
end
context "outside Celluloid::IO" do
it "should be blocking" do
Celluloid::IO.should_not be_evented
end
it "sends and receives packets" do
subject.send payload, 0, example_addr, example_port
subject.recvfrom(payload.size).first.should == payload
end
end
end
|