capybara-screenshot 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -63,7 +63,7 @@ The gem supports the default rendering method for Capybara to generate the scree
|
|
63
63
|
|
64
64
|
page.driver.render(path)
|
65
65
|
|
66
|
-
There are also some specific driver configurations for Selenium, Webkit, and Poltergeist. See [https://github.com/mattheworiordan/capybara-screenshot/blob/master/lib/capybara-screenshot.rb
|
66
|
+
There are also some specific driver configurations for Selenium, Webkit, and Poltergeist. See [the definitions here](https://github.com/mattheworiordan/capybara-screenshot/blob/master/lib/capybara-screenshot.rb). The Rack::Test driver, Rails' default, does not allow
|
67
67
|
rendering, so it has a driver definition as a noop.
|
68
68
|
|
69
69
|
If a driver is not found the default rendering will be used. If this doesn't work with your driver, then you can
|
@@ -86,6 +86,14 @@ you can override how the basename is generated for the file like so
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
Screenshot path in RSpec metadata
|
90
|
+
---------------------------------
|
91
|
+
|
92
|
+
By default capybara-screenshot will append the screenshot path to a failing spec's full_description which effectively
|
93
|
+
changes the name of the spec and breaks trend reporting using tools like CI Reporter. You can turn off the default behavior
|
94
|
+
with the following invocation
|
95
|
+
|
96
|
+
Capybara::Screenshot.append_screenshot_path = false
|
89
97
|
|
90
98
|
Example application
|
91
99
|
-------------------
|
data/lib/capybara-screenshot.rb
CHANGED
@@ -4,11 +4,13 @@ module Capybara
|
|
4
4
|
attr_accessor :autosave_on_failure
|
5
5
|
attr_accessor :registered_drivers
|
6
6
|
attr_accessor :filename_prefix_formatters
|
7
|
+
attr_accessor :append_screenshot_path
|
7
8
|
end
|
8
9
|
|
9
10
|
self.autosave_on_failure = true
|
10
11
|
self.registered_drivers = {}
|
11
12
|
self.filename_prefix_formatters = {}
|
13
|
+
self.append_screenshot_path = true
|
12
14
|
|
13
15
|
def self.screenshot_and_save_page
|
14
16
|
saver = Saver.new(Capybara, Capybara.page)
|
@@ -82,7 +84,11 @@ Capybara::Screenshot.class_eval do
|
|
82
84
|
end
|
83
85
|
|
84
86
|
register_driver(:webkit) do |driver, path|
|
85
|
-
driver.
|
87
|
+
if driver.respond_to?(:save_screenshot)
|
88
|
+
driver.save_screenshot(path)
|
89
|
+
else
|
90
|
+
driver.render(path)
|
91
|
+
end
|
86
92
|
end
|
87
93
|
|
88
94
|
register_driver(:webkit_debug) do |driver, path|
|
@@ -8,8 +8,10 @@ RSpec.configure do |config|
|
|
8
8
|
saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix)
|
9
9
|
saver.save
|
10
10
|
|
11
|
-
|
11
|
+
if Capybara::Screenshot.append_screenshot_path
|
12
|
+
example.metadata[:full_description] += "\n Screenshot: #{saver.screenshot_path}"
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -138,10 +138,28 @@ describe Capybara::Screenshot::Saver do
|
|
138
138
|
capybara_mock.stub(:current_driver).and_return(:webkit)
|
139
139
|
end
|
140
140
|
|
141
|
-
|
142
|
-
|
141
|
+
context 'has render method' do
|
142
|
+
before do
|
143
|
+
driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(false)
|
144
|
+
end
|
143
145
|
|
144
|
-
|
146
|
+
it 'should save driver render' do
|
147
|
+
driver_mock.should_receive(:render).with(screenshot_path)
|
148
|
+
|
149
|
+
saver.save
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'has save_screenshot method' do
|
154
|
+
before do
|
155
|
+
driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(true)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should save driver render' do
|
159
|
+
driver_mock.should_receive(:save_screenshot).with(screenshot_path)
|
160
|
+
|
161
|
+
saver.save
|
162
|
+
end
|
145
163
|
end
|
146
164
|
end
|
147
165
|
|
@@ -176,4 +194,4 @@ describe Capybara::Screenshot::Saver do
|
|
176
194
|
saver.save
|
177
195
|
end
|
178
196
|
end
|
179
|
-
end
|
197
|
+
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.2
|
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: 2012-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
segments:
|
108
108
|
- 0
|
109
|
-
hash: -
|
109
|
+
hash: -1096024297736661067
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash: -
|
118
|
+
hash: -1096024297736661067
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project: capybara-screenshot
|
121
121
|
rubygems_version: 1.8.24
|