Skip to content

Commit

Permalink
Fixed randomly fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
killondark committed Jan 7, 2025
1 parent 9e588b5 commit 88c3c3f
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions spec/yabeda/counter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@
let(:tags) { { foo: "bar" } }
let(:metric_value) { 10 }
let(:adapter) { instance_double(Yabeda::BaseAdapter, perform_counter_increment!: true, register!: true) }
let(:counter) { Yabeda.test_counter }

before do
Yabeda.register_adapter(:test_adapter, adapter)
end

context "when config has no group" do
let(:counter) { Yabeda.test_counter }

before do
Yabeda.configure do
counter :test_counter
end
Yabeda.configure! unless Yabeda.already_configured?
Yabeda.configure do
counter :test_counter
end
Yabeda.configure! unless Yabeda.already_configured?
end

it { expect(increment_counter).to eq(metric_value) }
it { expect(increment_counter).to eq(metric_value) }

it "increments counter with empty tags if tags are not provided" do
expect { counter.increment }.to change { counter.values[{}] }.by(1)
end
it "increments counter with empty tags if tags are not provided" do
expect { counter.increment }.to change { counter.values[{}] }.by(1)
end

it "execute perform_counter_increment!" do
increment_counter
expect(adapter).to have_received(:perform_counter_increment!).with(counter, tags, metric_value)
end
it "execute perform_counter_increment!" do
increment_counter
expect(adapter).to have_received(:perform_counter_increment!).with(counter, tags, metric_value)
end

context "with adapter option" do
Expand Down

0 comments on commit 88c3c3f

Please sign in to comment.