Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 49 lines (45 sloc) 0.986 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
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, @error_stream, @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
Something went wrong with that request. Please try again.