From a8282184f396fdd4da730b8e696246f9f17beb44 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Sun, 5 Jun 2016 03:36:42 -0700 Subject: [PATCH] Slight tidying of specs Any metric calls are now allowed. This should help us grow our metrics usage without accidentally failing tests that were too rigid. I also split some testing up to have more alignment between the 'it' description and the execution. Fixes #5472 --- .../spec/logstash/filter_delegator_spec.rb | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/logstash-core/spec/logstash/filter_delegator_spec.rb b/logstash-core/spec/logstash/filter_delegator_spec.rb index a381d97e1..027ddfdd1 100644 --- a/logstash-core/spec/logstash/filter_delegator_spec.rb +++ b/logstash-core/spec/logstash/filter_delegator_spec.rb @@ -67,11 +67,17 @@ describe LogStash::FilterDelegator do end context "when the filter buffer events" do - it "doesn't increment out" do - allow(metric).to receive(:increment).with(:time_ms, anything) - expect(metric).to receive(:increment).with(:in, events.size) - expect(metric).not_to receive(:increment).with(:out, anything) + before do + allow(metric).to receive(:increment).with(anything, anything) + end + it "has incremented :in" do + expect(metric).to receive(:increment).with(:in, events.size) + subject.multi_filter(events) + end + + it "has not incremented :out" do + expect(metric).not_to receive(:increment).with(:out, anything) subject.multi_filter(events) end end @@ -92,8 +98,11 @@ describe LogStash::FilterDelegator do end end + before do + allow(metric).to receive(:increment).with(anything, anything) + end + it "increments the in/out of the metric" do - allow(metric).to receive(:increment).with(:time_ms, anything) expect(metric).to receive(:increment).with(:in, events.size) expect(metric).to receive(:increment).with(:out, events.size * 2) @@ -114,12 +123,15 @@ describe LogStash::FilterDelegator do end end + before do + allow(metric).to receive(:increment).with(anything, anything) + end + it "doesnt define a flush method" do expect(subject.respond_to?(:flush)).to be_falsey end it "increments the in/out of the metric" do - allow(metric).to receive(:increment).with(:time_ms, anything) expect(metric).to receive(:increment).with(:in, events.size) expect(metric).to receive(:increment).with(:out, events.size)