spec/lib/consumer_spec.rb in vx-consumer-0.0.2 vs spec/lib/consumer_spec.rb in vx-consumer-0.1.0

- old
+ new

@@ -91,19 +91,34 @@ it "should wait shutdown" do consumer = Bob.subscribe Bob.publish a: 1 th = Thread.new { - consumer.wait + consumer.wait_shutdown } - sleep 1 + sleep 0.2 Vx::Consumer.shutdown Timeout.timeout(1) do th.join end expect(Bob._collected).to eq(["a" => 1]) + end + + it "should work with graceful shutdown" do + consumer = Bob.subscribe + 10.times do |n| + Bob.publish a: n + end + + sleep 0.2 + Timeout.timeout(1) do + consumer.graceful_shutdown + end + + expect(Bob._collected).to have_at_least(2).item + expect(Bob._collected).to have_at_most(8).item end def handle_errors begin yield