Sha256: 75931f025cbcb6a562297744b005b514cace09e1fd975a63248fb6a019ef890d

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'parallel_specs'
require File.join(File.dirname(__FILE__), 'spec_logger_base')

class ParallelSpecs::SpecStartFinishLogger < ParallelSpecs::SpecLoggerBase
  def initialize(options, output=nil)
    output ||= options # rspec 2 has output as first argument

    output = "#{output}_#{ENV['TEST_ENV_NUMBER']}.log"
    if String === output
      FileUtils.mkdir_p(File.dirname(output))
      File.open(output, 'w'){} # overwrite previous results
      @output = File.open(output, 'a')
    elsif File === output
      output.close # close file opened with 'w'
      @output = File.open(output.path, 'a')
    else
      @output = output
    end
  end

  def example_started(example)
    @output.puts ""
    @output.puts "started spec: #{example.description}"
  end

  def example_passed(example)
    @output.puts "finished spec: #{example.description}"
  end

  def example_pending(example, message)
    @output.puts "finished spec: #{example.description}"
  end

  def example_failed(example)
    @output.puts "finished spec: #{example.description}"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parallel_tests-instructure-0.6.17 lib/parallel_specs/spec_start_finish_logger.rb
parallel_tests-instructure-0.6.16 lib/parallel_specs/spec_start_finish_logger.rb