Evaluate benchmark blocks in the proper context

This ensures that blocks defines using "benchmark_subject" have access
to methods defined using let/subject & friends.
This commit is contained in:
Yorick Peterse 2015-10-05 16:26:37 +02:00
parent 39772f0116
commit 2fa4e2fb6a
1 changed files with 3 additions and 1 deletions

View File

@ -38,7 +38,9 @@ module BenchmarkMatchers
# Benchmarks the given block and returns a Benchmark::IPS::Report::Entry.
def benchmark(&block)
report = Benchmark.ips(quiet: true) do |bench|
bench.report(&block)
bench.report do
instance_eval(&block)
end
end
report.entries[0]