summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrismo <chrismo@clabs.org>2016-09-21 10:09:19 -0500
committerchrismo <chrismo@clabs.org>2016-09-21 16:57:41 -0500
commit62c53199d2f64e5274532b6831a0a7b790ac9350 (patch)
treed072ca7036923ba4d8fe9db2414eee2aa240e5bf
parentb3cb9516aaf83cf865c9ed76c52ec4d0d182015f (diff)
downloadbundler-62c53199d2f64e5274532b6831a0a7b790ac9350.tar.gz
@segiddins support for system bundler
Samuel contributed this patch to simulate a system bundler.
-rw-r--r--spec/support/helpers.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index fe79604f30..65603cb529 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -88,18 +88,28 @@ module Spec
bundle_bin = options.delete("bundle_bin") || File.expand_path("../../../exe/bundle", __FILE__)
+ if system_bundler = options.delete(:system_bundler)
+ bundle_bin = "-S bundle"
+ end
+
requires = options.delete(:requires) || []
requires << File.expand_path("../fakeweb/" + options.delete(:fakeweb) + ".rb", __FILE__) if options.key?(:fakeweb)
requires << File.expand_path("../artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice)
requires << "support/hax"
requires_str = requires.map {|r| "-r#{r}" }.join(" ")
+ load_path = []
+ load_path << lib unless system_bundler
+ load_path << spec
+ load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
+
env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}'" }.join(" ")
+ env["PATH"].gsub!("#{Path.root}/exe", "") if env["PATH"] && system_bundler
args = options.map do |k, v|
v == true ? " --#{k}" : " --#{k} #{v}" if v
end.join
- cmd = "#{env} #{sudo} #{Gem.ruby} -I#{lib}:#{spec} #{requires_str} #{bundle_bin} #{cmd}#{args}"
+ cmd = "#{env} #{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
sys_exec(cmd) {|i, o, thr| yield i, o, thr if block_given? }
end
bang :bundle
@@ -242,11 +252,17 @@ module Spec
def install_gems(*gems)
gems.each do |g|
- path = "#{gem_repo1}/gems/#{g}.gem"
+ path = if g == :bundler
+ Dir.chdir(root) { gem_command! :build, "#{root}/bundler.gemspec" }
+ bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
+ else
+ "#{gem_repo1}/gems/#{g}.gem"
+ end
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
+ gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies '#{path}'"
+ bundler_path && bundler_path.rmtree
end
end