From 2fa4e2fb6a669b98ed6abc568eabc8f5f9f28e8a Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 5 Oct 2015 16:26:37 +0200 Subject: [PATCH] Evaluate benchmark blocks in the proper context This ensures that blocks defines using "benchmark_subject" have access to methods defined using let/subject & friends. --- spec/support/matchers/benchmark_matchers.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/support/matchers/benchmark_matchers.rb b/spec/support/matchers/benchmark_matchers.rb index b73a53917f0..84f655c2119 100644 --- a/spec/support/matchers/benchmark_matchers.rb +++ b/spec/support/matchers/benchmark_matchers.rb @@ -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]