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
This commit is contained in:
Jordan Sissel 2016-06-05 03:36:42 -07:00
parent 6cb0b538e3
commit a8282184f3

View file

@ -67,11 +67,17 @@ describe LogStash::FilterDelegator do
end end
context "when the filter buffer events" do context "when the filter buffer events" do
it "doesn't increment out" do before do
allow(metric).to receive(:increment).with(:time_ms, anything) allow(metric).to receive(:increment).with(anything, anything)
expect(metric).to receive(:increment).with(:in, events.size) end
expect(metric).not_to receive(:increment).with(:out, anything)
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) subject.multi_filter(events)
end end
end end
@ -92,8 +98,11 @@ describe LogStash::FilterDelegator do
end end
end end
before do
allow(metric).to receive(:increment).with(anything, anything)
end
it "increments the in/out of the metric" do 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(:in, events.size)
expect(metric).to receive(:increment).with(:out, events.size * 2) expect(metric).to receive(:increment).with(:out, events.size * 2)
@ -114,12 +123,15 @@ describe LogStash::FilterDelegator do
end end
end end
before do
allow(metric).to receive(:increment).with(anything, anything)
end
it "doesnt define a flush method" do it "doesnt define a flush method" do
expect(subject.respond_to?(:flush)).to be_falsey expect(subject.respond_to?(:flush)).to be_falsey
end end
it "increments the in/out of the metric" do 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(:in, events.size)
expect(metric).to receive(:increment).with(:out, events.size) expect(metric).to receive(:increment).with(:out, events.size)