lib/mutant/bootstrap.rb in mutant-0.9.12 vs lib/mutant/bootstrap.rb in mutant-0.9.13

- old
+ new

@@ -34,11 +34,11 @@ env = Env .empty(world, config) .tap(&method(:infect)) .with(matchable_scopes: matchable_scopes(world, config)) - subjects = Matcher.from_config(env.config.matcher).call(env) + subjects = start_subject(env, Matcher.from_config(env.config.matcher).call(env)) Integration.setup(env).fmap do |integration| env.with( integration: integration, mutations: subjects.flat_map(&:mutations), @@ -46,9 +46,22 @@ subjects: subjects ) end end # rubocop:enable Metrics/MethodLength + + def self.start_subject(env, subjects) + start_expressions = env.config.matcher.start_expressions + + return subjects if start_expressions.empty? + + subjects.drop_while do |subject| + start_expressions.none? do |expression| + expression.prefix?(subject.expression) + end + end + end + private_class_method :start_subject def self.infect(env) config, world = env.config, env.world config.includes.each(&world.load_path.method(:<<))