From ae65509258b81b160d0f75a96c496318b411d98e Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 21 Dec 2014 21:05:16 +0000 Subject: [PATCH] Prevent ignore of metadata duplicates in rspec integration * Example groups with identical metadata still can represent different test cases. * Using the relative example group index as an additional key resolves this. [fixes #279] --- lib/mutant/integration/rspec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index 5077ac81..e8607b3d 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -81,28 +81,29 @@ module Mutant # @api private # def all_tests_index - all_examples.each_with_object({}) do |example, index| - index[parse_example(example)] = example + all_examples.each_with_index.each_with_object({}) do |(example, example_index), index| + index[parse_example(example, example_index)] = example end end memoize :all_tests_index # Parse example into test # - # @param [RSpec::Core::Example] + # @param [RSpec::Core::Example] example + # @param [Fixnum] index # # @return [Test] # # @api private # - def parse_example(example) + def parse_example(example, index) metadata = example.metadata location = metadata.fetch(:location) full_description = metadata.fetch(:full_description) expression = Expression.try_parse(full_description.split(EXPRESSION_DELIMITER, 2).first) || ALL Test.new( - id: "rspec:#{example.object_id}/#{location}/#{full_description}", + id: "rspec:#{index}:#{location}/#{full_description}", expression: expression ) end