From 0e5bb5b37fd993486cb3bc70fffdda143cbb97b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 30 Jan 2023 16:33:13 +0100 Subject: [PATCH] Fix autoload of WebDriver::Remote::Bridge::COMMANDS COMMANDS is defined on WebDriver::Remote::Bridge, but is defined as an autoload on WebDriver::Remote. Since it's used in WebDriver::Remote::Bridge#commands (with all the namespaces nested), Ruby will first look for the constant in WebDriver::Remote::Bridge, then WebDriver::Remote, where it finds the autoload. It requires the file, which defines WebDriver::Remote::Bridge::COMMANDS. Then Ruby emits a warning, because it expected selenium/webdriver/remote/commands to define WebDriver::Remote::COMMANDS, since that's what the autoload declares. After that, the constant can be resolved so it still works. This properly declares the constant as autoloaded under WebDriver::Remote::Bridge. --- rb/lib/selenium/webdriver/remote.rb | 1 - rb/lib/selenium/webdriver/remote/bridge.rb | 1 + rb/lib/selenium/webdriver/remote/{ => bridge}/commands.rb | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename rb/lib/selenium/webdriver/remote/{ => bridge}/commands.rb (100%) diff --git a/rb/lib/selenium/webdriver/remote.rb b/rb/lib/selenium/webdriver/remote.rb index 54101786a7fd9..14ccc60ee113d 100644 --- a/rb/lib/selenium/webdriver/remote.rb +++ b/rb/lib/selenium/webdriver/remote.rb @@ -27,7 +27,6 @@ module Remote autoload :Driver, 'selenium/webdriver/remote/driver' autoload :Response, 'selenium/webdriver/remote/response' autoload :Capabilities, 'selenium/webdriver/remote/capabilities' - autoload :COMMANDS, 'selenium/webdriver/remote/commands' module Http autoload :Common, 'selenium/webdriver/remote/http/common' diff --git a/rb/lib/selenium/webdriver/remote/bridge.rb b/rb/lib/selenium/webdriver/remote/bridge.rb index a061853d8252d..5d5908d8bbd83 100644 --- a/rb/lib/selenium/webdriver/remote/bridge.rb +++ b/rb/lib/selenium/webdriver/remote/bridge.rb @@ -21,6 +21,7 @@ module Selenium module WebDriver module Remote class Bridge + autoload :COMMANDS, 'selenium/webdriver/remote/bridge/commands' include Atoms PORT = 4444 diff --git a/rb/lib/selenium/webdriver/remote/commands.rb b/rb/lib/selenium/webdriver/remote/bridge/commands.rb similarity index 100% rename from rb/lib/selenium/webdriver/remote/commands.rb rename to rb/lib/selenium/webdriver/remote/bridge/commands.rb