rspec-page-regression 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +33 -6
- data/lib/rspec/page-regression/renderer.rb +7 -2
- data/lib/rspec/page-regression/version.rb +1 -1
- data/spec/match_expectation_spec.rb +18 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aaa9ac40a80fe376a23c570527ba53ad4183094
|
4
|
+
data.tar.gz: 18c9dd86aec2148f9d6fcfecbf22f74f486a18d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4f2fbf0f6ca04d2e02a2461e312b40c1de1b504748b15c1dc8f20987e40d78795e48265b176293a3c95f6c5465a16571075d5ad4ea1745c17dad8ca5bbd593a
|
7
|
+
data.tar.gz: 59b55a99a7e5f688f7e637628800b40bb72c083af60c9379224172dffb1df05323837930513143a2acad8e44dba1a908d0688fb04ea704fec46aa70d3eb4a70d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rspec-page-regression.png)](http://badge.fury.io/rb/rspec-page-regression)
|
3
|
+
[![Build Status](https://secure.travis-ci.org/ronen/rspec-page-regression.png)](http://travis-ci.org/ronen/rspec-page-regression)
|
4
|
+
[![Dependency Status](https://gemnasium.com/ronen/rspec-page-regression.png)](https://gemnasium.com/ronen/rspec-page-regression)
|
5
|
+
|
1
6
|
# rspec-page-regression
|
2
7
|
|
8
|
+
|
3
9
|
Rspec-page-regression is an [RSpec](https://github.com/rspec/rspec) plugin
|
4
10
|
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
11
|
|
6
12
|
It provides an RSpec matcher that compares the test snapshot to an expected image, and facilitates management of the images.
|
7
13
|
|
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)
|
14
|
+
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).
|
14
15
|
|
15
16
|
|
16
17
|
## Installation
|
@@ -106,6 +107,26 @@ The default window size for the renders is 1024 x 768 pixels. You can specify a
|
|
106
107
|
|
107
108
|
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.
|
108
109
|
|
110
|
+
### Using the selenium driver
|
111
|
+
|
112
|
+
You can also use the selenium driver with capybara. This offers the possiblity to visually test your pages against a range of real browsers.
|
113
|
+
|
114
|
+
Add the [selenium-webdriver](https://rubygems.org/gems/selenium-webdriver) to your Gemfile:
|
115
|
+
|
116
|
+
gem 'selenium-webdriver'
|
117
|
+
|
118
|
+
And in your spec_helper replace:
|
119
|
+
|
120
|
+
require 'capybara/poltergeist'
|
121
|
+
Capybara.javascript_driver = :poltergeist
|
122
|
+
|
123
|
+
With:
|
124
|
+
|
125
|
+
require 'selenium/webdriver'
|
126
|
+
Capybara.javascript_driver = :selenium
|
127
|
+
|
128
|
+
|
129
|
+
See also the [capybara readme](https://github.com/jnicklas/capybara#selenium) and [selenium wiki](https://code.google.com/p/selenium/wiki/RubyBindings) for more information.
|
109
130
|
|
110
131
|
## Contributing
|
111
132
|
|
@@ -123,4 +144,10 @@ Don't forget to include specs (`rake spec`) to verify your functionality. Code
|
|
123
144
|
|
124
145
|
Release Notes:
|
125
146
|
|
147
|
+
* 0.2.0 - Support selenium. Thanks to [@edwinvdgraaf](https://github.com/edwinvdgraaf)
|
148
|
+
|
126
149
|
* 0.1.2 - Remove existing difference images so they won't be shown in cases where files couldn't be differenced.
|
150
|
+
|
151
|
+
|
152
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ronen/rspec-page-regression/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
153
|
+
|
@@ -4,8 +4,13 @@ module RSpec::PageRegression
|
|
4
4
|
def self.render(page, test_image_path)
|
5
5
|
|
6
6
|
test_image_path.dirname.mkpath unless test_image_path.dirname.exist?
|
7
|
-
|
8
|
-
page.driver.
|
7
|
+
# Capybara doesn't implement resize in API
|
8
|
+
unless page.driver.respond_to? :resize
|
9
|
+
page.driver.browser.manage.window.resize_to *RSpec::PageRegression.page_size
|
10
|
+
else
|
11
|
+
page.driver.resize *RSpec::PageRegression.page_size
|
12
|
+
end
|
13
|
+
page.driver.save_screenshot test_image_path, :full => true
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -7,7 +7,7 @@ describe "match_expectation" do
|
|
7
7
|
@opts = { :full => true }
|
8
8
|
@driver = mock("Driver")
|
9
9
|
@driver.stubs :resize
|
10
|
-
@driver.stubs :
|
10
|
+
@driver.stubs :save_screenshot
|
11
11
|
@page = mock("Page")
|
12
12
|
@page.stubs(:driver).returns @driver
|
13
13
|
@match_argument = nil
|
@@ -25,7 +25,22 @@ describe "match_expectation" do
|
|
25
25
|
|
26
26
|
context "framework" do
|
27
27
|
Then { @driver.should have_received(:resize).with(1024, 768) }
|
28
|
-
Then { @driver.should have_received(:
|
28
|
+
Then { @driver.should have_received(:save_screenshot).with(test_path, @opts) }
|
29
|
+
|
30
|
+
context "selenium" do
|
31
|
+
Given {
|
32
|
+
@browser = mock("Browser")
|
33
|
+
@window = mock("Window")
|
34
|
+
@window.stubs(:resize_to)
|
35
|
+
manage = mock("Manage")
|
36
|
+
manage.stubs(:window).returns @window
|
37
|
+
@browser.stubs(:manage => manage)
|
38
|
+
@driver.stubs(:browser => @browser)
|
39
|
+
@driver.unstub(:resize)
|
40
|
+
}
|
41
|
+
|
42
|
+
Then { @window.should have_received(:resize_to).with(1024, 768) }
|
43
|
+
end
|
29
44
|
end
|
30
45
|
|
31
46
|
context "when files match" do
|
@@ -102,7 +117,7 @@ describe "match_expectation" do
|
|
102
117
|
example_group: { description: "parent" }
|
103
118
|
}
|
104
119
|
end
|
105
|
-
Then { @driver.should have_received(:
|
120
|
+
Then { @driver.should have_received(:save_screenshot).with(Pathname.new("tmp/spec/expectation/parent/test.png"), @opts) }
|
106
121
|
Then { @error.message.should include "Missing expectation image spec/expectation/parent/expected.png" }
|
107
122
|
end
|
108
123
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-page-regression
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|