Move test selection out of stategy

This commit is contained in:
Markus Schirp 2014-06-28 22:54:28 +00:00
parent 99ea641185
commit 19896c4d29
4 changed files with 23 additions and 23 deletions

View file

@ -29,5 +29,26 @@ module Mutant
self
end
# Return tests for mutation
#
# TODO: This logic is now centralized but still fucked.
#
# @param [Mutation] mutation
#
# @return [Enumerable<Test>]
#
# @api private
#
def tests(subject)
subject.match_expressions.each do |match_expression|
tests = strategy.all_tests.select do |test|
match_expression.prefix?(test.expression)
end
return tests if tests.any?
end
EMPTY_ARRAY
end
end # Config
end # Mutant

View file

@ -64,7 +64,7 @@ module Mutant
# @api private
#
def tests
config.strategy.tests(subject)
config.tests(subject)
end
memoize :tests

View file

@ -62,27 +62,6 @@ module Mutant
#
abstract_method :all_tests
# Return tests for mutation
#
# TODO: This logic is now centralized but still fucked.
#
# @param [Mutation] mutation
#
# @return [Enumerable<Test>]
#
# @api private
#
def tests(subject)
subject.match_expressions.each do |match_expression|
tests = all_tests.select do |test|
match_expression.prefix?(test.expression)
end
return tests if tests.any?
end
EMPTY_ARRAY
end
# Null strategy that never kills a mutation
class Null < self

View file

@ -30,7 +30,7 @@ describe Mutant::Runner::Subject, '#success?' do
let(:tests) { [double('test a'), double('test b')] }
before do
expect(strategy).to receive(:tests).with(mutation_subject).and_return(tests)
expect(config).to receive(:tests).with(mutation_subject).and_return(tests)
expect(Mutant::Runner).to receive(:run).with(config, mutation_a, tests).and_return(runner_a)
expect(Mutant::Runner).to receive(:run).with(config, mutation_b, tests).and_return(runner_b)
end