Class: ParallelTests::RSpec::LoggerBase

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/parallel_tests/rspec/logger_base.rb

Direct Known Subclasses

FailuresLogger, RuntimeLogger, SummaryLogger

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ LoggerBase

Returns a new instance of LoggerBase.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/parallel_tests/rspec/logger_base.rb', line 10

def initialize(*args)
  super

  @output ||= args[0]

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

Instance Method Details

#closeObject

stolen from Rspec



27
28
29
# File 'lib/parallel_tests/rspec/logger_base.rb', line 27

def close(*)
  @output.close if (IO === @output) & (@output != $stdout)
end