capybara-screenshot 0.3.22 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/.travis.yml +9 -0
  5. data/Appraisals +31 -0
  6. data/CHANGELOG.md +16 -0
  7. data/Gemfile +1 -0
  8. data/README.md +23 -17
  9. data/Rakefile +9 -1
  10. data/capybara-screenshot.gemspec +7 -1
  11. data/gemfiles/cucumber.1.2.gemfile +9 -0
  12. data/gemfiles/cucumber.1.2.gemfile.lock +99 -0
  13. data/gemfiles/cucumber.1.3.0.gemfile +9 -0
  14. data/gemfiles/cucumber.1.3.0.gemfile.lock +100 -0
  15. data/gemfiles/latest.gemfile +8 -0
  16. data/gemfiles/latest.gemfile.lock +102 -0
  17. data/gemfiles/rspec.2.14.gemfile +9 -0
  18. data/gemfiles/rspec.2.14.gemfile.lock +98 -0
  19. data/gemfiles/rspec.2.99.gemfile +9 -0
  20. data/gemfiles/rspec.2.99.gemfile.lock +98 -0
  21. data/gemfiles/rspec.3.0.gemfile +9 -0
  22. data/gemfiles/rspec.3.0.gemfile.lock +102 -0
  23. data/gemfiles/spinach.0.7.gemfile +9 -0
  24. data/gemfiles/spinach.0.7.gemfile.lock +100 -0
  25. data/gemfiles/spinach.0.8.0.gemfile +9 -0
  26. data/gemfiles/spinach.0.8.0.gemfile.lock +100 -0
  27. data/lib/capybara-screenshot.rb +5 -0
  28. data/lib/capybara-screenshot/capybara.rb +12 -0
  29. data/lib/capybara-screenshot/cucumber.rb +18 -12
  30. data/lib/capybara-screenshot/minitest.rb +15 -16
  31. data/lib/capybara-screenshot/rspec.rb +19 -11
  32. data/lib/capybara-screenshot/rspec/text_reporter.rb +21 -3
  33. data/lib/capybara-screenshot/spinach.rb +22 -6
  34. data/lib/capybara-screenshot/testunit.rb +25 -7
  35. data/lib/capybara-screenshot/version.rb +1 -1
  36. data/spec/cucumber/cucumber_spec.rb +64 -0
  37. data/spec/cucumber/step_definitions/step_definitions.rb +18 -0
  38. data/spec/cucumber/support/env.rb +17 -0
  39. data/spec/feature/minitest_spec.rb +90 -0
  40. data/spec/feature/testunit_spec.rb +71 -0
  41. data/spec/rspec/rspec_spec.rb +101 -0
  42. data/spec/spec_helper.rb +9 -1
  43. data/spec/spinach/spinach_spec.rb +53 -0
  44. data/spec/spinach/support/spinach_failure.rb +41 -0
  45. data/spec/support/common_setup.rb +28 -0
  46. data/spec/support/html_reporter_context.rb +1 -1
  47. data/spec/support/test_app.rb +13 -0
  48. data/spec/{rspec → unit}/base_reporter_spec.rb +2 -2
  49. data/spec/{rspec_spec.rb → unit/capybara-screenshot_rspec_spec.rb} +15 -10
  50. data/spec/{capybara-screenshot_spec.rb → unit/capybara-screenshot_spec.rb} +8 -8
  51. data/spec/unit/capybara_spec.rb +50 -0
  52. data/spec/{rspec → unit/rspec_reporters}/html_embed_reporter_spec.rb +2 -2
  53. data/spec/{rspec → unit/rspec_reporters}/html_link_reporter_spec.rb +2 -2
  54. data/spec/unit/rspec_reporters/text_reporter_spec.rb +96 -0
  55. data/spec/{rspec → unit/rspec_reporters}/textmate_link_reporter_spec.rb +5 -3
  56. data/spec/unit/saver_spec.rb +269 -0
  57. metadata +161 -41
  58. data/spec/capybara-screenshot/capybara_spec.rb +0 -18
  59. data/spec/capybara-screenshot/saver_spec.rb +0 -269
  60. data/spec/rspec/text_reporter_spec.rb +0 -76
metadata CHANGED
@@ -1,89 +1,173 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-screenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew O'Riordan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
- - - "<"
20
+ - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: '3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.0'
30
- - - "<"
30
+ - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: launchy
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: colored
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - '>='
66
66
  - !ruby/object:Gem::Version
