pretty_face 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +5 -0
  4. data/ChangeLog +2 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +17 -0
  7. data/README.md +21 -0
  8. data/Rakefile +18 -0
  9. data/cucumber.yml +3 -0
  10. data/features/pretty_face_report.feature +63 -0
  11. data/features/support/env.rb +9 -0
  12. data/features/support/hooks.rb +6 -0
  13. data/fixtures/advanced.feature +14 -0
  14. data/fixtures/basic.feature +17 -0
  15. data/fixtures/step_definitions/advanced_steps.rb +12 -0
  16. data/fixtures/step_definitions/basic_steps.rb +19 -0
  17. data/fixtures/support/env.rb +3 -0
  18. data/lib/pretty_face.rb +6 -0
  19. data/lib/pretty_face/formatter/html.rb +140 -0
  20. data/lib/pretty_face/formatter/report.rb +68 -0
  21. data/lib/pretty_face/formatter/view_helper.rb +60 -0
  22. data/lib/pretty_face/templates/face.jpg +0 -0
  23. data/lib/pretty_face/templates/failed.jpg +0 -0
  24. data/lib/pretty_face/templates/main.erb +194 -0
  25. data/lib/pretty_face/templates/passed.jpg +0 -0
  26. data/lib/pretty_face/templates/pending.jpg +0 -0
  27. data/lib/pretty_face/templates/skipped.jpg +0 -0
  28. data/lib/pretty_face/templates/undefined.jpg +0 -0
  29. data/lib/pretty_face/version.rb +3 -0
  30. data/pretty_face.gemspec +26 -0
  31. data/sample_report/LisaCrispin1.png +0 -0
  32. data/sample_report/LisaCrispin2.png +0 -0
  33. data/sample_report/blue_s.jpeg +0 -0
  34. data/sample_report/green_bar.jpeg +0 -0
  35. data/sample_report/green_check.jpg +0 -0
  36. data/sample_report/red_bar.gif +0 -0
  37. data/sample_report/red_x.jpg +0 -0
  38. data/sample_report/sample_report.html +167 -0
  39. data/sample_report/some_code/gherkin_formatter_adapter.rb +87 -0
  40. data/sample_report/some_code/html.rb +655 -0
  41. data/sample_report/some_code/ordered_xml_markup.rb +24 -0
  42. data/sample_report/some_code/summary.rb +35 -0
  43. data/sample_report/yellow_o.jpg +0 -0
  44. data/spec/lib/html_formatter_spec.rb +111 -0
  45. data/spec/spec_helper.rb +5 -0
  46. metadata +168 -0
