Class: Coverage
- Inherits:
-
BaseDocument
- Object
- BaseDocument
- Coverage
- Defined in:
- lib/almirah/doc_types/coverage.rb
Overview
rubocop:disable Style/Documentation
Instance Attribute Summary collapse
-
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
-
#covered_items ⇒ Object
Returns the value of attribute covered_items.
-
#failed_steps_number ⇒ Object
Returns the value of attribute failed_steps_number.
-
#passed_steps_number ⇒ Object
Returns the value of attribute passed_steps_number.
-
#top_doc ⇒ Object
Returns the value of attribute top_doc.
Attributes inherited from BaseDocument
Instance Method Summary collapse
-
#initialize(top_doc) ⇒ Coverage
constructor
A new instance of Coverage.
-
#render_table_row(top_item) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
- #to_console ⇒ Object
-
#to_html(nav_pane, output_file_path) ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from BaseDocument
Constructor Details
#initialize(top_doc) ⇒ Coverage
Returns a new instance of Coverage.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/almirah/doc_types/coverage.rb', line 8 def initialize(top_doc) super() @top_doc = top_doc @bottom_doc = nil @id = "#{top_doc.id}-tests" @title = "Coverage Matrix: #{@id}" @covered_items = {} @passed_steps_number = 0 @failed_steps_number = 0 end |
Instance Attribute Details
#bottom_doc ⇒ Object
Returns the value of attribute bottom_doc.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def bottom_doc @bottom_doc end |
#covered_items ⇒ Object
Returns the value of attribute covered_items.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def covered_items @covered_items end |
#failed_steps_number ⇒ Object
Returns the value of attribute failed_steps_number.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def failed_steps_number @failed_steps_number end |
#passed_steps_number ⇒ Object
Returns the value of attribute passed_steps_number.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def passed_steps_number @passed_steps_number end |
#top_doc ⇒ Object
Returns the value of attribute top_doc.
6 7 8 |
# File 'lib/almirah/doc_types/coverage.rb', line 6 def top_doc @top_doc end |
Instance Method Details
#render_table_row(top_item) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/almirah/doc_types/coverage.rb', line 46 def render_table_row(top_item) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength s = '' if top_item.coverage_links id_color = if top_item.coverage_links.length > 1 '' # "style='background-color: #fff8c5;'" # disabled for now else '' end top_item.coverage_links.each do |bottom_item| s += "\t<tr>\n" s += "\t\t<td class=\"item_id\" #{id_color}><a href=\"./../#{top_item.parent_doc.id}/#{top_item.parent_doc.id}.html##{top_item.id}\" class=\"external\">#{top_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 40%;'>#{top_item.text}</td>\n" test_step_color = case bottom_item.columns[-2].text.downcase when 'pass' @passed_steps_number += 1 "style='background-color: #cfc;'" when 'fail' @failed_steps_number += 1 "style='background-color: #fcc;'" else "style='background-color: #ffffee;'" end test_step_result = case bottom_item.columns[-2].text.downcase when 'pass' 'PASS' when 'fail' 'FAIL' else 'N/A' end s += "\t\t<td class=\"item_id\"><a href=\"./../../tests/protocols/#{bottom_item.parent_doc.id}/#{bottom_item.parent_doc.id}.html##{bottom_item.id}\" class=\"external\">#{bottom_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'>#{bottom_item.columns[1].text}</td>\n" s += "\t\t<td class=\"item_id\" #{test_step_color}>#{test_step_result}</td>\n" s += "\t</tr>\n" @covered_items[top_item.id.to_s.downcase] = top_item end else s += "\t<tr>\n" s += "\t\t<td class=\"item_id\"><a href=\"./../#{top_item.parent_doc.id}/#{top_item.parent_doc.id}.html##{top_item.id}\" class=\"external\">#{top_item.id}</a></td>\n" s += "\t\t<td class=\"item_text\" style='width: 40%;'>#{top_item.text}</td>\n" s += "\t\t<td class=\"item_id\"></td>\n" s += "\t\t<td class=\"item_text\" style='width: 42%;'></td>\n" s += "\t\t<td class=\"item_id\"></td>\n" s += "\t</tr>\n" end s end |
#to_console ⇒ Object
20 21 22 |
# File 'lib/almirah/doc_types/coverage.rb', line 20 def to_console puts "\e[35mTraceability: #{@id}\e[0m" end |
#to_html(nav_pane, output_file_path) ⇒ Object
rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/almirah/doc_types/coverage.rb', line 24 def to_html(nav_pane, output_file_path) # rubocop:disable Metrics/MethodLength html_rows = [] html_rows.append('') s = "<h1>#{@title}</h1>\n" s += "<table class=\"controlled\">\n" s += "\t<thead> <th>#</th> <th style='font-weight: bold;'>#{@top_doc.title}</th> " s += "<th title='TestCaseId.TestStepId'>#</th> <th style='font-weight: bold;'>Test Step Description</th> " s += "<th style='font-weight: bold;'>Result</th> </thead>\n" html_rows.append s sorted_items = @top_doc.controlled_items.sort_by(&:id) sorted_items.each do |top_item| row = render_table_row top_item html_rows.append row end html_rows.append "</table>\n" save_html_to_file(html_rows, nav_pane, output_file_path) end |