summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/matchers/benchmark_matchers.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/support/matchers/benchmark_matchers.rb b/spec/support/matchers/benchmark_matchers.rb
index 45a1d49345f..b73a53917f0 100644
--- a/spec/support/matchers/benchmark_matchers.rb
+++ b/spec/support/matchers/benchmark_matchers.rb
@@ -1,6 +1,10 @@
module BenchmarkMatchers
extend RSpec::Matchers::DSL
+ def self.included(into)
+ into.extend(ClassMethods)
+ end
+
matcher :iterate_per_second do |min_iterations|
supports_block_expectations
@@ -39,4 +43,17 @@ module BenchmarkMatchers
report.entries[0]
end
+
+ module ClassMethods
+ # Wraps around rspec's subject method so you can write:
+ #
+ # benchmark_subject { SomeClass.some_method }
+ #
+ # instead of:
+ #
+ # subject { -> { SomeClass.some_method } }
+ def benchmark_subject(&block)
+ subject { block }
+ end
+ end
end