Skip to content

Commit d463abc

Browse files
committed
fix 'ensure' case for Ruby2.4 with cleanup
1 parent 2ab559c commit d463abc

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ browser.screenshot(path: "google.jpg") # => 30902
346346
# Save to Base64 the whole page not only viewport and reduce quality
347347
browser.screenshot(full: true, quality: 60) # "iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAYAAAC6uhUNAAAAAXNSR0IArs4c6Q...
348348
# Save with specific background color
349-
browser.screenshot(background_rgba_color: [0, 0, 0, 0])
349+
browser.screenshot(background_rgba_color: [0, 0, 0, 0.0])
350350
```
351351

352352
#### pdf(\*\*options) : `String` | `Integer`

spec/screenshot_spec.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,30 @@ def create_screenshot(**options)
189189
include_examples 'background_rgba_color ArgumentError' do
190190
let(:background_rgba_color) do
191191
r, g, b = 0, 0, 0
192-
[r, g , b]
192+
[r, g, b]
193193
end
194194
end
195195

196196
include_examples 'background_rgba_color ArgumentError' do
197-
let(:background_rgba_color) { '#FFF' }
197+
let(:background_rgba_color) { '#FFF' }
198198
end
199199

200200
include_examples 'background_rgba_color ArgumentError' do
201-
let(:background_rgba_color) { %w[0 0 0 0] }
201+
let(:background_rgba_color) { %w[0 0 0 0] }
202202
end
203203

204204
it 'supports screenshotting page with the specific background color' do
205-
file = PROJECT_ROOT + "/spec/tmp/screenshot.jpeg"
206-
browser.go_to
207-
browser.screenshot(path: file)
208-
content = File.read(file)
209-
browser.screenshot(path: file, background_rgba_color: [0, 0, 0, 0.0])
210-
content_with_specific_bc = File.read(file)
211-
expect(content).not_to eq(content_with_specific_bc)
212-
ensure
213-
FileUtils.rm_f([file])
205+
begin
206+
file = PROJECT_ROOT + "/spec/tmp/screenshot.jpeg"
207+
browser.go_to
208+
browser.screenshot(path: file)
209+
content = File.read(file)
210+
browser.screenshot(path: file, background_rgba_color: [0, 0, 0, 0.0])
211+
content_with_specific_bc = File.read(file)
212+
expect(content).not_to eq(content_with_specific_bc)
213+
ensure
214+
FileUtils.rm_f([file])
215+
end
214216
end
215217
end
216218

0 commit comments

Comments
 (0)