module Cucumber module Formatters class HtmlFormatter def initialize(io, step_mother) @io = io @step_mother = step_mother @errors = [] end def visit_features(features) # IMPORTANT NOTICE ABOUT JQUERY BELOW. THE ORIGINAL BACKSLASHES (\) HAVE # BEEN REPLACED BY DOUBLE BACKSLASHES (\\) IN THIS FILE TO MAKE SURE THEY # ARE PRINTED PROPERLY WITH ONLY ONE BACKSLASH (\). @io.puts(<<-HTML) #{Cucumber.language['feature']}
HTML features.accept(self) @io.puts %{
} end def visit_feature(feature) @io.puts %{
} feature.accept(self) @io.puts %{ } @io.puts %{
} end def visit_header(header) header = header.gsub(/\n/, "
\n") @io.puts %{
#{header}} @io.puts %{
} @io.puts %{
} end def visit_regular_scenario(scenario) @io.puts %{
} @io.puts %{
#{Cucumber.language['scenario']}: #{scenario.name}
} @io.puts %{
} @io.puts %{
    } scenario.accept(self) @io.puts %{
} @io.puts %{
} @io.puts %{
} end def visit_row_scenario(scenario) @io.puts %{
} @io.puts %{
#{Cucumber.language['scenario']}: #{scenario.name}
} @io.puts %{
} @io.puts %{ } @io.puts %{ } @io.puts %{ } @io.puts %{ } @io.puts %{ } @io.puts %{ } @io.puts %{ } @io.puts %{ } scenario.accept(self) @io.puts %{ } @io.puts %{
COL 1COL 2
} @io.puts %{
} @io.puts %{
} end def visit_row_step(step) _, args, _ = step.regexp_args_proc(@step_mother) args.each do |arg| @io.puts %{ #{arg}} end end def visit_regular_step(step) regexp, _, _ = step.regexp_args_proc(@step_mother) @io.puts %{
  • #{step.keyword} #{step.format(regexp, '%s')}
  • } end def step_passed(step, regexp, args) print_javascript_tag("stepPassed(#{step.id})") end def step_failed(step, regexp, args) @errors << step.error print_javascript_tag("stepFailed(#{step.id}, #{step.error.message.inspect}, #{step.error.backtrace.join("\n").inspect})") end def step_pending(step, regexp, args) print_javascript_tag("stepPending(#{step.id})") end def step_skipped(step, regexp, args) # noop end def print_javascript_tag(js) @io.puts %{ } end def dump @io.puts <<-HTML HTML end end end end