67
- version: '2.9'
67
+ version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
- version: '2.9'
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: timecop
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: cucumber
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: aruba
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: sinatra
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: test-unit
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: spinach
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: minitest
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - '>='
80
164
  - !ruby/object:Gem::Version
81
165
  version: '0'
82
166
  type: :development
83
167
  prerelease: false
84
168
  version_requirements: !ruby/object:Gem::Requirement
85
169
  requirements:
86
- - - ">="
170
+ - - '>='
87
171
  - !ruby/object:Gem::Version
88
172
  version: '0'
89
173
  description: When a Cucumber step fails, it is useful to create a screenshot image
@@ -94,15 +178,32 @@ executables: []
94
178
  extensions: []
95
179
  extra_rdoc_files: []
96
180
  files:
97
- - ".gitignore"
98
- - ".rspec"
99
- - ".travis.yml"
181
+ - .gitignore
182
+ - .rspec
183
+ - .travis.yml
184
+ - Appraisals
100
185
  - CHANGELOG.md
101
186
  - Gemfile
102
187
  - LICENSE
103
188
  - README.md
104
189
  - Rakefile
105
190
  - capybara-screenshot.gemspec
191
+ - gemfiles/cucumber.1.2.gemfile
192
+ - gemfiles/cucumber.1.2.gemfile.lock
193
+ - gemfiles/cucumber.1.3.0.gemfile
194
+ - gemfiles/cucumber.1.3.0.gemfile.lock
195
+ - gemfiles/latest.gemfile
196
+ - gemfiles/latest.gemfile.lock
197
+ - gemfiles/rspec.2.14.gemfile
198
+ - gemfiles/rspec.2.14.gemfile.lock
199
+ - gemfiles/rspec.2.99.gemfile
200
+ - gemfiles/rspec.2.99.gemfile.lock
201
+ - gemfiles/rspec.3.0.gemfile
202
+ - gemfiles/rspec.3.0.gemfile.lock
203
+ - gemfiles/spinach.0.7.gemfile
204
+ - gemfiles/spinach.0.7.gemfile.lock
205
+ - gemfiles/spinach.0.8.0.gemfile
206
+ - gemfiles/spinach.0.8.0.gemfile.lock
106
207
  - lib/capybara-screenshot.rb
107
208
  - lib/capybara-screenshot/capybara.rb
108
209
  - lib/capybara-screenshot/cucumber.rb
@@ -117,17 +218,27 @@ files:
117
218
  - lib/capybara-screenshot/spinach.rb
118
219
  - lib/capybara-screenshot/testunit.rb
119
220
  - lib/capybara-screenshot/version.rb
120
- - spec/capybara-screenshot/capybara_spec.rb
121
- - spec/capybara-screenshot/saver_spec.rb
122
- - spec/capybara-screenshot_spec.rb
123
- - spec/rspec/base_reporter_spec.rb
124
- - spec/rspec/html_embed_reporter_spec.rb
125
- - spec/rspec/html_link_reporter_spec.rb
126
- - spec/rspec/text_reporter_spec.rb
127
- - spec/rspec/textmate_link_reporter_spec.rb
128
- - spec/rspec_spec.rb
221
+ - spec/cucumber/cucumber_spec.rb
222
+ - spec/cucumber/step_definitions/step_definitions.rb
223
+ - spec/cucumber/support/env.rb
224
+ - spec/feature/minitest_spec.rb
225
+ - spec/feature/testunit_spec.rb
226
+ - spec/rspec/rspec_spec.rb
129
227
  - spec/spec_helper.rb
228
+ - spec/spinach/spinach_spec.rb
229
+ - spec/spinach/support/spinach_failure.rb
230
+ - spec/support/common_setup.rb
130
231
  - spec/support/html_reporter_context.rb
232
+ - spec/support/test_app.rb
233
+ - spec/unit/base_reporter_spec.rb
234
+ - spec/unit/capybara-screenshot_rspec_spec.rb
235
+ - spec/unit/capybara-screenshot_spec.rb
236
+ - spec/unit/capybara_spec.rb
237
+ - spec/unit/rspec_reporters/html_embed_reporter_spec.rb
238
+ - spec/unit/rspec_reporters/html_link_reporter_spec.rb
239
+ - spec/unit/rspec_reporters/text_reporter_spec.rb
240
+ - spec/unit/rspec_reporters/textmate_link_reporter_spec.rb
241
+ - spec/unit/saver_spec.rb
131
242
  homepage: http://github.com/mattheworiordan/capybara-screenshot
