capybara-screenshot 1.0.13 → 1.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +11 -12
- data/Appraisals +14 -16
- data/CHANGELOG.md +69 -0
- data/Gemfile +4 -3
- data/README.md +96 -30
- data/capybara-screenshot.gemspec +12 -5
- data/gemfiles/cucumber.1.3.gemfile +12 -0
- data/gemfiles/cucumber.2.4.gemfile +12 -0
- data/gemfiles/latest.gemfile +5 -2
- data/gemfiles/rspec.3.0.gemfile +5 -2
- data/gemfiles/rspec.3.3.gemfile +12 -0
- data/gemfiles/spinach.0.8.gemfile +12 -0
- data/lib/capybara-screenshot/callbacks.rb +44 -0
- data/lib/capybara-screenshot/capybara.rb +26 -10
- data/lib/capybara-screenshot/cucumber.rb +12 -5
- data/lib/capybara-screenshot/minitest.rb +1 -1
- data/lib/capybara-screenshot/pruner.rb +5 -1
- data/lib/capybara-screenshot/rspec/base_reporter.rb +1 -2
- data/lib/capybara-screenshot/rspec/html_embed_reporter.rb +14 -3
- data/lib/capybara-screenshot/rspec/html_link_reporter.rb +1 -1
- data/lib/capybara-screenshot/rspec/text_reporter.rb +2 -2
- data/lib/capybara-screenshot/rspec.rb +25 -3
- data/lib/capybara-screenshot/s3_saver.rb +39 -11
- data/lib/capybara-screenshot/saver.rb +60 -15
- data/lib/capybara-screenshot/version.rb +1 -1
- data/lib/capybara-screenshot.rb +38 -3
- data/spec/cucumber/cucumber_spec.rb +4 -8
- data/spec/feature/minitest_spec.rb +2 -6
- data/spec/feature/testunit_spec.rb +3 -7
- data/spec/rspec/rspec_spec.rb +36 -8
- data/spec/spinach/spinach_spec.rb +4 -8
- data/spec/support/aruba.rb +0 -1
- data/spec/support/common_setup.rb +13 -5
- data/spec/unit/capybara-screenshot_spec.rb +2 -1
- data/spec/unit/capybara_spec.rb +13 -0
- data/spec/unit/pruner_spec.rb +2 -2
- data/spec/unit/rspec_reporters/html_embed_reporter_spec.rb +13 -0
- data/spec/unit/rspec_reporters/text_reporter_spec.rb +6 -6
- data/spec/unit/s3_saver_spec.rb +196 -14
- data/spec/unit/saver_spec.rb +132 -16
- metadata +19 -17
- data/gemfiles/cucumber.1.2.gemfile +0 -9
- data/gemfiles/cucumber.1.3.0.gemfile +0 -9
- data/gemfiles/rspec.2.14.gemfile +0 -9
- data/gemfiles/rspec.2.99.gemfile +0 -9
- data/gemfiles/spinach.0.7.gemfile +0 -9
- data/gemfiles/spinach.0.8.0.gemfile +0 -9
data/spec/unit/saver_spec.rb
CHANGED
@@ -21,11 +21,14 @@ describe Capybara::Screenshot::Saver do
|
|
21
21
|
let(:screenshot_path) { "#{capybara_root}/#{file_basename}.png" }
|
22
22
|
|
23
23
|
let(:driver_mock) { double('Capybara driver').as_null_object }
|
24
|
-
let(:page_mock) {
|
24
|
+
let(:page_mock) {
|
25
|
+
double('Capybara session page', :body => 'body', :driver => driver_mock).as_null_object.tap do |m|
|
26
|
+
allow(m).to receive(:current_path).and_return('/')
|
27
|
+
end
|
28
|
+
}
|
25
29
|
let(:capybara_mock) {
|
26
30
|
double(Capybara).as_null_object.tap do |m|
|
27
31
|
allow(m).to receive(:current_driver).and_return(:default)
|
28
|
-
allow(m).to receive(:current_path).and_return('/')
|
29
32
|
end
|
30
33
|
}
|
31
34
|
|
@@ -109,27 +112,93 @@ describe Capybara::Screenshot::Saver do
|
|
109
112
|
expect(saver).to_not be_html_saved
|
110
113
|
end
|
111
114
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
115
|
+
context 'the current_path is empty' do
|
116
|
+
before(:each) do
|
117
|
+
allow(page_mock).to receive(:current_path).and_return(nil)
|
118
|
+
end
|
116
119
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
+
it 'does not save' do
|
121
|
+
expect(capybara_mock).to_not receive(:save_page)
|
122
|
+
expect(driver_mock).to_not receive(:render)
|
123
|
+
|
124
|
+
saver.save
|
125
|
+
expect(saver).to_not be_screenshot_saved
|
126
|
+
expect(saver).to_not be_html_saved
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'prints a warning' do
|
130
|
+
expect(saver).to receive(:warn).with(
|
131
|
+
'WARN: Screenshot could not be saved. `page.current_path` is empty.',
|
132
|
+
)
|
133
|
+
saver.save
|
134
|
+
end
|
120
135
|
end
|
121
136
|
|
122
|
-
context 'when
|
137
|
+
context 'when save_html raises' do
|
138
|
+
before(:each) do
|
139
|
+
allow(saver).to receive(:save_html).and_raise(NoMethodError.new('some error'))
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'prints warning message' do
|
143
|
+
expect(saver).to receive(:warn).with(
|
144
|
+
'WARN: HTML source could not be saved. An exception is raised: #<NoMethodError: some error>.',
|
145
|
+
)
|
146
|
+
saver.save
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'tries to save screenshot' do
|
150
|
+
expect(saver).to receive(:save_screenshot)
|
151
|
+
saver.save
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when save_screenshot raises' do
|
156
|
+
before(:each) do
|
157
|
+
allow(saver).to receive(:save_screenshot).and_raise(NoMethodError.new('some error'))
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'prints warning message' do
|
161
|
+
expect(saver).to receive(:warn).with(
|
162
|
+
'WARN: Screenshot could not be saved. An exception is raised: #<NoMethodError: some error>.',
|
163
|
+
)
|
164
|
+
saver.save
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'tries to save screenshot' do
|
168
|
+
expect(saver).to receive(:save_html)
|
169
|
+
saver.save
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'when current_path raises' do
|
174
|
+
before(:each) do
|
175
|
+
allow(page_mock).to receive(:current_path).and_raise(NoMethodError.new('some error'))
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'prints warning message' do
|
179
|
+
expect(saver).to receive(:warn).with(
|
180
|
+
'WARN: Screenshot could not be saved. `page.current_path` raised exception: #<NoMethodError: some error>.',
|
181
|
+
)
|
182
|
+
saver.save
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'does not print extra warning message' do
|
186
|
+
expect(saver).not_to receive(:warn).with(/is empty/)
|
187
|
+
saver.save
|
188
|
+
end
|
189
|
+
|
123
190
|
it 'still restores the original value of Capybara.save_and_open_page_path' do
|
124
|
-
Capybara.
|
191
|
+
Capybara::Screenshot.capybara_tmp_path = 'tmp/bananas'
|
125
192
|
|
126
|
-
|
193
|
+
allow(page_mock).to receive(:current_path).and_raise
|
127
194
|
|
128
|
-
|
129
|
-
saver.save
|
130
|
-
}.to raise_error(RuntimeError)
|
195
|
+
saver.save
|
131
196
|
|
132
|
-
|
197
|
+
if Capybara.respond_to?(:save_path)
|
198
|
+
expect(Capybara.save_path).to eq('tmp/bananas')
|
199
|
+
else
|
200
|
+
expect(Capybara.save_and_open_page_path).to eq('tmp/bananas')
|
201
|
+
end
|
133
202
|
end
|
134
203
|
end
|
135
204
|
|
@@ -154,6 +223,40 @@ describe Capybara::Screenshot::Saver do
|
|
154
223
|
end
|
155
224
|
end
|
156
225
|
|
226
|
+
describe 'callbacks' do
|
227
|
+
let(:saver) { Capybara::Screenshot::Saver.new(capybara_mock, page_mock) }
|
228
|
+
|
229
|
+
before do
|
230
|
+
allow(saver).to receive(:html_path) { 'page.html' }
|
231
|
+
allow(saver).to receive(:screenshot_path) { 'screenshot.png' }
|
232
|
+
end
|
233
|
+
|
234
|
+
before :all do
|
235
|
+
Capybara::Screenshot.after_save_html do |path|
|
236
|
+
puts "after_save_html ran with #{path}"
|
237
|
+
end
|
238
|
+
Capybara::Screenshot.after_save_screenshot do |path|
|
239
|
+
puts "after_save_screenshot ran with #{path}"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
after :all do
|
244
|
+
Capybara::Screenshot::Saver.instance_eval { @callbacks = nil }
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'runs after_save_html callbacks' do
|
248
|
+
expect do
|
249
|
+
saver.save
|
250
|
+
end.to output(/after_save_html ran with page\.html/).to_stdout
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'runs after_save_screenshot callbacks' do
|
254
|
+
expect do
|
255
|
+
saver.save
|
256
|
+
end.to output(/after_save_screenshot ran with screenshot\.png/).to_stdout
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
157
260
|
describe "with selenium driver" do
|
158
261
|
before do
|
159
262
|
allow(capybara_mock).to receive(:current_driver).and_return(:selenium)
|
@@ -195,6 +298,19 @@ describe Capybara::Screenshot::Saver do
|
|
195
298
|
end
|
196
299
|
end
|
197
300
|
|
301
|
+
describe "with cuprite driver" do
|
302
|
+
before do
|
303
|
+
allow(capybara_mock).to receive(:current_driver).and_return(:cuprite)
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'saves driver render with :full => true' do
|
307
|
+
expect(driver_mock).to receive(:render).with(screenshot_path, {:full => true})
|
308
|
+
|
309
|
+
saver.save
|
310
|
+
expect(saver).to be_screenshot_saved
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
198
314
|
describe "with webkit driver" do
|
199
315
|
before do
|
200
316
|
allow(capybara_mock).to receive(:current_driver).and_return(:webkit)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew O'Riordan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '1.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '4'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '1.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: launchy
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +157,7 @@ dependencies:
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
|
-
name: aws-sdk
|
160
|
+
name: aws-sdk-s3
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - ">="
|
@@ -188,15 +188,14 @@ files:
|
|
188
188
|
- README.md
|
189
189
|
- Rakefile
|
190
190
|
- capybara-screenshot.gemspec
|
191
|
-
- gemfiles/cucumber.1.
|
192
|
-
- gemfiles/cucumber.
|
191
|
+
- gemfiles/cucumber.1.3.gemfile
|
192
|
+
- gemfiles/cucumber.2.4.gemfile
|
193
193
|
- gemfiles/latest.gemfile
|
194
|
-
- gemfiles/rspec.2.14.gemfile
|
195
|
-
- gemfiles/rspec.2.99.gemfile
|
196
194
|
- gemfiles/rspec.3.0.gemfile
|
197
|
-
- gemfiles/
|
198
|
-
- gemfiles/spinach.0.8.
|
195
|
+
- gemfiles/rspec.3.3.gemfile
|
196
|
+
- gemfiles/spinach.0.8.gemfile
|
199
197
|
- lib/capybara-screenshot.rb
|
198
|
+
- lib/capybara-screenshot/callbacks.rb
|
200
199
|
- lib/capybara-screenshot/capybara.rb
|
201
200
|
- lib/capybara-screenshot/cucumber.rb
|
202
201
|
- lib/capybara-screenshot/helpers.rb
|
@@ -241,8 +240,12 @@ files:
|
|
241
240
|
homepage: http://github.com/mattheworiordan/capybara-screenshot
|
242
241
|
licenses:
|
243
242
|
- MIT
|
244
|
-
metadata:
|
245
|
-
|
243
|
+
metadata:
|
244
|
+
bug_tracker_uri: https://github.com/mattheworiordan/capybara-screenshot/issues
|
245
|
+
changelog_uri: https://github.com/mattheworiordan/capybara-screenshot/blob/master/CHANGELOG.md
|
246
|
+
documentation_uri: https://www.rubydoc.info/gems/capybara-screenshot/1.0.26
|
247
|
+
source_code_uri: https://github.com/mattheworiordan/capybara-screenshot/tree/v1.0.26
|
248
|
+
post_install_message:
|
246
249
|
rdoc_options: []
|
247
250
|
require_paths:
|
248
251
|
- lib
|
@@ -257,9 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
260
|
- !ruby/object:Gem::Version
|
258
261
|
version: '0'
|
259
262
|
requirements: []
|
260
|
-
|
261
|
-
|
262
|
-
signing_key:
|
263
|
+
rubygems_version: 3.0.3
|
264
|
+
signing_key:
|
263
265
|
specification_version: 4
|
264
266
|
summary: Automatically create snapshots when Cucumber steps fail with Capybara and
|
265
267
|
Rails
|
data/gemfiles/rspec.2.14.gemfile
DELETED
data/gemfiles/rspec.2.99.gemfile
DELETED