Class: Cucumber::Formatter::Html
Instance Attribute Summary
Attributes inherited from Ast::Visitor
#options, #step_mother
Instance Method Summary
collapse
-
#announce(announcement) ⇒ Object
-
#initialize(step_mother, io, options) ⇒ Html
constructor
-
#visit_background(background) ⇒ Object
-
#visit_background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
-
#visit_examples_name(keyword, name) ⇒ Object
-
#visit_exception(exception, status) ⇒ Object
-
#visit_feature(feature) ⇒ Object
-
#visit_feature_element(feature_element) ⇒ Object
-
#visit_feature_name(name) ⇒ Object
-
#visit_features(features) ⇒ Object
-
#visit_multiline_arg(multiline_arg) ⇒ Object
-
#visit_outline_table(outline_table) ⇒ Object
-
#visit_py_string(string) ⇒ Object
-
#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
-
#visit_step(step) ⇒ Object
-
#visit_step_name(keyword, step_match, status, source_indent, background) ⇒ Object
-
#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
-
#visit_steps(steps) ⇒ Object
-
#visit_table_cell_value(value, width, status) ⇒ Object
-
#visit_table_row(table_row) ⇒ Object
#matches_scenario_names?, #visit_comment, #visit_comment_line, #visit_examples, #visit_table_cell, #visit_tag_name, #visit_tags
Constructor Details
#initialize(step_mother, io, options) ⇒ Html
Returns a new instance of Html.
14
15
16
17
|
# File 'lib/cucumber/formatter/html.rb', line 14
def initialize(step_mother, io, options)
super(step_mother)
@builder = Builder::XmlMarkup.new(:target => io, :indent => 2)
end
|
Instance Method Details
#announce(announcement) ⇒ Object
169
170
171
|
# File 'lib/cucumber/formatter/html.rb', line 169
def announce(announcement)
@builder.pre(announcement, :class => 'announcement')
end
|
#visit_background(background) ⇒ Object
58
59
60
61
62
|
# File 'lib/cucumber/formatter/html.rb', line 58
def visit_background(background)
@builder.div(:class => 'background') do
super
end
end
|
#visit_background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
64
65
66
|
# File 'lib/cucumber/formatter/html.rb', line 64
def visit_background_name(keyword, name, file_colon_line, source_indent)
@builder.h3("#{keyword} #{name}")
end
|
#visit_examples_name(keyword, name) ⇒ Object
87
88
89
|
# File 'lib/cucumber/formatter/html.rb', line 87
def visit_examples_name(keyword, name)
@builder.h4("#{keyword} #{name}")
end
|
#visit_exception(exception, status) ⇒ Object
122
123
124
|
# File 'lib/cucumber/formatter/html.rb', line 122
def visit_exception(exception, status)
@builder.pre(format_exception(exception), :class => status)
end
|
#visit_feature(feature) ⇒ Object
41
42
43
44
45
|
# File 'lib/cucumber/formatter/html.rb', line 41
def visit_feature(feature)
@builder.div(:class => 'feature') do
super
end
end
|
#visit_feature_element(feature_element) ⇒ Object
68
69
70
71
72
73
|
# File 'lib/cucumber/formatter/html.rb', line 68
def visit_feature_element(feature_element)
@builder.div(:class => 'scenario') do
super
end
@open_step_list = true
end
|
#visit_feature_name(name) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cucumber/formatter/html.rb', line 47
def visit_feature_name(name)
lines = name.split(/\r?\n/)
@builder.h2(lines[0])
@builder.p do
lines[1..-1].each do |line|
@builder.text!(line.strip)
@builder.br
end
end
end
|
#visit_features(features) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cucumber/formatter/html.rb', line 19
def visit_features(features)
@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.title 'Cucumber'
inline_css
end
@builder.body do
@builder.div(:class => 'cucumber') do
super
end
end
end
end
|
#visit_multiline_arg(multiline_arg) ⇒ Object
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/cucumber/formatter/html.rb', line 126
def visit_multiline_arg(multiline_arg)
return if @skip_step
if Ast::Table === multiline_arg
@builder.table do
super
end
else
super
end
end
|
#visit_outline_table(outline_table) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/cucumber/formatter/html.rb', line 79
def visit_outline_table(outline_table)
@outline_row = 0
@builder.table do
super(outline_table)
end
@outline_row = nil
end
|
#visit_py_string(string) ⇒ Object
137
138
139
140
141
|
# File 'lib/cucumber/formatter/html.rb', line 137
def visit_py_string(string)
@builder.pre(:class => @status) do |pre|
pre << string
end
end
|
#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
75
76
77
|
# File 'lib/cucumber/formatter/html.rb', line 75
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
@builder.h3("#{keyword} #{name}")
end
|
#visit_step(step) ⇒ Object
97
98
99
100
|
# File 'lib/cucumber/formatter/html.rb', line 97
def visit_step(step)
@step_id = step.dom_id
super
end
|
#visit_step_name(keyword, step_match, status, source_indent, background) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/cucumber/formatter/html.rb', line 109
def visit_step_name(keyword, step_match, status, source_indent, background)
@step_matches ||= []
@skip_step = @step_matches.index(step_match)
@step_matches << step_match
unless @skip_step
step_name = step_match.format_args(lambda{|param| "<span>#{param}</span>"})
@builder.div do |div|
div << h("#{keyword} #{step_name}")
end
end
end
|
#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/cucumber/formatter/html.rb', line 102
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
@status = status
@builder.li(:id => @step_id, :class => status) do
super(keyword, step_match, multiline_arg, status, exception, source_indent, background)
end
end
|
#visit_steps(steps) ⇒ Object
91
92
93
94
95
|
# File 'lib/cucumber/formatter/html.rb', line 91
def visit_steps(steps)
@builder.ol do
super
end
end
|
#visit_table_cell_value(value, width, status) ⇒ Object
161
162
163
164
165
166
167
|
# File 'lib/cucumber/formatter/html.rb', line 161
def visit_table_cell_value(value, width, status)
cell_type = @outline_row == 0 ? :th : :td
attributes = {:id => "#{@row_id}_#{@col_index}"}
attributes[:class] = status if status
@builder.__send__(cell_type, value, attributes)
@col_index += 1
end
|
#visit_table_row(table_row) ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/cucumber/formatter/html.rb', line 143
def visit_table_row(table_row)
@row_id = table_row.dom_id
@col_index = 0
@builder.tr(:id => @row_id) do
super
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
|