Skip to content

Commit

Permalink
Add Ferrum::Brower::Base.version method (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmexe authored Dec 2, 2024
1 parent b9cd95a commit 885d5d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 885d5d4

Please sign in to comment.