lib/cucumber/formatter/html.rb in aslakhellesoy-cucumber-0.2.3.1 vs lib/cucumber/formatter/html.rb in aslakhellesoy-cucumber-0.2.3.2

- old
+ new

@@ -1,15 +1,18 @@ +require 'erb' begin require 'builder' rescue LoadError gem 'builder' require 'builder' end module Cucumber module Formatter class Html < Ast::Visitor + include ERB::Util # for the #h method + def initialize(step_mother, io, options) super(step_mother) @builder = Builder::XmlMarkup.new(:target => io, :indent => 2) end @@ -91,11 +94,16 @@ end end def visit_step(step) @step_id = step.dom_id - @builder.li(:id => @step_id) do + super + end + + def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) + @status = status + @builder.li(:id => @step_id, :class => status) do super end end def visit_step_name(keyword, step_match, status, source_indent, background) @@ -103,12 +111,12 @@ @skip_step = @step_matches.index(step_match) @step_matches << step_match unless @skip_step step_name = step_match.format_args(lambda{|param| "<span>#{param}</span>"}) - @builder.div(:class => status) do |div| - div << "#{keyword} #{step_name}" + @builder.div do |div| + div << h("#{keyword} #{step_name}") end end end def visit_exception(exception, status) @@ -124,12 +132,12 @@ else super end end - def visit_py_string(string, status) - @builder.pre(:class => status) do |pre| + def visit_py_string(string) + @builder.pre(:class => @status) do |pre| pre << string end end def visit_table_row(table_row) @@ -150,10 +158,12 @@ @outline_row += 1 if @outline_row end def visit_table_cell_value(value, width, status) cell_type = @outline_row == 0 ? :th : :td - @builder.__send__(cell_type, value, :class => status, :id => "#{@row_id}_#{@col_index}") + attributes = {:id => "#{@row_id}_#{@col_index}"} + attributes[:class] = status if status + @builder.__send__(cell_type, value, attributes) @col_index += 1 end def announce(announcement) @builder.pre(announcement, :class => 'announcement')