statsd-instrument 3.5.3 → 3.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba71c5241926a499e771c33d9f1d4778a06b1cd419ecdbab19bd6e7b45629ef4
4
- data.tar.gz: 65ae8d434fd664932456a5126453043dd662b60302435e44dbb38918434b9c2d
3
+ metadata.gz: 0b4caa06189952666d3dd979521ec76bcf4bbf4265605c2d9d30198773f74ab8
4
+ data.tar.gz: ec65748283c1a32434f6388e24b167133ba53ec36353c4ec5f8ccfe920657b58
5
5
  SHA512:
6
- metadata.gz: bbdbb0774e5a2aba45e51a5e724384debd0e8503936741958ebe01a547780b935a9098491b4bbcd357d8fd950cd9815392c6713dc09b8d23daa7bc8ff0cc00db
7
- data.tar.gz: 06b848a06d4e88843f9245a9c6ffe681e692fb2225d13e29f328b0738ebdd591a848899208c2eac8690f2d86854520151aa62252aa8070305afc106adf981412
6
+ metadata.gz: af4a6f52973f439a4d9246fff0d68c74751173998b1a76c9fdbff87ac001f2718ccc8fe2c5abb6d5bdaa5555f9c82150f196c8fe6f819e913a6828ef269a2e14
7
+ data.tar.gz: 79f76342bc46cf2d07fd96f1d72bbe5bc2367251ff93b05b6c4ed938fe96d85bf44c8178ca4f1f4a7186f10921bfbaea456b2ce2d32e64db806ec526b2894d71
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ section below.
6
6
 
7
7
  ## Unreleased changes
8
8
 
9
+ ## Version 3.5.5
10
+
11
+ - Fix issue on 3.5.4, allowing user to specify compound matcher without tags
12
+
13
+ ## Version 3.5.4
14
+
15
+ - Allow user to assert different tags using RSpec composable matcher
16
+
9
17
  ## Version 3.5.3
10
18
 
11
19
  - Improve shapes friendliness for Ruby 3.2+
data/README.md CHANGED
@@ -355,6 +355,13 @@ RSpec.describe 'Matchers' do
355
355
  it 'will pass if there is no matching StatsD call on negative expectation' do
356
356
  expect { StatsD.increment('other_counter') }.not_to trigger_statsd_increment('counter')
357
357
  end
358
+
359
+ it 'will pass if every statsD call matches its call tag variations' do
360
+ expect do
361
+ StatsD.increment('counter', tags: ['variation:a'])
362
+ StatsD.increment('counter', tags: ['variation:b'])
363
+ end.to trigger_statsd_increment('counter', times: 1, tags: ["variation:a"]).and trigger_statsd_increment('counter', times: 1, tags: ["variation:b"])
364
+ end
358
365
  end
359
366
  end
360
367
  ```
@@ -43,7 +43,12 @@ module StatsD
43
43
 
44
44
  def expect_statsd_call(metric_type, metric_name, options, &block)
45
45
  metrics = capture_statsd_calls(&block)
46
- metrics = metrics.select { |m| m.type == metric_type && m.name == metric_name }
46
+ metrics = metrics.select do |m|
47
+ metric_tags = m.tags || []
48
+ options_tags = options[:tags] || []
49
+ tag_matches = options_tags.empty? || metric_tags.all? { |t| options_tags.include?(t) }
50
+ m.type == metric_type && m.name == metric_name && tag_matches
51
+ end
47
52
 
48
53
  if metrics.empty?
49
54
  raise RSpec::Expectations::ExpectationNotMetError, "No StatsD calls for metric #{metric_name} were made."
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StatsD
4
4
  module Instrument
5
- VERSION = "3.5.3"
5
+ VERSION = "3.5.5"
6
6
  end
7
7
  end
@@ -34,6 +34,37 @@ class MatchersTest < Minitest::Test
34
34
  }))
35
35
  end
36
36
 
37
+ def test_statsd_increment_compound_using_and_matched
38
+ matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["a"])
39
+ matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["b"])
40
+
41
+ assert(matcher_1.and(matcher_2).matches?(lambda {
42
+ StatsD.increment("counter", tags: ["a"])
43
+ StatsD.increment("counter", tags: ["b"])
44
+ }))
45
+ end
46
+
47
+ def test_statsd_increment_compound_using_and_not_matched
48
+ matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["a"])
49
+ matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1, tags: ["b"])
50
+
51
+ refute(matcher_1.and(matcher_2).matches?(lambda {
52
+ StatsD.increment("counter", tags: ["a"])
53
+ StatsD.increment("counter", tags: ["c"])
54
+ }))
55
+ end
56
+
57
+ def test_statsd_increment_compound_without_explicit_tags_using_and_matched
58
+ matcher_1 = StatsD::Instrument::Matchers::Increment.new(:c, "first_counter", times: 2)
59
+ matcher_2 = StatsD::Instrument::Matchers::Increment.new(:c, "second_counter", times: 1)
60
+
61
+ assert(matcher_1.and(matcher_2).matches?(lambda {
62
+ StatsD.increment("first_counter", tags: ["a"])
63
+ StatsD.increment("first_counter", tags: ["b"])
64
+ StatsD.increment("second_counter", tags: ["c"])
65
+ }))
66
+ end
67
+
37
68
  def test_statsd_increment_with_times_matched
38
69
  assert(StatsD::Instrument::Matchers::Increment.new(:c, "counter", times: 1)
39
70
  .matches?(lambda { StatsD.increment("counter") }))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsd-instrument
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Storimer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-01-16 00:00:00.000000000 Z
13
+ date: 2023-03-02 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
16
16
  StatsD instrumentation into your code.