diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4ea364..31c5245 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: - '3.0' - '3.1' - '3.2' + - '3.3' steps: - uses: actions/checkout@v4 - name: Setup Ruby diff --git a/.rubocop.yml b/.rubocop.yml index 29c4f01..7708093 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,5 +15,7 @@ Metrics/MethodLength: Enabled: false Metrics/PerceivedComplexity: Enabled: false +RSpec/IndexedLet: + Enabled: false Style/Documentation: Enabled: false diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index c5ea1c2..3b0e695 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -50,19 +50,6 @@ def wait_for(&block) raise 'wait_for condition never realized' end -def roundtrip_metric(metric) - message_id = next_message_id - - client_with_transport << { - service: 'metric-test', - metric: metric, - message_id: message_id - } - - e = wait_for_message_with_id(message_id) - expect(e.metric).to eq(metric) -end - RSpec.shared_examples 'a riemann client' do it 'is not connected before sending' do expect(client).not_to be_connected @@ -113,18 +100,34 @@ def roundtrip_metric(metric) end end - it 'send longs' do - roundtrip_metric(0) - roundtrip_metric(-3) - roundtrip_metric(5) - roundtrip_metric(-(2**63)) - roundtrip_metric(2**63 - 1) - end + context 'when sending metrics' do + [ + 0, + -3, + 5, + -(2**63), + 2**63 - 1, + 0.0, + 12.0, + 1.2300000190734863 + ].each do |metric| + context "with metric=#{metric}" do + before do + client_with_transport << { + service: 'metric-test', + metric: metric, + message_id: message_id + } + end - it 'send doubles' do - roundtrip_metric 0.0 - roundtrip_metric 12.0 - roundtrip_metric 1.2300000190734863 + let(:message_id) { next_message_id } + + it 'return the exact value that was sent' do + e = wait_for_message_with_id(message_id) + expect(e.metric).to eq(metric) + end + end + end end context 'when sending custom attributes' do @@ -485,7 +488,7 @@ def roundtrip_metric(metric) sleep INACTIVITY_TIME client_with_transport << message2 - wait_for_message_with_id(message_id2) + expect { wait_for_message_with_id(message_id2) }.not_to raise_exception end end @@ -517,7 +520,7 @@ def roundtrip_metric(metric) client.close client_with_transport << message2 - wait_for_message_with_id(message_id2) + expect { wait_for_message_with_id(message_id2) }.not_to raise_exception end end