class CukeParser::ReportEngine::FeaturePage
Public Class Methods
new(utils,cuke_metrics)
click to toggle source
# File lib/report_engine/feature_page.rb, line 5 def initialize(utils,cuke_metrics) @utils = utils @cuke_metrics = cuke_metrics end
Public Instance Methods
create_feature_page(feature,output_dir)
click to toggle source
# File lib/report_engine/feature_page.rb, line 10 def create_feature_page(feature,output_dir) output = File.new(output_dir+"/features/"+feature.name+".html","w+") builder = Nokogiri::HTML::Builder.new do |doc| doc.html{ doc.link(:href => "../assets/stylesheets/bootstrap.css", :rel => "stylesheet") doc.link(:href => "../assets/stylesheets/cuke_parser.css", :rel => "stylesheet") doc.script(:src => "../assets/javascripts/bootstrap.js", :type => "text/javascript") doc.script(:src => "../assets/javascripts/jquery.js", :type => "text/javascript") doc.body{ statistics_table(feature,doc) doc.div(:class => "container"){ doc.div(:class => "row"){ doc.div(:class => "span12"){ feature.scenarios.each {|scenario| scenario_info(scenario,doc)} } } } } } end output.puts builder.to_html end
scenario_info(scenario,doc)
click to toggle source
# File lib/report_engine/feature_page.rb, line 45 def scenario_info(scenario,doc) doc.div(:class => "rounded "+scenario.status){ doc.span({:class => "keyword-scenario"},scenario.keyword + ": ") doc.span({:class => "non-keyword-scenario"},scenario.name) scenario.steps.each {|step| doc.div({:class => "step "+step.status}){step_info(step,doc)}} doc.br{} } doc.br{} end
statistics_table(feature,doc)
click to toggle source
# File lib/report_engine/feature_page.rb, line 55 def statistics_table(feature,doc) doc.h1({:class => "fancy-header"},feature.name + " Result") doc.table(:class => "table table-bordered table-condensed feature-table neutral") { doc.thead { doc.tr { doc.th() doc.th({:colspan => 3, :class => "scenarios_header",},"Scenarios") doc.th({:colspan => 4, :align => "center"},"Steps") doc.th() doc.th() } doc.tr { doc.th("Feature") doc.th("Total") doc.th("Passed") doc.th("Failed") doc.th("Total") doc.th("Passed") doc.th("Failed") doc.th("Skipped") doc.th("Duration") doc.th("Status") } } doc.tr(@utils.model_status_display(feature.status)) { doc.td(feature.name) doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:scenario_count]) doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:passed]) doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:failed]) doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:step_count]) doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:passed]) doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:failed]) doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:skipped]) doc.td(@utils.time_to_words(feature.duration)) doc.td { doc.span(feature.status) } } } end
step_error(step,doc)
click to toggle source
# File lib/report_engine/feature_page.rb, line 33 def step_error(step,doc) doc.div(:class => "rounded error-message") { doc.span(step.reason_for_failure) } end
step_info(step,doc)
click to toggle source
# File lib/report_engine/feature_page.rb, line 39 def step_info(step,doc) doc.span({:class => "keyword-step"},step.keyword.strip + ": ") doc.span({:class => "non-keyword-step"},step.name) step_error(step,doc) if step.status.eql?("failed") end