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



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

def dump_summary(*args)
  lock_output do
    [@failed_examples, @passed_examples, @pending_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



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

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, counter) ⇒ Object



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

def example_passed(example, counter)
  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_pending(example, counter) ⇒ Object



33
34
35
36
37
38
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 33

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

#example_started(example) ⇒ Object



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

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