Skip to content

Commit

Permalink
A bit of cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Feb 20, 2012
1 parent cdc60a9 commit 7a5af59
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
9 changes: 9 additions & 0 deletions features/gemspec.feature
Expand Up @@ -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"
11 changes: 9 additions & 2 deletions lib/appraisal/dependency.rb
Expand Up @@ -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}"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/appraisal/file.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/appraisal/gemfile.rb
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/appraisal/gemspec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 7a5af59

Please sign in to comment.