Sha256: 2a4c4ebe3ba406d1ea31b59c8ddd3c6c918df3e8ccdf1664dff7ae209889ccd7

Contents?: true

Size: 1.36 KB

Versions: 31

Compression:

Stored size: 1.36 KB

Contents

require 'parallel_tests/rspec/logger_base'
require 'parallel_tests/rspec/runner'

class ParallelTests::RSpec::FailuresLogger < ParallelTests::RSpec::LoggerBase
  if RSPEC_1
    # RSpec 1: does not keep track of failures, so we do
    def example_failed(example, *args)
      if RSPEC_1
        @failed_examples ||= []
        @failed_examples << example
      else
        super
      end
    end

    def dump_failure(*args)
    end
  elsif RSPEC_2
    def dump_failures(*args)
    end
  else
    RSpec::Core::Formatters.register self, :dump_summary
  end

  def dump_summary(*args)
    lock_output do
      if RSPEC_1
        dump_commands_to_rerun_failed_examples_rspec_1
      elsif RSPEC_3
        notification = args.first
        unless notification.failed_examples.empty?
          colorizer = ::RSpec::Core::Formatters::ConsoleCodes
          output.puts notification.colorized_rerun_commands(colorizer)
        end
      else
        dump_commands_to_rerun_failed_examples
      end
    end
    @output.flush
  end

  private

  def dump_commands_to_rerun_failed_examples_rspec_1
    (@failed_examples||[]).each do |example|
      file, line = example.location.to_s.split(':')
      next unless file and line
      file.gsub!(%r(^.*?/spec/), './spec/')
      @output.puts "#{ParallelTests::RSpec::Runner.send(:executable)} #{file}:#{line} # #{example.description}"
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
parallel_tests-2.13.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.12.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.11.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.10.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.9.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.8.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.7.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.7.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.6.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.5.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.4.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.4.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.3.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.3.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.2.2 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.2.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.2.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.1.2 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.1.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-2.1.0 lib/parallel_tests/rspec/failures_logger.rb