Skip to content

Commit ad4b892

Browse files
committed
Model devices as simply hashes of options for the driver
1 parent 694efa0 commit ad4b892

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/capybara/cuprite/devices.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Capybara
4+
module Cuprite
5+
module Devices
6+
IPHONE_14 = { height: 844, width: 390, mobile: true, scale_factor: 3 }
7+
end
8+
end
9+
end

lib/capybara/cuprite/page.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ def prepare_page
144144
super
145145

146146
width, height = @options.window_size
147-
if @options.mobile
148-
resize(width: 0, height: 0, mobile: @options.mobile)
149-
else
150-
resize(width: width, height: height, mobile: @options.mobile)
151-
end
147+
resize(width: width, height: height, mobile: @options.mobile)
152148

153149
if @options.url_blacklist.any?
154150
network.blacklist = @options.url_blacklist

spec/spec_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
require "capybara/spec/spec_helper"
1313
require "capybara/cuprite"
14+
require "capybara/cuprite/devices"
1415

1516
require "support/test_app"
1617
require "support/external_browser"
@@ -31,7 +32,7 @@
3132
end
3233

3334
Capybara.register_driver(:cuprite_mobile) do |app|
34-
options = { mobile: true }
35+
options = Capybara::Cuprite::Devices::IPHONE_14
3536
options.merge!(inspector: true) if ENV["INSPECTOR"]
3637
options.merge!(logger: StringIO.new) if ENV["CI"]
3738
options.merge!(headless: false) if ENV["HEADLESS"] == "false"

0 commit comments

Comments
 (0)