Sha256: aec2946a0ddf15ecd390553369813bdd131c21434a3fb26c3d770314b2de1229

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

Stored size: 1.06 KB

Contents

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

class ParallelTests::RSpec::FailuresLogger < ParallelTests::RSpec::LoggerBase
  # 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

  # RSpec 1: dumps 1 failed spec
  def dump_failure(*args)
  end

  # RSpec 2: dumps all failed specs
  def dump_failures(*args)
  end

  def dump_summary(*args)
    lock_output do
      if RSPEC_1
        dump_commands_to_rerun_failed_examples_rspec_1
      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

25 entries across 25 versions & 2 rubygems

Version Path
parallel_tests-0.16.17 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.16 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.15 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.14 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.13 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.12 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.11 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.10 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.9 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.8 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.7 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.6 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.5 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.4 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.3 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.2 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.1 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.16.0 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.15.4 lib/parallel_tests/rspec/failures_logger.rb
parallel_tests-0.15.3 lib/parallel_tests/rspec/failures_logger.rb