Skip to content

Commit

Permalink
[rb] remove Firefox::Binary class
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jul 17, 2019
1 parent a0a20a6 commit 2fd646c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 172 deletions.
13 changes: 0 additions & 13 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ def chrome(**opts)
end

def firefox(**opts)
binary_path = Firefox::Binary.path
args = opts.delete(:args)
case args
when Hash
args[:binary] ||= binary_path
opts[:args] = args
when Array
opts[:args] = ["--binary=#{binary_path}"]
opts[:args] += args
else
opts[:args] = ["--binary=#{binary_path}"]
end

Firefox::Service.new(**opts)
end

Expand Down
8 changes: 6 additions & 2 deletions rb/lib/selenium/webdriver/firefox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Selenium
module WebDriver
module Firefox
autoload :Extension, 'selenium/webdriver/firefox/extension'
autoload :Binary, 'selenium/webdriver/firefox/binary'
autoload :ProfilesIni, 'selenium/webdriver/firefox/profiles_ini'
autoload :Profile, 'selenium/webdriver/firefox/profile'
autoload :Bridge, 'selenium/webdriver/firefox/bridge'
Expand All @@ -52,7 +51,12 @@ def self.driver_path
end

def self.path=(path)
Binary.path = path
Platform.assert_executable path
@path = path
end

def self.path
@path ||= nil
end
end # Firefox
end # WebDriver
Expand Down
110 changes: 0 additions & 110 deletions rb/lib/selenium/webdriver/firefox/binary.rb

This file was deleted.

5 changes: 4 additions & 1 deletion rb/lib/selenium/webdriver/firefox/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def log_level=(level)
#

def as_json(*)
{KEY => generate_as_json(super)}
options = super
options['binary'] ||= Firefox.path if Firefox.path

{KEY => generate_as_json(options)}
end

private
Expand Down
38 changes: 0 additions & 38 deletions rb/spec/unit/selenium/webdriver/firefox/binary_spec.rb

This file was deleted.

14 changes: 6 additions & 8 deletions rb/spec/unit/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module WebDriver

before do
allow(Platform).to receive(:assert_executable).and_return(true)
allow(Firefox::Binary).to receive(:path).and_return('/foo/bar')
end

describe '#new' do
Expand Down Expand Up @@ -85,20 +84,20 @@ module WebDriver
expect(service.executable_path).to eq path
end

it 'provides binary path by default' do
it 'does not create args by default' do
allow(Platform).to receive(:find_binary).and_return(service_path)

service = Service.firefox

expect(service.instance_variable_get('@extra_args')).to eq(['--binary=/foo/bar'])
expect(service.instance_variable_get('@extra_args')).to be_empty
end

it 'uses provided args' do
allow(Platform).to receive(:find_binary).and_return(service_path)

service = Service.firefox(args: ['--foo', '--bar'])

expect(service.instance_variable_get('@extra_args')).to include('--foo', '--bar')
expect(service.instance_variable_get('@extra_args')).to eq ['--foo', '--bar']
end

# This is deprecated behavior
Expand All @@ -108,7 +107,7 @@ module WebDriver
service = Service.firefox(args: {log: '/path/to/log',
marionette_port: 4})

expect(service.instance_variable_get('@extra_args')).to include('--log=/path/to/log', '--marionette-port=4')
expect(service.instance_variable_get('@extra_args')).to eq ['--log=/path/to/log', '--marionette-port=4']
end
end
end
Expand All @@ -120,7 +119,6 @@ module Firefox

before do
allow(Remote::Bridge).to receive(:new).and_return(bridge)
allow(Firefox::Binary).to receive(:path).and_return('/foo/bar')
end

it 'is not created when :url is provided' do
Expand All @@ -140,7 +138,7 @@ module Firefox

expect(Service).to receive(:new).with(path: driver_path,
port: nil,
args: ['--binary=/foo/bar']).and_return(service)
args: nil).and_return(service)

expect {
described_class.new(driver_path: driver_path)
Expand All @@ -152,7 +150,7 @@ module Firefox

expect(Service).to receive(:new).with(path: nil,
port: driver_port,
args: ['--binary=/foo/bar']).and_return(service)
args: nil).and_return(service)

expect {
described_class.new(port: driver_port)
Expand Down

0 comments on commit 2fd646c

Please sign in to comment.