summaryrefslogtreecommitdiff
path: root/spec/support/helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/helpers.rb')
-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 b30c44d1cb..6b30afd480 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
@@ -246,11 +256,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