Class: UglyFace::Formatter::Html
- Inherits:
-
Object
- Object
- UglyFace::Formatter::Html
show all
- Includes:
- Cucumber::Formatter::Console, Cucumber::Formatter::Duration, Cucumber::Formatter::Io, ViewHelper
- Defined in:
- lib/ugly_face/formatter/html.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from ViewHelper
#failed_scenario?, #scenario_average_duration, #scenario_count, #scenarios_summary_for, #start_time, #step_average_duration, #step_count, #steps_summary_for, #total_duration
Constructor Details
#initialize(step_mother, path_or_io, options) ⇒ Html
Returns a new instance of Html.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ugly_face/formatter/html.rb', line 27
def initialize(step_mother, path_or_io, options)
@path = path_or_io
set_path_and_file(path_or_io)
@path_to_erb = File.join(File.dirname(__FILE__), '..', 'templates')
@step_mother = step_mother
@options = options
@options[:expand] = false unless @options.nil?
@report = Report.new
@img_id = 0
@logo = 'logo.png'
@delayed_messages = []
end
|
Instance Attribute Details
#logo ⇒ Object
Returns the value of attribute logo.
25
26
27
|
# File 'lib/ugly_face/formatter/html.rb', line 25
def logo
@logo
end
|
#report ⇒ Object
Returns the value of attribute report.
25
26
27
|
# File 'lib/ugly_face/formatter/html.rb', line 25
def report
@report
end
|
Instance Method Details
#after_background(background) ⇒ Object
87
88
89
90
|
# File 'lib/ugly_face/formatter/html.rb', line 87
def after_background(background)
@report.end_background
@report.current_feature.background << ReportStep.new(background)
end
|
#after_feature(feature) ⇒ Object
79
80
81
|
# File 'lib/ugly_face/formatter/html.rb', line 79
def after_feature(feature)
@report.current_feature.close(feature)
end
|
#after_feature_element(feature_element) ⇒ Object
98
99
100
101
102
|
# File 'lib/ugly_face/formatter/html.rb', line 98
def after_feature_element(feature_element)
unless scenario_outline?(feature_element)
process_scenario(feature_element)
end
end
|
#after_features(features) ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/ugly_face/formatter/html.rb', line 128
def after_features(features)
@features = features
@duration = format_duration(Time.now - @tests_started)
copy_images
copy_stylesheets
generate_report
end
|
#after_step(step) ⇒ Object
120
121
122
123
124
125
126
|
# File 'lib/ugly_face/formatter/html.rb', line 120
def after_step(step)
step = process_step(step) unless step_belongs_to_outline? step
if @cells
step.table = @cells
@cells = nil
end
end
|
#after_table_row(example_row) ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/ugly_face/formatter/html.rb', line 108
def after_table_row(example_row)
unless info_row?(example_row)
@report.current_scenario.populate(example_row)
build_scenario_outline_steps(example_row)
end
populate_cells(example_row) if example_row.instance_of? Cucumber::Ast::Table::Cells
end
|
#before_background(background) ⇒ Object
83
84
85
|
# File 'lib/ugly_face/formatter/html.rb', line 83
def before_background(background)
@report.begin_background
end
|
#before_feature(feature) ⇒ Object
75
76
77
|
# File 'lib/ugly_face/formatter/html.rb', line 75
def before_feature(feature)
@report.add_feature ReportFeature.new(feature, features_summary_file)
end
|
#before_feature_element(feature_element) ⇒ Object
92
93
94
95
96
|
# File 'lib/ugly_face/formatter/html.rb', line 92
def before_feature_element(feature_element)
unless scenario_outline? feature_element
@report.add_scenario ReportScenario.new(feature_element)
end
end
|
#before_features(features) ⇒ Object
65
66
67
68
|
# File 'lib/ugly_face/formatter/html.rb', line 65
def before_features(features)
make_output_directories
@tests_started = Time.now
end
|
#before_step(step) ⇒ Object
116
117
118
|
# File 'lib/ugly_face/formatter/html.rb', line 116
def before_step(step)
@step_timer = Time.now
end
|
#before_table_row(example_row) ⇒ Object
104
105
106
|
# File 'lib/ugly_face/formatter/html.rb', line 104
def before_table_row(example_row)
@report.add_scenario ReportScenario.new(example_row) unless info_row?(example_row)
end
|
149
150
151
152
153
154
155
156
|
# File 'lib/ugly_face/formatter/html.rb', line 149
def
return false unless customization_directory
Dir.foreach(customization_directory) do |file|
return true if file == '_feature_header.erb'
end
false
end
|
140
141
142
143
144
145
146
147
|
# File 'lib/ugly_face/formatter/html.rb', line 140
def
return false unless customization_directory
Dir.foreach(customization_directory) do |file|
return true if file == '_suite_header.erb'
end
false
end
|
#embed(src, mime_type, label) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/ugly_face/formatter/html.rb', line 49
def embed(src, mime_type, label)
case(mime_type)
when /^image\/(png|gif|jpg|jpeg)/
embed_image(src, label)
end
end
|
#embed_image(src, label) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/ugly_face/formatter/html.rb', line 56
def embed_image(src, label)
@report.current_scenario.image << src.split(separator).last
@report.current_scenario.image_label << label
@report.current_scenario.image_id << "img_#{@img_id}"
@img_id += 1
filename = "#{File.dirname(@path)}#{separator}images"
FileUtils.cp src, filename
end
|
#features ⇒ Object
136
137
138
|
# File 'lib/ugly_face/formatter/html.rb', line 136
def features
@report.features
end
|
#features_summary_file ⇒ Object
70
71
72
73
|
# File 'lib/ugly_face/formatter/html.rb', line 70
def features_summary_file
parts = @io.path.split(separator)
parts[parts.length - 1]
end
|
#set_path_and_file(path_or_io) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/ugly_face/formatter/html.rb', line 42
def set_path_and_file(path_or_io)
return if path_or_io.nil?
dir = File.dirname(path_or_io)
FileUtils.mkdir_p dir unless File.directory? dir
@io = ensure_io(path_or_io, 'html')
end
|