fix build error with ruby 3.1

This commit is contained in:
lyn1001 2023-01-17 10:33:41 +08:00
parent 230658f017
commit 7256ea4eae
3 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,10 @@
--- a/capybara-3.34.0.gemspec 2023-01-05 14:47:52.021052878 +0800
+++ b/capybara-3.34.0.gemspec 2023-01-05 14:56:30.781466150 +0800
@@ -26,6 +26,7 @@
if s.respond_to? :add_runtime_dependency then
s.add_runtime_dependency(%q<addressable>.freeze, [">= 0"])
+ s.add_runtime_dependency(%q<matrix>.freeze, [">= 0"])
s.add_runtime_dependency(%q<mini_mime>.freeze, [">= 0.1.3"])
s.add_runtime_dependency(%q<nokogiri>.freeze, ["~> 1.8"])
s.add_runtime_dependency(%q<rack>.freeze, [">= 1.6.0"])

View File

@ -0,0 +1,26 @@
From c5151907f29a101912b1f419aff25a1db02c7978 Mon Sep 17 00:00:00 2001
From: Thomas Walpole <twalpole@gmail.com>
Date: Fri, 28 May 2021 17:38:46 -0700
Subject: [PATCH 1/2] Use Psych safe load in tests
---
lib/capybara/spec/spec_helper.rb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/capybara/spec/spec_helper.rb b/lib/capybara/spec/spec_helper.rb
index 7a3eb2ea49..c471afc26a 100644
--- a/lib/capybara/spec/spec_helper.rb
+++ b/lib/capybara/spec/spec_helper.rb
@@ -117,8 +117,9 @@ def quietly(&block)
def extract_results(session)
expect(session).to have_xpath("//pre[@id='results']")
- # YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
- YAML.load Capybara::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
+ perms = [(::Sinatra::IndifferentHash if defined? ::Sinatra::IndifferentHash)].compact
+ results = Capybara::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
+ YAML.safe_load results, permitted_classes: perms
end
def be_an_invalid_element_error(session)

View File

@ -1,7 +1,7 @@
%global gem_name capybara %global gem_name capybara
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 3.34.0 Version: 3.34.0
Release: 1 Release: 2
Summary: Capybara aims to simplify the process of integration testing Rack applications Summary: Capybara aims to simplify the process of integration testing Rack applications
License: MIT License: MIT
URL: https://github.com/teamcapybara/capybara URL: https://github.com/teamcapybara/capybara
@ -9,10 +9,13 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# git clone https://github.com/teamcapybara/capybara.git --no-checkout # git clone https://github.com/teamcapybara/capybara.git --no-checkout
# cd capybara && git archive -v -o capybara-3.34.0-tests.txz 3.34.0 features/ # cd capybara && git archive -v -o capybara-3.34.0-tests.txz 3.34.0 features/
Source1: %{gem_name}-%{version}-tests.txz Source1: %{gem_name}-%{version}-tests.txz
#https://github.com/teamcapybara/capybara/pull/2471
Patch0001: Use-Psych-safe-load-in-tests.patch
Patch0002: Add-matrix-as-a-dependency-for-Ruby-3.1-compatibility.patch
BuildRequires: ruby(release) rubygems-devel ruby rubygem(selenium-webdriver) rubygem(sinatra) BuildRequires: ruby(release) rubygems-devel ruby rubygem(selenium-webdriver) rubygem(sinatra)
BuildRequires: rubygem(rspec) rubygem(launchy) rubygem(minitest) rubygem(puma) BuildRequires: rubygem(rspec) rubygem(launchy) rubygem(minitest) rubygem(puma)
BuildRequires: rubygem(nokogiri) rubygem(xpath) rubygem(rack-test) rubygem(mini_mime) BuildRequires: rubygem(nokogiri) rubygem(xpath) rubygem(rack-test) rubygem(mini_mime)
BuildRequires: rubygem(cucumber) rubygem(regexp_parser) BuildRequires: rubygem(cucumber) rubygem(regexp_parser) rubygem(matrix)
BuildArch: noarch BuildArch: noarch
%description %description
Capybara is an integration testing tool for rack based web applications. It Capybara is an integration testing tool for rack based web applications. It
@ -30,6 +33,11 @@ Documentation for %{name}.
%gemspec_remove_dep -g regexp_parser ['~>1.5'] %gemspec_remove_dep -g regexp_parser ['~>1.5']
%gemspec_add_dep -g regexp_parser ['>=1.5', '<3.0'] %gemspec_add_dep -g regexp_parser ['>=1.5', '<3.0']
%patch0001 -p1
pushd %_builddir
%patch0002 -p1
popd
%build %build
gem build ../%{gem_name}-%{version}.gemspec gem build ../%{gem_name}-%{version}.gemspec
%gem_install %gem_install
@ -69,6 +77,9 @@ popd
%{gem_instdir}/spec %{gem_instdir}/spec
%changelog %changelog
* Thu Jan 5 2023 liyanan <liyanan32@h-partners.com> - 3.34.0-2
- fix build error with ruby 3.1
* Tue Mar 29 2022 liyanan <liyanan32@huawei.com> - 3.34.0-1 * Tue Mar 29 2022 liyanan <liyanan32@huawei.com> - 3.34.0-1
- update to 3.34.0 - update to 3.34.0