Class: CukeParser::ReportEngine::FeaturePage
- Inherits:
-
Object
- Object
- CukeParser::ReportEngine::FeaturePage
- Defined in:
- lib/report_engine/feature_page.rb
Instance Method Summary collapse
- #create_feature_page(feature, output_dir) ⇒ Object
-
#initialize(utils, cuke_metrics) ⇒ FeaturePage
constructor
A new instance of FeaturePage.
- #scenario_info(scenario, doc) ⇒ Object
- #statistics_table(feature, doc) ⇒ Object
- #step_error(step, doc) ⇒ Object
- #step_info(step, doc) ⇒ Object
Constructor Details
#initialize(utils, cuke_metrics) ⇒ FeaturePage
Returns a new instance of FeaturePage.
5 6 7 8 |
# File 'lib/report_engine/feature_page.rb', line 5 def initialize(utils,cuke_metrics) @utils = utils @cuke_metrics = cuke_metrics end |
Instance Method Details
#create_feature_page(feature, output_dir) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# 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) ⇒ Object
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/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) ⇒ Object
33 34 35 36 37 |
# 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) ⇒ Object
39 40 41 42 43 |
# 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 |