Skip to content

Commit

Permalink
[rubygems/rubygems] Warn on duplicate dependency in a specification
Browse files Browse the repository at this point in the history
  • Loading branch information
bronzdoc authored and hsbt committed Jul 31, 2020
1 parent 985309a commit 00bdac1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rubygems/specification.rb
Expand Up @@ -556,6 +556,10 @@ def add_development_dependency(gem, *requirements)
# spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'

def add_runtime_dependency(gem, *requirements)
if requirements.uniq.size != requirements.size
warn "WARNING: duplicate dependency #{requirements}"
end

add_dependency_with_type(gem, :runtime, requirements)
end

Expand Down
7 changes: 7 additions & 0 deletions test/rubygems/test_gem_specification.rb
Expand Up @@ -3051,6 +3051,13 @@ def test_unresolved_specs_with_versions
end
end

def test_duplicate_runtime_dependency
expected = "WARNING: duplicate dependency [\"~> 3.0\", \"~> 3.0\"]\n"
assert_output nil, expected do
@a1.add_runtime_dependency "b", "~> 3.0", "~> 3.0"
end
end

def set_orig(cls)
s_cls = cls.singleton_class
s_cls.send :alias_method, :orig_unresolved_deps , :unresolved_deps
Expand Down

0 comments on commit 00bdac1

Please sign in to comment.