Skip to content

Commit 885d5d4

Browse files
authored
Add Ferrum::Brower::Base.version method (#504)
1 parent b9cd95a commit 885d5d4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/ferrum/browser/options/base.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "singleton"
4+
require "open3"
45

56
module Ferrum
67
class Browser
@@ -12,6 +13,14 @@ def self.options
1213
instance
1314
end
1415

16+
# @return [String, nil]
17+
def self.version
18+
out, = Open3.capture2(instance.detect_path, "--version")
19+
out.strip
20+
rescue Errno::ENOENT
21+
nil
22+
end
23+
1524
def to_h
1625
self.class::DEFAULT_OPTIONS
1726
end

spec/browser/options/chrome_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@
2525
expect(defaults.merge_default({}, options)).not_to include("use-angle" => "metal")
2626
end
2727
end
28+
29+
describe ".version" do
30+
it "returns an executable version" do
31+
expect(described_class.version).to match(/(Chromium|Chrome) \d/)
32+
end
33+
end
2834
end

0 commit comments

Comments
 (0)