Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download correct geckdriver file on Apple Silicon #234

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/webdrivers/geckodriver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def platform_ext
when 'linux'
"linux#{System.bitsize}.tar.gz"
when 'mac'
'macos.tar.gz'
System.apple_m1_architecture? ? 'macos-aarch64.tar.gz' : 'macos.tar.gz'
when 'win'
"win#{System.bitsize}.zip"
end
Expand Down
34 changes: 34 additions & 0 deletions spec/webdrivers/geckodriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,40 @@
msg = /Net::HTTPServerException: 404 "Not Found"/
expect { geckodriver.update }.to raise_error(StandardError, msg)
end

context 'when platform is Apple Sillicon' do
it 'downloads aarch64 binary' do
allow(Webdrivers::System).to receive(:platform).and_return('mac')
allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
base = 'https://github.com/mozilla/geckodriver/releases/download'
binary = 'geckodriver-v0.31.0-macos-aarch64.tar.gz'
url = "#{base}/v0.31.0/#{binary}"

allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)

geckodriver.required_version = '0.31.0'
geckodriver.update

expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
end
end

context 'when platform isn\'t Apple Sillicon' do
it 'downloads default binary' do
allow(Webdrivers::System).to receive(:platform).and_return('mac')
allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(false)
base = 'https://github.com/mozilla/geckodriver/releases/download'
binary = 'geckodriver-v0.31.0-macos.tar.gz'
url = "#{base}/v0.31.0/#{binary}"

allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)

geckodriver.required_version = '0.31.0'
geckodriver.update

expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
end
end
end

describe '#current_version' do
Expand Down