Skip to content

Commit 2ab559c

Browse files
committed
add test for specific background color option
1 parent e86ba16 commit 2ab559c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/ferrum/page/screenshot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def validate_background_rgba_color(option)
134134
option && !(
135135
option.is_a?(Array) &&
136136
option.size == 4 &&
137-
option.all? { |value| value.is_a?(Integer) }
137+
option.all? { |value| value.is_a?(Numeric) }
138138
)
139139
end
140140

spec/screenshot_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ def create_screenshot(**options)
200200
include_examples 'background_rgba_color ArgumentError' do
201201
let(:background_rgba_color) { %w[0 0 0 0] }
202202
end
203+
204+
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])
214+
end
203215
end
204216

205217
shared_examples "when scale is set" do

0 commit comments

Comments
 (0)