Sha256: ec1030f9e6dd45f21fbb20bee82c53a764ca9f58beca5acd5b5d4f55bb4484d8
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
context 'Paired sockets' do setup do @bound, @connected = EZMQ.create_linked_pair end should 'initialize properly' do assert_kind_of EZMQ::Socket, @bound assert_kind_of EZMQ::Socket, @connected end should 'return the length of messages they send' do assert_equal 7, @connected.send('message') end should 'return the contents of messages they receive' do @connected.send 'message' assert_equal 'message', @bound.receive end should 'yield the contents of messages they receive, if given a block' do @bound.send 'message' assert_equal 'message', @connected.receive { |m| m } end should 'block if no message is present' do assert_raises Timeout::Error do Timeout.timeout(0.1) do @connected.receive end end end should 'receive multiple messages if listening' do 3.times { @bound.send 'message' } messages = [] begin Timeout.timeout(0.1) do @connected.listen do |message| messages << message end end rescue Timeout::Error assert_equal 3, messages.size end end end context 'Paired sockets with encoding/decoding' do setup do e = -> message { JSON.dump message } d = -> message { JSON.load message } @bound, @connected = EZMQ.create_linked_pair encoding: e, decoding: d end should 'return the length of messages they send' do assert_equal 7, @connected.send('message') end should 'return the contents of messages they receive' do @connected.send 'message' assert_equal 'message', @bound.receive end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ezmq-0.4.2 | tests/ezmq/pair.rb |
ezmq-0.4.1 | tests/ezmq/pair.rb |
ezmq-0.4.0 | tests/ezmq/pair.rb |