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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +11 -12
  3. data/Appraisals +14 -16
  4. data/CHANGELOG.md +69 -0
  5. data/Gemfile +4 -3
  6. data/README.md +96 -30
  7. data/capybara-screenshot.gemspec +12 -5
  8. data/gemfiles/cucumber.1.3.gemfile +12 -0
  9. data/gemfiles/cucumber.2.4.gemfile +12 -0
  10. data/gemfiles/latest.gemfile +5 -2
  11. data/gemfiles/rspec.3.0.gemfile +5 -2
  12. data/gemfiles/rspec.3.3.gemfile +12 -0
  13. data/gemfiles/spinach.0.8.gemfile +12 -0
  14. data/lib/capybara-screenshot/callbacks.rb +44 -0
  15. data/lib/capybara-screenshot/capybara.rb +26 -10
  16. data/lib/capybara-screenshot/cucumber.rb +12 -5
  17. data/lib/capybara-screenshot/minitest.rb +1 -1
  18. data/lib/capybara-screenshot/pruner.rb +5 -1
  19. data/lib/capybara-screenshot/rspec/base_reporter.rb +1 -2
  20. data/lib/capybara-screenshot/rspec/html_embed_reporter.rb +14 -3
  21. data/lib/capybara-screenshot/rspec/html_link_reporter.rb +1 -1
  22. data/lib/capybara-screenshot/rspec/text_reporter.rb +2 -2
  23. data/lib/capybara-screenshot/rspec.rb +25 -3
  24. data/lib/capybara-screenshot/s3_saver.rb +39 -11
  25. data/lib/capybara-screenshot/saver.rb +60 -15
  26. data/lib/capybara-screenshot/version.rb +1 -1
  27. data/lib/capybara-screenshot.rb +38 -3
  28. data/spec/cucumber/cucumber_spec.rb +4 -8
  29. data/spec/feature/minitest_spec.rb +2 -6
  30. data/spec/feature/testunit_spec.rb +3 -7
  31. data/spec/rspec/rspec_spec.rb +36 -8
  32. data/spec/spinach/spinach_spec.rb +4 -8
  33. data/spec/support/aruba.rb +0 -1
  34. data/spec/support/common_setup.rb +13 -5
  35. data/spec/unit/capybara-screenshot_spec.rb +2 -1
  36. data/spec/unit/capybara_spec.rb +13 -0
  37. data/spec/unit/pruner_spec.rb +2 -2
  38. data/spec/unit/rspec_reporters/html_embed_reporter_spec.rb +13 -0
  39. data/spec/unit/rspec_reporters/text_reporter_spec.rb +6 -6
  40. data/spec/unit/s3_saver_spec.rb +196 -14
  41. data/spec/unit/saver_spec.rb +132 -16
  42. metadata +19 -17
  43. data/gemfiles/cucumber.1.2.gemfile +0 -9
  44. data/gemfiles/cucumber.1.3.0.gemfile +0 -9
  45. data/gemfiles/rspec.2.14.gemfile +0 -9
  46. data/gemfiles/rspec.2.99.gemfile +0 -9
  47. data/gemfiles/spinach.0.7.gemfile +0 -9
  48. data/gemfiles/spinach.0.8.0.gemfile +0 -9
@@ -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) { double('Capybara session page', :body => 'body', :driver => driver_mock).as_null_object }
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
- it 'does not save if current_path is empty' do
113
- allow(capybara_mock).to receive(:current_path).and_return(nil)
114
- expect(capybara_mock).to_not receive(:save_page)
115
- expect(driver_mock).to_not receive(:render)
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
- saver.save
118
- expect(saver).to_not be_screenshot_saved
119
- expect(saver).to_not be_html_saved
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 saving a screenshot fails' do
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.save_and_open_page_path = 'tmp/bananas'
191
+ Capybara::Screenshot.capybara_tmp_path = 'tmp/bananas'
125
192
 
126
- expect(capybara_mock).to receive(:save_page).and_raise
193
+ allow(page_mock).to receive(:current_path).and_raise
127
194
 
128
- expect {
129
- saver.save
130
- }.to raise_error(RuntimeError)
195
+ saver.save
131
196
 
132
- expect(Capybara.save_and_open_page_path).to eq('tmp/bananas')
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.13
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: 2016-05-23 00:00:00.000000000 Z
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: '3'
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: '3'
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.2.gemfile
192
- - gemfiles/cucumber.1.3.0.gemfile
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/spinach.0.7.gemfile
198
- - gemfiles/spinach.0.8.0.gemfile
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
- post_install_message:
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
- rubyforge_project: capybara-screenshot
261
- rubygems_version: 2.4.6
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
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "cucumber", "1.2"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "cucumber", "1.3.0"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rspec", "2.14"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rspec", "2.99"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "spinach", "0.7"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "spinach", "0.8.0"
8
-
9
- gemspec :path => "../"