diff --git a/lib/webdrivers/chromedriver.rb b/lib/webdrivers/chromedriver.rb index 88688880..de2f19dd 100644 --- a/lib/webdrivers/chromedriver.rb +++ b/lib/webdrivers/chromedriver.rb @@ -97,11 +97,11 @@ def apple_m1_compatible?(driver_version) false end - def apple_filename(driver_version) + def apple_m1_filename(driver_version) if apple_m1_compatible?(driver_version) - driver_version >= normalize_version('106.0.5249.61') ? 'mac_arm64' : 'mac64_m1' + driver_version >= normalize_version('106.0.5249.61') ? "mac_arm64" : "mac64_m1" else - 'mac64' + "mac64" end end @@ -115,7 +115,7 @@ def driver_filename(driver_version) elsif System.platform == 'linux' 'linux64' elsif System.platform == 'mac' - apple_filename(driver_version) + apple_m1_filename(driver_version) else raise 'Failed to determine driver filename to download for your OS.' end diff --git a/spec/webdrivers/chromedriver_spec.rb b/spec/webdrivers/chromedriver_spec.rb index 82107ade..ff8bec91 100644 --- a/spec/webdrivers/chromedriver_spec.rb +++ b/spec/webdrivers/chromedriver_spec.rb @@ -273,4 +273,42 @@ expect(chromedriver.browser_version).to be Gem::Version.new('72.0.0.0') end end + + describe "private methods" do + describe "#direct_url" do + context "with mac platform" do + + before do + allow(Webdrivers::System).to receive(:platform) { 'mac' } + end + + context "when version is lower than 106.0.5249.61" do + it do + version_string = '71.0.3578.137' + version = Gem::Version.new(version_string) + + expect(chromedriver.send(:direct_url, version)).to eq "#{chromedriver.base_url}/#{version_string}/chromedriver_mac64.zip" + end + end + + context "when version is 106.0.5249.61" do + it do + version_string = '106.0.5249.61' + version = Gem::Version.new(version_string) + + expect(chromedriver.send(:direct_url, version)).to eq "#{chromedriver.base_url}/#{version_string}/chromedriver_mac_arm64.zip" + end + end + + context "when version is higher than 106.0.5249.61" do + it do + version_string = '106.0.5249.21' + version = Gem::Version.new(version_string) + + expect(chromedriver.send(:direct_url, version)).to eq "#{chromedriver.base_url}/#{version_string}/chromedriver_mac64_m1.zip" + end + end + end + end + end end