From 86b60f756050974c1c97ef00806b3ae13705df4a Mon Sep 17 00:00:00 2001 From: Tobias Klonk Date: Thu, 16 Feb 2023 12:32:28 +0100 Subject: [PATCH 1/5] add last_request.url this is now required since https://github.com/teamcapybara/capybara/commit/fae938ef4e62bd6936f1c4dd99015d538df3cedb changed the referrer_urls are constructed this fixes the incompatibillity to capybara 3.37.0 described here: https://github.com/phillbaker/capybara-mechanize/pull/72 --- lib/capybara/mechanize/browser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/capybara/mechanize/browser.rb b/lib/capybara/mechanize/browser.rb index 1bcb804..d69329c 100644 --- a/lib/capybara/mechanize/browser.rb +++ b/lib/capybara/mechanize/browser.rb @@ -34,7 +34,7 @@ def last_response end def last_request - last_request_remote? ? OpenStruct.new(request_method: @last_method, params: @last_params) : super + last_request_remote? ? OpenStruct.new(request_method: @last_method, params: @last_params, url: remote_response.current_url) : super end # For each of these http methods, we want to intercept the method call. From 838e0b624319d2cf9a1f8176c79cf0f8cd3720c8 Mon Sep 17 00:00:00 2001 From: Tobias Klonk Date: Thu, 16 Feb 2023 12:35:06 +0100 Subject: [PATCH 2/5] ignore :offset option for click capybara 3.38.0 introcuded a new default were the :offset option with a value :center is send with every click. https://github.com/teamcapybara/capybara/blob/master/History.md#version-3380 --- lib/capybara/mechanize/node.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/capybara/mechanize/node.rb b/lib/capybara/mechanize/node.rb index 90ea6eb..c7c6589 100644 --- a/lib/capybara/mechanize/node.rb +++ b/lib/capybara/mechanize/node.rb @@ -2,6 +2,7 @@ class Capybara::Mechanize::Node < Capybara::RackTest::Node def click(keys = [], **options) + options.delete(:offset) raise ArgumentError, 'The mechanize driver does not support click options' unless keys.empty? && options.empty? submits = respond_to?(:submits?) ? submits? : From 08fd48d051dfa5999baa4729b18f36e988e4e1cf Mon Sep 17 00:00:00 2001 From: Tobias Klonk Date: Thu, 16 Feb 2023 12:36:01 +0100 Subject: [PATCH 3/5] relax capybara version restriction to allow all version up to 4 --- capybara-mechanize.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capybara-mechanize.gemspec b/capybara-mechanize.gemspec index e4e3a54..41425a0 100644 --- a/capybara-mechanize.gemspec +++ b/capybara-mechanize.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.rubygems_version = '1.3.7' - s.add_runtime_dependency('capybara', ['>= 3.0.0', '< 3.37.0']) + s.add_runtime_dependency('capybara', ['>= 3.0.0', '< 4']) s.add_runtime_dependency('mechanize', ['~> 2.8.5']) s.add_development_dependency('launchy', ['>= 2.0.4']) From 478425166c72660fa1fcdcff15785f888eeb5b08 Mon Sep 17 00:00:00 2001 From: Tobias Klonk Date: Thu, 16 Feb 2023 12:37:14 +0100 Subject: [PATCH 4/5] update puma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is now possible 🚀 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 160dab1..5cb7c97 100644 --- a/Gemfile +++ b/Gemfile @@ -4,5 +4,5 @@ source 'http://rubygems.org' gemspec -gem 'puma' +gem 'puma', '~> 6.0' gem 'sinatra', '~> 2.0' From 416609e63f8200dc4e11f2cb93b90f6630667a23 Mon Sep 17 00:00:00 2001 From: Tobias Klonk Date: Thu, 16 Feb 2023 13:19:41 +0100 Subject: [PATCH 5/5] added matrix build --- .github/workflows/test_and_release.yml | 11 +++++++++-- gemfiles/puma5.gemfile | 9 +++++++++ gemfiles/puma5_capybara36.gemfile | 9 +++++++++ gemfiles/puma6.gemfile | 9 +++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 gemfiles/puma5.gemfile create mode 100644 gemfiles/puma5_capybara36.gemfile create mode 100644 gemfiles/puma6.gemfile diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml index 63bb9a2..c3cd15c 100644 --- a/.github/workflows/test_and_release.yml +++ b/.github/workflows/test_and_release.yml @@ -7,9 +7,16 @@ jobs: matrix: ruby-version: ['2.6', '2.7', '3.0', '3.1'] gemfile: - - Gemfile + - puma5 + - puma5_capybara36 + - puma6 + exclude: + - ruby-version: '2.6' + gemfile: puma6 + - ruby-version: '2.6' + gemfile: puma5 env: - BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile steps: - uses: actions/checkout@v3 - name: Set up Ruby diff --git a/gemfiles/puma5.gemfile b/gemfiles/puma5.gemfile new file mode 100644 index 0000000..4948f6b --- /dev/null +++ b/gemfiles/puma5.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source 'http://rubygems.org' + +gemspec path: '..' + +gem 'capybara', '> 3.37' +gem 'puma', '~> 5.0' +gem 'sinatra', '~> 2.0' diff --git a/gemfiles/puma5_capybara36.gemfile b/gemfiles/puma5_capybara36.gemfile new file mode 100644 index 0000000..696d36a --- /dev/null +++ b/gemfiles/puma5_capybara36.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source 'http://rubygems.org' + +gemspec path: '..' + +gem 'capybara', '= 3.36' +gem 'puma', '~> 5.0' +gem 'sinatra', '~> 2.0' diff --git a/gemfiles/puma6.gemfile b/gemfiles/puma6.gemfile new file mode 100644 index 0000000..4948f6b --- /dev/null +++ b/gemfiles/puma6.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source 'http://rubygems.org' + +gemspec path: '..' + +gem 'capybara', '> 3.37' +gem 'puma', '~> 5.0' +gem 'sinatra', '~> 2.0'