Shopify / statsd-instrument

A StatsD client for Ruby apps. Provides metaprogramming methods to inject StatsD instrumentation into your code.
http://shopify.github.io/statsd-instrument
MIT License
570 stars 94 forks source link

Allow user to provide expectation with times zero #326

Closed rafaelzimmermann closed 1 year ago

rafaelzimmermann commented 1 year ago

This allows to mix positive and negative expectations, meaning user is able to assert that a given metric is not present while checking for the presence of others.

foo_1_metric = StatsD::Instrument::Expectation.increment("counter", times: 2, tags: ["foo:1"])
foo_2_metric = StatsD::Instrument::Expectation.increment("counter", times: 0, tags: ["foo:2"])
assert_statsd_expectations([foo_1_metric, foo_2_metric]) do
  ...
end

Without this change, if user passes times: 0 as expectation the test does not fail and the metric is not checked to make sure it was not called, given an impression to the user that the feature is available.