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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72a4f9ee17017a996fd72fd83a81a9dfeb49d4cb
4
- data.tar.gz: 0000e7eb2782beb039debe4e6a30a89f7134c95f
3
+ metadata.gz: 0aaa9ac40a80fe376a23c570527ba53ad4183094
4
+ data.tar.gz: 18c9dd86aec2148f9d6fcfecbf22f74f486a18d9
5
5
  SHA512:
6
- metadata.gz: 37300c7d8d06f07905aecf5ca5030d2b07fc549ccb6408e1908827ad5e58b9e368357216a1cc4bee4cb8b596d15726cee81397c2981e6a32c356e3b20b1e0227
7
- data.tar.gz: 4be3fb7c2998990b62c3736a4cb6c163d83b5dec047f29b0bb8adaf2769fc24c727a0d2f1cef973ec1901e8e3821910e20184dc3cd56650ac1795c47a194c905
6
+ metadata.gz: d4f2fbf0f6ca04d2e02a2461e312b40c1de1b504748b15c1dc8f20987e40d78795e48265b176293a3c95f6c5465a16571075d5ad4ea1745c17dad8ca5bbd593a
7
+ data.tar.gz: 59b55a99a7e5f688f7e637628800b40bb72c083af60c9379224172dffb1df05323837930513143a2acad8e44dba1a908d0688fb04ea704fec46aa70d3eb4a70d
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  rvm:
2
2
  - 1.9.3
3
+ - 2.0.0
3
4
  notifications:
4
5
  recipients:
5
6
  - ronen@barzel.org
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
- page.driver.resize *RSpec::PageRegression.page_size
8
- page.driver.render test_image_path, :full => true
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
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module PageRegression
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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 :render
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(:render).with(test_path, @opts) }
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(:render).with(Pathname.new("tmp/spec/expectation/parent/test.png"), @opts) }
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.1.2
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: 2013-09-24 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport