pretty_face 0.1

Sign up to get free protection for your applications and to get access to all the features.
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,24 @@
1
+ begin
2
+ require 'builder'
3
+ rescue LoadError
4
+ gem 'builder'
5
+ require 'builder'
6
+ end
7
+
8
+ module Cucumber
9
+ module Formatter
10
+ # Emits attributes ordered alphabetically, so that we can predicatbly test output.
11
+ class OrderedXmlMarkup < Builder::XmlMarkup #:nodoc:
12
+ def _insert_attributes(attrs, order=[])
13
+ return if attrs.nil?
14
+ keys = attrs.keys.map{|k| k.to_s}
15
+ keys.sort!
16
+ keys.reverse! if (attrs.keys - [:version, :encoding] == []) #HACK to ensure the 'version' attribute is first in xml declaration.
17
+ keys.each do |k|
18
+ v = attrs[k.to_sym] || attrs[k]
19
+ @target << %{ #{k}="#{_attr_value(v)}"} if v
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module Cucumber
2
+ module Formatter
3
+ module Summary
4
+
5
+ def scenario_summary(step_mother, &block)
6
+ scenarios_proc = lambda{|status| step_mother.scenarios(status)}
7
+ dump_count(step_mother.scenarios.length, "scenario") + dump_status_counts(scenarios_proc, &block)
8
+ end
9
+
10
+ def step_summary(step_mother, &block)
11
+ steps_proc = lambda{|status| step_mother.steps(status)}
12
+ dump_count(step_mother.steps.length, "step") + dump_status_counts(steps_proc, &block)
13
+ end
14
+
15
+ private
16
+
17
+ def dump_status_counts(find_elements_proc)
18
+ counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status|
19
+ elements = find_elements_proc.call(status)
20
+ elements.any? ? yield("#{elements.length} #{status.to_s}", status) : nil
21
+ end.compact
22
+ if counts.any?
23
+ " (#{counts.join(', ')})"
24
+ else
25
+ ""
26
+ end
27
+ end
28
+
29
+ def dump_count(count, what, state=nil)
30
+ [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ")
31
+ end
32
+
33
+ end
34
+ end
35
+ end
Binary file
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+ require 'cucumber/ast/step'
3
+
4
+ describe PrettyFace::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
+ formatter.before_features(nil)
13
+ formatter.start_time.should eq Time.now.strftime("%a %B %-d, %Y at %H:%M:%S")
14
+ end
15
+
16
+ it "should know how long it takes" do
17
+ formatter.should_receive(:generate_report)
18
+ formatter.should_receive(:copy_images_directory)
19
+ formatter.before_features(nil)
20
+
21
+ formatter.after_features(nil)
22
+ formatter.total_duration.should include '0.0'
23
+ end
24
+ end
25
+
26
+ context "when building the report for scenarios" do
27
+ it "should track number of scenarios" do
28
+ step_mother.should_receive(:scenarios).and_return([1,2,3])
29
+ formatter.scenario_count.should eq 3
30
+ end
31
+
32
+ it "should track average scenario durations" do
33
+ feature = stub('feature')
34
+ parameter.stub(:status).and_return(:passed)
35
+ formatter.before_feature(feature)
36
+ formatter.before_feature_element(nil)
37
+ formatter.after_feature_element(parameter)
38
+ formatter.before_feature_element(nil)
39
+ formatter.after_feature_element(parameter)
40
+
41
+ formatter.scenario_average_duration.should include '0.0'
42
+ end
43
+
44
+ it "should keep track of passing scenarios" do
45
+ step_mother.should_receive(:scenarios).with(:passed).and_return([1,2])
46
+ step_mother.should_receive(:scenarios).and_return([1,2])
47
+ formatter.scenarios_summary_for(:passed).should == "2 (100.0%)"
48
+ end
49
+
50
+ it "should keep track of failing scenarios" do
51
+ step_mother.should_receive(:scenarios).with(:failed).and_return([1,2])
52
+ step_mother.should_receive(:scenarios).and_return([1,2])
53
+ formatter.scenarios_summary_for(:failed).should == "2 (100.0%)"
54
+ end
55
+
56
+ it "should keep track of pending scenarios" do
57
+ step_mother.should_receive(:scenarios).with(:pending).and_return([1,2])
58
+ step_mother.should_receive(:scenarios).and_return([1,2])
59
+ formatter.scenarios_summary_for(:pending).should == "2 (100.0%)"
60
+ end
61
+
62
+ it "should keep track of undefined scenarios" do
63
+ step_mother.should_receive(:scenarios).with(:undefined).and_return([1,2])
64
+ step_mother.should_receive(:scenarios).and_return([1,2])
65
+ formatter.scenarios_summary_for(:undefined).should == "2 (100.0%)"
66
+ end
67
+
68
+ it "should keep track of skipped scenarios" do
69
+ step_mother.should_receive(:scenarios).with(:skipped).and_return([1,2])
70
+ step_mother.should_receive(:scenarios).and_return([1,2])
71
+ formatter.scenarios_summary_for(:skipped).should == "2 (100.0%)"
72
+ end
73
+ end
74
+
75
+ context "when building the report for steps" do
76
+ it "should track number of steps" do
77
+ step_mother.should_receive(:steps).and_return([1,2])
78
+ formatter.step_count.should == 2
79
+ end
80
+
81
+ it "should keep track of passing steps" do
82
+ step_mother.should_receive(:steps).with(:passed).and_return([1,2])
83
+ step_mother.should_receive(:steps).and_return([1,2])
84
+ formatter.steps_summary_for(:passed).should == "2 (100.0%)"
85
+ end
86
+
87
+ it "should keep track of failing steps" do
88
+ step_mother.should_receive(:steps).with(:failed).and_return([1,2])
89
+ step_mother.should_receive(:steps).and_return([1,2])
90
+ formatter.steps_summary_for(:failed).should == "2 (100.0%)"
91
+ end
92
+
93
+ it "should keep track of skipped steps" do
94
+ step_mother.should_receive(:steps).with(:skipped).and_return([1,2])
95
+ step_mother.should_receive(:steps).and_return([1,2])
96
+ formatter.steps_summary_for(:skipped).should == "2 (100.0%)"
97
+ end
98
+
99
+ it "should keep track of pending steps" do
100
+ step_mother.should_receive(:steps).with(:pending).and_return([1,2])
101
+ step_mother.should_receive(:steps).and_return([1,2])
102
+ formatter.steps_summary_for(:pending).should == "2 (100.0%)"
103
+ end
104
+
105
+ it "should keep track of undefined steps" do
106
+ step_mother.should_receive(:steps).with(:undefined).and_return([1,2])
107
+ step_mother.should_receive(:steps).and_return([1,2])
108
+ formatter.steps_summary_for(:undefined).should == "2 (100.0%)"
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,5 @@
1
+ require 'pretty_face'
2
+
3
+ include PrettyFace
4
+ include PrettyFace::Formatter
5
+
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty_face
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeffrey S. Morgan
9
+ - Joel Byler
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-11-17 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: cucumber
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: aruba
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: cucumber
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: HTML Report/Formatter for cucumber that allows user to modify erb in
80
+ order to customize.
81
+ email:
82
+ - jeff.morgan@leandog.com
83
+ - joelbyler@gmail.com
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - .rspec
90
+ - .travis.yml
91
+ - ChangeLog
92
+ - Gemfile
93
+ - Guardfile
94
+ - README.md
95
+ - Rakefile
96
+ - cucumber.yml
97
+ - features/pretty_face_report.feature
98
+ - features/support/env.rb
99
+ - features/support/hooks.rb
100
+ - fixtures/advanced.feature
101
+ - fixtures/basic.feature
102
+ - fixtures/step_definitions/advanced_steps.rb
103
+ - fixtures/step_definitions/basic_steps.rb
104
+ - fixtures/support/env.rb
105
+ - lib/pretty_face.rb
106
+ - lib/pretty_face/formatter/html.rb
107
+ - lib/pretty_face/formatter/report.rb
108
+ - lib/pretty_face/formatter/view_helper.rb
109
+ - lib/pretty_face/templates/face.jpg
110
+ - lib/pretty_face/templates/failed.jpg
111
+ - lib/pretty_face/templates/main.erb
112
+ - lib/pretty_face/templates/passed.jpg
113
+ - lib/pretty_face/templates/pending.jpg
114
+ - lib/pretty_face/templates/skipped.jpg
115
+ - lib/pretty_face/templates/undefined.jpg
116
+ - lib/pretty_face/version.rb
117
+ - pretty_face.gemspec
118
+ - sample_report/LisaCrispin1.png
119
+ - sample_report/LisaCrispin2.png
120
+ - sample_report/blue_s.jpeg
121
+ - sample_report/green_bar.jpeg
122
+ - sample_report/green_check.jpg
123
+ - sample_report/red_bar.gif
124
+ - sample_report/red_x.jpg
125
+ - sample_report/sample_report.html
126
+ - sample_report/some_code/gherkin_formatter_adapter.rb
127
+ - sample_report/some_code/html.rb
128
+ - sample_report/some_code/ordered_xml_markup.rb
129
+ - sample_report/some_code/summary.rb
130
+ - sample_report/yellow_o.jpg
131
+ - spec/lib/html_formatter_spec.rb
132
+ - spec/spec_helper.rb
133
+ homepage: http://github.com/cheezy/pretty_face
134
+ licenses: []
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ segments:
146
+ - 0
147
+ hash: -2027867954849647701
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
155
+ - 0
156
+ hash: -2027867954849647701
157
+ requirements: []
158
+ rubyforge_project: pretty_face
159
+ rubygems_version: 1.8.24
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: HTML Report/Formatter for Cucumber and RSpec
163
+ test_files:
164
+ - features/pretty_face_report.feature
165
+ - features/support/env.rb
166
+ - features/support/hooks.rb
167
+ - spec/lib/html_formatter_spec.rb
168
+ - spec/spec_helper.rb