Skip to content
Browse files

Support zero/multiple sources

  • Loading branch information...
1 parent f5da0ba commit 2d7616badf625cb1a24a09a7bf75663f07191aaf @jferris jferris committed Nov 11, 2011
View
1 features/appraisals.feature
@@ -13,7 +13,6 @@ Feature: run a rake task through several appraisals
When I cd to "projecto"
And I write to "Gemfile" with:
"""
- source "http://rubygems.org"
gem "dummy_rake", "0.8.7"
gem "dummy_girl"
group :assets do
View
2 features/gemspec.feature
@@ -49,7 +49,6 @@ Feature: appraisals using an existing gemspec
Scenario: run a gem in the gemspec
And I write to "Gemfile" with:
"""
- source "http://rubygems.org"
gemspec
"""
When I add "appraisal" from this project as a dependency
@@ -62,7 +61,6 @@ Feature: appraisals using an existing gemspec
Scenario: run a gem in the gemspec via path
And I write to "Gemfile" with:
"""
- source "http://rubygems.org"
gemspec :path => './specdir'
"""
When I add "appraisal" from this project as a dependency
View
4 features/step_definitions/dependency_steps.rb
@@ -22,9 +22,9 @@
SPEC
write_file(gem_path, spec)
write_file(version_path, "$#{name}_version = '#{version}'")
- run_simple("gem build #{gem_path}")
+ in_current_dir { `gem build #{gem_path} 2>&1` }
set_env("GEM_HOME", TMP_GEM_ROOT)
- run_simple("gem install #{name}-#{version}.gem")
+ in_current_dir { `gem install #{name}-#{version}.gem 2>&1` }
FileUtils.rm_rf(File.join(current_dir, name))
dirs.pop
end
View
7 lib/appraisal/gemfile.rb
@@ -7,6 +7,7 @@ class Gemfile
attr_reader :dependencies
def initialize
+ @sources = []
@dependencies = {}
end
@@ -27,7 +28,7 @@ def group(name)
end
def source(source)
- @source = source
+ @sources << source
end
def to_s
@@ -36,7 +37,7 @@ def to_s
def dup
gemfile = Gemfile.new
- gemfile.source @source
+ @sources.each { |source| gemfile.source source }
dependencies.values.each do |dependency|
gemfile.gem(dependency.name, *dependency.requirements)
end
@@ -51,7 +52,7 @@ def gemspec(options = {})
protected
def source_entry
- %(source "#{@source}")
+ @sources.map { |source| %(source "#{source}") }.join("\n")
end
def dependencies_entry
View
16 spec/appraisal/gemfile_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+require 'appraisal/gemfile'
+
+describe Appraisal::Gemfile do
+ it "supports gemfiles without sources" do
+ gemfile = Appraisal::Gemfile.new
+ gemfile.to_s.strip.should == ""
+ end
+
+ it "supports multiple sources" do
+ gemfile = Appraisal::Gemfile.new
+ gemfile.source "one"
+ gemfile.source "two"
+ gemfile.to_s.strip.should == %{source "one"\nsource "two"}
+ end
+end

0 comments on commit 2d7616b

Please sign in to comment.
Something went wrong with that request. Please try again.