Sha256: 90ba75fcd6dc2103e7f70b4e030aeb22c72d62e5e6ab640290f4904bbd46d8e6
Contents?: true
Size: 1.48 KB
Versions: 10
Compression:
Stored size: 1.48 KB
Contents
require File.join(File.dirname(__FILE__), %w[spec_helper]) describe ZK::MessageQueue do before(:each) do @zk = ZK.new("localhost:#{ZK.test_port}") @zk2 = ZK.new("localhost:#{ZK.test_port}") wait_until{ @zk.connected? && @zk2.connected? } @queue_name = "_specQueue" @consume_queue = @zk.queue(@queue_name) @publish_queue = @zk2.queue(@queue_name) end after(:each) do @consume_queue.destroy! @zk.close! @zk2.close! wait_until{ !@zk.connected? && !@zk2.connected? } end it "should be able to receive a published message" do message_received = false @consume_queue.subscribe do |title, data| data.should == 'mydata' message_received = true end @publish_queue.publish("mydata") wait_until {message_received } message_received.should be_true end it "should be able to receive a custom message title" do message_title = false @consume_queue.subscribe do |title, data| title.should == 'title' message_title = true end @publish_queue.publish("data", "title") wait_until { message_title } message_title.should be_true end it "should work even after processing a message from before" do @publish_queue.publish("data1", "title") message_times = 0 @consume_queue.subscribe do |title, data| title.should == "title" message_times += 1 end @publish_queue.publish("data2", "title") wait_until { message_times == 2 } message_times.should == 2 end end
Version data entries
10 entries across 10 versions & 1 rubygems