free_mutant/lib/mutant/killer/rspec.rb
Markus Schirp 40d5230c68 Introduce noop mutation guards and argument mutators
* Sorry for not splitting up into smaller commit
2012-12-11 00:17:19 +01:00

49 lines
1,002 B
Ruby

module Mutant
class Killer
# Runner for rspec tests
class Rspec < self
TYPE = 'rspec'.freeze
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
mutation.insert
!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).zero?
end
memoize :run
# Return command line arguments
#
# @return [Array]
#
# @api private
#
def command_line_arguments
%W(
--fail-fast
) + strategy.spec_files(mutation)
end
end
end
end