Class: ParallelizedSpecs::TrendingExampleFailures

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

Constant Summary

Constants inherited from SpecLoggerBase

SpecLoggerBase::RSPEC_1

Instance Method Summary collapse

Methods inherited from SpecLoggerBase

#close, #dump_failure, #dump_failures, #dump_pending, #lock_output

Constructor Details

#initialize(*args) ⇒ TrendingExampleFailures

Returns a new instance of TrendingExampleFailures.



5
6
7
8
9
10
11
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 5

def initialize(*args)
  @passed_examples = {}
  @failed_examples = {}
  @pending_examples = {}
  @hudson_build_info = File.read("#{Rails.root}/spec/build_info.txt")
  super
end

Instance Method Details

#dump_summary(*args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 40

def dump_summary(*args)
  lock_output do
    [@failed_examples, @passed_examples].each do | example_results |
      unless example_results.empty?
        (example_results).each_pair do |example, details|
          @output.puts "#{example}#{details}#{@hudson_build_info}"
        end
      end
    end
    @output.flush
  end
end

#example_failed(example, counter, failure) ⇒ Object



17
18
19
20
21
22
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 17

def example_failed(example, counter, failure)
  total_time = Time.now - @spec_start_time
  if example.location != nil
    @failed_examples["#{example.location.match(/spec.*\d/).to_s}*"] = ["#{example.description}*", "#{Date.today}*", "failed*", "#{total_time}*", "#{failure.header}*", "#{failure.exception.to_s.gsub(/\n/, "")}*", "#{failure.exception.backtrace.to_s.gsub(/\n/)}*"]
  end
end

#example_passed(example) ⇒ Object



24
25
26
27
28
29
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 24

def example_passed(example)
  total_time = Time.now - @spec_start_time
  if example.location != nil
    @passed_examples["#{example.location.match(/spec.*\d/).to_s}*"] = ["#{example.description}*", "#{Date.today}*", "passed*", "#{total_time}*","NA*","NA*","NA*"]
  end
end

#example_started(example) ⇒ Object



13
14
15
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 13

def example_started(example)
  @spec_start_time = Time.now
end