Method: ParallelizedSpecs::SpecLoggerBase#initialize

Defined in:
lib/parallelized_specs/spec_logger_base.rb

#initialize(*args) ⇒ SpecLoggerBase

Returns a new instance of SpecLoggerBase.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/parallelized_specs/spec_logger_base.rb', line 15

def initialize(*args)
  super

  @output ||= args[1] || args[0] # rspec 1 has output as second argument

  if String === @output # a path ?
    FileUtils.mkdir_p(File.dirname(@output))
    File.open(@output, 'w'){} # overwrite previous results
    @output = File.open(@output, 'a')
  elsif File === @output # close and restart in append mode
    @output.close
    @output = File.open(@output.path, 'a')
  end
end