diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bdff0062..3b0f1fae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,8 +5,8 @@ on: pull_request: branches: [ master ] paths: - - '*.rb' - - '*.yml' + - '**.rb' + - '**.yml' - '.github/workflows/lint.yml' - '!bin/**' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb9beeee..e1f30d9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ on: workflow_dispatch: env: - BUNDLE_GEMFILE: gemfiles/rails70_gems.rb + BUNDLE_GEMFILE: gemfiles/rails71_gems.rb DEBIAN_FRONTEND: noninteractive FERRUM_PROCESS_TIMEOUT: 40 RUBY_YJIT_ENABLE: 1 @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0 + ruby-version: 3.2 bundler-cache: true - name: Cache Webdrivers uses: actions/cache@v3 @@ -137,29 +137,33 @@ jobs: matrix: ruby-version: [ 3.2, 3.1, 3.0, jruby ] gemfile: + - rails71_gems.rb - rails70_gems.rb - rails61_gems.rb experimental: [ false ] exclude: # We already tested last version - ruby-version: 3.2 - gemfile: gemfiles/rails70_gems.rb + gemfile: rails71_gems.rb experimental: false include: - ruby-version: 3.2 gemfile: edge_gems.rb experimental: true - ruby-version: ruby-head - gemfile: rails70_gems.rb + gemfile: rails71_gems.rb + experimental: true + - ruby-version: 3.3.0-preview2 + gemfile: rails71_gems.rb experimental: true - ruby-version: jruby-head - gemfile: rails70_gems.rb + gemfile: rails71_gems.rb experimental: true - ruby-version: truffleruby - gemfile: rails70_gems.rb + gemfile: rails71_gems.rb experimental: true - ruby-version: truffleruby+graalvm - gemfile: rails70_gems.rb + gemfile: rails71_gems.rb experimental: true env: diff --git a/Rakefile b/Rakefile index 374080c8..fa696d71 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ task "clobber" do end task "test:benchmark" do - require_relative "./scripts/benchmark/find_region_benchmark" + require_relative "scripts/benchmark/find_region_benchmark" benchmark = Capybara::Screenshot::Diff::Drivers::FindRegionBenchmark.new puts "For Medium Screen Size: 800x600" diff --git a/gemfiles/rails71_gems.rb b/gemfiles/rails71_gems.rb new file mode 100644 index 00000000..32be55d6 --- /dev/null +++ b/gemfiles/rails71_gems.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +gems = "#{File.dirname __dir__}/gems.rb" +eval File.read(gems), binding, gems + +gem "actionpack", "~> 7.1", "< 7.2" +gem "capybara", ">= 3.26" diff --git a/lib/capybara/screenshot/diff/image_compare.rb b/lib/capybara/screenshot/diff/image_compare.rb index 63b6c8c0..3acb1194 100644 --- a/lib/capybara/screenshot/diff/image_compare.rb +++ b/lib/capybara/screenshot/diff/image_compare.rb @@ -159,11 +159,6 @@ def preprocess_images(images) def preprocess_image(image) result = image - # FIXME: How can we access to this method from public interface? Is this not documented feature? - if dimensions && driver.inscribed?(dimensions, result) - result = driver.crop(dimensions, result) - end - if skip_area result = ignore_skipped_area(result) end @@ -209,14 +204,14 @@ def annotate_and_save_image(difference, image, image_path) DIFF_COLOR = [255, 0, 0, 255].freeze def annotate_difference(image, region) - driver.draw_rectangles(Array[image], region, DIFF_COLOR, offset: 1).first + driver.draw_rectangles([image], region, DIFF_COLOR, offset: 1).first end SKIP_COLOR = [255, 192, 0, 255].freeze def annotate_skip_areas(image, skip_areas) skip_areas.reduce(image) do |memo, region| - driver.draw_rectangles(Array[memo], region, SKIP_COLOR).first + driver.draw_rectangles([memo], region, SKIP_COLOR).first end end end diff --git a/test/capybara/screenshot/diff/image_compare_test.rb b/test/capybara/screenshot/diff/image_compare_test.rb index 5bea8e35..06dbf19b 100644 --- a/test/capybara/screenshot/diff/image_compare_test.rb +++ b/test/capybara/screenshot/diff/image_compare_test.rb @@ -5,7 +5,7 @@ require "capybara/screenshot/diff/drivers/chunky_png_driver" if defined?(Vips) require "capybara/screenshot/diff/drivers/vips_driver" -elsif ENV['SCREENSHOT_DRIVER'] == 'vips' +elsif ENV["SCREENSHOT_DRIVER"] == "vips" raise 'Required `ruby-vips` gem or `vips` library is missing. Ensure "ruby-vips" gem and "vips" library is installed.' end @@ -43,10 +43,10 @@ class ImageCompareTest < ActionDispatch::IntegrationTest test "it can handle very long input filenames" do skip "VIPS not present. Skipping VIPS driver tests." unless defined?(Vips) - filename = %w(this-0000000000000000000000000000000000000000000000000-path/is/extremely/ + filename = %w[this-0000000000000000000000000000000000000000000000000-path/is/extremely/ long/and/if/the/directories/are/flattened/in/ the_temporary_they_will_cause_the_filename_to_exceed_ - the_limit_on_most_unix_systems_which_nobody_wants.png).join + the_limit_on_most_unix_systems_which_nobody_wants.png].join comparison = make_comparison(:a, :b, destination: (Rails.root / filename), driver: :vips) assert comparison.different? diff --git a/test/integration/browser_screenshot_test.rb b/test/integration/browser_screenshot_test.rb index 7039b211..ab4600cd 100644 --- a/test/integration/browser_screenshot_test.rb +++ b/test/integration/browser_screenshot_test.rb @@ -192,7 +192,7 @@ def test_screenshot_selected_element def test_await_all_images_are_loaded visit "/index.html" assert_raises Minitest::Assertion do - BrowserHelpers.stub(:pending_image_to_load, 'http://127.0.0.1:62815/image.png') do + BrowserHelpers.stub(:pending_image_to_load, "http://127.0.0.1:62815/image.png") do screenshot :index end end