Skip to content

Commit

Permalink
[rb] fix things I've missed
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jan 11, 2024
1 parent 13ea716 commit f21e64b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def initialize(path: nil, port: nil, log: nil, args: nil)
def launch
@executable_path ||= begin
default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new
DriverFinder.result(default_options, self.class)[:driver_path]
DriverFinder.new(default_options, self.class).driver_path
end
ServiceManager.new(self).tap(&:start)
end
Expand Down
16 changes: 8 additions & 8 deletions rb/spec/unit/selenium/webdriver/common/driver_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ module WebDriver
describe DriverFinder do
it 'class path accepts a String without calling Selenium Manager' do
allow(Chrome::Service).to receive(:driver_path).and_return('path')
allow(SeleniumManager).to receive(:result)
allow(SeleniumManager).to receive(:binary_paths)
allow(Platform).to receive(:assert_executable).with('path').and_return(true)

described_class.new(Options.chrome, Service.chrome).driver_path

expect(SeleniumManager).not_to have_received(:result)
expect(SeleniumManager).not_to have_received(:binary_paths)
expect(Platform).to have_received(:assert_executable).with('path')
end

it 'class path accepts a proc without calling Selenium Manager' do
allow(Chrome::Service).to receive(:driver_path).and_return(proc { 'path' })
allow(SeleniumManager).to receive(:result)
allow(SeleniumManager).to receive(:binary_paths)
allow(Platform).to receive(:assert_executable).with('path').and_return(true)

described_class.new(Options.chrome, Service.chrome).driver_path

expect(SeleniumManager).not_to have_received(:result)
expect(SeleniumManager).not_to have_received(:binary_paths)
expect(Platform).to have_received(:assert_executable).with('path')
end

it 'validates all returned files' do
allow(SeleniumManager).to receive(:result).and_return({'browser_path' => '/path/to/browser',
allow(SeleniumManager).to receive(:binary_paths).and_return({'browser_path' => '/path/to/browser',
'driver_path' => '/path/to/driver'})
allow(Platform).to receive(:assert_executable).with('/path/to/browser').and_return(true)
allow(Platform).to receive(:assert_executable).with('/path/to/driver').and_return(true)
Expand All @@ -57,7 +57,7 @@ module WebDriver
end

it 'wraps error with NoSuchDriverError' do
allow(SeleniumManager).to receive(:result).and_raise(Error::WebDriverError, 'this error')
allow(SeleniumManager).to receive(:binary_paths).and_raise(Error::WebDriverError, 'this error')

expect {
expect {
Expand All @@ -68,7 +68,7 @@ module WebDriver
end

it 'creates arguments' do
allow(SeleniumManager).to receive(:result).and_return({'browser_path' => '/path/to/browser',
allow(SeleniumManager).to receive(:binary_paths).and_return({'browser_path' => '/path/to/browser',
'driver_path' => '/path/to/driver'})
proxy = instance_double(Proxy, ssl: 'proxy')
options = Options.chrome(browser_version: 'stable', proxy: proxy, binary: 'path/to/browser')
Expand All @@ -77,7 +77,7 @@ module WebDriver

described_class.new(options, Service.chrome).driver_path

expect(SeleniumManager).to have_received(:result).with('--browser',
expect(SeleniumManager).to have_received(:binary_paths).with('--browser',
options.browser_name,
'--browser-version',
options.browser_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ module WebDriver
end
end

describe '.results' do
describe '.binary_paths' do
it 'returns exact output from #run' do
return_map = {}
allow(described_class).to receive_messages(binary: 'binary', run: return_map)
expect(described_class.result('something')).to eq(return_map)
expect(described_class.binary_paths('something')).to eq(return_map)
end
end
end
Expand Down

0 comments on commit f21e64b

Please sign in to comment.