free_mutant/lib/mutant/strategy.rb

68 lines
1.2 KiB
Ruby
Raw Normal View History

2012-11-21 18:10:50 -05:00
module Mutant
class Strategy
2012-11-26 05:30:00 -05:00
include AbstractType
2012-11-21 18:10:50 -05:00
# Kill mutation
#
# @param [Mutation]
#
# @return [Killer]
#
# @api private
#
def self.kill(mutation)
killer.new(self, mutation)
end
def self.killer
self::KILLER
2012-11-21 18:10:50 -05:00
end
class Static < self
class Fail < self
KILLER = Killer::Static::Fail
end
class Success < self
KILLER = Killer::Static::Success
end
end
2012-11-21 18:10:50 -05:00
class Rspec < self
2012-12-04 12:23:56 -05:00
KILLER = Killer::Forking.new(Killer::Rspec)
2012-11-21 18:10:50 -05:00
class DM2 < self
def self.filename_pattern(mutation)
subject = mutation.subject
name = subject.context.scope.name
matcher = subject.matcher
2012-11-21 18:10:50 -05:00
append = matcher.kind_of?(Matcher::Method::Singleton) ? '/class_methods' : ''
2012-11-21 18:10:50 -05:00
path = Inflector.underscore(name)
base = "spec/unit/#{path}#{append}"
"#{base}/#{matcher.method_name}_spec.rb"
2012-11-21 18:10:50 -05:00
end
end
class Unit < self
def self.filename_pattern(mutation)
2012-11-21 18:14:13 -05:00
'spec/unit/**/*_spec.rb'
end
end
class Full < self
def self.filename_pattern(mutation)
'spec/**/*_spec.rb'
2012-11-21 18:10:50 -05:00
end
end
end
end
end