Class: ParallelSpecs::SpecLoggerBase

Inherits:
SpecLoggerBaseBase
  • Object
show all
Defined in:
lib/parallel_specs/spec_logger_base.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, output = nil) ⇒ SpecLoggerBase

Returns a new instance of SpecLoggerBase.



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

def initialize(options, output=nil)
  output ||= options # rspec 2 has output as first argument

  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

  @failed_examples = [] # only needed for rspec 2
end

Instance Method Details

#closeObject

stolen from Rspec



55
56
57
# File 'lib/parallel_specs/spec_logger_base.rb', line 55

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

#dump_failure(*args) ⇒ Object



51
52
# File 'lib/parallel_specs/spec_logger_base.rb', line 51

def dump_failure(*args)
end

#dump_pending(*args) ⇒ Object



48
49
# File 'lib/parallel_specs/spec_logger_base.rb', line 48

def dump_pending(*args)
end

#dump_summary(*args) ⇒ Object



45
46
# File 'lib/parallel_specs/spec_logger_base.rb', line 45

def dump_summary(*args)
end

#example_failed(*args) ⇒ Object



39
40
# File 'lib/parallel_specs/spec_logger_base.rb', line 39

def example_failed(*args)
end

#example_passed(example) ⇒ Object



33
34
# File 'lib/parallel_specs/spec_logger_base.rb', line 33

def example_passed(example)
end

#example_pending(*args) ⇒ Object



36
37
# File 'lib/parallel_specs/spec_logger_base.rb', line 36

def example_pending(*args)
end

#example_started(*args) ⇒ Object



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

def example_started(*args)
end

#lock_outputObject

do not let multiple processes get in each others way



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/parallel_specs/spec_logger_base.rb', line 60

def lock_output
  if File === @output
    begin
      @output.flock File::LOCK_EX
      yield
    ensure
      @output.flock File::LOCK_UN
    end
  else
    yield
  end
end

#start_dump(*args) ⇒ Object



42
43
# File 'lib/parallel_specs/spec_logger_base.rb', line 42

def start_dump(*args)
end