Permalink
Browse files

Don't ever use system gems during tests

  • Loading branch information...
1 parent 94e403a commit 770309be6e79a9009921204e67880294972a69db Carl Lerche committed Dec 16, 2009
Showing with 34 additions and 16 deletions.
  1. +13 −0 Rakefile
  2. +1 −1 lib/bundler/environment.rb
  3. +10 −8 spec/bundler/manifest_spec.rb
  4. +8 −6 spec/spec_helper.rb
  5. +2 −1 spec/support/helpers.rb
View
13 Rakefile
@@ -37,6 +37,19 @@ else
end
end
+namespace :spec do
+ file "tmp/rg_deps" do
+ repo = File.dirname(__FILE__) + '/tmp/rg_deps'
+ FileUtils.mkdir_p(repo)
+ p repo
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = repo, repo
+ system "gem install builder --no-rdoc --no-ri"
+ end
+
+ desc "Do all setup needed to run the specs"
+ task :setup => "tmp/rg_deps"
+end
+
begin
require 'rake/gempackagetask'
rescue LoadError
View
2 lib/bundler/environment.rb
@@ -81,7 +81,7 @@ def load_paths_for_specs(specs, options)
specs.each do |spec|
next if options[:no_bundle].include?(spec.name)
full_gem_path = Pathname.new(spec.full_gem_path)
-
+
load_paths << load_path_for(full_gem_path, spec.bindir) if spec.bindir
spec.require_paths.each do |path|
load_paths << load_path_for(full_gem_path, path)
View
18 spec/bundler/manifest_spec.rb
@@ -104,14 +104,16 @@
describe "runtime" do
it "is able to work system gems" do
- install_manifest <<-Gemfile
- clear_sources
- source "file://#{gem_repo1}"
- gem "rack"
- Gemfile
-
- out = run_in_context "require 'rake' ; puts Rake"
- out.should == "Rake"
+ system_gems "rake-0.8.7" do
+ install_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ gem "rack"
+ Gemfile
+
+ out = run_in_context "require 'rake' ; puts RAKE"
+ out.should == "0.8.7"
+ end
end
it "it does not work with system gems if system gems have been disabled" do
View
14 spec/spec_helper.rb
@@ -1,21 +1,23 @@
$:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
+
require "pp"
require "rubygems"
require "bundler"
require "spec"
require "rbconfig"
+Gem.clear_paths
+
+root = File.expand_path("../..", __FILE__)
+FileUtils.rm_rf("#{root}/tmp/repos")
+`rake -f #{root}/Rakefile spec:setup`
+ENV['GEM_HOME'], ENV['GEM_PATH'] = "#{root}/tmp/rg_deps", "#{root}/tmp/rg_deps"
+
Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |file|
require file
end
-tmpdir = File.expand_path('../../tmp', __FILE__)
-FileUtils.mkdir_p(tmpdir) unless File.exist?(tmpdir)
-Dir["#{tmpdir}/*"].each do |file|
- FileUtils.rm_rf file
-end
-
Spec::Runner.configure do |config|
config.include Spec::Builders
config.include Spec::Matchers
View
3 spec/support/helpers.rb
@@ -116,7 +116,8 @@ def system_gems(*gems)
def reset!
Dir["#{tmp_path}/*"].each do |file|
- FileUtils.rm_rf(file) unless File.basename(file) == "repos"
+ next if %w(repos rg_deps).include?(File.basename(file))
+ FileUtils.rm_rf(file)
end
FileUtils.mkdir_p(tmp_path)
end

0 comments on commit 770309b

Please sign in to comment.