Class: Cucumber::Formatter::Html
- Includes:
- Duration, ERB::Util
- Defined in:
- lib/cucumber/formatter/html.rb
Overview
The formatter used for --format html
Instance Method Summary collapse
- #after_background(background) ⇒ Object
- #after_comment(comment) ⇒ Object
- #after_examples(examples) ⇒ Object
- #after_feature(feature) ⇒ Object
- #after_feature_element(feature_element) ⇒ Object
- #after_features(features) ⇒ Object
- #after_multiline_arg(multiline_arg) ⇒ Object
- #after_outline_table(outline_table) ⇒ Object
- #after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
- #after_steps(steps) ⇒ Object
- #after_table_row(table_row) ⇒ Object
- #after_tags(tags) ⇒ Object
- #announce(announcement) ⇒ Object
- #background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
- #before_background(background) ⇒ Object
- #before_comment(comment) ⇒ Object
- #before_examples(examples) ⇒ Object
- #before_feature(feature) ⇒ Object
- #before_feature_element(feature_element) ⇒ Object
- #before_features(features) ⇒ Object
- #before_multiline_arg(multiline_arg) ⇒ Object
- #before_outline_table(outline_table) ⇒ Object
- #before_step(step) ⇒ Object
- #before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
- #before_steps(steps) ⇒ Object
- #before_table_row(table_row) ⇒ Object
- #comment_line(comment_line) ⇒ Object
- #examples_name(keyword, name) ⇒ Object
- #exception(exception, status) ⇒ Object
- #feature_name(name) ⇒ Object
-
#initialize(step_mother, io, options) ⇒ Html
constructor
A new instance of Html.
- #py_string(string) ⇒ Object
- #scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
- #step_name(keyword, step_match, status, source_indent, background) ⇒ Object
- #table_cell_value(value, status) ⇒ Object
- #tag_name(tag_name) ⇒ Object
Methods included from Duration
Constructor Details
#initialize(step_mother, io, options) ⇒ Html
Returns a new instance of Html.
11 12 13 14 15 16 |
# File 'lib/cucumber/formatter/html.rb', line 11 def initialize(step_mother, io, ) @io = io @options = @buffer = {} @current_builder = create_builder(@io) end |
Instance Method Details
#after_background(background) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/cucumber/formatter/html.rb', line 104 def after_background(background) stop_buffering :background @in_background = nil builder.div(:class => 'background') do builder << buffer(:background) end end |
#after_comment(comment) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/cucumber/formatter/html.rb', line 63 def after_comment(comment) stop_buffering :comment builder.pre(:class => 'comment') do builder << buffer(:comment) end end |
#after_examples(examples) ⇒ Object
164 165 166 167 168 169 |
# File 'lib/cucumber/formatter/html.rb', line 164 def after_examples(examples) stop_buffering :examples builder.div(:class => 'examples') do builder << buffer(:examples) end end |
#after_feature(feature) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/cucumber/formatter/html.rb', line 52 def after_feature(feature) stop_buffering :feature builder.div(:class => 'feature') do builder << buffer(:feature) end end |
#after_feature_element(feature_element) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cucumber/formatter/html.rb', line 125 def after_feature_element(feature_element) stop_buffering :feature_element css_class = { Ast::Scenario => 'scenario', Ast::ScenarioOutline => 'scenario outline' }[feature_element.class] builder.div(:class => css_class) do builder << buffer(:feature_element) end @open_step_list = true end |
#after_features(features) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cucumber/formatter/html.rb', line 22 def after_features(features) stop_buffering :features # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> builder.declare!( :DOCTYPE, :html, :PUBLIC, '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ) builder.html(:xmlns => 'http://www.w3.org/1999/xhtml') do builder.head do builder.(:content => 'text/html;charset=utf-8') builder.title 'Cucumber' inline_css end builder.body do builder.div(:class => 'cucumber') do builder << buffer(:features) builder.div(format_duration(features.duration), :class => 'duration') end end end end |
#after_multiline_arg(multiline_arg) ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/cucumber/formatter/html.rb', line 239 def after_multiline_arg(multiline_arg) stop_buffering :multiline_arg return if @hide_this_step || @skip_step if Ast::Table === multiline_arg builder.table do builder << buffer(:multiline_arg) end else builder << buffer(:multiline_arg) end end |
#after_outline_table(outline_table) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/cucumber/formatter/html.rb', line 152 def after_outline_table(outline_table) stop_buffering :outline_table builder.table do builder << buffer(:outline_table) end @outline_row = nil end |
#after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/cucumber/formatter/html.rb', line 211 def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) stop_buffering :step_result return if @hide_this_step builder.li(:id => @step_id, :class => "step #{status}") do builder << buffer(:step_result) end end |
#after_steps(steps) ⇒ Object
183 184 185 186 187 188 |
# File 'lib/cucumber/formatter/html.rb', line 183 def after_steps(steps) stop_buffering :steps builder.ol do builder << buffer(:steps) end end |
#after_table_row(table_row) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/cucumber/formatter/html.rb', line 264 def after_table_row(table_row) stop_buffering :table_row return if @hide_this_step builder.tr(:id => @row_id) do builder << buffer(:table_row) end if table_row.exception builder.tr do builder.td(:colspan => @col_index.to_s, :class => 'failed') do builder.pre do |pre| pre << format_exception(table_row.exception) end end end end @outline_row += 1 if @outline_row end |
#after_tags(tags) ⇒ Object
75 76 77 |
# File 'lib/cucumber/formatter/html.rb', line 75 def () @tag_spacer = nil end |
#announce(announcement) ⇒ Object
292 293 294 |
# File 'lib/cucumber/formatter/html.rb', line 292 def announce(announcement) builder.pre(announcement, :class => 'announcement') end |
#background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/cucumber/formatter/html.rb', line 112 def background_name(keyword, name, file_colon_line, source_indent) @listing_background = true builder.h3 do |h3| builder.span(keyword, :class => 'keyword') builder.text!(' ') builder.span(name, :class => 'val') end end |
#before_background(background) ⇒ Object
99 100 101 102 |
# File 'lib/cucumber/formatter/html.rb', line 99 def before_background(background) @in_background = true start_buffering :background end |
#before_comment(comment) ⇒ Object
59 60 61 |
# File 'lib/cucumber/formatter/html.rb', line 59 def before_comment(comment) start_buffering :comment end |
#before_examples(examples) ⇒ Object
160 161 162 |
# File 'lib/cucumber/formatter/html.rb', line 160 def before_examples(examples) start_buffering :examples end |
#before_feature(feature) ⇒ Object
47 48 49 50 |
# File 'lib/cucumber/formatter/html.rb', line 47 def before_feature(feature) start_buffering :feature @exceptions = [] end |
#before_feature_element(feature_element) ⇒ Object
121 122 123 |
# File 'lib/cucumber/formatter/html.rb', line 121 def before_feature_element(feature_element) start_buffering :feature_element end |
#before_features(features) ⇒ Object
18 19 20 |
# File 'lib/cucumber/formatter/html.rb', line 18 def before_features(features) start_buffering :features end |
#before_multiline_arg(multiline_arg) ⇒ Object
235 236 237 |
# File 'lib/cucumber/formatter/html.rb', line 235 def before_multiline_arg(multiline_arg) start_buffering :multiline_arg end |
#before_outline_table(outline_table) ⇒ Object
147 148 149 150 |
# File 'lib/cucumber/formatter/html.rb', line 147 def before_outline_table(outline_table) @outline_row = 0 start_buffering :outline_table end |
#before_step(step) ⇒ Object
190 191 192 |
# File 'lib/cucumber/formatter/html.rb', line 190 def before_step(step) @step_id = step.dom_id end |
#before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/cucumber/formatter/html.rb', line 194 def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) start_buffering :step_result @hide_this_step = false if exception if @exceptions.include?(exception) @hide_this_step = true return end @exceptions << exception end if status != :failed && @in_background ^ background @hide_this_step = true return end @status = status end |
#before_steps(steps) ⇒ Object
179 180 181 |
# File 'lib/cucumber/formatter/html.rb', line 179 def before_steps(steps) start_buffering :steps end |
#before_table_row(table_row) ⇒ Object
258 259 260 261 262 |
# File 'lib/cucumber/formatter/html.rb', line 258 def before_table_row(table_row) @row_id = table_row.dom_id @col_index = 0 start_buffering :table_row end |
#comment_line(comment_line) ⇒ Object
70 71 72 73 |
# File 'lib/cucumber/formatter/html.rb', line 70 def comment_line(comment_line) builder.text!(comment_line) builder.br end |
#examples_name(keyword, name) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/cucumber/formatter/html.rb', line 171 def examples_name(keyword, name) builder.h4 do builder.span(keyword, :class => 'keyword') builder.text!(' ') builder.span(name, :class => 'val') end end |
#exception(exception, status) ⇒ Object
230 231 232 233 |
# File 'lib/cucumber/formatter/html.rb', line 230 def exception(exception, status) return if @hide_this_step builder.pre(format_exception(exception), :class => status) end |
#feature_name(name) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cucumber/formatter/html.rb', line 85 def feature_name(name) lines = name.split(/\r?\n/) return if lines.empty? builder.h2 do |h2| builder.span(lines[0], :class => 'val') end builder.p(:class => 'narrative') do lines[1..-1].each do |line| builder.text!(line.strip) builder.br end end end |
#py_string(string) ⇒ Object
251 252 253 254 255 256 |
# File 'lib/cucumber/formatter/html.rb', line 251 def py_string(string) return if @hide_this_step builder.pre(:class => 'val') do |pre| builder << string.gsub("\n", '
') end end |
#scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/cucumber/formatter/html.rb', line 138 def scenario_name(keyword, name, file_colon_line, source_indent) @listing_background = false builder.h3 do builder.span(keyword, :class => 'keyword') builder.text!(' ') builder.span(name, :class => 'val') end end |
#step_name(keyword, step_match, status, source_indent, background) ⇒ Object
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/cucumber/formatter/html.rb', line 219 def step_name(keyword, step_match, status, source_indent, background) @step_matches ||= [] background_in_scenario = background && !@listing_background @skip_step = @step_matches.index(step_match) || background_in_scenario @step_matches << step_match unless @skip_step build_step(keyword, step_match, status) end end |
#table_cell_value(value, status) ⇒ Object
282 283 284 285 286 287 288 289 290 |
# File 'lib/cucumber/formatter/html.rb', line 282 def table_cell_value(value, status) return if @hide_this_step cell_type = @outline_row == 0 ? :th : :td attributes = {:id => "#{@row_id}_#{@col_index}", :class => 'val'} attributes[:class] += " #{status}" if status build_cell(cell_type, value, attributes) @col_index += 1 end |
#tag_name(tag_name) ⇒ Object
79 80 81 82 83 |
# File 'lib/cucumber/formatter/html.rb', line 79 def tag_name(tag_name) builder.text!(@tag_spacer) if @tag_spacer @tag_spacer = ' ' builder.span(tag_name, :class => 'tag') end |