|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | describe Ferrum::Browser::Options::Chrome do |
4 | | - def reload_chrome_class |
5 | | - described_class.constants(false).each do |const| |
6 | | - described_class.send(:remove_const, const) |
7 | | - end |
8 | | - load 'ferrum/browser/options/chrome.rb' |
9 | | - end |
| 4 | + let(:defaults) { described_class.options } |
| 5 | + let(:options) { Ferrum::Browser::Options.new } |
10 | 6 |
|
11 | | - describe "DEFAULT_OPTIONS" do |
12 | | - it "includes `disable-gpu` flag only on windows" do |
| 7 | + describe "#merge_default" do |
| 8 | + it "includes --disable-gpu flag on windows" do |
13 | 9 | allow(Ferrum::Utils::Platform).to receive(:windows?).and_return(true) |
14 | | - reload_chrome_class |
15 | | - expect(described_class::DEFAULT_OPTIONS).to include("disable-gpu" => nil) |
| 10 | + expect(defaults.merge_default({}, options)).to include("disable-gpu" => nil) |
| 11 | + end |
16 | 12 |
|
| 13 | + it "excludes --disable-gpu flag on other platforms" do |
17 | 14 | allow(Ferrum::Utils::Platform).to receive(:windows?).and_return(false) |
18 | | - reload_chrome_class |
19 | | - expect(described_class::DEFAULT_OPTIONS).not_to include("disable-gpu" => nil) |
20 | | - |
21 | | - allow(Ferrum::Utils::Platform).to receive(:windows?).and_call_original |
22 | | - reload_chrome_class |
| 15 | + expect(defaults.merge_default({}, options)).not_to include("disable-gpu" => nil) |
23 | 16 | end |
24 | 17 |
|
25 | | - it "includes `use-angle=metal` flag only on mac arm" do |
| 18 | + it "includes --use-angle=metal flag on mac arm" do |
26 | 19 | allow(Ferrum::Utils::Platform).to receive(:mac_arm?).and_return(true) |
27 | | - reload_chrome_class |
28 | | - expect(described_class::DEFAULT_OPTIONS).to include("use-angle" => "metal") |
| 20 | + expect(defaults.merge_default({}, options)).to include("use-angle" => "metal") |
| 21 | + end |
29 | 22 |
|
| 23 | + it "excludes --use-angle=metal flag on mac arm" do |
30 | 24 | allow(Ferrum::Utils::Platform).to receive(:mac_arm?).and_return(false) |
31 | | - reload_chrome_class |
32 | | - expect(described_class::DEFAULT_OPTIONS).not_to include("use-angle" => "metal") |
33 | | - |
34 | | - allow(Ferrum::Utils::Platform).to receive(:mac_arm?).and_call_original |
35 | | - reload_chrome_class |
| 25 | + expect(defaults.merge_default({}, options)).not_to include("use-angle" => "metal") |
36 | 26 | end |
37 | 27 | end |
38 | 28 | end |
0 commit comments