132
243
  licenses:
133
244
  - MIT
@@ -138,31 +249,40 @@ require_paths:
138
249
  - lib
139
250
  required_ruby_version: !ruby/object:Gem::Requirement
140
251
  requirements:
141
- - - ">="
252
+ - - '>='
142
253
  - !ruby/object:Gem::Version
143
254
  version: '0'
144
255
  required_rubygems_version: !ruby/object:Gem::Requirement
145
256
  requirements:
146
- - - ">="
257
+ - - '>='
147
258
  - !ruby/object:Gem::Version
148
259
  version: '0'
149
260
  requirements: []
150
261
  rubyforge_project: capybara-screenshot
151
- rubygems_version: 2.2.2
262
+ rubygems_version: 2.0.14
152
263
  signing_key:
153
264
  specification_version: 4
154
265
  summary: Automatically create snapshots when Cucumber steps fail with Capybara and
155
266
  Rails
156
267
  test_files:
157
- - spec/capybara-screenshot/capybara_spec.rb
158
- - spec/capybara-screenshot/saver_spec.rb
159
- - spec/capybara-screenshot_spec.rb
160
- - spec/rspec/base_reporter_spec.rb
161
- - spec/rspec/html_embed_reporter_spec.rb
162
- - spec/rspec/html_link_reporter_spec.rb
163
- - spec/rspec/text_reporter_spec.rb
164
- - spec/rspec/textmate_link_reporter_spec.rb
165
- - spec/rspec_spec.rb
268
+ - spec/cucumber/cucumber_spec.rb
269
+ - spec/cucumber/step_definitions/step_definitions.rb
270
+ - spec/cucumber/support/env.rb
271
+ - spec/feature/minitest_spec.rb
272
+ - spec/feature/testunit_spec.rb
273
+ - spec/rspec/rspec_spec.rb
166
274
  - spec/spec_helper.rb
275
+ - spec/spinach/spinach_spec.rb
276
+ - spec/spinach/support/spinach_failure.rb
277
+ - spec/support/common_setup.rb
167
278
  - spec/support/html_reporter_context.rb
