Skip to content

Commit

Permalink
Fix keyword arguments warnings in Ruby 2.7
Browse files Browse the repository at this point in the history
Passing Hash to the method accepting **kwargs is deprecated in Ruby 2.7.
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0

Fixes #8315.
  • Loading branch information
p0deje committed May 28, 2020
1 parent af6c1fd commit e6f53e8
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Options < WebDriver::Options
#

def initialize(profile: nil, encoded_extensions: nil, **opts)
super(opts)
super(**opts)

@profile = profile
@options[:encoded_extensions] = encoded_extensions if encoded_extensions
Expand Down
20 changes: 10 additions & 10 deletions rb/lib/selenium/webdriver/common/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ class << self
def for(browser, opts = {})
case browser
when :chrome
Chrome::Driver.new(opts)
Chrome::Driver.new(**opts)
when :internet_explorer, :ie
IE::Driver.new(opts)
IE::Driver.new(**opts)
when :safari
Safari::Driver.new(opts)
Safari::Driver.new(**opts)
when :firefox, :ff
Firefox::Driver.new(opts)
Firefox::Driver.new(**opts)
when :edge
Edge::Driver.new(opts)
Edge::Driver.new(**opts)
when :edge_chrome
EdgeChrome::Driver.new(opts)
EdgeChrome::Driver.new(**opts)
when :edge_html
EdgeHtml::Driver.new(opts)
EdgeHtml::Driver.new(**opts)
when :remote
Remote::Driver.new(opts)
Remote::Driver.new(**opts)
else
raise ArgumentError, "unknown driver: #{browser.inspect}"
end
Expand All @@ -73,7 +73,7 @@ def for(browser, opts = {})

def initialize(bridge: nil, listener: nil, **opts)
@service = nil
bridge ||= create_bridge(opts)
bridge ||= create_bridge(**opts)
@bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
end

Expand Down Expand Up @@ -322,7 +322,7 @@ def create_bridge(**opts)
bridge_opts = {http_client: opts.delete(:http_client), url: opts.delete(:url)}
raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?

bridge = (respond_to?(:bridge_class) ? bridge_class : Remote::Bridge).new(bridge_opts)
bridge = (respond_to?(:bridge_class) ? bridge_class : Remote::Bridge).new(**bridge_opts)

bridge.create_session(capabilities)
bridge
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge_html/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Options < WebDriver::Options
#

def initialize(**opts)
super
super(**opts)
@options[:extensions]&.each(&method(:validate_extension))
end

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/firefox/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Options < WebDriver::Options
#

def initialize(log_level: nil, **opts)
super(opts)
super(**opts)

@options[:log] ||= {level: log_level} if log_level
process_profile(@options[:profile]) if @options.key?(:profile)
Expand Down
6 changes: 3 additions & 3 deletions rb/lib/selenium/webdriver/ie/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class Options < WebDriver::Options
# @option opts [Boolean] validate_cookie_document_type
#

def initialize(args: nil, **opts)
super(opts)
def initialize(**opts)
@args = (opts.delete(:args) || []).to_set
super(**opts)

@args = (args || []).to_set
@options[:native_events] = true if @options[:native_events].nil?
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def quit_driver
end

def create_driver!(**opts, &block)
GlobalTestEnv.create_driver!(opts, &block)
GlobalTestEnv.create_driver!(**opts, &block)
end

def ensure_single_window
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def expect_request(body: nil, endpoint: nil)
expect_request(body: {capabilities: {firstMatch: ["browserName": "chrome", "goog:chromeOptions": opts]}})

expect {
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -129,7 +129,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/unit/selenium/webdriver/edge/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def expect_request(body: nil, endpoint: nil)
"ms:startPage": "http://selenium.dev"]}})

expect {
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -136,7 +136,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down Expand Up @@ -215,7 +215,7 @@ def as_json(*)
expect_request(body: {capabilities: {firstMatch: [browserName: "MicrosoftEdge",
'ms:startPage': 'http://selenium.dev']}})

expect { Driver.new(capabilities: [Options.new(browser_opts)]) }.not_to raise_exception
expect { Driver.new(capabilities: [Options.new(**browser_opts)]) }.not_to raise_exception
end

it 'with Capabilities instance' do
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def expect_request(body: nil, endpoint: nil)
expect_request(body: {capabilities: {firstMatch: ["browserName": "firefox", "moz:firefoxOptions": opts]}})

expect {
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -129,7 +129,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/unit/selenium/webdriver/ie/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def expect_request(body: nil, endpoint: nil)
"ie.browserCommandLineSwitches": "-f"}]}})

expect {
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -143,7 +143,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down Expand Up @@ -223,7 +223,7 @@ def as_json(*)
'se:ieOptions': {"startPage": 'http://selenium.dev',
'nativeEvents': true}]}})

expect { Driver.new(capabilities: [Options.new(browser_opts)]) }.not_to raise_exception
expect { Driver.new(capabilities: [Options.new(**browser_opts)]) }.not_to raise_exception
end

it 'with Capabilities instance' do
Expand Down
4 changes: 2 additions & 2 deletions rb/spec/unit/selenium/webdriver/remote/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def expect_request(body: nil, endpoint: nil)
expect_request(body: {capabilities: {firstMatch: [browserName: 'chrome', "goog:chromeOptions": opts]}})

expect {
expect { Driver.new(options: Chrome::Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Chrome::Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -142,7 +142,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(desired_capabilities: :chrome, options: Chrome::Options.new(opts))
Driver.new(desired_capabilities: :chrome, options: Chrome::Options.new(**opts))
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/unit/selenium/webdriver/safari/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def expect_request(body: nil, endpoint: nil)
"safari:automaticInspection": true]}})

expect {
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
}.not_to raise_exception
end

Expand All @@ -140,7 +140,7 @@ def expect_request(body: nil, endpoint: nil)

expect {
expect {
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
}.to have_deprecated(%i[browser_options desired_capabilities])
}.not_to raise_exception
end
Expand Down Expand Up @@ -219,7 +219,7 @@ def as_json(*)
expect_request(body: {capabilities: {firstMatch: [browserName: "safari",
'safari:automaticInspection': true]}})

expect { Driver.new(capabilities: [Options.new(browser_opts)]) }.not_to raise_exception
expect { Driver.new(capabilities: [Options.new(**browser_opts)]) }.not_to raise_exception
end

it 'with Capabilities instance' do
Expand Down

0 comments on commit e6f53e8

Please sign in to comment.