Sha256: 5f225f0e3e7251fbcdd63f5b2f071256f110ab5074ee39183a5f6398e41e2ed0
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
require "spec_helper" describe Rdkafka::Producer::DeliveryHandle do let(:response) { 0 } subject do Rdkafka::Producer::DeliveryHandle.new.tap do |handle| handle[:pending] = pending handle[:response] = response handle[:partition] = 2 handle[:offset] = 100 end end describe "#pending?" do context "when true" do let(:pending) { true } it "should be true" do expect(subject.pending?).to be true end end context "when not true" do let(:pending) { false } it "should be false" do expect(subject.pending?).to be false end end end describe "#wait" do let(:pending) { true } it "should wait until the timeout and then raise an error" do expect { subject.wait(0.1) }.to raise_error Rdkafka::Producer::DeliveryHandle::WaitTimeoutError end context "when not pending anymore and no error" do let(:pending) { false } it "should return a delivery report" do report = subject.wait expect(report.partition).to eq(2) expect(report.offset).to eq(100) end end context "when not pending anymore and there was an error" do let(:pending) { false } let(:response) { 20 } it "should raise an rdkafka error" do expect { subject.wait }.to raise_error Rdkafka::RdkafkaError end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rdkafka-0.3.0 | spec/rdkafka/producer/delivery_handle_spec.rb |
rdkafka-0.2.0 | spec/rdkafka/producer/delivery_handle_spec.rb |