pretty_face 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3-p392@testgen --create
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
- === Release 0.2
1
+ === Release 0.3 / 2013-3-9
2
+ * Allow users to provide replacement logo for report
3
+ * Allow users to provide replacement header for top level page
4
+ * Allow users to provide replacement header for feature pages
5
+
6
+ === Release 0.2 / 2013-2-23
2
7
  * Creating a page for each feature file
3
8
  * Displaying Background
4
9
  * Displaying Errors on feature pages
@@ -17,7 +17,6 @@ Feature: pages that show details for features
17
17
 
18
18
  Scenario: Including an image / logo
19
19
  Then the file "results/basic.html" should contain "<img src="
20
- And the file "results/basic.html" should contain "images/face.jpg"
21
20
 
22
21
  Scenario: It should show start time and duration in the header
23
22
  Then the file "results/basic.html" should contain "Feature started:"
@@ -47,9 +46,8 @@ Feature: pages that show details for features
47
46
  And the file "results/advanced.html" should contain "I am using a scenario outline"
48
47
 
49
48
  Scenario: It should display the step and data for scenario outline steps
50
- I use &#x27;aaa&#x27;\
51
- Then the file "results/advanced.html" should contain "I use &#x27;aaa&#x27;"
52
- And the file "results/advanced.html" should contain "I use &#x27;bbb&#x27;"
49
+ Then the file "results/advanced.html" should contain "I use aaa"
50
+ And the file "results/advanced.html" should contain "I use bbb"
53
51
 
54
52
  Scenario: It should display descriptions for features
55
53
  Then the file "results/basic.html" should contain "As a stakeholder"
@@ -91,4 +89,9 @@ Feature: pages that show details for features
91
89
  Then the following files should exist:
92
90
  | results/more/more.html |
93
91
 
94
-
92
+ Scenario: It should replace the header for the feature pages
93
+ When I have a feature header partial in the correct location
94
+ And I run `cucumber fixtures --profile fixture`
95
+ Then the file "results/basic.html" should contain "The Code Monkeys"
96
+ And the file "results/basic.html" should contain "Test Results"
97
+ And I should remove the feature header partial file
@@ -26,7 +26,6 @@ Feature: pretty face report
26
26
 
27
27
  Scenario: Including an image / logo
28
28
  Then the file "results/fixture.html" should contain "<img src="
29
- And the file "results/fixture.html" should contain "images/face.jpg"
30
29
 
31
30
  Scenario: It should copy the style sheet to the stylesheets directory
32
31
  Then the following files should exist:
@@ -66,4 +65,16 @@ Feature: pretty face report
66
65
  Then the file "results/fixture.html" should contain "| aaa | bbb |"
67
66
  And the file "results/fixture.html" should contain "| ccc | ddd |"
68
67
 
68
+ Scenario: It should replace the logo image on the top level page
69
+ When I have a logo file in the correct location
70
+ And I run `cucumber fixtures --profile fixture`
71
+ Then the file "results/fixture.html" should contain "img src='images/logo.png'"
72
+ And I should remove the logo file
73
+
74
+ Scenario: It should replace the header for the main page of the report
75
+ When I have a suite header partial in the correct location
76
+ And I run `cucumber fixtures --profile fixture`
77
+ Then the file "results/fixture.html" should contain "The Code Monkeys"
78
+ And the file "results/fixture.html" should contain "Test Results"
79
+ And I should remove the suite header partial file
69
80
 
