2012-08-14 06:27:56 -04:00
|
|
|
module Mutant
|
|
|
|
class Killer
|
2012-08-28 13:14:10 -04:00
|
|
|
# Runner for rspec tests
|
2012-08-14 06:27:56 -04:00
|
|
|
class Rspec < self
|
2012-11-21 16:55:53 -05:00
|
|
|
TYPE = 'rspec'.freeze
|
2012-08-14 06:27:56 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Initialize rspec runner
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def initialize(*)
|
|
|
|
@error_stream, @output_stream = StringIO.new, StringIO.new
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
# Run rspec test
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# returns true when test is NOT successful and the mutant was killed
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# returns false otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def run
|
2012-12-07 12:53:03 -05:00
|
|
|
mutation.insert
|
2012-12-10 18:17:19 -05:00
|
|
|
!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).zero?
|
2012-08-28 13:14:10 -04:00
|
|
|
end
|
2012-11-21 16:55:53 -05:00
|
|
|
memoize :run
|
2012-08-28 13:14:10 -04:00
|
|
|
|
2012-08-14 06:27:56 -04:00
|
|
|
# Return command line arguments
|
|
|
|
#
|
|
|
|
# @return [Array]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def command_line_arguments
|
|
|
|
%W(
|
|
|
|
--fail-fast
|
2012-12-07 10:55:53 -05:00
|
|
|
) + strategy.spec_files(mutation)
|
2012-11-21 16:28:08 -05:00
|
|
|
end
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|