tests/ezmq/subscribe.rb in ezmq-0.4.0 vs tests/ezmq/subscribe.rb in ezmq-0.4.1
- old
+ new
@@ -7,10 +7,11 @@
Thread.new do
loop do
@publisher.send 'message'
@publisher.send 'message', topic: 'bad'
@publisher.send 'message', topic: 'good'
+ @publisher.send "message\nmessage", topic: 'multiline'
end
end
end
should 'receive messages' do
@@ -19,11 +20,11 @@
1000.times do
message, topic = @subscriber.receive
messages << message
topics << topic
end
- assert_equal 1000, messages.select { |m| m == 'message' }.size
+ assert_equal 1000, messages.size
assert topics.include? ''
assert topics.include? 'bad'
assert topics.include? 'good'
end
@@ -72,9 +73,21 @@
_, topic = @subscriber.receive
topics << topic
end
assert topics.include? 'good'
assert_equal false, topics.include?('bad')
+ end
+
+ should 'receive the message as it was sent' do
+ @subscriber.subscribe ''
+ messages = []
+ 1000.times do
+ message, _ = @subscriber.receive
+ messages << message
+ end
+ assert_equal 2, messages.uniq.size
+ assert messages.include? 'message'
+ assert messages.include? "message\nmessage"
end
should 'return the contents of a message with a subscribed topic' do
# assert
end