ugly_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 (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/ChangeLog +2 -0
  4. data/Gemfile +13 -0
  5. data/Guardfile +19 -0
  6. data/LICENSE +21 -0
  7. data/README.md +25 -0
  8. data/Rakefile +19 -0
  9. data/autotrader.png +0 -0
  10. data/cucumber.yml +4 -0
  11. data/features/feature_pages.feature +110 -0
  12. data/features/pretty_face_report.feature +81 -0
  13. data/features/step_definitions/report_steps.rb +36 -0
  14. data/features/support/_feature_header.erb +2 -0
  15. data/features/support/_suite_header.erb +2 -0
  16. data/features/support/env.rb +20 -0
  17. data/features/support/error_display.rb +16 -0
  18. data/features/support/hooks.rb +11 -0
  19. data/features/support/logo.png +0 -0
  20. data/fixtures/advanced.feature +57 -0
  21. data/fixtures/background.feature +10 -0
  22. data/fixtures/basic.feature +20 -0
  23. data/fixtures/failing_background.feature +7 -0
  24. data/fixtures/more/more.feature +8 -0
  25. data/fixtures/onemore/deep/more.feature +8 -0
  26. data/fixtures/onemore/more.feature +8 -0
  27. data/fixtures/step_definitions/advanced_steps.rb +34 -0
  28. data/fixtures/step_definitions/basic_steps.rb +25 -0
  29. data/fixtures/support/env.rb +3 -0
  30. data/lib/.DS_Store +0 -0
  31. data/lib/ugly_face/.DS_Store +0 -0
  32. data/lib/ugly_face/formatter/html.rb +289 -0
  33. data/lib/ugly_face/formatter/report.rb +285 -0
  34. data/lib/ugly_face/formatter/view_helper.rb +61 -0
  35. data/lib/ugly_face/templates/_main_header.erb +1 -0
  36. data/lib/ugly_face/templates/_page_header.erb +2 -0
  37. data/lib/ugly_face/templates/_step.erb +39 -0
  38. data/lib/ugly_face/templates/debug.png +0 -0
  39. data/lib/ugly_face/templates/failed.png +0 -0
  40. data/lib/ugly_face/templates/feature.erb +143 -0
  41. data/lib/ugly_face/templates/logo.png +0 -0
  42. data/lib/ugly_face/templates/main.erb +162 -0
  43. data/lib/ugly_face/templates/passed.png +0 -0
  44. data/lib/ugly_face/templates/pending.png +0 -0
  45. data/lib/ugly_face/templates/screenshot.png +0 -0
  46. data/lib/ugly_face/templates/skipped.png +0 -0
  47. data/lib/ugly_face/templates/style.css +346 -0
  48. data/lib/ugly_face/templates/table_failed.png +0 -0
  49. data/lib/ugly_face/templates/table_passed.png +0 -0
  50. data/lib/ugly_face/templates/table_pending.png +0 -0
  51. data/lib/ugly_face/templates/table_skipped.png +0 -0
  52. data/lib/ugly_face/templates/table_undefined.png +0 -0
  53. data/lib/ugly_face/templates/undefined.png +0 -0
  54. data/lib/ugly_face/version.rb +3 -0
  55. data/lib/ugly_face.rb +45 -0
  56. data/spec/lib/customization_spec.rb +23 -0
  57. data/spec/lib/html_formatter_spec.rb +140 -0
  58. data/spec/spec_helper.rb +5 -0
  59. data/ugly_face.gemspec +29 -0
  60. metadata +199 -0
data/lib/ugly_face.rb ADDED
@@ -0,0 +1,45 @@
1
+ require "ugly_face/version"
2
+ require "ugly_face/formatter/html"
3
+
4
+ module UglyFace
5
+ @index = 0
6
+ @scenario_msgs = Hash.new
7
+ @msg_storage = Array.new
8
+ @cli_output=''
9
+ @html_output=''
10
+
11
+ def self.add_msg(key='', msg='')
12
+ @scenario_msgs[:"#{key}"] = msg
13
+ end
14
+
15
+ def self.process_scenario
16
+ raw_output=''
17
+ @scenario_msgs.each { |key, value| raw_output << "+#{key}:+ #{value}+" }
18
+ raw_output= raw_output.gsub("+ ++","++")
19
+ @cli_output= raw_output.gsub("+","\n")
20
+ @html_output= raw_output.gsub("+","<br />")
21
+ @msg_storage.push(@html_output)
22
+ $stdout.puts @cli_output unless ENV['DEBUG']== 'FALSE'
23
+ end
24
+
25
+ def self.reset
26
+ @scenario_msgs= {}
27
+ @cli_output= ''
28
+ @html_output= ''
29
+ end
30
+
31
+ def self.pop_scenario
32
+ @msg_storage.at(@index)
33
+ @index+=1
34
+ end
35
+
36
+ def self.formatted_cli
37
+ @cli_output
38
+ end
39
+
40
+ def self.formatted_html
41
+ @html_output
42
+ end
43
+
44
+
45
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ module UglyFace::Formatter
4
+ class Html
5
+ def customization_directory
6
+ nil
7
+ end
8
+ end
9
+ end
10
+
11
+ describe UglyFace::Formatter::Html do
12
+ let(:formatter) { Html.new(nil, nil, nil) }
13
+
14
+ context "when not customizing the report" do
15
+ it "indicates that there are no custom components" do
16
+ expect(formatter.custom_suite_header?).to be false
17
+ expect(formatter.custom_feature_header?).to be false
18
+ expect(formatter.send(:logo_file)).to be nil
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,140 @@
1
+ require 'spec_helper'
2
+ require 'cucumber/core/ast/step'
3
+
4
+ describe UglyFace::Formatter::Html do
5
+ let(:step_mother) { double('step_mother') }
6
+ let(:formatter) { Html.new(step_mother, nil, nil) }
7
+ let(:parameter) { double('parameter') }
8
+ let(:step) { Cucumber::Ast::Step.new(1, 'Given', 'A cucumber Step') }
9
+
10
+ context "when building the header for the main page" do
11
+ it "should know the start time" do
12
+ allow(formatter).to receive(:make_output_directories)
13
+ formatter.before_features(nil)
14
+ expect(formatter.start_time).to eql Time.now.strftime("%a %B %-d, %Y at %H:%M:%S")
15
+ end
16
+
17
+ it "should know how long it takes" do
18
+ expect(formatter).to receive(:generate_report)
19
+ expect(formatter).to receive(:copy_images)
20
+ expect(formatter).to receive(:copy_stylesheets)
21
+ allow(formatter).to receive(:make_output_directories)
22
+ formatter.before_features(nil)
23
+
24
+ formatter.after_features(nil)
25
+ expect(formatter.total_duration).to include '0.0'
26
+ end
27
+ end
28
+
29
+ context "when building the report for scenarios" do
30
+ it "should track number of scenarios" do
31
+ expect(step_mother).to receive(:scenarios).and_return([1,2,3])
32
+ expect(formatter.scenario_count).to eql 3
33
+ end
34
+
35
+ it "should keep track of passing scenarios" do
36
+ expect(step_mother).to receive(:scenarios).with(:passed).and_return([1,2])
37
+ expect(step_mother).to receive(:scenarios).and_return([1,2])
38
+ expect(formatter.scenarios_summary_for(:passed)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
39
+ end
40
+
41
+ it "should keep track of failing scenarios" do
42
+ expect(step_mother).to receive(:scenarios).with(:failed).and_return([1,2])
43
+ expect(step_mother).to receive(:scenarios).and_return([1,2])
44
+ expect(formatter.scenarios_summary_for(:failed)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
45
+ end
46
+
47
+ it "should keep track of pending scenarios" do
48
+ expect(step_mother).to receive(:scenarios).with(:pending).and_return([1,2])
49
+ expect(step_mother).to receive(:scenarios).and_return([1,2])
50
+ expect(formatter.scenarios_summary_for(:pending)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
51
+ end
52
+
53
+ it "should keep track of undefined scenarios" do
54
+ expect(step_mother).to receive(:scenarios).with(:undefined).and_return([1,2])
55
+ expect(step_mother).to receive(:scenarios).and_return([1,2])
56
+ expect(formatter.scenarios_summary_for(:undefined)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
57
+ end
58
+
59
+ it "should keep track of skipped scenarios" do
60
+ expect(step_mother).to receive(:scenarios).with(:skipped).and_return([1,2])
61
+ expect(step_mother).to receive(:scenarios).and_return([1,2])
62
+ expect(formatter.scenarios_summary_for(:skipped)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
63
+ end
64
+ end
65
+
66
+ context "when building the report for steps" do
67
+ it "should track number of steps" do
68
+ expect(step_mother).to receive(:steps).and_return([1,2])
69
+ expect(formatter.step_count).to eql 2
70
+ end
71
+
72
+ it "should keep track of passing steps" do
73
+ expect(step_mother).to receive(:steps).with(:passed).and_return([1,2])
74
+ expect(step_mother).to receive(:steps).and_return([1,2])
75
+ expect(formatter.steps_summary_for(:passed)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
76
+ end
77
+
78
+ it "should keep track of failing steps" do
79
+ expect(step_mother).to receive(:steps).with(:failed).and_return([1,2])
80
+ expect(step_mother).to receive(:steps).and_return([1,2])
81
+ expect(formatter.steps_summary_for(:failed)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
82
+ end
83
+
84
+ it "should keep track of skipped steps" do
85
+ expect(step_mother).to receive(:steps).with(:skipped).and_return([1,2])
86
+ expect(step_mother).to receive(:steps).and_return([1,2])
87
+ expect(formatter.steps_summary_for(:skipped)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
88
+ end
89
+
90
+ it "should keep track of pending steps" do
91
+ expect(step_mother).to receive(:steps).with(:pending).and_return([1,2])
92
+ expect(step_mother).to receive(:steps).and_return([1,2])
93
+ expect(formatter.steps_summary_for(:pending)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
94
+ end
95
+
96
+ it "should keep track of undefined steps" do
97
+ expect(step_mother).to receive(:steps).with(:undefined).and_return([1,2])
98
+ expect(step_mother).to receive(:steps).and_return([1,2])
99
+ expect(formatter.steps_summary_for(:undefined)).to eql "2 <span class=\"percentage\">(100.0%)</span>"
100
+ end
101
+ end
102
+
103
+ context "when embedding an image" do
104
+ before(:each) do
105
+ cuke_feature = double('cuke_feature')
106
+ expect(cuke_feature).to receive(:description)
107
+ report_feature = ReportFeature.new(cuke_feature, 'foo')
108
+ formatter.report.features << report_feature
109
+ @scenario = ReportScenario.new(nil)
110
+ formatter.report.current_feature.scenarios << @scenario
111
+ allow(File).to receive(:dirname).and_return('')
112
+ allow(FileUtils).to receive(:cp)
113
+ end
114
+
115
+ it "should generate an id" do
116
+ formatter.embed('image.png', 'image/png', 'the label')
117
+ expect(@scenario.image_id).to include 'img_0'
118
+ end
119
+
120
+ it "should get the filename from the src" do
121
+ formatter.embed('directory/image.png', 'image/png', 'the label')
122
+ expect(@scenario.image).to include 'image.png'
123
+ end
124
+
125
+ it "should get the image label" do
126
+ formatter.embed('directory/image.png', 'image/png', 'the label')
127
+ expect(@scenario.image_label).to include 'the label'
128
+ end
129
+
130
+ it "scenario should know if it has an image" do
131
+ formatter.embed('directory/image.png', 'image/png', 'the label')
132
+ expect(@scenario).to have_image
133
+ end
134
+
135
+ it "should copy the image to the output directory" do
136
+ expect(FileUtils).to receive(:cp).with('directory/image.png', '/images')
137
+ formatter.embed('directory/image.png', 'image/png', 'the label')
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,5 @@
1
+ require 'ugly_face'
2
+
3
+ include UglyFace
4
+ include UglyFace::Formatter
5
+
data/ugly_face.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ugly_face/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ugly_face"
7
+ s.version = UglyFace::VERSION
8
+ s.license = 'MIT'
9
+ s.authors = ["Justin Commmu", "Jeffrey S. Morgan"]
10
+ s.email = ["jcommu@gmail.com", "jeff.morgan@leandog.com"]
11
+ s.homepage = "http://github.com/tk8817/ugly_face"
12
+ s.summary = %q{A customized version of PrettyFace with new features (debug data, screenshot section, ENV var readouts)}
13
+ s.description = %q{A customized version of PrettyFace with new features (debug data, screenshot section, ENV var readouts)}
14
+
15
+ s.rubyforge_project = "ugly_face"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features,fixtures}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency "actionpack", ">= 3.2.13"
23
+ s.add_dependency "syntax"
24
+
25
+ s.add_development_dependency "rspec"
26
+ s.add_development_dependency "aruba"
27
+
28
+ s.add_runtime_dependency "cucumber", ">= 0", ">= 0"
29
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ugly_face
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Justin Commmu
8
+ - Jeffrey S. Morgan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-11-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 3.2.13
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 3.2.13
28
+ - !ruby/object:Gem::Dependency
29
+ name: syntax
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: aruba
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: cucumber
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: A customized version of PrettyFace with new features (debug data, screenshot
85
+ section, ENV var readouts)
86
+ email:
87
+ - jcommu@gmail.com
88
+ - jeff.morgan@leandog.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ChangeLog
95
+ - Gemfile
96
+ - Guardfile
97
+ - LICENSE
98
+ - README.md
99
+ - Rakefile
100
+ - autotrader.png
101
+ - cucumber.yml
102
+ - features/feature_pages.feature
103
+ - features/pretty_face_report.feature
104
+ - features/step_definitions/report_steps.rb
105
+ - features/support/_feature_header.erb
106
+ - features/support/_suite_header.erb
107
+ - features/support/env.rb
108
+ - features/support/error_display.rb
109
+ - features/support/hooks.rb
110
+ - features/support/logo.png
111
+ - fixtures/advanced.feature
112
+ - fixtures/background.feature
113
+ - fixtures/basic.feature
114
+ - fixtures/failing_background.feature
115
+ - fixtures/more/more.feature
116
+ - fixtures/onemore/deep/more.feature
117
+ - fixtures/onemore/more.feature
118
+ - fixtures/step_definitions/advanced_steps.rb
119
+ - fixtures/step_definitions/basic_steps.rb
120
+ - fixtures/support/env.rb
121
+ - lib/.DS_Store
122
+ - lib/ugly_face.rb
123
+ - lib/ugly_face/.DS_Store
124
+ - lib/ugly_face/formatter/html.rb
125
+ - lib/ugly_face/formatter/report.rb
126
+ - lib/ugly_face/formatter/view_helper.rb
127
+ - lib/ugly_face/templates/_main_header.erb
128
+ - lib/ugly_face/templates/_page_header.erb
129
+ - lib/ugly_face/templates/_step.erb
130
+ - lib/ugly_face/templates/debug.png
131
+ - lib/ugly_face/templates/failed.png
132
+ - lib/ugly_face/templates/feature.erb
133
+ - lib/ugly_face/templates/logo.png
134
+ - lib/ugly_face/templates/main.erb
135
+ - lib/ugly_face/templates/passed.png
136
+ - lib/ugly_face/templates/pending.png
137
+ - lib/ugly_face/templates/screenshot.png
138
+ - lib/ugly_face/templates/skipped.png
139
+ - lib/ugly_face/templates/style.css
140
+ - lib/ugly_face/templates/table_failed.png
141
+ - lib/ugly_face/templates/table_passed.png
142
+ - lib/ugly_face/templates/table_pending.png
143
+ - lib/ugly_face/templates/table_skipped.png
144
+ - lib/ugly_face/templates/table_undefined.png
145
+ - lib/ugly_face/templates/undefined.png
146
+ - lib/ugly_face/version.rb
147
+ - spec/lib/customization_spec.rb
148
+ - spec/lib/html_formatter_spec.rb
149
+ - spec/spec_helper.rb
150
+ - ugly_face.gemspec
151
+ homepage: http://github.com/tk8817/ugly_face
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project: ugly_face
171
+ rubygems_version: 2.2.5
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: A customized version of PrettyFace with new features (debug data, screenshot
175
+ section, ENV var readouts)
176
+ test_files:
177
+ - features/feature_pages.feature
178
+ - features/pretty_face_report.feature
179
+ - features/step_definitions/report_steps.rb
180
+ - features/support/_feature_header.erb
181
+ - features/support/_suite_header.erb
182
+ - features/support/env.rb
183
+ - features/support/error_display.rb
184
+ - features/support/hooks.rb
185
+ - features/support/logo.png
186
+ - fixtures/advanced.feature
187
+ - fixtures/background.feature
188
+ - fixtures/basic.feature
189
+ - fixtures/failing_background.feature
190
+ - fixtures/more/more.feature
191
+ - fixtures/onemore/deep/more.feature
192
+ - fixtures/onemore/more.feature
193
+ - fixtures/step_definitions/advanced_steps.rb
194
+ - fixtures/step_definitions/basic_steps.rb
195
+ - fixtures/support/env.rb
196
+ - spec/lib/customization_spec.rb
197
+ - spec/lib/html_formatter_spec.rb
198
+ - spec/spec_helper.rb
199
+ has_rdoc: