diff --git a/config/flay.yml b/config/flay.yml index 7d97443b..aab35aa9 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 18 -total_score: 1240 +total_score: 1241 diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index 813821d7..f5a1c3dd 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -111,19 +111,33 @@ module Mutant # @api private # def parse_example(example, index) - metadata = example.metadata - location = metadata.fetch(:location) + metadata = example.metadata + location = metadata.fetch(:location) full_description = metadata.fetch(:full_description) - match = EXPRESSION_CANDIDATE.match(full_description) - expression = Expression.try_parse(match.captures.first) || ALL - Test.new( id: "rspec:#{index}:#{location}/#{full_description}", - expression: expression + expression: parse_expression(metadata) ) end + # Parse metadata into expression + # + # @param [RSpec::Core::Example::Medatada] metadata + # + # @return [Expression] + # + # @api private + # + def parse_expression(metadata) + if metadata.key?(:mutant_expression) + Expression.parse(metadata.fetch(:mutant_expression)) + else + match = EXPRESSION_CANDIDATE.match(metadata.fetch(:full_description)) + Expression.try_parse(match.captures.first) || ALL + end + end + # Return all examples # # @return [Array