@@ -0,0 +1,25 @@
1
+ require 'fileutils'
2
+
3
+ When /^I have a logo file in the correct location$/ do
4
+ FileUtils.cp "features/support/logo.png", "features/support/pretty_face/"
5
+ end
6
+
7
+ Then /^I should remove the logo file$/ do
8
+ FileUtils.rm "features/support/pretty_face/logo.png"
9
+ end
10
+
11
+ When /^I have a suite header partial in the correct location$/ do
12
+ FileUtils.cp "features/support/_suite_header.erb", "features/support/pretty_face"
13
+ end
14
+
15
+ Then /^I should remove the suite header partial file$/ do
16
+ FileUtils.rm "features/support/pretty_face/_suite_header.erb"
17
+ end
18
+
19
+ When /^I have a feature header partial in the correct location$/ do
20
+ FileUtils.cp "features/support/_feature_header.erb", "features/support/pretty_face"
21
+ end
22
+
23
+ Then /^I should remove the feature header partial file$/ do
24
+ FileUtils.rm "features/support/pretty_face/_feature_header.erb"
25
+ end
@@ -0,0 +1,2 @@
1
+ <h1>The Code Monkeys</h1>
2
+ <h2>Test Results</h2>
@@ -0,0 +1,2 @@
1
+ <h1>The Code Monkeys</h1>
2
+ <h2>Test Results</h2>
Binary file
File without changes
@@ -16,7 +16,7 @@ module PrettyFace
16
16
  include Cucumber::Formatter::Duration
17
17
  include ViewHelper
18
18
 
19
- attr_reader :report
19
+ attr_reader :report, :logo
20
20
 
21
21
  def initialize(step_mother, path_or_io, options)
22
22
  @path = path_or_io
@@ -26,6 +26,7 @@ module PrettyFace
26
26
  @options = options
27
27
  @report = Report.new
28
28
  @img_id = 0
29
+ @logo = 'face.jpg'
29
30
  end
30
31
 
31
32
  def embed(src, mime_type, label)
@@ -109,35 +110,51 @@ module PrettyFace
109
110
  def after_features(features)
110
111
  @features = features
111
112
  @duration = format_duration(Time.now - @tests_started)
113
+ copy_images
114
+ copy_stylesheets
112
115
  generate_report
113
- copy_images_directory
114
- copy_stylesheets_directory
115
116
  end
116
117
 
117
118
  def features
118
119
  @report.features
119
120
  end
120
121
 
122
+ def custom_suite_header?
123
+ Dir.foreach(customization_directory) do |file|
124
+ return true if file == '_suite_header.erb'
125
+ end
126
+ false
127
+ end
128
+
129
+ def custom_feature_header?
130
+ Dir.foreach(customization_directory) do |file|
131
+ return true if file == '_feature_header.erb'
132
+ end
133
+ false
134
+ end
135
+
121
136
  private
122
137
 
123
138
  def generate_report
124
- renderer = ActionView::Base.new(@path_to_erb)
139
+ paths = [@path_to_erb, customization_directory.to_s]
140
+ renderer = ActionView::Base.new(paths)
125
141
  filename = File.join(@path_to_erb, 'main')
126
- @io.puts renderer.render(:file => filename, :locals => {:report => self})
142
+ @io.puts renderer.render(:file => filename, :locals => {:report => self, :logo => @logo})
127
143
  features.each do |feature|
128
144
  write_feature_file(feature)
129
145
  end
130
146
  end
131
147
 
132
148
  def write_feature_file(feature)
133
- renderer = ActionView::Base.new(@path_to_erb)
149
+ paths = [@path_to_erb, customization_directory.to_s]
150
+ renderer = ActionView::Base.new(paths)
134
151
  filename = File.join(@path_to_erb, 'feature')
135
152
  output_file = "#{File.dirname(@path)}/#{feature.file}"
136
153
  to_cut = output_file.split('/').last
137
154
  directory = output_file.sub("/#{to_cut}", '')
138
155
  FileUtils.mkdir directory unless File.directory? directory
139
156
  file = File.new(output_file, Cucumber.file_mode('w'))
140
- file.puts renderer.render(:file => filename, :locals => {:feature => feature})
157
+ file.puts renderer.render(:file => filename, :locals => {:feature => feature, :logo => @logo, :customize => custom_feature_header?})
141
158
  file.flush
142
159
  file.close
143
160
  end
@@ -155,19 +172,40 @@ module PrettyFace
155
172
  def copy_directory(dir, file_names, file_extension)
156
173
  path = "#{File.dirname(@path)}/#{dir}"
157
174
  file_names.each do |file|
158
- FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', "#{file}.#{file_extension}"), path
175
+ copy_file File.join(File.dirname(__FILE__), '..', 'templates', "#{file}.#{file_extension}"), path
159
176
  end
160
177
  end
