Skip to content

Commit a2d804c

Browse files
committed
remove constant and use instance variable instead
1 parent da15ccd commit a2d804c

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

java/.idea/workspace.xml

Lines changed: 28 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rb/lib/selenium/webdriver/common/network.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
module Selenium
2121
module WebDriver
2222
class Network
23-
AUTH_CALLBACKS = {}
23+
attr_reader :auth_callbacks
24+
2425
def initialize(bridge)
2526
@network = BiDi::Network.new(bridge.bidi)
27+
@auth_callbacks = {}
2628
end
2729

2830
def add_auth_handler(username, password)
@@ -31,19 +33,19 @@ def add_auth_handler(username, password)
3133
request_id = event['requestId']
3234
@network.continue_with_auth(request_id, username, password)
3335
end
34-
AUTH_CALLBACKS[auth_id] = intercept
36+
@auth_callbacks[auth_id] = intercept
3537

3638
auth_id
3739
end
3840

3941
def remove_auth_handler(id)
40-
intercept = AUTH_CALLBACKS[id]
42+
intercept = @auth_callbacks[id]
4143
@network.remove_intercept(intercept['intercept'])
42-
AUTH_CALLBACKS.delete(id)
44+
@auth_callbacks.delete(id)
4345
end
4446

4547
def clear_auth_handlers
46-
AUTH_CALLBACKS.each_key { |id| remove_auth_handler(id) }
48+
@auth_callbacks.each_key { |id| remove_auth_handler(id) }
4749
end
4850
end # Network
4951
end # WebDriver

rb/sig/lib/selenium/webdriver/common/network.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module Selenium
22
module WebDriver
33
class Network
4-
AUTH_CALLBACKS: Hash[String, String]
5-
64
@network: BiDi::Network
75

6+
attr_reader auth_callbacks: Hash[String, String]
7+
88
def initialize: (Remote::Bridge bridge) -> void
99

1010
def add_auth_handler: (String username, String password) -> String

rb/spec/integration/selenium/webdriver/network_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module WebDriver
3131
reset_driver!(web_socket_url: true) do |driver|
3232
network = described_class.new(driver)
3333
network.add_auth_handler(username, password)
34-
expect(described_class::AUTH_CALLBACKS.count).to be 1
34+
expect(network.auth_callbacks.count).to be 1
3535
end
3636
end
3737

@@ -40,7 +40,7 @@ module WebDriver
4040
network = described_class.new(driver)
4141
id = network.add_auth_handler(username, password)
4242
network.remove_auth_handler(id)
43-
expect(described_class::AUTH_CALLBACKS.count).to be 0
43+
expect(network.auth_callbacks.count).to be 0
4444
end
4545
end
4646

@@ -50,7 +50,7 @@ module WebDriver
5050
network.add_auth_handler(username, password)
5151
network.add_auth_handler(username, password)
5252
network.clear_auth_handlers
53-
expect(described_class::AUTH_CALLBACKS.count).to be 0
53+
expect(network.auth_callbacks.count).to be 0
5454
end
5555
end
5656
end

0 commit comments

Comments
 (0)