From e1edf672dc81ebaa476a981973e8179479466d2d Mon Sep 17 00:00:00 2001 From: Piotr Solnica Date: Mon, 5 Aug 2013 18:21:10 +0000 Subject: [PATCH] Automatically expand scope of example groups Given a subject Foo::Bar#baz mutant will run example groups with description starting with: - Foo::Bar#baz - Foo::Bar - Foo This basically means you can kill a mutation via a dedicated spec for a given method, all specs for a given object or all the specs within the object's namespace. In most of the cases you should target killing mutations via a dedicated spec for a particular method *however* there are valid cases where implicit coverage is absolutely fine. --- lib/mutant/killer/rspec.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/mutant/killer/rspec.rb b/lib/mutant/killer/rspec.rb index da38d77c..ec55a942 100644 --- a/lib/mutant/killer/rspec.rb +++ b/lib/mutant/killer/rspec.rb @@ -29,7 +29,7 @@ module Mutant reporter = RSpec::Core::Reporter.new - example_groups.each do |group| + groups.each do |group| return true unless group.run(reporter) end @@ -53,12 +53,7 @@ module Mutant # @api private # def example_groups - match_prefixes.each do |match_expression| - example_groups = find_with(match_expression) - return example_groups unless example_groups.empty? - end - - nil + match_prefixes.flat_map { |prefix| find_with(prefix) }.compact.uniq end # Return example groups that match expression