Class: ParallelizedSpecs::SpecStartFinishLogger

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

Constant Summary

Constants inherited from SpecLoggerBase

ParallelizedSpecs::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/parallelized_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



39
40
41
42
43
# File 'lib/parallelized_specs/spec_start_finish_logger.rb', line 39

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

#example_passed(example) ⇒ Object



27
28
29
30
31
# File 'lib/parallelized_specs/spec_start_finish_logger.rb', line 27

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

#example_pending(example, message) ⇒ Object



33
34
35
36
37
# File 'lib/parallelized_specs/spec_start_finish_logger.rb', line 33

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

#example_started(example) ⇒ Object



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

def example_started(example)
  lock_output do
    @output.puts "\nstarted spec: #{example.description}"
  end
end