Class: Launcuke::ReportsIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/launcuke/index.rb

Overview

Generate the index page reporting on the features and their status. Provides the links to the actual full Cucumber html reports.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reports_path, features_dirs, last_run_time) ⇒ ReportsIndex

Returns a new instance of ReportsIndex.



13
14
15
16
17
# File 'lib/launcuke/index.rb', line 13

def initialize(reports_path, features_dirs, last_run_time)
  @features_dirs = features_dirs
  @index_path = File.join(reports_path, "index.html")
  @last_run_time = last_run_time
end

Instance Attribute Details

#features_dirsObject (readonly)

Collection of ran features directories results used for reporting



8
9
10
# File 'lib/launcuke/index.rb', line 8

def features_dirs
  @features_dirs
end

#index_pathObject (readonly)

Full path for the index html file



11
12
13
# File 'lib/launcuke/index.rb', line 11

def index_path
  @index_path
end

Instance Method Details

#generateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/launcuke/index.rb', line 19

def generate
  index_file = File.new(index_path, "w")

  b = Builder::XmlMarkup.new :target => index_file, :indent => 2
  b.html {
    b.head {
      b.title("Cucumber Reports")
      b.style(css_content)
    }
    b.body {
      b.h2("Features")
      b.h3("Last run time: #{@last_run_time}")
      b.ul {
        features_dirs.each { |features_dir|
            b.li(:class => (features_dir.failed? ? "failed" : "success")) {
              b.a(features_dir.human_name, :href => "#{features_dir.dir_name}.html")
              b.span("[#{features_dir.duration}]", :class => "duration")
              b.span("Scenarios: #{features_dir.scenarios_results}, Steps: #{features_dir.steps_results}, Last tested time: #{features_dir.last_tested_time}", :class => "result")
            }
        }
      }
    }
  }

  index_file.close
end