diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index a05edcd5c9c6..ae9517b579c4 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -125,15 +125,17 @@ def validate_dependencies # :nodoc: seen[dep.type][dep.name] = dep - prerelease_dep = dep.requirements_list.any? do |req| - Gem::Requirement.new(req).prerelease? + dep_requirements = dep.requirement.requirements + + prerelease_dep = dep_requirements.any? do |op, version| + version.prerelease? and op != '<' end warning_messages << "prerelease dependency on #{dep} is not recommended" if prerelease_dep && !version.prerelease? - overly_strict = dep.requirement.requirements.length == 1 && - dep.requirement.requirements.any? do |op, version| + overly_strict = dep_requirements.length == 1 && + dep_requirements.any? do |op, version| op == '~>' and not version.prerelease? and version.segments.length > 2 and @@ -141,7 +143,7 @@ def validate_dependencies # :nodoc: end if overly_strict then - _, dep_version = dep.requirement.requirements.first + _, dep_version = dep_requirements.first base = dep_version.segments.first 2 upper_bound = dep_version.segments.first(dep_version.segments.length - 1) @@ -156,12 +158,12 @@ def validate_dependencies # :nodoc: WARNING end - open_ended = dep.requirement.requirements.all? do |op, version| + open_ended = dep_requirements.all? do |op, version| not version.prerelease? and (op == '>' or op == '>=') end if open_ended then - op, dep_version = dep.requirement.requirements.first + op, dep_version = dep_requirements.first base = dep_version.segments.first 2 diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 34665edec1f1..8aee50e43b66 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -2650,6 +2650,7 @@ def test_validate_dependencies @a1.add_runtime_dependency 'l', '> 1.2.3' @a1.add_runtime_dependency 'm', '~> 2.1.0' @a1.add_runtime_dependency 'n', '~> 0.1.0' + @a1.add_runtime_dependency 'o', '< 1.0.x' use_ui @ui do @a1.validate