2013-01-13 17:47:00 -05:00
|
|
|
module Mutant
|
|
|
|
class Strategy
|
|
|
|
class Rspec
|
|
|
|
class DM2
|
|
|
|
|
2013-04-17 23:31:21 -04:00
|
|
|
# Example lookup for the rspec dm2
|
2013-01-13 17:47:00 -05:00
|
|
|
class Lookup
|
|
|
|
include AbstractType, Adamantium::Flat, Equalizer.new(:subject)
|
|
|
|
|
|
|
|
# Return subject
|
|
|
|
#
|
|
|
|
# @return [Subject]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :subject
|
|
|
|
|
|
|
|
# Return glob expression
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
abstract_method :spec_files
|
|
|
|
|
|
|
|
# Initalize object
|
|
|
|
#
|
|
|
|
# @param [Mutation] mutation
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def initialize(subject)
|
|
|
|
@subject = subject
|
|
|
|
end
|
|
|
|
|
|
|
|
# Perform example lookup
|
|
|
|
#
|
|
|
|
# @param [Subject] subject
|
|
|
|
#
|
|
|
|
# @return [Enumerable<String>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.run(subject)
|
2013-01-21 17:54:25 -05:00
|
|
|
build(subject).spec_files
|
2013-01-13 17:47:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
REGISTRY = {}
|
|
|
|
|
|
|
|
# Register subject hander
|
|
|
|
#
|
|
|
|
# @param [Class:Subject]
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.handle(subject_class)
|
|
|
|
REGISTRY[subject_class]=self
|
|
|
|
end
|
|
|
|
private_class_method :handle
|
|
|
|
|
|
|
|
# Build lookup object
|
|
|
|
#
|
|
|
|
# @param [Subjecŧ] subject
|
|
|
|
#
|
2013-04-17 23:31:21 -04:00
|
|
|
# @return [Lookup]
|
2013-01-13 17:47:00 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.build(subject)
|
|
|
|
REGISTRY.fetch(subject.class).new(subject)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|