Class: ParallelSpecs::SpecStartFinishLogger

Inherits:
SpecLoggerBase show all
Defined in:
lib/parallel_specs/spec_start_finish_logger.rb

Constant Summary

Constants inherited from SpecLoggerBase

ParallelSpecs::SpecLoggerBase::RSPEC_1

Instance Method Summary collapse

Methods inherited from SpecLoggerBase

#close, #dump_failure, #dump_failures, #dump_pending, #dump_summary, #lock_output

Constructor Details

#initialize(options, output = nil) ⇒ SpecStartFinishLogger

Returns a new instance of SpecStartFinishLogger.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/parallel_specs/spec_start_finish_logger.rb', line 5

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

Instance Method Details

#example_failed(example, count, failure) ⇒ Object



34
35
36
# File 'lib/parallel_specs/spec_start_finish_logger.rb', line 34

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

#example_passed(example) ⇒ Object



26
27
28
# File 'lib/parallel_specs/spec_start_finish_logger.rb', line 26

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

#example_pending(example, message) ⇒ Object



30
31
32
# File 'lib/parallel_specs/spec_start_finish_logger.rb', line 30

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

#example_started(example) ⇒ Object



21
22
23
24
# File 'lib/parallel_specs/spec_start_finish_logger.rb', line 21

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