Skip to content

Commit

Permalink
[rb] fix bug with values nested inside chrome prefs getting camelcased
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Mar 24, 2021
1 parent 84dd610 commit eebed33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions rb/lib/selenium/webdriver/common/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def generate_as_json(value, camelize_keys: true)
value.each_with_object({}) do |(key, val), hash|
next if val.respond_to?(:empty?) && val.empty?

key = convert_json_key(key, camelize: camelize_keys)
hash[key] = generate_as_json(val, camelize_keys: camelize?(key))
camelize = camelize_keys ? camelize?(key) : false
key = convert_json_key(key, camelize: camelize)
hash[key] = generate_as_json(val, camelize_keys: camelize)
end
elsif value.respond_to?(:as_json)
value.as_json
Expand Down
6 changes: 4 additions & 2 deletions rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ module Chrome
set_window_rect: false,
args: %w[foo bar],
prefs: {foo: 'bar',
key_that_should_not_be_camelcased: 'baz'},
key_that_should_not_be_camelcased: 'baz',
nested_one: {nested_two: 'bazbar'}},
binary: '/foo/bar',
extensions: ['foo.crx', 'bar.crx'],
encoded_extensions: ['encoded_foobar'],
Expand Down Expand Up @@ -262,7 +263,8 @@ module Chrome
'setWindowRect' => false,
key => {'args' => %w[foo bar],
'prefs' => {'foo' => 'bar',
'key_that_should_not_be_camelcased' => 'baz'},
'key_that_should_not_be_camelcased' => 'baz',
'nested_one' => {'nested_two' => 'bazbar'}},
'binary' => '/foo/bar',
'extensions' => %w[encoded_foobar encoded_foo encoded_bar],
'foo' => 'bar',
Expand Down

0 comments on commit eebed33

Please sign in to comment.