spec/lib/consumer_spec.rb in vx-consumer-0.1.6 vs spec/lib/consumer_spec.rb in vx-consumer-0.1.7
- old
+ new
@@ -36,18 +36,21 @@
it "simple pub/sub" do
consumer = Bob.subscribe
sleep 1
3.times {|n| Bob.publish("a" => n) }
- Timeout.timeout(3) do
+ Timeout.timeout(5) do
loop do
break if Bob._collected.size == 3
sleep 0.1
end
end
- consumer.cancel
+ Timeout.timeout(3) do
+ consumer.graceful_shutdown
+ end
+
expect(Bob._collected).to eq([{"a"=>0}, {"a"=>1}, {"a"=>2}])
end
it "pub/sub in multithreaded environment" do
handle_errors do
@@ -66,10 +69,13 @@
loop do
break if Bob._collected.size >= 90
sleep 0.1
end
end
- cns.map(&:cancel)
+
+ Timeout.timeout(1) do
+ cns.map(&:graceful_shutdown)
+ end
expect(Bob._collected.map{|c| c["a"] }.uniq.sort).to eq((0...90).to_a)
end
end