@@ -0,0 +1,60 @@
1
+ require 'cucumber/ast/scenario_outline'
2
+
3
+ module PrettyFace
4
+ module Formatter
5
+ module ViewHelper
6
+
7
+ def start_time
8
+ @tests_started.strftime("%a %B %-d, %Y at %H:%M:%S")
9
+ end
10
+
11
+ def step_count
12
+ @step_mother.steps.length
13
+ end
14
+
15
+ def scenario_count
16
+ @step_mother.scenarios.length
17
+ end
18
+
19
+ def total_duration
20
+ @duration
21
+ end
22
+
23
+ def step_average_duration
24
+ format_duration get_average_from_float_array @step_times
25
+ end
26
+
27
+ def scenario_average_duration
28
+ format_duration get_average_from_float_array @scenario_times
29
+ end
30
+
31
+ def scenarios_summary_for(status)
32
+ summary_percent(@step_mother.scenarios(status).length, scenario_count)
33
+ end
34
+
35
+ def steps_summary_for(status)
36
+ summary_percent(@step_mother.steps(status).length, step_count)
37
+ end
38
+
39
+ def failed_scenario?(scenario)
40
+ scenario.status == :failed
41
+ end
42
+
43
+ def image_tag_for(scenario)
44
+ status = scenario.status.to_s
45
+ "<img src=\"images/#{status}.jpg\" alt=\"#{status}\" title=\"#{status}\" width=\"30\""
46
+ end
47
+
48
+ private
49
+
50
+ def get_average_from_float_array (arr)
51
+ arr.reduce(:+).to_f / arr.size
52
+ end
53
+
54
+ def summary_percent(number, total)
55
+ percent = (number.to_f / total) * 100
56
+ "#{number} (#{'%.1f' % percent}%)"
57
+ end
58
+ end
59
+ end
60
+ end
Binary file
@@ -0,0 +1,194 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <style type='text/css'>
5
+ /* TODO: lets move this to an external .css file */
6
+ body {
7
+ font-family: GeosansLightRegular,Arial,Helvetica,sans-serif;
8
+ font-size: 1em;
9
+ }
10
+ a, a:visited {
11
+ color: #4B7CAB;
12
+ }
13
+ div {
14
+ padding: 5px;
15
+ }
16
+
17
+ h2 {
18
+ margin: 0;
19
+ }
20
+
21
+ .summary_body {
22
+ width: 99%;
23
+ margin-top: 15px;
24
+ float: left;
25
+ -moz-border-radius: 15px;
26
+ border-radius: 15px;
27
+ background-color: #E0E0E0;
28
+ }
29
+ .summary_row_header {
30
+ text-align: left;
31
+ font-size: 1em;
32
+ font-weight: bold;
33
+ }
34
+ .summary td {
35
+ font-size: .8em;
36
+ text-align: center;
37
+ width: 150px;
38
+ }
39
+ .summary td:first-child {
40
+ font-size: inherit;
41
+ text-align: inherit;
42
+ width: inherit;
43
+ }
44
+
45
+ .failed td {
46
+ font-size: .8em;
47
+ }
48
+
49
+ .footer {
50
+ width: 100%;
51
+ background-color: #4B7CAB;
52
+ float: left;
53
+ margin-left: -7px;
54
+ margin-top: 25px;
55
+ font-family: Verdana;
56
+ font-size: 0.8em;
57
+ color: white
58
+ }
59
+ h2.failures {
60
+ color: #A00000;
61
+ margin-top: 15px;
62
+ margin-left: 5px;
63
+ }
64
+ h2.scenarios {
65
+ color: #4B7CAB;
66
+ margin-top: 15px;
67
+ margin-left: 5px;
68
+ }
69
+ h2.results {
70
+ color: #282828;
71
+ margin-top: 12px;
72
+ margin-bottom: 15px;
73
+ }
74
+ h2.summary {
75
+ color: white;
76
+ margin-left: 5px;
77
+ margin-top: 5px;
78
+ }
79
+
80
+ .feature_title {
81
+ background-color: #F0F0F0;
82
+ font-size: 0.9em;
83
+ }
84
+ </style>
85
+
86
+ <title>Test Results</title>
87
+ </head>
88
+
89
+ <body>
90
+ <div style="float: left;">
91
+ <img src="images/face.jpg" width="200" />
92
+ </div>
93
+ <div style="float: left;">
94
+ <h2 class="results">Test Results</h2>
95
+ <span>Tests started: <%= start_time %></span>
96
+ <br />
97
+ <span>Duration: <%= total_duration %></span>
98
+ </div>
99
+
100
+ <div class="summary_body">
101
+ <h2 class="summary">Summary</h2>
102
+
103
+ <table cellspacing="0" cellpadding="7" class="summary">
104
+ <tr>
105
+ <th></th>
106
+ <th>Executed</th>
107
+ <th>Passed</th>
108
+ <th>Failed</th>
109
+ <th>Skipped</th>
110
+ <th>Undefined</th>
111
+ <th>Pending</th>
112
+ <th>Average<br/>Duration</th>
113
+ </tr>
114
+ <tr>
115
+ <td class="summary_row_header">Scenarios</td>
116
+ <td><%= scenario_count %></td>
117
+ <td><%= scenarios_summary_for :passed %></td>
118
+ <td><%= scenarios_summary_for :failed %></td>
119
+ <td><%= scenarios_summary_for :skipped %></td>
120
+ <td><%= scenarios_summary_for :undefined %></td>
121
+ <td><%= scenarios_summary_for :pending %></td>
122
+ <td><%= scenario_average_duration %></td>
123
+ </tr>
124
+ <tr>
125
+ <td class="summary_row_header">Steps</td>
126
+ <td><%= step_count %></td>
127
+ <td><%= steps_summary_for :passed %></td>
128
+ <td><%= steps_summary_for :failed %></td>
129
+ <td><%= steps_summary_for :skipped %></td>
130
+ <td><%= steps_summary_for :undefined %></td>
131
+ <td><%= steps_summary_for :pending %></td>
132
+ <td><%= step_average_duration %></td>
133
+ </tr>
134
+ </table>
135
+ </div>
136
+
137
+ <div style="width: 100%; float: left;">
138
+ <br />
139
+ <h2 class="failures">Tests With Failures:</h2>
140
+ <br />
141
+ <table cellspacing="0" cellpadding="7" border="0" class="failed">
142
+ <tr style="background-color: #E0E0E0;">
143
+ <th></th>
144
+ <th style="text-align: left;">Feature</th>
145
+ <th style="text-align: left;">Scenario</th>
146
+ <th style="text-align: left;">File</th>
147
+ </tr>
148
+ <% features.each do |feature| %>
149
+ <% feature.scenarios.each do |scenario| %>
150
+ <% if failed_scenario? scenario %>
151
+ <tr>
152
+ <td><img src="images/failed.jpg" width="30"/></td>
153
+ <td><%= feature.title %> </td>
154
+ <td><%= scenario.name %></td>
155
+ <td style="color: gray;"><%= scenario.file_colon_line %></td>
156
+ </tr>
157
+ <% end %>
158
+ <% end %>
159
+ <% end %>
160
+ </table>
161
+
162
+ <br />
163
+ <h2 class="scenarios">Scenario Overview:</h2>
164
+ <br />
165
+
166
+ <table cellspacing="0" cellpadding="7" border="0" class="failed">
167
+ <tr style="background-color: #E0E0E0;">
168
+ <th style="text-align: left;">Result</th>
169
+ <th style="text-align: left;">Name</th>
170
+ <th style="text-align: left;">File</th>
171
+ <th style="text-align: left;"># Steps</th>
172
+ </tr>
173
+ <% features.each do |feature| %>
174
+ <tr>
175
+ <td class="feature_title" colspan="4">Feature: <%= feature.title %></td>
176
+ </tr>
177
+ <% feature.scenarios.each do |scenario| %>
178
+ <tr>
179
+ <td><%= image_tag_for scenario %></td>
180
+ <td><%= scenario.name %></td>
181
+ <td style="color: gray;"><%= scenario.file_colon_line %></td>
182
+ <td><%= scenario.steps.length %></td>
183
+ </tr>
184
+ <% end %>
185
+ <% end %>
186
+ </table>
187
+ </div>
188
+
189
+ <div class="footer">
190
+ Generated by PrettyFace
191
+ </div>
192
+
193
+ </body>
194
+ </html>
@@ -0,0 +1,3 @@
1
+ module PrettyFace
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "pretty_face/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pretty_face"
7
+ s.version = PrettyFace::VERSION
8
+ s.authors = ["Jeffrey S. Morgan", "Joel Byler"]
9
+ s.email = ["jeff.morgan@leandog.com", "joelbyler@gmail.com"]
10
+ s.homepage = "http://github.com/cheezy/pretty_face"
11
+ s.summary = %q{HTML Report/Formatter for Cucumber and RSpec}
12
+ s.description = %q{HTML Report/Formatter for cucumber that allows user to modify erb in order to customize.}
13
+
14
+ s.rubyforge_project = "pretty_face"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "cucumber"
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "aruba"
24
+
25
+ s.add_runtime_dependency "cucumber"
26
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,167 @@
1
+ <html>
2
+ <head>
3
+ <style type="text/css">
4
+
5
+ a, a:visited {
6
+ color: #4B7CAB;
7
+ }
8
+
9
+ div {
10
+ padding: 5px;
11
+ }
12
+
13
+ h2 {
14
+ margin: 0;
15
+ }
16
+
17
+ .summary td {
18
+ font-size: .8em;
19
+ text-align: center;
20
+ width: 150px;
21
+ }
22
+
23
+ .failed td {
24
+ font-size: .8em;
25
+ }
26
+ </style>
27
+
28
+ </head>
29
+ <body style="font-family: GeosansLightRegular,Arial,Helvetica,sans-serif; font-size: .8em">
30
+ <div style="float: left;"><img src="dogs.png" width="200" /></div>
31
+ <div style="float: left;">
32
+ <h2 style="color: #282828; margin-top: 12px; margin-bottom: 15px;">Project Name Test Results</h2>
33
+ <span>Tests started: Wed August 7, 2012 at 3:26:18 PM</span>
34
+ <br />
35
+ <span>Duration: 45 minutes, 26 seconds</span>
36
+ </div>
37
+ <div style="float: right;">
38
+ <input type="text" value="Search by feature or scenario" style="width: 250px; color: gray;" />
39
+ </div>
40
+
41
+ <br />
42
+ <div style="width: 99%; margin-top: 15px; float: left; -moz-border-radius: 15px; border-radius: 15px; background-color: #E0E0E0">
43
+ <h2 style="color: white; margin-left: 5px; margin-top: 5px;">Summary</h2>
44
+
45
+ <table cellspacing="0" cellpadding="7" class="summary">
46
+ <tr>
47
+ <th></th>
48
+ <th>Executed</th>
49
+ <th><a href="">Passed</a></th>
50
+ <th><a href="">Failed</a></th>
51
+ <th><a href="">Skipped</a></th>
52
+ <th><a href="">Undefined</a></th>
53
+ <th><a href="">Pending</a></th>
54
+ <th>Average<br /> Duration</th>
55
+ </tr>
56
+ <tr>
57
+ <td style="text-align: left; font-size: 1em; font-weight: bold">Scenarios</td>
58
+ <td>112</td>
59
+ <td>100 (89%)</td>
60
+ <td>12 (11%)</td>
61
+ <td>0 (0%)</td>
62
+ <td>0 (0%)</td>
63
+ <td>0 (0%)</td>
64
+ <td>00:00:24</td>
65
+ </tr>
66
+ <tr>
67
+ <td style="text-align: left; font-size: 1em; font-weight: bold">Steps</td>
68
+ <td>580</td>
69
+ <td>565 (97%)</td>
70
+ <td>15 (3%)</td>
71
+ <td>0 (0%)</td>
72
+ <td>0 (0%)</td>
73
+ <td>0 (0%)</td>
74
+ <td>00:00:05</td>
75
+ </tr>
76
+ </table>
77
+ </div>
78
+
79
+ <div style="width: 100%; float: left;">
80
+ <br />
81
+ <h2 style="color: #A00000; margin-top: 15px; margin-left: 5px;">Tests With Failures:</h2>
82
+ <br />
83
+ <table cellspacing="0" cellpadding="7" border="0" class="failed">
84
+ <tr>
85
+ <th></th>
86
+ <th style="text-align: left;">Feature</th>
87
+ <th style="text-align: left;">Scenario</th>
88
+ <th style="text-align: left;">File</th>
89
+ </tr>
90
+ <tr>
91
+ <td><img src="red_x.jpg" width="30"/></td>
92
+ <td>Adopting Puppies</td>
93
+ <td><a href=".">Thank you message should be displayed when adoption is complete</a></td>
94
+ <td style="color: gray;">/projects/pretty_face/features/adopting_puppies.feature</td>
95
+ </tr>
96
+ <tr>
97
+ <td><img src="red_x.jpg" width="30"/></td>
98
+ <td>Adopting Puppies</td>
99
+ <td><a href=".">First name is a required field</a></td>
100
+ <td style="color: gray;">/projects/pretty_face/features/adopting_puppies.feature</td>
101
+ </tr>
102
+ <tr>
103
+ <td><img src="red_x.jpg" width="30"/></td>
104
+ <td>Adopting Kittens</td>
105
+ <td><a href=".">First name is a required field</a></td>
106
+ <td style="color: gray;">/projects/pretty_face/features/adopting_kittens.feature</td>
107
+ </tr>
108
+ <tr>
109
+ <td><img src="red_x.jpg" width="30"/></td>
110
+ <td>Adopting Hamsters</td>
111
+ <td><a href=".">First name is a required field</a></td>
112
+ <td style="color: gray;">/projects/pretty_face/features/adopting_hamsters.feature</td>
113
+ </tr>
114
+ <tr>
115
+ <td><img src="red_x.jpg" width="30"/></td>
116
+ <td>Adopting Ponies</td>
117
+ <td><a href=".">First name is a required field</a></td>
118
+ <td style="color: gray;">/projects/pretty_face/features/adopting_ponies.feature</td>
119
+ </tr>
120
+ <tr>
121
+ <td><img src="red_x.jpg" width="30"/></td>
122
+ <td>Adopting Frogs</td>
123
+ <td><a href=".">First name is a required field</a></td>
124
+ <td style="color: gray;">/projects/pretty_face/features/adopting_frogs.feature</td>
125
+ </tr>
126
+ <tr>
127
+ <td><img src="red_x.jpg" width="30"/></td>
128
+ <td>Adopting Monkeys</td>
129
+ <td><a href=".">First name is a required field</a></td>
130
+ <td style="color: gray;">/projects/pretty_face/features/adopting_monkeys.feature</td>
131
+ </tr>
132
+ <tr>
133
+ <td><img src="red_x.jpg" width="30"/></td>
134
+ <td>Adopting Zebras</td>
135
+ <td><a href=".">First name is a required field</a></td>
136
+ <td style="color: gray;">/projects/pretty_face/features/adopting_zebras.feature</td>
137
+ </tr>
138
+ <tr>
139
+ <td><img src="red_x.jpg" width="30"/></td>
140
+ <td>Adopting Hippos</td>
141
+ <td><a href=".">First name is a required field</a></td>
142
+ <td style="color: gray;">/projects/pretty_face/features/adopting_hippos.feature</td>
143
+ </tr>
144
+ <tr>
145
+ <td><img src="red_x.jpg" width="30"/></td>
146
+ <td>Adopting Giraffes</td>
147
+ <td><a href=".">First name is a required field</a></td>
148
+ <td style="color: gray;">/projects/pretty_face/features/adopting_giraffes.feature</td>
149
+ </tr>
150
+ <tr>
151
+ <td><img src="red_x.jpg" width="30"/></td>
152
+ <td>Adopting Elephants</td>
153
+ <td><a href=".">First name is a required field</a></td>
154
+ <td style="color: gray;">/projects/pretty_face/features/adopting_elephants.feature</td>
155
+ </tr>
156
+ <tr>
157
+ <td><img src="red_x.jpg" width="30"/></td>
158
+ <td>Adopting Lions</td>
159
+ <td><a href=".">First name is a required field</a></td>
160
+ <td style="color: gray;">/projects/pretty_face/features/adopting_lions.feature</td>
161
+ </tr>
162
+ </table>
163
+ </div>
164
+
165
+ <div style="width: 100%; background-color: #4B7CAB; float: left; margin-left: -7px; margin-top: 25px; font-family: Verdana; color: white">Generated by PrettyFace</div>
166
+ </body>
167
+ </html>