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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/parallelized_specs/trending_example_failures_logger.rb', line 33

def dump_summary(*args)

if File.exists?("#{Rails.root}/spec/build_info.txt")
  @hudson_build_info = File.read("#{Rails.root}/spec/build_info.txt")
else
  @hudson_build_info = "no*hudson build*info"
end

  [@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

#example_failed(example, counter, failure) ⇒ Object



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

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

#example_passed(example) ⇒ Object



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

def example_passed(example)
  total_time = Time.now - @spec_start_time
  no_failure_info = '*'
  if example.location != nil
    @passed_examples["#{example.location.match(/spec.*rb:\w*/).to_s}*"] = "#{example.description}*#{Date.today}*passed*#{total_time}*#{no_failure_info}*"
  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