summaryrefslogtreecommitdiff
path: root/spec/bundler/support/matchers.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-02-01 16:17:16 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-03-08 13:47:35 +0900
commit53468cc11147b0d285fc376fc546b677dad600ca (patch)
treeeb9c97f544d089be2d324126b025b11f41a22c90 /spec/bundler/support/matchers.rb
parent2ab6b7a7516e1b2c48a66ce513afabb62d101461 (diff)
Sync latest development version of bundler & rubygems
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4143
Diffstat (limited to 'spec/bundler/support/matchers.rb')
-rw-r--r--spec/bundler/support/matchers.rb33
1 files changed, 19 insertions, 14 deletions
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
index 6c9ab0d410..5d129ed849 100644
--- a/spec/bundler/support/matchers.rb
+++ b/spec/bundler/support/matchers.rb
@@ -115,7 +115,6 @@ module Spec
opts = names.last.is_a?(Hash) ? names.pop : {}
source = opts.delete(:source)
groups = Array(opts[:groups])
- exclude_from_load_path = opts.delete(:exclude_from_load_path)
opts[:raise_on_error] = false
groups << opts
@errors = names.map do |name|
@@ -123,11 +122,6 @@ module Spec
require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/")
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
code = []
- if exclude_from_load_path
- code << "exclude_from_load_path = File.expand_path('#{exclude_from_load_path}')"
- code << "$LOAD_PATH.delete_if { |path| File.expand_path(path) == exclude_from_load_path }"
- end
- code << "$LOADED_FEATURES.delete_if { |feature| File.basename(feature, '.*') == '#{require_path}' }"
code << "require '#{require_path}.rb'"
code << "puts #{version_const}"
run code.join("; "), *groups
@@ -151,23 +145,34 @@ module Spec
match_when_negated do
opts = names.last.is_a?(Hash) ? names.pop : {}
- groups = Array(opts[:groups]) || []
+ groups = Array(opts.delete(:groups)).map(&:inspect).join(", ")
opts[:raise_on_error] = false
@errors = names.map do |name|
name, version = name.split(/\s+/, 2)
- run <<-R, *(groups + [opts])
+ ruby <<-R, opts
+ begin
+ require '#{lib_dir}/bundler'
+ Bundler.setup(#{groups})
+ rescue Bundler::GemNotFound, Bundler::GitError
+ exit 0
+ end
+
begin
require '#{name}'
- puts #{Spec::Builders.constantize(name)}
+ name_constant = '#{Spec::Builders.constantize(name)}'
+ if #{version.nil?} || name_constant == '#{version}'
+ exit 64
+ else
+ exit 0
+ end
rescue LoadError, NameError
- puts "WIN"
+ exit 0
end
R
- next if out == "WIN"
+ next if exitstatus == 0
+ next "command to check version of #{name} installed failed" unless exitstatus == 64
next "expected #{name} to not be installed, but it was" if version.nil?
- if Gem::Version.new(out) == Gem::Version.new(version)
- next "expected #{name} (#{version}) not to be installed, but it was"
- end
+ next "expected #{name} (#{version}) not to be installed, but it was"
end.compact
@errors.empty?