161
178
 
162
- def copy_images_directory
163
- copy_directory 'images', ['face'], 'jpg'
179
+ def copy_file(source, destination)
180
+ FileUtils.cp source, destination
181
+ end
182
+
183
+ def copy_images
164
184
  copy_directory 'images', %w(failed passed pending undefined skipped), "png"
185
+ logo = logo_file
186
+ copy_file logo, "#{File.join(File.dirname(@path), 'images')}" if logo
187
+ copy_directory 'images', ['face'], 'jpg' unless logo
165
188
  end
166
189
 
167
- def copy_stylesheets_directory
190
+ def copy_stylesheets
168
191
  copy_directory 'stylesheets', ['style'], 'css'
169
192
  end
170
193
 
194
+ def logo_file
195
+ dir = customization_directory
196
+ Dir.foreach(dir) do |file|
197
+ if file =~ /^logo\.(png|gif|jpg|jpeg)$/
198
+ @logo = file
199
+ return File.join(dir, file)
200
+ end
201
+ end if dir
202
+ end
203
+
204
+ def customization_directory
205
+ dir = File.join(File.expand_path('features'), 'support', 'pretty_face')
206
+ return dir if File.exists? dir
207
+ end
208
+
171
209
  def process_scenario(scenario)
172
210
  @report.current_scenario.populate(scenario)
173
211
  end
@@ -0,0 +1 @@
1
+ <h2 class="results">Test Results</h2>
@@ -0,0 +1,2 @@
1
+ <h2 class="results">Feature Results: <%= feature.title %></h2>
2
+ <br />
@@ -9,12 +9,15 @@
9
9
  <body>
10
10
 
11
11
  <div style="float: left;">
12
- <img src="<%= feature.directory_prefix_for(feature.file) %>images/face.jpg" width="200" />
12
+ <img src="<%= feature.directory_prefix_for(feature.file) %>images/<%= logo %>" width="200" />
13
13
  </div>
14
14
  <div style="float: left;">
15
15
  <a href="<%= feature.parent_filename %>">Back</a>
16
- <h2 class="results">Feature Results: <%= feature.title %></h2>
17
- <br />
16
+ <% if customize %>
17
+ <%= render "feature_header" %>
18
+ <% else %>
19
+ <%= render "page_header", :feature => feature %>
20
+ <% end %>
18
21
  <span>Feature started: <%= feature.start_time.strftime("%a %B %-d, %Y at %H:%M:%S") %></span>
19
22
  <br />
20
23
  <span>Duration: <%= feature.formatted_duration(feature.duration) %></span>
@@ -8,10 +8,14 @@
8
8
 
9
9
  <body>
10
10
  <div style="float: left;">
11
- <img src="images/face.jpg" width="200" />
11
+ <img src='images/<%= logo %>' width="200" />
12
12
  </div>
13
13
  <div style="float: left;">
14
- <h2 class="results">Test Results</h2>
14
+ <% if report.custom_suite_header? %>
15
+ <%= render "suite_header" %>
16
+ <% else %>
17
+ <%= render "main_header" %>
18
+ <% end %>
15
19
  <span>Tests started: <%= report.start_time %></span>
16
20
  <br />
17
21
  <span>Duration: <%= report.total_duration %></span>
@@ -1,3 +1,3 @@
1
1
  module PrettyFace
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
data/pretty_face.gemspec CHANGED
@@ -5,7 +5,7 @@ require "pretty_face/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "pretty_face"
7
7
  s.version = PrettyFace::VERSION
8
- s.authors = ["Jeffrey S. Morgan", "Joel Byler"]
8
+ s.authors = ["Jeffrey S. Morgan", "Joel Byler", "Steve Jackson"]
9
9
  s.email = ["jeff.morgan@leandog.com", "joelbyler@gmail.com", "steve.jackson@leandogsoftware.com"]
10
10
  s.homepage = "http://github.com/cheezy/pretty_face"
11
11
  s.summary = %q{HTML Report/Formatter for Cucumber and RSpec}
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency "actionpack", ">= 3.2.11"
21
+ s.add_dependency "actionpack"
22
22
 
