diff --git a/features/appraisals.feature b/features/appraisals.feature index 57c6739e..aa9d4332 100644 --- a/features/appraisals.feature +++ b/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 diff --git a/features/gemspec.feature b/features/gemspec.feature index 71ca0c53..21a10daa 100644 --- a/features/gemspec.feature +++ b/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 diff --git a/features/step_definitions/dependency_steps.rb b/features/step_definitions/dependency_steps.rb index 021cdf45..382fa5c7 100644 --- a/features/step_definitions/dependency_steps.rb +++ b/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 diff --git a/lib/appraisal/gemfile.rb b/lib/appraisal/gemfile.rb index da15749d..126593c0 100644 --- a/lib/appraisal/gemfile.rb +++ b/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 diff --git a/spec/appraisal/gemfile_spec.rb b/spec/appraisal/gemfile_spec.rb new file mode 100644 index 00000000..69c2189a --- /dev/null +++ b/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