Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hoe::Bundler handles duplicate dependency declarations like Gem::Spec…

…ification does.
  • Loading branch information...
commit e345f5c3f3f681a0e322ee5448628e00de0fc3de 1 parent 3113f97
@flavorjones authored
Showing with 32 additions and 0 deletions.
  1. +11 −0 lib/hoe/bundler.rb
  2. +21 −0 test/test_hoe_bundler.rb
View
11 lib/hoe/bundler.rb
@@ -24,17 +24,28 @@ def hoe_bundler_contents
gemfile.puts
gemfile.puts "source \"https://rubygems.org/\""
gemfile.puts
+
+ extra_deps = {}
self.extra_deps.each do |name, version|
version ||= ">=0"
+ extra_deps[name] = version unless extra_deps.key?(name)
+ end
+ extra_deps.each do |name, version|
gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}"}
end
gemfile.puts
+
+ extra_dev_deps = {}
self.extra_dev_deps.each do |name, version|
version ||= ">=0"
+ extra_dev_deps[name] = version unless extra_dev_deps.key?(name)
+ end
+ extra_dev_deps.each do |name, version|
gemfile.puts %Q{gem "#{name}", "#{version.gsub(/ /,'')}", :group => [:development, :test]}
end
gemfile.puts
gemfile.puts "# vim: syntax=ruby"
+
gemfile.rewind
gemfile.read
end
View
21 test/test_hoe_bundler.rb
@@ -1,6 +1,9 @@
require "test/unit"
require "fileutils"
+require "hoe"
+Hoe.plugin :bundler
+
class TestHoeBundler < Test::Unit::TestCase
def test_output
gemfile = nil
@@ -24,4 +27,22 @@ def test_output
assert_match %r{^gem "hoe", .* :group => \[:development, :test\]$}, gemfile
assert_match %r{^# vim: syntax=ruby$}, gemfile
end
+
+ def test_handles_duplicate_dependencies_like_gemspec
+ Dir.chdir(File.join(File.dirname(__FILE__), "fixture_project")) do
+ hoe = Hoe.spec "foo" do
+ developer("MCA","mca@example.com")
+ extra_deps << ["yyy", ">=0"]
+ extra_deps << ["yyy", ">=1"]
+ extra_dev_deps << ["bbb", ">= 1"]
+ extra_dev_deps << ["bbb", ">= 0"]
+ end
+
+ lines = hoe.hoe_bundler_contents.split("\n")
+ assert_equal 1, lines.grep(/yyy/).length
+ assert_match(/>=0/, lines.grep(/yyy/).first)
+ assert_equal 1, lines.grep(/bbb/).length
+ assert_match(/>=1/, lines.grep(/bbb/).first)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.