diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-07-23 18:20:24 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-07-23 18:20:24 +0300 |
commit | 01cac53d714c7e33fd30b77c2e836c5f5a20e431 (patch) | |
tree | fd68ad90855cb649ad4828d23297b8b217373f81 /spec/support | |
parent | 68547bc0e0e3f85e8ac07c6f81c316e1f4456758 (diff) |
Make it easier to stub authentication metrics
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/stub_metrics.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/spec/support/helpers/stub_metrics.rb b/spec/support/helpers/stub_metrics.rb index 112fd1e8421..53abf33f2e5 100644 --- a/spec/support/helpers/stub_metrics.rb +++ b/spec/support/helpers/stub_metrics.rb @@ -6,11 +6,23 @@ module StubMetrics def stub_authentication_activity_metrics(debug: false) authentication_metrics.each_counter do |name, metric, description| double("#{metric} - #{description}").tap do |counter| - allow(counter).to receive(:increment) do - puts "Authentication activity metric incremented: #{metric}" - end - allow(authentication_metrics).to receive(name).and_return(counter) + allow(counter).to receive(:increment) # TODO, require expectations + end + end + + debug_authentication_activity_metrics if debug + end + + def debug_authentication_activity_metrics + authentication_metrics.tap do |metrics| + metrics.each_counter do |name, metric| + "#{name}_increment!".tap do |incrementer| + allow(metrics).to receive(incrementer).and_wrap_original do |method| + puts "Authentication activity metric incremented: #{name}" + method.call + end + end end end end |