Class: Zucchini::Report

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

Class Method Summary collapse

Class Method Details

.html(features, ci, report_html_path = "/tmp/zucchini_report.html") ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/report.rb', line 15

def self.html(features, ci, report_html_path = "/tmp/zucchini_report.html" )
  template_path = File.expand_path("#{File.dirname(__FILE__)}/report/template.erb")
  
  report = Zucchini::ReportView.new(features, ci) 
  html   = (ERB.new(File.open(template_path).read)).result(report.get_binding)
  
  File.open(report_html_path, 'w+') { |f| f.write(html) }
  report_html_path
end

.present(features, ci) ⇒ Object



25
26
27
28
# File 'lib/report.rb', line 25

def self.present(features, ci)
  puts self.text(features)
  system "open #{self.html(features, ci)}"  
end

.text(features) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/report.rb', line 6

def self.text(features)
  features.map do |f|
    failed_list = f.stats[:failed].empty? ? "" : "\n\nFailed:\n" + f.stats[:failed].map { |s| "   #{s.file_name}: #{s.diff[1]}" }.join
    summary     = f.stats.map { |key, set| "#{set.length.to_s} #{key}" }.join(", ")
    
    "#{f.name}:\n#{summary}#{failed_list}"
  end.join("\n\n")
end