spec/rabbitmq_client_spec.rb in jerryluk-rabbitmq-jruby-client-0.1.6 vs spec/rabbitmq_client_spec.rb in jerryluk-rabbitmq-jruby-client-0.1.7

- old
+ new

@@ -40,10 +40,12 @@ it "should able to publish and retrieve a message" do @queue.bind(@exchange) @queue.publish('Hello World') @queue.retrieve.should == 'Hello World' + @queue.publish('人大') + @queue.retrieve.should == '人大' end it "should able to subscribe with a callback function" do a = 0 @queue.bind(@exchange) @@ -51,9 +53,28 @@ a += v.to_i end @queue.publish("1") @queue.publish("2") sleep 1 + a.should == 3 + end + + it "should able to subscribe to a queue using loop_subscribe" do + a = 0 + @queue.bind(@exchange) + Thread.new do + begin + timeout(1) do + @queue.loop_subscribe do |v| + a += v.to_i + end + end + rescue Timeout::Error => e + end + end + @queue.publish("1") + @queue.publish("2") + sleep 2 a.should == 3 end it "should raise an exception if binding a persistent queue with non-persistent exchange and vice versa" do persistent_queue = @client.queue('test_queue1', true) \ No newline at end of file