Skip to content

Commit

Permalink
Convert non-string dependency names to strings
Browse files Browse the repository at this point in the history
Apparently some people used non-string dependency names at one time and
older RubyGems supported this.  See also rubygems/bundler-api #33.

Fixes #505
  • Loading branch information
drbrain committed Jun 15, 2013
1 parent 05b8966 commit 9ffb276
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -32,6 +32,8 @@ Bug fixes:
Steve Klabnik
* Fixed typo in `gem spec` help. Pull request #563 by oooooooo
* Fixed creation of build_info with --install-dir. Bug #457 by Vít Ondruch.
* RubyGems converts non-string dependency names to strings now. Bug #505 by
Terence Lee

=== 2.0.3 / 2012-03-11

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/specification.rb
Expand Up @@ -1257,7 +1257,7 @@ def add_dependency_with_type(dependency, type, *requirements)

unless dependency.respond_to?(:name) &&
dependency.respond_to?(:version_requirements)
dependency = Gem::Dependency.new(dependency, requirements, type)
dependency = Gem::Dependency.new(dependency.to_s, requirements, type)
end

dependencies << dependency
Expand Down
11 changes: 10 additions & 1 deletion test/rubygems/test_gem_specification.rb
Expand Up @@ -597,7 +597,16 @@ def test_activate
assert @a2.activated?
end

def test_add_dependency_with_explicit_type
def test_add_dependency_with_type
gem = quick_spec "awesome", "1.0" do |awesome|
awesome.add_dependency true
awesome.add_dependency :gem_name
end

assert_equal %w[true gem_name], gem.dependencies.map { |dep| dep.name }
end

def test_add_dependency_with_type_explicit
gem = quick_spec "awesome", "1.0" do |awesome|
awesome.add_development_dependency "monkey"
end
Expand Down

0 comments on commit 9ffb276

Please sign in to comment.