Skip to content
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
9 changes: 9 additions & 0 deletions lib/ferrum/browser/options/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "singleton"
require "open3"

module Ferrum
class Browser
Expand All @@ -12,6 +13,14 @@ def self.options
instance
end

# @return [String, nil]
def self.version
out, = Open3.capture2(instance.detect_path, "--version")
out.strip
rescue Errno::ENOENT
nil
end

def to_h
self.class::DEFAULT_OPTIONS
end
Expand Down
6 changes: 6 additions & 0 deletions spec/browser/options/chrome_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@
expect(defaults.merge_default({}, options)).not_to include("use-angle" => "metal")
end
end

describe ".version" do
it "returns an executable version" do
expect(described_class.version).to match(/(Chromium|Chrome) \d/)
end
end
end