|
1 | 1 | # encoding: UTF-8 |
2 | 2 |
|
| 3 | +# TODO: Convert these tests to use a fake metric class rather than shared examples |
| 4 | +# |
| 5 | +# Right now, we're using shared examples that we include in every metric type's tests |
| 6 | +# to validate the behaviour of the base metric class. |
| 7 | +# |
| 8 | +# This makes it difficult to test certain behaviour, as the interfaces of those metric |
| 9 | +# types differ and these tests can end up needing to know about them. |
| 10 | +# |
| 11 | +# You can see that in the tests for #get, which depend on `type` which isn't defined in |
| 12 | +# this file. The test files that include these shared examples have to do so with a block |
| 13 | +# that provides the `type` variable. |
| 14 | +# |
| 15 | +# This cropped up in a much worse way when trying to test the code that makes sure label |
| 16 | +# values are all strings. Writing a test here that gets included in all the real metric |
| 17 | +# implementations is near impossible. You need your test to call a different method to |
| 18 | +# alter a metric value (e.g. `set`, `increment` or `observe` depending on the metric type) |
| 19 | +# which means having each concrete metric type's tests passing us a lambda that we can |
| 20 | +# call agnostically of the metric type. |
| 21 | +# |
| 22 | +# The resultant code is confusing to follow, so we opted to duplicate those tests in each |
| 23 | +# metric type's test file. |
| 24 | +# |
| 25 | +# Changing this file to implement a fake metric class (e.g. `FakeTestCounter`) would let |
| 26 | +# us easily test the functionality of the base `Prometheus::Client::Metric` without |
| 27 | +# getting caught up in the specifics of the real metric types. |
| 28 | + |
3 | 29 | shared_examples_for Prometheus::Client::Metric do |
4 | 30 | subject { described_class.new(:foo, docstring: 'foo description') } |
5 | 31 |
|
|
0 commit comments