diff --git a/features/gemspec.feature b/features/gemspec.feature index 21a10daa..c11b379e 100644 --- a/features/gemspec.feature +++ b/features/gemspec.feature @@ -68,3 +68,12 @@ Feature: appraisals using an existing gemspec When I run `bundle exec rake appraisal version --trace` Then the output should contain "Loaded 1.3.0" + Scenario: run a gem in the gemspec via path + And I write to "Gemfile" with: + """ + gemspec :path => './specdir' + """ + When I add "appraisal" from this project as a dependency + When I successfully run `bundle exec rake appraisal:install --trace` + When I run `bundle exec rake appraisal version --trace` + Then the output should contain "Loaded 1.3.0" diff --git a/lib/appraisal/dependency.rb b/lib/appraisal/dependency.rb index de226871..c217e861 100644 --- a/lib/appraisal/dependency.rb +++ b/lib/appraisal/dependency.rb @@ -9,8 +9,7 @@ def initialize(name, requirements) end def to_s - gem_name = %{gem "#{name}"} - if requirements.nil? || requirements.empty? + if no_requirements? gem_name else "#{gem_name}, #{inspect_requirements}" @@ -19,6 +18,14 @@ def to_s private + def gem_name + %{gem "#{name}"} + end + + def no_requirements? + requirements.nil? || requirements.empty? + end + def inspect_requirements requirements.map { |requirement| requirement.inspect.gsub(/^\{|\}$/, '') }.join(", ") end diff --git a/lib/appraisal/file.rb b/lib/appraisal/file.rb index b4148838..37e22a02 100644 --- a/lib/appraisal/file.rb +++ b/lib/appraisal/file.rb @@ -30,7 +30,7 @@ def appraise(name, &block) private def run(definitions) - instance_eval definitions, __FILE__, __LINE__ + instance_eval(definitions, __FILE__, __LINE__) end def path diff --git a/lib/appraisal/gemfile.rb b/lib/appraisal/gemfile.rb index 8c3e8402..1287faee 100644 --- a/lib/appraisal/gemfile.rb +++ b/lib/appraisal/gemfile.rb @@ -38,7 +38,7 @@ def to_s def dup gemfile = Gemfile.new - @sources.each { |source| gemfile.source source } + @sources.each { |source| gemfile.source(source) } dependencies.each do |dependency| gemfile.gem(dependency.name, *dependency.requirements) end diff --git a/lib/appraisal/gemspec.rb b/lib/appraisal/gemspec.rb index 6061bc54..6569ecb9 100644 --- a/lib/appraisal/gemspec.rb +++ b/lib/appraisal/gemspec.rb @@ -14,7 +14,9 @@ def exists? end def to_s - "gemspec #{exported_options.inspect.gsub(/^\{|\}$/, '')}" if exists? + if exists? + "gemspec #{exported_options.inspect.gsub(/^\{|\}$/, '')}" + end end private