diff options
Diffstat (limited to 'spec/support/path.rb')
-rw-r--r-- | spec/support/path.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/path.rb b/spec/support/path.rb index de910ca145..16ba2ca134 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -18,6 +18,15 @@ module Spec system_gem_path(*path) end + def build_install_path(*path) + tmp.join(*path) + end + + def make_install_path(*path) + root = build_install_path(*path) + Dir.exists?(root) ? root.expand_path : FileUtils.mkdir_p(root)[0] + end + def bundled_app(*path) root = tmp.join("bundled_app") FileUtils.mkdir_p(root) @@ -68,6 +77,20 @@ module Spec Pathname.new(File.expand_path('../../../lib', __FILE__)) end + def set_bundle_install_path(type, location, opts = {}) + path = make_install_path(location) + if type == :env + hsh = { 'BUNDLE_INSTALL_PATH' => path } + hsh['BUNDLE_GEMFILE'] = opts['gemfile'] if opts['gemfile'] + hsh={:env => hsh, :exitstatus => true } + elsif type == :global + bundle("config gemfile #{opts['gemfile']}", {'no-color' => false}) if opts['gemfile'] + bundle("config install-path #{path}", {'no-color' => false}) + hsh={:install_path => path} + end + hsh + end + extend self end end |