dev-ruby/capybara: fix compatibility with sinatra 4.1.0, add ruby34

Signed-off-by: Hans de Graaff <graaff@gentoo.org>
This commit is contained in:
Hans de Graaff
2025-05-29 10:10:38 +02:00
parent a62c5a22ac
commit c1cc13a4fd
2 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
USE_RUBY="ruby32 ruby33 ruby34"
RUBY_FAKEGEM_EXTRADOC="History.md README.md"
# Rake tasks are not distributed in the gem.
RUBY_FAKEGEM_TASK_TEST=""
inherit virtualx ruby-fakegem
DESCRIPTION="Capybara aims to simplify the process of integration testing Rack applications"
HOMEPAGE="https://github.com/teamcapybara/capybara"
LICENSE="MIT"
SLOT="$(ver_cut 1)"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86"
IUSE="test"
DEPEND="${DEPEND} test? ( || ( www-client/firefox www-client/firefox-bin ) )"
PATCHES=( "${FILESDIR}/${P}-sinatra.patch" )
ruby_add_bdepend "test? (
dev-ruby/rspec:3
>=dev-ruby/launchy-2.4.0
>=dev-ruby/selenium-webdriver-4.8:4
dev-ruby/sinatra:4
www-servers/puma
)"
ruby_add_rdepend "
dev-ruby/addressable
dev-ruby/matrix
>=dev-ruby/mini_mime-0.1.3
>=dev-ruby/nokogiri-1.11:0
>=dev-ruby/rack-1.6.0:*
>=dev-ruby/rack-test-0.6.3:*
dev-ruby/regexp_parser:2
>=dev-ruby/xpath-3.2:3"
all_ruby_prepare() {
sed -i -e '/bundler/d' -e '/pry/d' -e '2igem "sinatra", "~> 4.0"' -e '/statistics/Id' spec/spec_helper.rb || die
# Avoid window-manager specific tests (sizes are specific for fluxbox)
sed -i -e '/#maximize/,/^ end/ s:^:#:' lib/capybara/spec/session/window/window_spec.rb || die
# Avoid spec that requires unpackaged geckodriver
#sed -i -e '/describe.*register_server/,/^ end/ s:^:#:' spec/capybara_spec.rb || die
# Avoid test dependency on puma server for now
sed -i -e '/should have :puma registered/,/^ end/ s:^:#:' spec/capybara_spec.rb || die
# Update spec to catch the right error code. This seems to have
# changed recently across ruby versions.
sed -i -e '/raise_error/ s/EOFError/Net::ReadTimeout/' spec/server_spec.rb || die
}
each_ruby_test() {
virtx ${RUBY} -Ilib -S rspec-3 spec
}

View File

@@ -0,0 +1,13 @@
Account for the new host_authorization setting introduced in Sinatra
4.1.0.
--- a/lib/capybara/spec/test_app.rb 2025-05-28 08:55:50.434344191 +0200
+++ b/lib/capybara/spec/test_app.rb 2025-05-29 09:00:09.004354200 +0200
@@ -19,6 +19,7 @@
set :static, true
set :raise_errors, true
set :show_exceptions, false
+ set :host_authorization, { permitted_hosts: ['www.example.com', IPAddr.new('0.0.0.0/0')] }
# Also check lib/capybara/spec/views/*.erb for pages not listed here