Skip to content
Snippets Groups Projects
Commit 2fa4e2fb authored by Yorick Peterse's avatar Yorick Peterse
Browse files

Evaluate benchmark blocks in the proper context

This ensures that blocks defines using "benchmark_subject" have access
to methods defined using let/subject & friends.
parent 39772f01
Branches
Tags
No related merge requests found
Pipeline #
Loading
@@ -38,7 +38,9 @@ module BenchmarkMatchers
Loading
@@ -38,7 +38,9 @@ module BenchmarkMatchers
# Benchmarks the given block and returns a Benchmark::IPS::Report::Entry. # Benchmarks the given block and returns a Benchmark::IPS::Report::Entry.
def benchmark(&block) def benchmark(&block)
report = Benchmark.ips(quiet: true) do |bench| report = Benchmark.ips(quiet: true) do |bench|
bench.report(&block) bench.report do
instance_eval(&block)
end
end end
   
report.entries[0] report.entries[0]
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment