capybara-screenshot 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -3
- data/README.md +3 -0
- data/lib/capybara-screenshot/saver.rb +22 -8
- data/lib/capybara-screenshot/version.rb +1 -1
- metadata +4 -4
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,11 +2,14 @@ capybara-screenshot gem
|
|
2
2
|
=======================
|
3
3
|
|
4
4
|
[](https://travis-ci.org/mattheworiordan/capybara-screenshot)
|
5
|
+
[](https://codeclimate.com/github/mattheworiordan/capybara-screenshot)
|
5
6
|
|
6
7
|
Using this gem, whenever a [Capybara](https://github.com/jnicklas/capybara) test in [Cucumber](http://cukes.info/), [Rspec](https://www.relishapp.com/rspec) or Minitest fails, the HTML for the failed page and a screenshot (when using [capybara-webkit](https://github.com/thoughtbot/capybara-webkit), [Selenium](http://seleniumhq.org/) or [poltergeist](https://github.com/jonleighton/poltergeist)) is saved into $APPLICATION_ROOT/tmp/capybara.
|
7
8
|
|
8
9
|
This is a huge help when trying to diagnose a problem in your failing steps as you can view the source code and potentially how the page looked at the time of the failure.
|
9
10
|
|
11
|
+
_Please note that Ruby 1.9 is required to use this Gem. For Ruby 1.8 support, please see the [capybara-screenshot Ruby 1.8 branch](https://github.com/mattheworiordan/capybara-screenshot/tree/ruby-1.8-support)_
|
12
|
+
|
10
13
|
Installation
|
11
14
|
-----
|
12
15
|
|
@@ -18,19 +18,24 @@ module Capybara
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def save_html
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
clear_save_and_open_page_path do
|
22
|
+
if Capybara::VERSION.match(/^\d+/)[0] == '1'
|
23
|
+
capybara.save_page(page.body, "#{html_path}")
|
24
|
+
else
|
25
|
+
capybara.save_page("#{html_path}")
|
26
|
+
end
|
25
27
|
end
|
26
28
|
warn "Saved file #{html_path}"
|
27
29
|
end
|
28
30
|
|
29
31
|
def save_screenshot
|
30
|
-
|
31
|
-
|
32
|
-
Capybara::Screenshot.registered_drivers
|
33
|
-
|
32
|
+
clear_save_and_open_page_path do
|
33
|
+
Capybara.save_and_open_page_path = nil
|
34
|
+
Capybara::Screenshot.registered_drivers.fetch(capybara.current_driver) { |driver_name|
|
35
|
+
warn "capybara-screenshot could not detect a screenshot driver for '#{capybara.current_driver}'. Saving with default with unknown results."
|
36
|
+
Capybara::Screenshot.registered_drivers[:default]
|
37
|
+
}.call(page.driver, screenshot_path)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
def html_path
|
@@ -41,6 +46,15 @@ module Capybara
|
|
41
46
|
File.join(Capybara::Screenshot.capybara_root, "#{file_base_name}.png")
|
42
47
|
end
|
43
48
|
|
49
|
+
# If Capybara.save_and_open_page_path is set then
|
50
|
+
# the html_path or screenshot_path will be appended to this path
|
51
|
+
# instead of replacing it
|
52
|
+
def clear_save_and_open_page_path
|
53
|
+
old_path = Capybara.save_and_open_page_path
|
54
|
+
Capybara.save_and_open_page_path = nil
|
55
|
+
yield
|
56
|
+
Capybara.save_and_open_page_path = old_path
|
57
|
+
end
|
44
58
|
end
|
45
59
|
end
|
46
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash:
|
110
|
+
hash: -2459750308362478257
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
none: false
|
113
113
|
requirements:
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash:
|
119
|
+
hash: -2459750308362478257
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project: capybara-screenshot
|
122
122
|
rubygems_version: 1.8.24
|