168
- has_rdoc:
279
+ - spec/support/test_app.rb
280
+ - spec/unit/base_reporter_spec.rb
281
+ - spec/unit/capybara-screenshot_rspec_spec.rb
282
+ - spec/unit/capybara-screenshot_spec.rb
283
+ - spec/unit/capybara_spec.rb
284
+ - spec/unit/rspec_reporters/html_embed_reporter_spec.rb
285
+ - spec/unit/rspec_reporters/html_link_reporter_spec.rb
286
+ - spec/unit/rspec_reporters/text_reporter_spec.rb
287
+ - spec/unit/rspec_reporters/textmate_link_reporter_spec.rb
288
+ - spec/unit/saver_spec.rb
@@ -1,18 +0,0 @@
1
- require 'capybara/dsl'
2
-
3
- module Capybara::Screenshot
4
- describe Capybara do
5
-
6
- it 'should add screen shot methods to the Capybara module' do
7
- ::Capybara.should respond_to(:screenshot_and_save_page)
8
- ::Capybara.should respond_to(:screenshot_and_open_image)
9
- end
10
-
11
- context 'request type example', :type => :request do
12
- it 'should have access to screen shot instance methods' do
13
- self.should respond_to(:screenshot_and_save_page)
14
- self.should respond_to(:screenshot_and_open_image)
15
- end
16
- end
17
- end
18
- end
@@ -1,269 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Capybara::Screenshot::Saver do
4
- before(:all) do
5
- @original_drivers = Capybara::Screenshot.registered_drivers
6
- Capybara::Screenshot.registered_drivers[:default] = lambda {|driver, path| driver.render(path) }
7
- end
8
-
9
- after(:all) do
10
- Capybara::Screenshot.registered_drivers = @original_drivers
11
- end
12
-
13
- before do
14
- Capybara::Screenshot.stub(:capybara_root).and_return(capybara_root)
15
- Timecop.freeze(Time.local(2012, 6, 7, 8, 9, 10, 0))
16
- end
17
-
18
- let(:capybara_root) { '/tmp' }
19
- let(:timestamp) { '2012-06-07-08-09-10.000' }
20
- let(:file_basename) { "screenshot_#{timestamp}" }
21
- let(:screenshot_path) { "#{capybara_root}/#{file_basename}.png" }
22
-
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 }
25
- let(:capybara_mock) {
26
- double(Capybara).as_null_object.tap do |m|
27
- m.stub(:current_driver).and_return(:default)
28
- m.stub(:current_path).and_return('/')
29
- end
30
- }
31
-
32
- let(:saver) { Capybara::Screenshot::Saver.new(capybara_mock, page_mock) }
33
-
34
- context 'html filename with Capybara Version 1' do
35
- before do
36
- stub_const("Capybara::VERSION", '1')
37
- end
38
-
39
- it 'should have default format of "screenshot_Y-M-D-H-M-S.ms.html"' do
40
- capybara_mock.should_receive(:save_page).with('body', File.join(capybara_root, "#{file_basename}.html"))
41
-
42
- saver.save
43
- end
44
-
45
- it 'should use name argument as prefix' do
46
- saver = Capybara::Screenshot::Saver.new(capybara_mock, page_mock, true, 'custom-prefix')
47
-
48
- capybara_mock.should_receive(:save_page).with('body', File.join(capybara_root, "custom-prefix_#{timestamp}.html"))
49
-
50
- saver.save
51
- end
52
- end
53
-
54
- context 'html filename with Capybara Version 2' do
55
- before do
56
- stub_const("Capybara::VERSION", '2')
57
- end
58
-
59
- it 'should have default format of "screenshot_Y-M-D-H-M-S.ms.html"' do
60
- capybara_mock.should_receive(:save_page).with(File.join(capybara_root, "#{file_basename}.html"))
61
-
62
- saver.save
63
- end
64
-
65
- it 'should use name argument as prefix' do
66
- saver = Capybara::Screenshot::Saver.new(capybara_mock, page_mock, true, 'custom-prefix')
67
-
68
- capybara_mock.should_receive(:save_page).with(File.join(capybara_root, "custom-prefix_#{timestamp}.html"))
69
-
70
- saver.save
71
- end
72
- end
73
-
74
- context 'screenshot image path' do
75
- it 'should be in capybara root output' do
76
- driver_mock.should_receive(:render).with(/^#{capybara_root}\//)
77
-
78
- saver.save
79
- end
80
-
81
- it 'should have default filename format of "screenshot_Y-M-D-H-M-S.ms.png"' do
82
- driver_mock.should_receive(:render).with(/#{file_basename}\.png$/)
83
-
84
- saver.save
85
- end
86
-
87
- it "should not append timestamp if append_timestamp is false " do
88
- default_config = Capybara::Screenshot.append_timestamp
89
- Capybara::Screenshot.append_timestamp = false
90
- driver_mock.should_receive(:render).with(/screenshot.png$/)
91
-
92
- saver.save
93
- Capybara::Screenshot.append_timestamp = default_config
94
- end
95
-
96
- it 'should use filename prefix argument as basename prefix' do
97
- saver = Capybara::Screenshot::Saver.new(capybara_mock, page_mock, true, 'custom-prefix')
98
- driver_mock.should_receive(:render).with(/#{capybara_root}\/custom-prefix_#{timestamp}\.png$/)
99
-
100
- saver.save
101
- end
102
- end
103
-
104
- it 'should not save html if false passed as html argument' do
105
- saver = Capybara::Screenshot::Saver.new(capybara_mock, page_mock, false)
106
- capybara_mock.should_not_receive(:save_page)
107
-
108
- saver.save
109
- expect(saver.html_saved?).to be_falsey
110
- end
111
-
112
- it 'should not save if current_path is empty' do
113
- capybara_mock.stub(:current_path).and_return(nil)
114
- capybara_mock.should_not_receive(:save_page)
115
- driver_mock.should_not_receive(:render)
116
-
117
- saver.save
118
- expect(saver.screenshot_saved?).to be_falsey
119
- expect(saver.html_saved?).to be_falsey
120
- end
121
-
122
- describe '#output_screenshot_path' do
123
- let(:saver) { Capybara::Screenshot::Saver.new(capybara_mock, page_mock) }
124
-
125
- before do
126
- allow(saver).to receive(:html_path) { 'page.html' }
127
- allow(saver).to receive(:screenshot_path) { 'screenshot.png' }
128
- end
129
-
130
- it 'should output the path for the HTML screenshot' do
131
- saver.stub(:html_saved?).and_return(true)
132
- expect(saver).to receive(:output).with("HTML screenshot: page.html")
133
- saver.output_screenshot_path
134
- end
135
-
136
- it 'should output the path for the Image screenshot' do
137
- saver.stub(:screenshot_saved?).and_return(true)
138
- expect(saver).to receive(:output).with("Image screenshot: screenshot.png")
139
- saver.output_screenshot_path
140
- end
141
- end
142
-
143
- describe "with selenium driver" do
144
- before do
145
- capybara_mock.stub(:current_driver).and_return(:selenium)
146
- end
147
-
148
- it 'should save via browser' do
149
- browser_mock = double('browser')
150
- driver_mock.should_receive(:browser).and_return(browser_mock)
151
- browser_mock.should_receive(:save_screenshot).with(screenshot_path)
152
-
153
- saver.save
154
- expect(saver.screenshot_saved?).to be_truthy
155
- end
156
- end
157
-
158
- describe "with poltergeist driver" do
159
- before do
160
- capybara_mock.stub(:current_driver).and_return(:poltergeist)
161
- end
162
-
163
- it 'should save driver render with :full => true' do
164
- driver_mock.should_receive(:render).with(screenshot_path, {:full => true})
165
-
166
- saver.save
167
- expect(saver.screenshot_saved?).to be_truthy
168
- end
169
- end
170
-
171
- describe "with webkit driver" do
172
- before do
173
- capybara_mock.stub(:current_driver).and_return(:webkit)
174
- end
175
-
176
- context 'has render method' do
177
- before do
178
- driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(false)
179
- end
180
-
181
- it 'should save driver render' do
182
- driver_mock.should_receive(:render).with(screenshot_path)
183
-
184
- saver.save
185
- expect(saver.screenshot_saved?).to be_truthy
186
- end
187
- end
188
-
189
- context 'has save_screenshot method' do
190
- let(:webkit_options){ {width: 800, height: 600} }
191
-
192
- before do
193
- driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(true)
194
- end
195
-
196
- it 'should save driver render' do
197
- driver_mock.should_receive(:save_screenshot).with(screenshot_path, {})
198
-
199
- saver.save
200
- expect(saver.screenshot_saved?).to be_truthy
201
- end
202
-
203
- it 'should pass webkit_options to driver' do
204
- Capybara::Screenshot.stub(:webkit_options).and_return( webkit_options )
205
- driver_mock.should_receive(:save_screenshot).with(screenshot_path, webkit_options)
206
-
207
- saver.save
208
- expect(saver.screenshot_saved?).to be_truthy
209
- end
210
- end
211
- end
212
-
213
- describe "with webkit debug driver" do
214
- before do
215
- capybara_mock.stub(:current_driver).and_return(:webkit_debug)
216
- end
217
-
218
- it 'should save driver render' do
219
- driver_mock.should_receive(:render).with(screenshot_path)
220
-
221
- saver.save
222
- expect(saver.screenshot_saved?).to be_truthy
223
- end
224
- end
225
-
226
- describe "with unknown driver" do
227
- before do
228
- capybara_mock.stub(:current_driver).and_return(:unknown)
229
- saver.stub(:warn).and_return(nil)
230
- end
231
-
232
- it 'should save driver render' do
233
- driver_mock.should_receive(:render).with(screenshot_path)
234
-
235
- saver.save
236
- expect(saver.screenshot_saved?).to be_truthy
237
- end
238
-
239
- it 'should output warning about unknown results' do
240
- # Not pure mock testing
241
- saver.should_receive(:warn).with(/screenshot driver for 'unknown'.*unknown results/).and_return(nil)
242
-
243
- saver.save
244
- expect(saver.screenshot_saved?).to be_truthy
245
- end
246
-
247
- describe "with rack_test driver" do
248
- before do
249
- capybara_mock.stub(:current_driver).and_return(:rack_test)
250
- end
251
-
252
- it 'should indicate that a screenshot could not be saved' do
253
- saver.save
254
- expect(saver.screenshot_saved?).to be_falsey
255
- end
256
- end
257
-
258
- describe "with mechanize driver" do
259
- before do
260
- capybara_mock.stub(:current_driver).and_return(:mechanize)
261
- end
262
-
263
- it 'should indicate that a screenshot could not be saved' do
264
- saver.save
265
- expect(saver.screenshot_saved?).to be_falsey
266
- end
267
- end
268
- end
269
- end