Instantiate strategies

Doing that stuff on singletons is wired. Future strategies will have a
state.
This commit is contained in:
Markus Schirp 2013-07-17 19:59:44 +02:00
parent 02b6fce79d
commit d358324450
4 changed files with 13 additions and 12 deletions

View file

@ -241,7 +241,7 @@ module Mutant
#
def add_strategies(opts)
opts.on('--rspec', 'kills mutations with rspec') do
set_strategy Strategy::Rspec
set_strategy Strategy::Rspec.new
end
end

View file

@ -4,24 +4,22 @@ module Mutant
class Strategy
include AbstractType, Adamantium::Flat
# Perform setup
# Perform strategy setup
#
# @return [self]
#
# @api private
#
def self.setup
self
def setup
end
# Perform teardown
# Perform strategy teardown
#
# @return [self]
#
# @api private
#
def self.teardown
self
def teardown
end
# Kill mutation
@ -32,18 +30,20 @@ module Mutant
#
# @api private
#
def self.kill(mutation)
def kill(mutation)
killer.new(self, mutation)
end
private
# Return killer
#
# @return [Class:Killer]
#
# @api private
#
def self.killer
self::KILLER
def killer
self.class::KILLER
end
end # Strategy

View file

@ -2,6 +2,7 @@ module Mutant
class Strategy
# Rspec killer strategy
class Rspec < self
include Equalizer.new
KILLER = Killer::Forking.new(Killer::Rspec)
@ -11,7 +12,7 @@ module Mutant
#
# @api private
#
def self.setup
def setup
self
end

View file

@ -25,7 +25,7 @@ describe Mutant::CLI, '.new' do
# Defaults
let(:expected_filter) { Mutant::Mutation::Filter::ALL }
let(:expected_strategy) { Mutant::Strategy::Rspec }
let(:expected_strategy) { Mutant::Strategy::Rspec.new }
let(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
let(:cli) { object.new(arguments) }