spec/inputs/rabbitmq_spec.rb in logstash-input-rabbitmq-3.0.3 vs spec/inputs/rabbitmq_spec.rb in logstash-input-rabbitmq-3.1.1

- old
+ new

@@ -14,11 +14,12 @@ let(:queue) { "myqueue" } let(:rabbitmq_settings) { { "host" => host, "port" => port, - "queue" => queue + "queue" => queue, + "prefetch_count" => 123 } } let(:instance) { klass.new(rabbitmq_settings) } let(:hare_info) { instance.instance_variable_get(:@hare_info) } @@ -35,24 +36,33 @@ allow(connection).to receive(:create_channel).and_return(channel) allow(connection).to receive(:on_blocked) allow(connection).to receive(:on_unblocked) allow(channel).to receive(:exchange).and_return(exchange) allow(channel).to receive(:queue).and_return(queue) + allow(channel).to receive(:prefetch=) allow(queue).to receive(:build_consumer).with(:block => true) allow(queue).to receive(:subscribe_with).with(any_args) instance.register end + it "should default the codec to JSON" do + expect(instance.codec).to be_a(LogStash::Codecs::JSON) + end + describe "#connect!" do subject { hare_info } it "should set the queue correctly" do expect(subject.queue).to eql(queue) end + it "should set the prefetch value correctly" do + expect(channel).to have_received(:prefetch=).with(123) + end + context "with an exchange declared" do let(:instance) { rabbitmq_settings.merge("exchange" => "myexchange", "exchange_type" => "fanout") } end end end @@ -105,9 +115,13 @@ context "using defaults" do it "should start, connect, and stop cleanly" do expect(instance.connected?).to be_truthy end + end + + it "should have the correct prefetch value" do + expect(instance.instance_variable_get(:@hare_info).channel.prefetch).to eql(256) end describe "receiving a message with a queue specified" do let(:queue_name) { "foo_queue" } let(:config) { super.merge("queue" => queue_name) } \ No newline at end of file