Sha256: bbaf123be4d02daf9f9b9cedd02e557bef686b87aceff336daece78d2772133d

Contents?: true

Size: 1021 Bytes

Versions: 15

Compression:

Stored size: 1021 Bytes

Contents

require 'parallel_specs/spec_logger_base'

class ParallelSpecs::SpecFailuresLogger < ParallelSpecs::SpecLoggerBase
  # 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 "#{ParallelSpecs.executable} #{file}:#{line} # #{example.description}"
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
parallelized_specs-0.0.1 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.20 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-instructure-0.6.19 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.19 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.18 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-instructure-0.6.18 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.17 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-instructure-0.6.17 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-instructure-0.6.16 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.16 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.15 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.14 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.13 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.12 lib/parallel_specs/spec_failures_logger.rb
parallel_tests-0.6.11 lib/parallel_specs/spec_failures_logger.rb