Class: RSSNotification::UnitTestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/kwala/notifications/rss.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_hash, timestamp) ⇒ UnitTestResult

Returns a new instance of UnitTestResult.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kwala/notifications/rss.rb', line 24

def initialize(result_hash, timestamp)
  @filename = result_hash[:file_name]
  @errors = result_hash[:sys_errors]
  @warnings = result_hash[:warnings]
  @first_seen = @last_seen = timestamp

  @test_results = Hash.new
  result_hash[:version].each do |r|
    if !r[:test_results].empty?
      @test_results[r[:version_name]] = r[:test_results]
    end
  end
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



21
22
23
# File 'lib/kwala/notifications/rss.rb', line 21

def errors
  @errors
end

#filenameObject (readonly)

Returns the value of attribute filename.



21
22
23
# File 'lib/kwala/notifications/rss.rb', line 21

def filename
  @filename
end

#first_seenObject (readonly)

Returns the value of attribute first_seen.



21
22
23
# File 'lib/kwala/notifications/rss.rb', line 21

def first_seen
  @first_seen
end

#last_seenObject

Returns the value of attribute last_seen.



22
23
24
# File 'lib/kwala/notifications/rss.rb', line 22

def last_seen
  @last_seen
end

#test_resultsObject (readonly)

Returns the value of attribute test_results.



21
22
23
# File 'lib/kwala/notifications/rss.rb', line 21

def test_results
  @test_results
end

#warningsObject (readonly)

Returns the value of attribute warnings.



21
22
23
# File 'lib/kwala/notifications/rss.rb', line 21

def warnings
  @warnings
end

Instance Method Details

#==(obj) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/kwala/notifications/rss.rb', line 42

def ==(obj)
  res = obj.kind_of?(UnitTestResult)
  res &= obj.filename == @filename
  res &= obj.errors == @errors
  res &= obj.warnings == @warnings
  res &= obj.test_results == @test_results
  res
end

#pass?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/kwala/notifications/rss.rb', line 38

def pass?
  @errors.empty? && @warnings.empty? && @test_results.empty?
end

#to_rss_item(compare_timestamp) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/kwala/notifications/rss.rb', line 51

def to_rss_item(compare_timestamp)
  if @last_seen < compare_timestamp
    defect_status = "Fixed"
  else
    defect_status = "New"
  end

  item = RSS::Rss::Channel::Item.new
  item.title = "#{@first_seen.strftime("%b %d, %H:%M")} - #{defect_status} defects in #{@filename}"
  item.pubDate = @first_seen
  item.description = defect_details_html
  item
end