From ad054975ad33470026e3934479d3dbefdef5e51c Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Thu, 12 May 2022 08:55:49 +0200 Subject: [PATCH] Supported Ruby 2.6 --- .github/workflows/tests.yml | 2 +- .rubocop.yml | 2 +- CHANGELOG.md | 2 +- ferrum.gemspec | 2 +- lib/ferrum/browser/binary.rb | 8 +++++--- spec/browser/binary_spec.rb | 4 ++++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 12e3026c..2c226190 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: gemfile: [websocket-driver-0.6.x, websocket-driver-0.7.x] - ruby: [2.7, 3.0, 3.1] + ruby: [2.6, 2.7, 3.0, 3.1] runs-on: ubuntu-latest env: FERRUM_PROCESS_TIMEOUT: 20 diff --git a/.rubocop.yml b/.rubocop.yml index 48b82ff6..fdb84d9b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 2.6 NewCops: enable Layout/FirstArrayElementIndentation: diff --git a/CHANGELOG.md b/CHANGELOG.md index 813b96b2..c1168b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ a block with this page, after which the page is closed. ### Changed - Use `Concurrent::MVar` as `execution_id` in `Ferrum::Frame` -- Min Ruby version >= 2.7 +- Min Ruby version is 2.6 and 3.0 is supported - `Ferrum::Page#bypass_csp` accepts hash as argument `enabled: true` by default - `Ferrum::Context#has_target?` -> `Ferrum::Context#target?` - We now start looking for Chrome first instead of Chromium, the order for checking binaries has changed diff --git a/ferrum.gemspec b/ferrum.gemspec index f35852b6..69eb5622 100644 --- a/ferrum.gemspec +++ b/ferrum.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| "rubygems_mfa_required" => "true" } - s.required_ruby_version = ">= 2.7.0" + s.required_ruby_version = ">= 2.6.0" s.add_runtime_dependency "addressable", "~> 2.5" s.add_runtime_dependency "concurrent-ruby", "~> 1.1" diff --git a/lib/ferrum/browser/binary.rb b/lib/ferrum/browser/binary.rb index 733db009..36bd456c 100644 --- a/lib/ferrum/browser/binary.rb +++ b/lib/ferrum/browser/binary.rb @@ -28,14 +28,16 @@ def prepare_paths end def lazy_find(cmds) - cmds.lazy.filter_map do |cmd, path, ext| - cmd = File.expand_path("#{cmd}#{ext}", path) unless File.absolute_path?(cmd) + cmds.lazy.map do |cmd, path, ext| + absolute_path = File.absolute_path(cmd) + is_absolute_path = absolute_path == cmd + cmd = File.expand_path("#{cmd}#{ext}", path) unless is_absolute_path next unless File.executable?(cmd) next if File.directory?(cmd) cmd - end + end.reject(&:nil?) end end end diff --git a/spec/browser/binary_spec.rb b/spec/browser/binary_spec.rb index 011bcd44..2e944031 100644 --- a/spec/browser/binary_spec.rb +++ b/spec/browser/binary_spec.rb @@ -45,6 +45,10 @@ class Browser expect(Binary.find(%w[bin4])).to eq(bin4_exe) end + it "finds binary with absolute path" do + expect(Binary.find(bin4_exe)).to eq(bin4_exe) + end + it "finds binary without ext" do ENV["PATHEXT"] = ".com;.exe"