From 935a2a0d1ddd5a1bba576781e6b56e66a3db62a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Wed, 9 Sep 2026 15:01:21 +0200 Subject: [PATCH] Add support for patch version in Rails Currently, the test fails with the following error: ~~~ ... snip ... :: [ 17:58:30 ] :: [ PASS ] :: Creating new rails application (Expected 0, got 0) :: [ 17:58:30 ] :: [ BEGIN ] :: Running 'pushd app/' /tmp/tmp.QUuaPCQMYg/app /tmp/tmp.QUuaPCQMYg /var/ARTIFACTS/work-all5lab20yf/plans/all/discover/default-0/tests/run-basic-rails-application :: [ 17:58:30 ] :: [ PASS ] :: Command 'pushd app/' (Expected 0, got 0) :: [ 17:58:30 ] :: [ PASS ] :: Directory app should exist :: [ 17:58:30 ] :: [ BEGIN ] :: Updating Gemfile to ensure Rails RPM version is used :: actually running 'sed -i.orig -E -e '/^gem "rails"/ s/~> //' Gemfile' :: [ 17:58:30 ] :: [ PASS ] :: Updating Gemfile to ensure Rails RPM version is used (Expected 0, got 0) :: [ 17:58:30 ] :: [ BEGIN ] :: Printing the Gemfile modifications :: actually running 'diff Gemfile.orig Gemfile' STDOUT: 4c4 STDOUT: < gem "rails", "~> 8.1.3", ">= 8.1.3.1" STDOUT: --- STDOUT: > gem "rails", "8.1.3", ">= 8.1.3.1" :: [ 17:58:30 ] :: [ PASS ] :: Printing the Gemfile modifications (Expected 1, got 1) :: [ 17:58:30 ] :: [ BEGIN ] :: Installing dependencies specified in Gemfile :: actually running 'bundle install' Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this machine. Fetching gem metadata from https://rubygems.org/.......... Local specification for nokogiri-1.19.4 has different dependencies than the remote gem, ignoring it Local specification for activesupport-8.1.3.1 has different dependencies than the remote gem, ignoring it Could not find gem 'rails (= 8.1.3, >= 8.1.3.1)' in rubygems repository ... snip ... ~~~ The issue here is that there are two possible variants of `gem "rails"` depeindency, as can be seen here: https://github.com/rails/rails/blob/main/railties/lib/rails/generators/app_base.rb#L482-L493 This fixes the test to always end up with the hard dependency, such as: ~~~ gem "rails", "8.1.3.1" ~~~ Resolves: rhbz#2530704 --- run-basic-rails-application/runtest.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run-basic-rails-application/runtest.sh b/run-basic-rails-application/runtest.sh index 200fd1a..1c7cc36 100755 --- a/run-basic-rails-application/runtest.sh +++ b/run-basic-rails-application/runtest.sh @@ -46,7 +46,11 @@ rlJournalStart rlRun "rails new app --skip-bundle" 0 "Creating new rails application" rlRun "pushd app/" rlAssertExists "app" - rlRun "sed -i.orig -E -e '/^gem \"rails\"/ s/~> //' Gemfile" 0 \ + # There are two variants of the `gem "rails"` line: + # https://github.com/rails/rails/blob/main/railties/lib/rails/generators/app_base.rb#L482-L493 + rlRun "sed -i.orig -E \ + -e '/^gem \"rails\"/ s/\"~> [^\"]+\", \">= ([^\"]+)\"/\"\1\"/' \ + -e '/^gem \"rails\"/ s/~> //' Gemfile" 0 \ "Updating Gemfile to ensure Rails RPM version is used" rlRun -t "diff Gemfile.orig Gemfile" 1 \ "Printing the Gemfile modifications"