Instantiate strategies
Doing that stuff on singletons is wired. Future strategies will have a state.
This commit is contained in:
parent
02b6fce79d
commit
d358324450
4 changed files with 13 additions and 12 deletions
|
@ -241,7 +241,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
def add_strategies(opts)
|
def add_strategies(opts)
|
||||||
opts.on('--rspec', 'kills mutations with rspec') do
|
opts.on('--rspec', 'kills mutations with rspec') do
|
||||||
set_strategy Strategy::Rspec
|
set_strategy Strategy::Rspec.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,24 +4,22 @@ module Mutant
|
||||||
class Strategy
|
class Strategy
|
||||||
include AbstractType, Adamantium::Flat
|
include AbstractType, Adamantium::Flat
|
||||||
|
|
||||||
# Perform setup
|
# Perform strategy setup
|
||||||
#
|
#
|
||||||
# @return [self]
|
# @return [self]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.setup
|
def setup
|
||||||
self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Perform teardown
|
# Perform strategy teardown
|
||||||
#
|
#
|
||||||
# @return [self]
|
# @return [self]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.teardown
|
def teardown
|
||||||
self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Kill mutation
|
# Kill mutation
|
||||||
|
@ -32,18 +30,20 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.kill(mutation)
|
def kill(mutation)
|
||||||
killer.new(self, mutation)
|
killer.new(self, mutation)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
# Return killer
|
# Return killer
|
||||||
#
|
#
|
||||||
# @return [Class:Killer]
|
# @return [Class:Killer]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.killer
|
def killer
|
||||||
self::KILLER
|
self.class::KILLER
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Strategy
|
end # Strategy
|
||||||
|
|
|
@ -2,6 +2,7 @@ module Mutant
|
||||||
class Strategy
|
class Strategy
|
||||||
# Rspec killer strategy
|
# Rspec killer strategy
|
||||||
class Rspec < self
|
class Rspec < self
|
||||||
|
include Equalizer.new
|
||||||
|
|
||||||
KILLER = Killer::Forking.new(Killer::Rspec)
|
KILLER = Killer::Forking.new(Killer::Rspec)
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.setup
|
def setup
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe Mutant::CLI, '.new' do
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
let(:expected_filter) { Mutant::Mutation::Filter::ALL }
|
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(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
|
||||||
|
|
||||||
let(:cli) { object.new(arguments) }
|
let(:cli) { object.new(arguments) }
|
||||||
|
|
Loading…
Reference in a new issue