summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-09-05 19:56:03 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-09-06 09:16:55 +0900
commit4d7d012575df55efa87abb2687df051f70782267 (patch)
tree662d6841f54f5af54891941a282e520ad266fb7f /spec/support
parentd5592453ba6c60809fe827d329f430b9eab4634a (diff)
downloadbundler-4d7d012575df55efa87abb2687df051f70782267.tar.gz
To use helper methods for relative path references.
Ruby core needs to change `Spec::Path.root` and gemspec, bin, spec directories structure. * Added Spec::Path.bin, gemspec, spec methods. * Replace Spec::Path methods from relative references like "../../..".
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/artifice/endpoint.rb2
-rw-r--r--spec/support/helpers.rb13
-rw-r--r--spec/support/path.rb14
3 files changed, 21 insertions, 8 deletions
diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb
index 33e2a9b411..21c44ba6e0 100644
--- a/spec/support/artifice/endpoint.rb
+++ b/spec/support/artifice/endpoint.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require File.expand_path("../../path.rb", __FILE__)
-require File.expand_path("../../../../lib/bundler/deprecate", __FILE__)
+require File.expand_path("#{Spec::Path.root}/lib/bundler/deprecate", __FILE__)
include Spec::Path
$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,rack,tilt,sinatra}-*/lib")].map(&:to_s))
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 08c3c5e921..ef9f55974e 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require File.expand_path("../path.rb", __FILE__)
module Spec
module Helpers
@@ -88,11 +89,11 @@ module Spec
end
def lib
- File.expand_path("../../../lib", __FILE__)
+ File.expand_path("#{Spec::Path.root}/lib", __FILE__)
end
def spec
- File.expand_path("../../../spec", __FILE__)
+ File.expand_path(Spec::Path.spec.to_s, __FILE__)
end
def bundle(cmd, options = {})
@@ -102,7 +103,7 @@ module Spec
no_color = options.delete("no-color") { cmd.to_s !~ /\A(e|ex|exe|exec|conf|confi|config)(\s|\z)/ }
options["no-color"] = true if no_color
- bundle_bin = options.delete("bundle_bin") || File.expand_path("../../../exe/bundle", __FILE__)
+ bundle_bin = options.delete("bundle_bin") || File.expand_path("#{Spec::Path.bin}/bundle", __FILE__)
if system_bundler = options.delete(:system_bundler)
bundle_bin = "-S bundle"
@@ -171,12 +172,12 @@ module Spec
end
def bundler(cmd, options = {})
- options["bundle_bin"] = File.expand_path("../../../exe/bundler", __FILE__)
+ options["bundle_bin"] = File.expand_path("#{Spec::Path.bin}/bundler", __FILE__)
bundle(cmd, options)
end
def bundle_ruby(options = {})
- options["bundle_bin"] = File.expand_path("../../../exe/bundle_ruby", __FILE__)
+ options["bundle_bin"] = File.expand_path("#{Spec::Path.bin}/bundle_ruby", __FILE__)
bundle("", options)
end
@@ -300,7 +301,7 @@ module Spec
gem_repo = options.fetch(:gem_repo) { gem_repo1 }
gems.each do |g|
path = if g == :bundler
- Dir.chdir(root) { gem_command! :build, "#{root}/bundler.gemspec" }
+ Dir.chdir(root) { gem_command! :build, Spec::Path.gemspec.to_s }
bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
elsif g.to_s =~ %r{\A/.*\.gem\z}
g
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 54fc03c850..56c7a4591b 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -8,6 +8,18 @@ module Spec
@root ||= Pathname.new(File.expand_path("../../..", __FILE__))
end
+ def gemspec
+ @gemspec ||= Pathname.new(File.expand_path("#{root}/bundler.gemspec", __FILE__))
+ end
+
+ def bin
+ @bin ||= Pathname.new(File.expand_path("#{root}/exe", __FILE__))
+ end
+
+ def spec
+ @spec ||= Pathname.new(File.expand_path("#{root}/spec", __FILE__))
+ end
+
def tmp(*path)
root.join("tmp", *path)
end
@@ -83,7 +95,7 @@ module Spec
end
def bundler_path
- Pathname.new(File.expand_path("../../../lib", __FILE__))
+ Pathname.new(File.expand_path("#{root}/lib", __FILE__))
end
def global_plugin_gem(*args)