Skip to content

Commit 2a98236

Browse files
committed
[rb] driver constructor no longer accepts service parameters only service objects
1 parent c6cc197 commit 2a98236

File tree

6 files changed

+9
-192
lines changed

6 files changed

+9
-192
lines changed

rb/lib/selenium/webdriver/common/driver.rb

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def ref
308308
attr_reader :bridge
309309

310310
def create_bridge(**opts)
311-
opts[:url] ||= service_url(opts)
311+
opts[:url] ||= service_url(opts.delete(:service))
312312
caps = opts.delete(:capabilities)
313313
# NOTE: This is deprecated
314314
cap_array = caps.is_a?(Hash) ? [caps] : Array(caps)
@@ -359,19 +359,9 @@ def generate_capabilities(cap_array)
359359
}.inject(:merge) || Remote::Capabilities.send(browser || :new)
360360
end
361361

362-
def service_url(opts)
363-
service_config = opts.delete(:service)
364-
%i[driver_opts driver_path port].each do |key|
365-
next unless opts.key? key
366-
367-
WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service',
368-
id: "service_#{key}".to_sym)
369-
end
370-
service_config ||= Service.send(browser,
371-
args: opts.delete(:driver_opts),
372-
path: opts.delete(:driver_path),
373-
port: opts.delete(:port))
374-
@service = service_config.launch
362+
def service_url(service)
363+
service ||= Service.send(browser)
364+
@service = service.launch
375365
@service.uri
376366
end
377367

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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -134,44 +134,7 @@ module WebDriver
134134
allow(Service).to receive(:new).and_return(service)
135135

136136
driver.new
137-
expect(Service).to have_received(:new).with(hash_excluding(url: anything))
138-
end
139-
140-
it 'accepts :driver_path but throws deprecation notice' do
141-
driver_path = '/path/to/driver'
142-
143-
allow(Service).to receive(:new).with(path: driver_path,
144-
port: nil,
145-
args: nil).and_return(service)
146-
147-
expect {
148-
driver.new(driver_path: driver_path)
149-
}.to have_deprecated(:service_driver_path)
150-
end
151-
152-
it 'accepts :port but throws deprecation notice' do
153-
driver_port = 1234
154-
155-
allow(Service).to receive(:new).with(path: nil,
156-
port: driver_port,
157-
args: nil).and_return(service)
158-
159-
expect {
160-
driver.new(port: driver_port)
161-
}.to have_deprecated(:service_port)
162-
end
163-
164-
it 'accepts :driver_opts but throws deprecation notice' do
165-
driver_opts = {foo: 'bar',
166-
bar: ['--foo', '--bar']}
167-
168-
allow(Service).to receive(:new).with(path: nil,
169-
port: nil,
170-
args: driver_opts).and_return(service)
171-
172-
expect {
173-
driver.new(driver_opts: driver_opts)
174-
}.to have_deprecated(:service_driver_opts)
137+
expect(Service).to have_received(:new).with(no_args)
175138
end
176139

177140
it 'accepts :service without creating a new instance' do

rb/spec/unit/selenium/webdriver/edge/service_spec.rb

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,32 +123,7 @@ module WebDriver
123123
allow(Service).to receive(:new).and_return(service)
124124

125125
driver.new
126-
expect(Service).to have_received(:new).with(hash_excluding(url: anything))
127-
end
128-
129-
it 'accepts :port but throws deprecation notice' do
130-
driver_port = 1234
131-
132-
allow(Service).to receive(:new).with(path: nil,
133-
port: driver_port,
134-
args: nil).and_return(service)
135-
136-
expect {
137-
driver.new(port: driver_port)
138-
}.to have_deprecated(:service_port)
139-
end
140-
141-
it 'accepts :driver_opts but throws deprecation notice' do
142-
driver_opts = {foo: 'bar',
143-
bar: ['--foo', '--bar']}
144-
145-
allow(Service).to receive(:new).with(path: nil,
146-
port: nil,
147-
args: driver_opts).and_return(service)
148-
149-
expect {
150-
driver.new(driver_opts: driver_opts)
151-
}.to have_deprecated(:service_driver_opts)
126+
expect(Service).to have_received(:new).with(no_args)
152127
end
153128

154129
it 'accepts :service without creating a new instance' do

rb/spec/unit/selenium/webdriver/firefox/service_spec.rb

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -132,44 +132,7 @@ module WebDriver
132132
allow(Service).to receive(:new).and_return(service)
133133

