summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/metrics/sampler_shared_examples.rb
blob: ebf199c3a8dd470ecd32fc4b3c5b39f0daa9546f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

RSpec.shared_examples 'metrics sampler' do |env_prefix|
  context 'when sampling interval is passed explicitly' do
    subject { described_class.new(42) }

    specify { expect(subject.interval).to eq(42) }
  end

  context 'when sampling interval is passed through the environment' do
    subject { described_class.new }

    before do
      stub_env("#{env_prefix}_INTERVAL_SECONDS", '42')
    end

    specify { expect(subject.interval).to eq(42) }
  end

  context 'when no sampling interval is passed anywhere' do
    subject { described_class.new }

    it 'uses the hardcoded default' do
      expect(subject.interval).to eq(described_class::DEFAULT_SAMPLING_INTERVAL_SECONDS)
    end
  end
end