Skip to content

Commit eebed33

Browse files
committed
[rb] fix bug with values nested inside chrome prefs getting camelcased
1 parent 84dd610 commit eebed33

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

rb/lib/selenium/webdriver/common/options.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ def generate_as_json(value, camelize_keys: true)
137137
value.each_with_object({}) do |(key, val), hash|
138138
next if val.respond_to?(:empty?) && val.empty?
139139

140-
key = convert_json_key(key, camelize: camelize_keys)
141-
hash[key] = generate_as_json(val, camelize_keys: camelize?(key))
140+
camelize = camelize_keys ? camelize?(key) : false
141+
key = convert_json_key(key, camelize: camelize)
142+
hash[key] = generate_as_json(val, camelize_keys: camelize)
142143
end
143144
elsif value.respond_to?(:as_json)
144145
value.as_json

rb/spec/unit/selenium/webdriver/chrome/options_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ module Chrome
234234
set_window_rect: false,
235235
args: %w[foo bar],
236236
prefs: {foo: 'bar',
237-
key_that_should_not_be_camelcased: 'baz'},
237+
key_that_should_not_be_camelcased: 'baz',
238+
nested_one: {nested_two: 'bazbar'}},
238239
binary: '/foo/bar',
239240
extensions: ['foo.crx', 'bar.crx'],
240241
encoded_extensions: ['encoded_foobar'],
@@ -262,7 +263,8 @@ module Chrome
262263
'setWindowRect' => false,
263264
key => {'args' => %w[foo bar],
264265
'prefs' => {'foo' => 'bar',
265-
'key_that_should_not_be_camelcased' => 'baz'},
266+
'key_that_should_not_be_camelcased' => 'baz',
267+
'nested_one' => {'nested_two' => 'bazbar'}},
266268
'binary' => '/foo/bar',
267269
'extensions' => %w[encoded_foobar encoded_foo encoded_bar],
268270
'foo' => 'bar',

0 commit comments

Comments
 (0)