ruby/test_rubygems_prov.rb
Jarek Prokop b017ed037a Test RPM dependency generators for rubygems.
Add tests for RPM dependency generators that execute during build.
The tests make use of methods available in tools present in the
upstream ruby tar archive to find and set up the ruby executable.
This is then used to execute the dependency generator script with
a given test input passed into the subprocess and collect the output
given out by the generator for testing.

Skip "test_generator_on_gem_with_multiple_conflict_constraints" for
now. rubygems.req is currently only capable of filtering out a single
conflict requirement that is specified on a given dependency.

Execute it in the %check section before the long-running
Ruby test suite starts. If testing the generators fails it means there
is the possibility of generating bogus requires,
which is a valuable information to get sooner rather than later.
2024-09-04 12:56:13 +02:00

53 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require 'test/unit'
require 'rpm_test_helper'
class TestRubyGemsProv < Test::Unit::TestCase
include RPMTestHelper
def test_provides_the_gem_version
gem_i = GemInfo.new(version: '1.2')
lines = run_generator_single_file(gem_i)
assert_equal(1, lines.size)
assert_equal("#{gem_i.to_rpm_str} = #{gem_i.version}\n", lines.first)
gem_i = GemInfo.new(name: 'somegem_foo', version: '4.5.6')
lines = run_generator_single_file(gem_i)
assert_equal(1, lines.size)
assert_equal("#{gem_i.to_rpm_str} = #{gem_i.version}\n", lines.first)
deps = [
Dependency.new('bar'),
Dependency.new('baq', [">= 1.2"]),
Dependency.new('quz', ["!= 3.2"])
]
gem_i = GemInfo.new(dependencies: deps)
lines = run_generator_single_file(gem_i)
assert_equal(1, lines.size)
assert_equal("#{gem_i.to_rpm_str} = #{gem_i.version}\n", lines.first)
end
def test_translates_prelease_version_provides_from_rubygems_to_rpm
gem_i = GemInfo.new(version: '1.2.3.dev')
lines = run_generator_single_file(gem_i)
assert_equal(1, lines.size)
assert_equal("#{gem_i.to_rpm_str} = 1.2.3~dev\n", lines.first)
gem_i = GemInfo.new(name: 'foo2', version: '1.2.3.dev.2')
lines = run_generator_single_file(gem_i)
assert_equal(1, lines.size)
assert_equal("#{gem_i.to_rpm_str} = 1.2.3~dev.2\n", lines.first)
end
end