134134
driver.new
135-
expect(Service).to have_received(:new).with(hash_excluding(url: anything))
136-
end
137-
138-
it 'accepts :driver_path but throws deprecation notice' do
139-
driver_path = '/path/to/driver'
140-
141-
allow(Service).to receive(:new).with(path: driver_path,
142-
port: nil,
143-
args: nil).and_return(service)
144-
145-
expect {
146-
driver.new(driver_path: driver_path)
147-
}.to have_deprecated(:service_driver_path)
148-
end
149-
150-
it 'accepts :port but throws deprecation notice' do
151-
driver_port = 1234
152-
153-
allow(Service).to receive(:new).with(path: nil,
154-
port: driver_port,
155-
args: nil).and_return(service)
156-
157-
expect {
158-
driver.new(port: driver_port)
159-
}.to have_deprecated(:service_port)
160-
end
161-
162-
it 'accepts :driver_opts but throws deprecation notice' do
163-
driver_opts = {foo: 'bar',
164-
bar: ['--foo', '--bar']}
165-
166-
allow(Service).to receive(:new).with(path: nil,
167-
port: nil,
168-
args: driver_opts).and_return(service)
169-
170-
expect {
171-
driver.new(driver_opts: driver_opts)
172-
}.to have_deprecated(:service_driver_opts)
135+
expect(Service).to have_received(:new).with(no_args)
173136
end
174137

175138
it 'accepts :service without creating a new instance' do

rb/spec/unit/selenium/webdriver/ie/service_spec.rb

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -135,44 +135,7 @@ module WebDriver
135135
allow(Service).to receive(:new).and_return(service)
136136

137137
driver.new
138-
expect(Service).to have_received(:new).with(hash_excluding(url: anything))
139-
end
140-
141-
it 'accepts :driver_path but throws deprecation notice' do
142-
driver_path = '/path/to/driver'
143-
144-
allow(Service).to receive(:new).with(path: driver_path,
145-
port: nil,
146-
args: nil).and_return(service)
147-
148-
expect {
149-
driver.new(driver_path: driver_path)
150-
}.to have_deprecated(:service_driver_path)
151-
end
152-
153-
it 'accepts :port but throws deprecation notice' do
154-
driver_port = 1234
155-
156-
allow(Service).to receive(:new).with(path: nil,
157-
port: driver_port,
158-
args: nil).and_return(service)
159-
160-
expect {
161-
driver.new(port: driver_port)
162-
}.to have_deprecated(:service_port)
163-
end
164-
165-
it 'accepts :driver_opts but throws deprecation notice' do
166-
driver_opts = {foo: 'bar',
167-
bar: ['--foo', '--bar']}
168-
169-
allow(Service).to receive(:new).with(path: nil,
170-
port: nil,
171-
args: driver_opts).and_return(service)
172-
173-
expect {
174-
driver.new(driver_opts: driver_opts)
175-
}.to have_deprecated(:service_driver_opts)
138+
expect(Service).to have_received(:new).with(no_args)
176139
end
177140

178141
it 'accepts :service without creating a new instance' do

rb/spec/unit/selenium/webdriver/safari/service_spec.rb

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -126,44 +126,7 @@ module WebDriver
126126
allow(Service).to receive(:new).and_return(service)
127127

128128
driver.new
129-
expect(Service).to have_received(:new).with(hash_excluding(url: anything))
130-
end
131-
132-
it 'accepts :driver_path but throws deprecation notice' do
133-
driver_path = '/path/to/driver'
134-
135-
allow(Service).to receive(:new).with(path: driver_path,
136-
port: nil,
137-
args: nil).and_return(service)
138-
139-
expect {
140-
driver.new(driver_path: driver_path)
141-
}.to have_deprecated(:service_driver_path)
142-
end
143-
144-
it 'accepts :port but throws deprecation notice' do
145-
driver_port = 1234
146-
147-
allow(Service).to receive(:new).with(path: nil,
148-
port: driver_port,
149-
args: nil).and_return(service)
150-
151-
expect {
152-
driver.new(port: driver_port)
153-
}.to have_deprecated(:service_port)
154-
end
155-
156-
it 'accepts :driver_opts but throws deprecation notice' do
157-
driver_opts = {foo: 'bar',
158-
bar: ['--foo', '--bar']}
159-
160-
allow(Service).to receive(:new).with(path: nil,
161-
port: nil,
162-
args: driver_opts).and_return(service)
163-
164-
expect {
165-
driver.new(driver_opts: driver_opts)
166-
}.to have_deprecated(:service_driver_opts)
129+
expect(Service).to have_received(:new).with(no_args)
167130
end
168131

169132
it 'accepts :service without creating a new instance' do

0 commit comments

Comments
 (0)