2 require 'spec/runner/formatter/base_text_formatter'
8 class HtmlFormatter < BaseTextFormatter
11 def run_started(count)
13 <?xml version="1.0" encoding="UTF-8"?>
15 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
16 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
19 <title>Stories</title>
20 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
21 <meta http-equiv="Expires" content="-1" />
22 <meta http-equiv="Pragma" content="no-cache" />
23 <script src="javascripts/prototype.js" type="text/javascript"></script>
24 <script src="javascripts/scriptaculous.js" type="text/javascript"></script>
25 <script src="javascripts/rspec.js" type="text/javascript"></script>
26 <link href="stylesheets/rspec.css" rel="stylesheet" type="text/css" />
33 def collected_steps(steps)
35 @output.puts " <ul id=\"stock_steps\" style=\"display: none;\">"
37 @output.puts " <li>#{step}</li>"
51 def story_started(title, narrative)
53 <dl class="story passed">
54 <dt>Story: #{h title}</dt>
57 #{h(narrative).split("\n").join("<br />")}
62 def story_ended(title, narrative)
69 def scenario_started(story_title, scenario_name)
72 <dt>Scenario: #{h scenario_name}</dt>
86 def found_scenario(type, description)
89 def scenario_succeeded(story_title, scenario_name)
93 def scenario_pending(story_title, scenario_name, reason)
97 def scenario_failed(story_title, scenario_name, err)
101 def step_succeeded(type, description, *args)
102 print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
105 def step_pending(type, description, *args)
106 print_step('pending', type, description, *args)
109 def step_failed(type, description, *args)
110 print_step('failed', type, description, *args)
113 def print_step(klass, type, description, *args)
114 spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
115 desc_string = description.step_name
116 arg_regexp = description.arg_regexp
118 inner = type.to_s.capitalize + ' ' + desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
119 @output.puts " <li class=\"#{klass}\">#{inner}</li>"