spec/spec_helper.rb in rdkafka-0.15.2 vs spec/spec_helper.rb in rdkafka-0.16.0.beta1

- old
+ new

@@ -137,11 +137,11 @@ partitioner_test_topic: 25, example_topic: 1 }.each do |topic, partitions| create_topic_handle = admin.create_topic(topic.to_s, partitions, 1) begin - create_topic_handle.wait(max_wait_timeout: 15) + create_topic_handle.wait(max_wait_timeout: 1.0) rescue Rdkafka::RdkafkaError => ex raise unless ex.message.match?(/topic_already_exists/) end end admin.close @@ -151,7 +151,22 @@ # Timeout specs after a minute. If they take longer # they are probably stuck Timeout::timeout(60) do example.run end + end +end + +class RdKafkaTestConsumer + def self.with + consumer = Rdkafka::Bindings.rd_kafka_new( + :rd_kafka_consumer, + nil, + nil, + 0 + ) + yield consumer + ensure + Rdkafka::Bindings.rd_kafka_consumer_close(consumer) + Rdkafka::Bindings.rd_kafka_destroy(consumer) end end