require 'erb' require 'spec/runner/formatter/base_text_formatter' module Spec module Runner module Formatter module Story class HtmlFormatter < BaseTextFormatter include ERB::Util def run_started(count) @output.puts <<-EOF Stories
EOF end def collected_steps(steps) unless steps.empty? @output.puts " " end end def run_ended @output.puts <<-EOF
EOF end def story_started(title, narrative) @output.puts <<-EOF
Story: #{h title}

#{h(narrative).split("\n").join("
")}

EOF end def story_ended(title, narrative) @output.puts <<-EOF
EOF end def scenario_started(story_title, scenario_name) @output.puts <<-EOF
Scenario: #{h scenario_name}
EOF end def found_scenario(type, description) end def scenario_succeeded(story_title, scenario_name) scenario_ended end def scenario_pending(story_title, scenario_name, reason) scenario_ended end def scenario_failed(story_title, scenario_name, err) scenario_ended end def step_upcoming(type, description, *args) end def step_succeeded(type, description, *args) print_step('passed', type, description, *args) # TODO: uses succeeded CSS class end def step_pending(type, description, *args) print_step('pending', type, description, *args) end def step_failed(type, description, *args) print_step('failed', type, description, *args) end def print_step(klass, type, description, *args) spans = args.map { |arg| "#{arg}" } desc_string = description.step_name arg_regexp = description.arg_regexp i = -1 inner = type.to_s.capitalize + ' ' + desc_string.gsub(arg_regexp) { |param| spans[i+=1] } @output.puts "
  • #{inner}
  • " end end end end end end