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
This commit is contained in:
Vít Ondruch 2026-09-09 15:01:21 +02:00
commit 935a2a0d1d

View file

@ -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"