Class: ParallelTests::RSpec::LoggerBase

Inherits:
LoggerBaseBase
  • Object
show all
Defined in:
lib/parallel_tests/rspec/logger_base.rb

Direct Known Subclasses

FailuresLogger, RuntimeLogger, SummaryLogger

Constant Summary collapse

RSPEC_1 =

do not test for Spec, this will trigger deprecation warning in rspec 2

!defined?(RSpec::Core::Formatters::BaseTextFormatter) # do not test for Spec, this will trigger deprecation warning in rspec 2
RSPEC_2 =
!RSPEC_1 && RSpec::Core::Version::STRING.start_with?('2')
RSPEC_3 =
!RSPEC_1 && RSpec::Core::Version::STRING.start_with?('3')

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ LoggerBase

Returns a new instance of LoggerBase.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/parallel_tests/rspec/logger_base.rb', line 21

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

Instance Method Details

#close(*args) ⇒ Object

stolen from Rspec



37
38
39
# File 'lib/parallel_tests/rspec/logger_base.rb', line 37

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