summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-12-15 16:31:24 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2015-12-17 17:25:48 +0100
commit13dbd663acbbe91ddac77b650a90377cd12c54b8 (patch)
tree936993d1abb579ffb3c66f64c887bf58cbe5a01f /spec
parentd67e2045a02d105bfbc7abf1805fe477eb9155ca (diff)
downloadgitlab-ce-13dbd663acbbe91ddac77b650a90377cd12c54b8.tar.gz
Allow filtering of what methods to instrument
This makes it possible to determine if a method should be instrumented or not using a block.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/metrics/instrumentation_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics/instrumentation_spec.rb b/spec/lib/gitlab/metrics/instrumentation_spec.rb
index 80dc160ebd2..5fe7a369cba 100644
--- a/spec/lib/gitlab/metrics/instrumentation_spec.rb
+++ b/spec/lib/gitlab/metrics/instrumentation_spec.rb
@@ -132,6 +132,14 @@ describe Gitlab::Metrics::Instrumentation do
expect(@dummy).to_not respond_to(:_original_kittens)
end
+
+ it 'can take a block to determine if a method should be instrumented' do
+ described_class.instrument_methods(@dummy) do
+ false
+ end
+
+ expect(@dummy).to_not respond_to(:_original_foo)
+ end
end
describe '.instrument_instance_methods' do
@@ -157,5 +165,13 @@ describe Gitlab::Metrics::Instrumentation do
expect(@dummy.method_defined?(:_original_kittens)).to eq(false)
end
+
+ it 'can take a block to determine if a method should be instrumented' do
+ described_class.instrument_instance_methods(@dummy) do
+ false
+ end
+
+ expect(@dummy.method_defined?(:_original_bar)).to eq(false)
+ end
end
end