Sha256: e6ffc45f15ab81ba8f8761a3168bc262a723c2749747a807ae80c642400a5136
Contents?: true
Size: 1.86 KB
Versions: 5
Compression:
Stored size: 1.86 KB
Contents
shared_examples "a poller" do let(:message) { double "message" } let(:queue) { double "Queue", peek: [], approximate_number_of_messages: 0 } let(:block) { lambda{ |m| true } } let(:thread_count) { 1 } let(:options) { {} } subject do described_class.new queue, block, options, thread_count end it { should respond_to :poll } describe "profiling", perf: true do let(:magnitude) { 3000 } before do message.stub delete: true subject.stub quit_on_empty?: true subject.stub(:pop_new_message).and_return(*([message]*magnitude), nil) end describe "with 1 thread" do let(:thread_count) { 1 } before do queue.stub(:peek).and_return *([message] * magnitude), nil queue.stub(:approximate_number_of_messages).and_return *([message] * magnitude).map{|m| m.size}, 0 end it "can poll" do not_for_null do subject.poll end end end describe "with 3 threads" do let(:thread_count) { 3 } before do queue.stub(:peek).and_return *([message, message, message] * (magnitude/3)), nil queue.stub(:approximate_number_of_messages).and_return *([message, message, message] * (magnitude/3)).map{|m| m.size}, 0 end it "can poll" do not_for_null do subject.poll end end end end describe "limited loops" do describe "with 2 yields, one nil" do before do subject.stub quit_on_empty?: true queue.stub(:peek).and_return [message], nil queue.stub(:approximate_number_of_messages).and_return 1, 0 subject.stub(:pop_new_message).and_return(message, nil) end it "can poll" do not_for_null do block.should_receive(:call).once.and_return true message.should_receive(:delete) subject.poll end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems