From 7b63266269d3a994c8d3b0c0c982de232871bdf9 Mon Sep 17 00:00:00 2001 From: nalabjp Date: Wed, 17 Aug 2016 20:57:48 +0900 Subject: [PATCH] Set the caller of `.with_them` to metadata of ExampleGroup `RSpec::Parameterized::ExampleGroupMethods` calls `RSpec::Core::ExampleGroup.describe` via `.with_them`. At that time, the metadata of ExapmleGroup is used `Proc#sorce_location` of block that have been passed to `RSpec::Core::ExampleGroup.describe`. https://github.com/rspec/rspec-core/blob/v3.5.2/lib/rspec/core/metadata.rb#L150 This is the line that `RSpec::Parameterized::ExampleGroupMethods` was calling `RSpec::Core::ExampleGroup.describe`, not the line where you have to call `RSpec::Parameterized::ExampleGroupMethods.with_them`. For example, if I use `RspecJUnitFormatter`, the difference of the output is 'classname' and 'file' in each testcase. before: ``` ``` after: ``` ``` --- lib/rspec/parameterized.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rspec/parameterized.rb b/lib/rspec/parameterized.rb index c27edb8..62b8cc4 100644 --- a/lib/rspec/parameterized.rb +++ b/lib/rspec/parameterized.rb @@ -62,6 +62,10 @@ def where(*args, &b) # end # def with_them(*args, &b) + opts = args.last.is_a?(Hash) ? args.pop : {} + opts[:caller] = caller unless opts[:caller] + args.push(opts) + if @parameter.nil? @parameterized_pending_cases ||= [] @parameterized_pending_cases << [args, b]