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-08-28 13:14:10 -04:00
|
|
|
!run_rspec.zero?
|
|
|
|
end
|
2012-11-21 16:55:53 -05:00
|
|
|
memoize :run
|
2012-08-28 13:14:10 -04:00
|
|
|
|
|
|
|
# Run rspec with some wired compat stuff
|
|
|
|
#
|
|
|
|
# @return [Fixnum]
|
|
|
|
# returns the exit status from rspec runner
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def run_rspec
|
2012-11-21 20:50:17 -05:00
|
|
|
::RSpec::Core::Runner.run(command_line_arguments, @error_stream, @output_stream)
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# 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
|