Sha256: f3b83380f256765428e1e40f77c0a14bd0c27eaf263a76087aecda85d02062c6
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
require File.join(File.dirname(__FILE__), %w[spec_helper]) module ZMQ describe Device do include APIHelper before(:each) do @ctx = Context.new poller_setup @front_endpoint = "inproc://device_front_test" @back_endpoint = "inproc://device_back_test" @mutex = Mutex.new end after(:each) do @ctx.terminate end def create_streamer @device_thread = false Thread.new do back = @ctx.socket(ZMQ::PULL) back.bind(@back_endpoint) front = @ctx.socket(ZMQ::PUSH) front.bind(@front_endpoint) @mutex.synchronize { @device_thread = true } puts "create streamer device and running..." Device.new(back, front) puts "device exited" back.close front.close end end def wait_for_device loop do can_break = @mutex.synchronize { @device_thread } break if can_break end puts "broke out of wait_for_device loop" end it "should create a device without error given valid opts" do create_streamer wait_for_device end it "should be able to send messages through the device" do create_streamer wait_for_device pusher = @ctx.socket(ZMQ::PUSH) connect_to_inproc(pusher, @back_endpoint) puller = @ctx.socket(ZMQ::PULL) connect_to_inproc(puller, @front_endpoint) poll_it_for_read(puller) do pusher.send_string("hello") end res = '' rc = puller.recv_string(res, ZMQ::DONTWAIT) res.should == "hello" pusher.close puller.close end it "should raise an ArgumentError when trying to pass non-socket objects into the device" do lambda { Device.new(1,2) }.should raise_exception(ArgumentError) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffi-rzmq-2.0.1 | spec/device_spec.rb |
ffi-rzmq-2.0.0 | spec/device_spec.rb |