free_mutant/lib/mutant/integration.rb

84 lines
1.3 KiB
Ruby
Raw Normal View History

2012-11-21 18:10:50 -05:00
module Mutant
2014-06-28 19:04:18 -04:00
# Abstract base class mutant test framework integrations
class Integration
2014-01-17 18:25:16 -05:00
include AbstractType, Adamantium::Flat, Equalizer.new
2014-01-17 18:15:42 -05:00
REGISTRY = {}
2014-06-28 19:04:18 -04:00
# Lookup integration for name
2014-01-17 18:15:42 -05:00
#
# @param [String] name
#
2014-06-28 19:04:18 -04:00
# @return [Integration]
2014-01-17 18:15:42 -05:00
# if found
#
# @api private
#
def self.lookup(name)
REGISTRY.fetch(name)
end
2014-06-28 19:04:18 -04:00
# Register integration
2014-01-17 18:15:42 -05:00
#
# @param [String] name
#
# @return [undefined]
#
# @api private
#
def self.register(name)
REGISTRY[name] = self
define_method(:name) { name }
2014-01-17 18:15:42 -05:00
end
private_class_method :register
2014-06-28 19:04:18 -04:00
# Perform integration setup
#
2013-01-15 17:46:05 -05:00
# @return [self]
#
# @api private
#
def setup
2013-09-02 16:02:51 -04:00
self
end
2014-06-28 19:04:18 -04:00
# Perform integration teardown
#
2013-01-15 17:46:05 -05:00
# @return [self]
#
# @api private
#
def teardown
2013-09-02 16:02:51 -04:00
self
end
2012-11-21 18:10:50 -05:00
2014-06-28 19:04:18 -04:00
# Return all available tests by integration
#
# @return [Enumerable<Test>]
#
# @api private
#
abstract_method :all_tests
2014-06-28 19:04:18 -04:00
# Null integration that never kills a mutation
2014-01-17 18:15:42 -05:00
class Null < self
register('null')
2014-01-17 18:15:42 -05:00
# Return all tests
#
# @return [Enumerable<Test>]
#
# @api private
#
def all_tests
EMPTY_ARRAY
end
2014-01-17 18:15:42 -05:00
end # Null
2014-06-28 19:04:18 -04:00
end # Integration
2013-06-14 14:54:02 -04:00
end # Mutant