23
23
  s.add_development_dependency "cucumber"
24
24
  s.add_development_dependency "rspec"
@@ -16,8 +16,8 @@ describe PrettyFace::Formatter::Html do
16
16
 
17
17
  it "should know how long it takes" do
18
18
  formatter.should_receive(:generate_report)
19
- formatter.should_receive(:copy_images_directory)
20
- formatter.should_receive(:copy_stylesheets_directory)
19
+ formatter.should_receive(:copy_images)
20
+ formatter.should_receive(:copy_stylesheets)
21
21
  formatter.stub(:make_output_directories)
22
22
  formatter.before_features(nil)
23
23
 
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_face
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeffrey S. Morgan
9
9
  - Joel Byler
10
+ - Steve Jackson
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-02-23 00:00:00.000000000 Z
14
+ date: 2013-03-09 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: actionpack
@@ -19,7 +20,7 @@ dependencies:
19
20
  requirements:
20
21
  - - ! '>='
21
22
  - !ruby/object:Gem::Version
22
- version: 3.2.11
23
+ version: '0'
23
24
  type: :runtime
24
25
  prerelease: false
25
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +28,7 @@ dependencies:
27
28
  requirements:
28
29
  - - ! '>='
29
30
  - !ruby/object:Gem::Version
30
- version: 3.2.11
31
+ version: '0'
31
32
  - !ruby/object:Gem::Dependency
32
33
  name: cucumber
33
34
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +105,7 @@ extra_rdoc_files: []
104
105
  files:
105
106
  - .gitignore
106
107
  - .rspec
108
+ - .rvmrc
107
109
  - .travis.yml
108
110
  - ChangeLog
109
111
  - Gemfile
@@ -114,8 +116,13 @@ files:
114
116
  - cucumber.yml
115
117
  - features/feature_pages.feature
116
118
  - features/pretty_face_report.feature
119
+ - features/step_definitions/report_steps.rb
120
+ - features/support/_feature_header.erb
121
+ - features/support/_suite_header.erb
117
122
  - features/support/env.rb
118
123
  - features/support/hooks.rb
124
+ - features/support/logo.png
125
+ - features/support/pretty_face/blah.txt
119
126
  - fixtures/advanced.feature
120
127
  - fixtures/background.feature
121
128
  - fixtures/basic.feature
@@ -128,6 +135,8 @@ files:
128
135
  - lib/pretty_face/formatter/html.rb
129
136
  - lib/pretty_face/formatter/report.rb
130
137
  - lib/pretty_face/formatter/view_helper.rb
138
+ - lib/pretty_face/templates/_main_header.erb
139
+ - lib/pretty_face/templates/_page_header.erb
131
140
  - lib/pretty_face/templates/_step.erb
132
141
  - lib/pretty_face/templates/face.jpg
133
142
  - lib/pretty_face/templates/failed.jpg
@@ -174,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
183
  version: '0'
175
184
  segments:
176
185
  - 0
177
- hash: -4205723903375013439
186
+ hash: -2360201377690045592
178
187
  required_rubygems_version: !ruby/object:Gem::Requirement
179
188
  none: false
180
189
  requirements:
@@ -183,17 +192,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
192
  version: '0'
184
193
  segments:
185
194
  - 0
186
- hash: -4205723903375013439
195
+ hash: -2360201377690045592
187
196
  requirements: []
188
197
  rubyforge_project: pretty_face
189
- rubygems_version: 1.8.24
198
+ rubygems_version: 1.8.25
190
199
  signing_key:
191
200
  specification_version: 3
192
201
  summary: HTML Report/Formatter for Cucumber and RSpec
193
202
  test_files:
194
203
  - features/feature_pages.feature
195
204
  - features/pretty_face_report.feature
205
+ - features/step_definitions/report_steps.rb
206
+ - features/support/_feature_header.erb
207
+ - features/support/_suite_header.erb
196
208
  - features/support/env.rb
197
209
  - features/support/hooks.rb
210
+ - features/support/logo.png
211
+ - features/support/pretty_face/blah.txt
198
212
  - spec/lib/html_formatter_spec.rb
199
213
  - spec/spec_helper.rb