Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Gemspecs must be eval'ed at the top level, not inside the Bundler class

  • Loading branch information...
commit 5656587ce411e91985b9975a52bb77220ca21800 1 parent d2ee319
@indirect indirect authored
View
4 lib/bundler/templates/environment.erb
@@ -15,10 +15,10 @@ module Bundler
<% end -%>
].map do |hash|
if hash[:virtual_spec]
- spec = eval(hash[:virtual_spec], binding, "<virtual spec for '#{hash[:name]}'>")
+ spec = eval(hash[:virtual_spec], TOPLEVEL_BINDING, "<virtual spec for '#{hash[:name]}'>")
else
dir = File.dirname(hash[:loaded_from])
- spec = Dir.chdir(dir){ eval(File.read(hash[:loaded_from]), binding, hash[:loaded_from]) }
+ spec = Dir.chdir(dir){ eval(File.read(hash[:loaded_from]), TOPLEVEL_BINDING, hash[:loaded_from]) }
end
spec.loaded_from = hash[:loaded_from]
spec.require_paths = hash[:load_paths]
View
21 spec/runtime/environment_rb_spec.rb
@@ -109,7 +109,10 @@
build_git "bar", :gemspec => false do |s|
s.write "lib/bar/version.rb", %{BAR_VERSION = '1.0'}
s.write "bar.gemspec", <<-G
- require 'lib/bar/version'
+ lib = File.expand_path('../lib/', __FILE__)
+ $:.unshift lib unless $:.include?(lib)
+ require 'bar/version'
+
Gem::Specification.new do |s|
s.name = 'bar'
s.version = BAR_VERSION
@@ -126,13 +129,23 @@
end
it "evals each gemspec in the context of its parent directory" do
-
- run <<-R, :lite_runtime => true
+ run <<-RUBY, :lite_runtime => true
require 'bar'
puts BAR
- R
+ RUBY
out.should == "1.0"
end
+
+ it "evals each gemspec with a binding from the top level" do
+ ruby <<-RUBY
+ require 'bundler'
+ def Bundler.require(path)
+ raise "LOSE"
+ end
+ Bundler.load
+ RUBY
+ out.should == ""
+ end
end
it "get regenerated when out of date" do
Please sign in to comment.
Something went wrong with that request. Please try again.