Class Spec::Runner::Formatter::Story::HtmlFormatter
In: vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb
Parent: Spec::Runner::Formatter::BaseTextFormatter

Methods

Included Modules

ERB::Util

Public Class methods

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 11
11:           def initialize(options, where)
12:             super
13:             @previous_type = nil
14:             @scenario_text = ""
15:             @story_text = ""
16:             @scenario_failed = false
17:             @story_failed = false
18:           end

Public Instance methods

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 43
43:           def collected_steps(steps)
44:             unless steps.empty?
45:               @output.puts "      <ul id=\"stock_steps\" style=\"display: none;\">"
46:               steps.each do |step|
47:                 @output.puts "        <li>#{step}</li>"
48:               end
49:               @output.puts "      </ul>"
50:             end
51:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 127
127:           def found_scenario(type, description)
128:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 159
159:           def print_step(klass, type, description, *args)
160:             spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
161:             desc_string = description.step_name
162:             arg_regexp = description.arg_regexp           
163:             inner = if(type == @previous_type)
164:               "And "
165:             else
166:               "#{type.to_s.capitalize} "
167:             end
168:             i = -1
169:             inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
170:             
171:             @scenario_text += "                  <li class=\"#{klass}\">#{inner}</li>\n"
172:             
173:             if type == :'given scenario'
174:               @previous_type = :given
175:             else
176:               @previous_type = type
177:             end
178:             
179:           end

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 53
53:           def run_ended
54:             @output.puts "</div>\n</body>\n</head>\n"
55:           end

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 20
20:           def run_started(count)
21:             @output.puts "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html\nPUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n<title>Stories</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta http-equiv=\"Expires\" content=\"-1\" />\n<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n<script src=\"javascripts/prototype.js\" type=\"text/javascript\"></script>\n<script src=\"javascripts/scriptaculous.js\" type=\"text/javascript\"></script>\n<script src=\"javascripts/rspec.js\" type=\"text/javascript\"></script>\n<link href=\"stylesheets/rspec.css\" rel=\"stylesheet\" type=\"text/css\" />\n</head>\n<body>\n<div id=\"container\">\n"
22:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 105
105:           def scenario_ended
106:             if @scenario_failed
107:               @story_text += "<dl class=\"failed\">\n"
108:             else
109:               @story_text += "<dl class=\"passed\">\n"
110:             end
111:             
112:             @story_text += "\#{@scenario_text}\n</ul>\n</dd>\n</dl>\n"
113:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 138
138:           def scenario_failed(story_title, scenario_name, err)
139:             @scenario_failed = true
140:             @story_failed = true
141:             scenario_ended
142:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 134
134:           def scenario_pending(story_title, scenario_name, reason)
135:             scenario_ended
136:           end

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 94
94:           def scenario_started(story_title, scenario_name)
95:             @previous_type = nil
96:             @scenario_failed = false
97:             @scenario_text = "<dt>Scenario: \#{h scenario_name}</dt>\n<dd>\n<ul class=\"steps\">\n"
98:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 130
130:           def scenario_succeeded(story_title, scenario_name)
131:             scenario_ended
132:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 155
155:           def step_failed(type, description, *args)
156:             print_step('failed', type, description, *args)
157:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 151
151:           def step_pending(type, description, *args)
152:             print_step('pending', type, description, *args)
153:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 147
147:           def step_succeeded(type, description, *args)
148:             print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
149:           end

[Source]

     # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 144
144:           def step_upcoming(type, description, *args)
145:           end

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 74
74:           def story_ended(title, narrative)     
75:             if @story_failed
76:               @output.puts "<dl class=\"story failed\">\n"
77:             else
78:               @output.puts "<dl class=\"story passed\">\n"
79:             end
80:               @output.puts "\#{@story_text}\n</dd>\n</dl>\n"
81:           end

[Source]

    # File vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb, line 62
62:           def story_started(title, narrative)
63:             @story_failed = false
64:             @story_text = "<dt>Story: \#{h title}</dt>\n<dd>\n<p>\n\#{h(narrative).split(\"\\n\").join(\"<br />\")}\n</p>\n" 
65:           end

[Validate]