rspec-page-regression 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72a4f9ee17017a996fd72fd83a81a9dfeb49d4cb
4
+ data.tar.gz: 0000e7eb2782beb039debe4e6a30a89f7134c95f
5
+ SHA512:
6
+ metadata.gz: 37300c7d8d06f07905aecf5ca5030d2b07fc549ccb6408e1908827ad5e58b9e368357216a1cc4bee4cb8b596d15726cee81397c2981e6a32c356e3b20b1e0227
7
+ data.tar.gz: 4be3fb7c2998990b62c3736a4cb6c163d83b5dec047f29b0bb8adaf2769fc24c727a0d2f1cef973ec1901e8e3821910e20184dc3cd56650ac1795c47a194c905
data/README.md CHANGED
@@ -1,14 +1,22 @@
1
1
  # rspec-page-regression
2
2
 
3
3
  Rspec-page-regression is an [RSpec](https://github.com/rspec/rspec) plugin
4
- that makes it easy to regression test your web application pages, to make
5
- sure the pages continue to look the way you expect them to look.
4
+ that makes it easy to headlessly regression test your web application pages to make sure the pages continue to look the way you expect them to look, taking into account HTML, CSS, and JavaScript.
5
+
6
+ It provides an RSpec matcher that compares the test snapshot to an expected image, and facilitates management of the images.
7
+
8
+ Rspec-page-regression uses [PhantomJS](http://www.phantomjs.org/) to headlessly render web page snapshots, by virtue of the [Poltergeist](https://github.com/jonleighton/poltergeist) driver for [Capybara](https://github.com/jnicklas/capybara).
9
+
10
+
11
+ [![Gem Version](https://badge.fury.io/rb/rspec-page-regression.png)](http://badge.fury.io/rb/rspec-page-regression)
12
+ [![Build Status](https://secure.travis-ci.org/ronen/rspec-page-regression.png)](http://travis-ci.org/ronen/rspec-page-regression)
13
+ [![Dependency Status](https://gemnasium.com/ronen/rspec-page-regression.png)](https://gemnasium.com/ronen/rspec-page-regression)
6
14
 
7
- [<img src="https://secure.travis-ci.org/ronen/rspec-page-regression.png"/>](http://travis-ci.org/ronen/rspec-page-regression)[<img src="https://gemnasium.com/ronen/rspec-page-regression.png" alt="Dependency Status" />](https://gemnasium.com/ronen/rspec-page-regression)
8
15
 
9
16
  ## Installation
10
17
 
11
- Rspec-page-regression uses [PhantomJS](http://www.phantomjs.org/) to render web page snapshots, by virtue of the [Poltergeist](https://github.com/jnicklas/capybara) driver for [Capybara](https://github.com/jnicklas/capybara). Assuming you have those installed and ready to go...
18
+
19
+ Install PhantomJS as per [PhantomJS: Download and Install](http://phantomjs.org/download.html) and/or [Poltergeist: Installing PhantomJS](https://github.com/jonleighton/poltergeist#installing-phantomjs). There are no other external dependencies (no need for Qt, nor an X server, nor ImageMagick, etc.)
12
20
 
13
21
  In your Gemfile:
14
22
 
@@ -16,17 +24,22 @@ In your Gemfile:
16
24
 
17
25
  And in your spec_helper:
18
26
 
19
- require 'rspec'
27
+ require 'rspec' # or 'rspec/rails' if you're using Rails
20
28
  require 'rspec/page-regression'
29
+
30
+ require 'capybara/rspec'
31
+ require 'capybara/poltergeist'
32
+ Capybara.javascript_driver = :poltergeist
21
33
 
22
- Rspec-page-regression presupposes the convention that your spec files are under a directory named `spec` (checked in to your repo), with a sibling directory `tmp` (.gitignore'd)
34
+ Rspec-page-regression presupposes the convention that your spec files are somwhere under a directory named `spec` (checked in to your repo), which has a sibling directory `tmp` (.gitignore'd)
23
35
 
24
36
  ## Usage
25
37
 
26
38
  Rspec-page-regression provides a matcher that renders the page and compares
27
- the resulting image against an expected image. To use it, you need to enable
28
- Capybara and Poltergeist by specifying `:type => :feature` and `:js => true`:
39
+ the resulting image against an expected image. To use it, you need to enable Capybara and Poltergeist by specifying `:type => :feature` and `:js => true`:
29
40
 
41
+ require 'spec_helper'
42
+
30
43
  describe "my page", :type => :feature, :js => true do
31
44
 
32
45
  before(:each) do
@@ -53,24 +66,24 @@ Notice that the second line gives a command you can copy and paste in order to v
53
66
 
54
67
  It also shows a "difference image" in which each pixel contains the per-channel absolute difference between the test and expected images. That is, the difference images is black everywhere except has some funky colored pixels where the test and expected images differ. To help you locate those, it also has a red bounding box drawn around the region with differences.
55
68
 
56
- ### How do you create expectation images?
69
+ ### How do I create expectation images?
57
70
 
58
- The easiest way to create an expected image is to run the test for the first time and let it fail. You'll then get a failure message like:
71
+ The easiest way to create an expectation image is to run the test for the first time and let it fail. You'll then get a failure message like:
59
72
 
60
73
  Missing expectation image spec/expectation/my_page/popup_help/expected.png
61
74
  $ open tmp/spec/expectation/my_page/popup_help/test.png
62
75
  To create it:
63
76
  $ mkdir -p spec/expectation/my_page/popup_help && cp tmp/spec/expectation/my_page/popup_help/test.png spec/expectation/my_page/popup_help/expected.png
64
77
 
65
- First view the image to make sure it really is what you expect. Then copy and past the last line to install it. (And then of course commit it into your repository.)
78
+ First view the test image to make sure it really is what you expect. Then copy and paste the last line to install it as the expected image. (And then of course commit the expected image into your repository.)
66
79
 
67
- ### How do you update expectation images?
80
+ ### How do I update expectation images?
68
81
 
69
- If you've deliberatly changed something that affects the look of your web page, then your regression test will fail. The "test" image will contain the new look, and the "expected" image will contain the old.
82
+ If you've deliberatly changed something that affects the look of your web page, your regression test will fail. The "test" image will contain the new look, and the "expected" image will contain the old.
70
83
 
71
- Once you've visually checked the test image to make sure it's really what you want, then simply copy the test image over the old expected image. (And then of course commit it it into your repository.)
84
+ Once you've visually checked the test image to make sure it's really what you want, then simply copy the test image over the old expectation image. (And then of course commit it it into your repository.)
72
85
 
73
- The failure message doesn't include a ready-to-copy-and-paste `$ cp` command, but you can copy and past the individual file paths from the "does not match" message. (The reason not to have a ready-to-copy-and-paste command is that in most cases the failure will be real, and it shouldn't be too easy to mindlessly copy and past to make it go away.)
86
+ The failure message doesn't include a ready-to-copy-and-paste `cp` command, but you can copy and paste the individual file paths from the message. (The reason not to have a ready-to-copy-and-paste command is if the failure is real, it shouldn't be too easy to mindlessly copy and paste to make it go away.)
74
87
 
75
88
  ### Where are the expectation images?
76
89
 
@@ -80,18 +93,18 @@ If that default scheme doesn't suit you, you can pass a path to where the expect
80
93
 
81
94
  page.should match_expectation "/path/to/my/file.png"
82
95
 
83
- Everything else will work normally, and the failure messages will refer to your path.
96
+ Everything will work normally, and the failure messages will refer to your path.
84
97
 
85
98
  ## Configuration
86
99
 
87
- The default window size for the renders is 1024 x 768. You can specify another size as `[height, width]` in pixels:
100
+ The default window size for the renders is 1024 x 768 pixels. You can specify another size as `[height, width]` in pixels:
88
101
 
89
102
  # in spec_helper.rb:
90
- RSpec::PageRecression.configure do |config|
103
+ RSpec::PageRegression.configure do |config|
91
104
  config.page_size = [1280, 1024]
92
105
  end
93
106
 
94
- Note that this specifies the size of the browser window viewport; but rspec-page-regression requests a render of the full page, which might extend beyond the window. So the rendered file sizes may be larger than this configuration value.
107
+ Note that this specifies the size of the browser window viewport; but rspec-page-regression requests a render of the full page, which might extend beyond the window. So the rendered file dimensions may be larger than this configuration value.
95
108
 
96
109
 
97
110
  ## Contributing
@@ -104,4 +117,10 @@ Contributions are welcome! As usual, here's the drill:
104
117
  4. Push to the branch (`git push origin my-new-feature`)
105
118
  5. Create new Pull Request
106
119
 
107
- Don't forget to include specs (`rake spec`)! Code coverage should be 100%
120
+ Don't forget to include specs (`rake spec`) to verify your functionality. Code coverage should be 100%
121
+
122
+ ## History
123
+
124
+ Release Notes:
125
+
126
+ * 0.1.2 - Remove existing difference images so they won't be shown in cases where files couldn't be differenced.
@@ -23,6 +23,8 @@ module RSpec::PageRegression
23
23
  private
24
24
 
25
25
  def compare
26
+ @filepaths.difference_image.unlink if @filepaths.difference_image.exist?
27
+
26
28
  return :missing_expected unless @filepaths.expected_image.exist?
27
29
  return :missing_test unless @filepaths.test_image.exist?
28
30
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module PageRegression
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = RSpec::PageRegression::VERSION
9
9
  spec.authors = ["ronen barzel"]
10
10
  spec.email = ["ronen@barzel.org"]
11
- spec.summary = %q{Web page rendering (html, css, and javascript) regression for RSpec}
12
- spec.description = %q{Rspec-page-regression provides a mechanism for regression testing of web page renders in RSpec. It takes into account html, css, and javascript, by virtue of using phantomjs (via the poltergeist gem) to render snapshots. It provides an RSpec matcher that compares the test snapshot to an expected image, and facilitates management of the images.}
11
+ spec.summary = %q{Web page rendering (HTML, CSS, and JavasSript) regression for RSpec}
12
+ spec.description = %q{Rspec-page-regression provides a mechanism for headless regression testing of web page renders in RSpec. It takes into account HTML, CSS, and JavaScript, by virtue of using PhantomJS (via the Poltergeist gem) to render snapshots. It provides an RSpec matcher that compares the test snapshot to an expected image, and facilitates management of the images.}
13
13
  spec.homepage = "https://github.com/ronen/rspec-page-regression"
14
14
  spec.license = "MIT"
15
15
 
@@ -53,6 +53,10 @@ describe "match_expectation" do
53
53
  Then { @error.should_not be_nil }
54
54
  Then { @error.message.should include "Missing test image #{test_path}" }
55
55
  Then { @error.message.should =~ viewer_pattern(expected_path) }
56
+ context "with previously-created difference image" do
57
+ Given { preexisting_difference_image }
58
+ Then { difference_path.should_not be_exist }
59
+ end
56
60
  end
57
61
 
58
62
  context "when expected image is missing" do
@@ -62,6 +66,10 @@ describe "match_expectation" do
62
66
  Then { @error.message.should include "Missing expectation image #{expected_path}" }
63
67
  Then { @error.message.should =~ viewer_pattern(test_path) }
64
68
  Then { @error.message.should include "mkdir -p #{expected_path.dirname} && cp #{test_path} #{expected_path}" }
69
+ context "with previously-created difference image" do
70
+ Given { preexisting_difference_image }
71
+ Then { difference_path.should_not be_exist }
72
+ end
65
73
  end
66
74
 
67
75
  context "when sizes mismatch" do
@@ -71,11 +79,19 @@ describe "match_expectation" do
71
79
  Then { @error.should_not be_nil }
72
80
  Then { @error.message.should include "Test image size 256x167 does not match expectation 512x334" }
73
81
  Then { @error.message.should =~ viewer_pattern(test_path, expected_path) }
82
+ context "with previously-created difference image" do
83
+ Given { preexisting_difference_image }
84
+ Then { difference_path.should_not be_exist }
85
+ end
74
86
  end
75
87
 
76
88
  context "with match argument" do
77
89
  Given { @match_argument = "/this/is/a/test.png" }
78
90
  Then { @error.message.should include "Missing expectation image /this/is/a/test.png" }
91
+ context "with previously-created difference image" do
92
+ Given { preexisting_difference_image }
93
+ Then { difference_path.should_not be_exist }
94
+ end
79
95
  end
80
96
 
81
97
  context "with trivial example description" do
@@ -135,6 +151,9 @@ describe "match_expectation" do
135
151
  FileUtils.cp fixture_image(name), path
136
152
  end
137
153
 
154
+ def create_existing_difference_image
155
+ end
156
+
138
157
  def use_test_image(name)
139
158
  use_fixture_image(name, test_path)
140
159
  end
@@ -143,6 +162,11 @@ describe "match_expectation" do
143
162
  use_fixture_image(name, expected_path)
144
163
  end
145
164
 
165
+ def preexisting_difference_image
166
+ difference_path.dirname.mkpath unless difference_path.dirname.exist?
167
+ FileUtils.touch difference_path
168
+ end
169
+
146
170
  def viewer_pattern(*paths)
147
171
  %r{
148
172
  \b
metadata CHANGED
@@ -1,116 +1,102 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-page-regression
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - ronen barzel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
11
+ date: 2013-09-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: oily_png
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: poltergeist
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: which_works
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: bourne
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: bundler
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,88 +111,78 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: mocha
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rake
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rspec-given
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '>='
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '>='
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: simplecov
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - '>='
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - '>='
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: simplecov-gem-adapter
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - '>='
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - '>='
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0'
206
- description: Rspec-page-regression provides a mechanism for regression testing of
207
- web page renders in RSpec. It takes into account html, css, and javascript, by
208
- virtue of using phantomjs (via the poltergeist gem) to render snapshots. It provides
209
- an RSpec matcher that compares the test snapshot to an expected image, and facilitates
210
- management of the images.
181
+ description: Rspec-page-regression provides a mechanism for headless regression testing
182
+ of web page renders in RSpec. It takes into account HTML, CSS, and JavaScript,
183
+ by virtue of using PhantomJS (via the Poltergeist gem) to render snapshots. It
184
+ provides an RSpec matcher that compares the test snapshot to an expected image,
185
+ and facilitates management of the images.
211
186
  email:
212
187
  - ronen@barzel.org
213
188
  executables: []
@@ -239,28 +214,27 @@ files:
239
214
  homepage: https://github.com/ronen/rspec-page-regression
240
215
  licenses:
241
216
  - MIT
217
+ metadata: {}
242
218
  post_install_message:
243
219
  rdoc_options: []
244
220
  require_paths:
245
221
  - lib
246
222
  required_ruby_version: !ruby/object:Gem::Requirement
247
- none: false
248
223
  requirements:
249
- - - ! '>='
224
+ - - '>='
250
225
  - !ruby/object:Gem::Version
251
226
  version: '0'
252
227
  required_rubygems_version: !ruby/object:Gem::Requirement
253
- none: false
254
228
  requirements:
255
- - - ! '>='
229
+ - - '>='
256
230
  - !ruby/object:Gem::Version
257
231
  version: '0'
258
232
  requirements: []
259
233
  rubyforge_project:
260
- rubygems_version: 1.8.24
234
+ rubygems_version: 2.0.3
261
235
  signing_key:
262
- specification_version: 3
263
- summary: Web page rendering (html, css, and javascript) regression for RSpec
236
+ specification_version: 4
237
+ summary: Web page rendering (HTML, CSS, and JavasSript) regression for RSpec
264
238
  test_files:
265
239
  - spec/fixtures/A.png
266
240
  - spec/fixtures/ABdiff.png
@@ -270,4 +244,3 @@ test_files:
270
244
  - spec/spec_helper.rb
271
245
  - spec/support/helpers.rb
272
246
  - spec/support/matchers.rb
273
- has_rdoc: