summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/cli_spec.rb3
-rw-r--r--spec/bundler/env_spec.rb2
-rw-r--r--spec/bundler/mirror_spec.rb2
-rw-r--r--spec/bundler/shared_helpers_spec.rb3
-rw-r--r--spec/bundler/ssl_certs/certificate_manager_spec.rb9
-rw-r--r--spec/commands/binstubs_spec.rb2
-rw-r--r--spec/commands/clean_spec.rb4
-rw-r--r--spec/commands/exec_spec.rb10
-rw-r--r--spec/commands/info_spec.rb2
-rw-r--r--spec/commands/newgem_spec.rb5
-rw-r--r--spec/commands/pristine_spec.rb2
-rw-r--r--spec/commands/show_spec.rb2
-rw-r--r--spec/install/deploy_spec.rb2
-rw-r--r--spec/install/gemfile/git_spec.rb6
-rw-r--r--spec/install/gemfile/platform_spec.rb14
-rw-r--r--spec/install/gems/native_extensions_spec.rb2
-rw-r--r--spec/install/gems/resolving_spec.rb6
-rw-r--r--spec/install/gems/standalone_spec.rb2
-rw-r--r--spec/install/global_cache_spec.rb2
-rw-r--r--spec/install/path_spec.rb2
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb2
-rw-r--r--spec/quality_spec.rb23
-rw-r--r--spec/runtime/gem_tasks_spec.rb2
-rw-r--r--spec/runtime/setup_spec.rb11
-rw-r--r--spec/runtime/with_clean_env_spec.rb6
-rw-r--r--spec/spec_helper.rb16
-rw-r--r--spec/support/helpers.rb9
-rw-r--r--spec/support/path.rb19
28 files changed, 110 insertions, 60 deletions
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index 28a3f1a9d9..9a2591ac96 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -15,7 +15,8 @@ RSpec.describe "bundle executable" do
it "looks for a binary and executes it if it's named bundler-<task>" do
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
- f.puts "#!/usr/bin/env ruby\nputs 'Hello, world'\n"
+ ruby = ENV["BUNDLE_RUBY"] || "/usr/bin/env ruby"
+ f.puts "#!#{ruby}\nputs 'Hello, world'\n"
end
with_path_added(tmp) do
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 10762b3cd2..20bd38b021 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe Bundler::Env do
end
end
- describe ".version_of" do
+ describe ".version_of", :ruby_repo do
let(:parsed_version) { described_class.send(:version_of, "ruby") }
it "strips version of new line characters" do
diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb
index 0a8b9f8926..acd0895f2f 100644
--- a/spec/bundler/mirror_spec.rb
+++ b/spec/bundler/mirror_spec.rb
@@ -304,7 +304,7 @@ RSpec.describe Bundler::Settings::TCPSocketProbe do
server.close unless server.closed?
end
- it "probes the server correctly" do
+ it "probes the server correctly", :ruby_repo do
with_server_and_mirror do |server, mirror|
expect(server.closed?).to be_falsey
expect(probe.replies?(mirror)).to be_truthy
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 72b1c2a51f..b66c43fd92 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -384,7 +384,8 @@ RSpec.describe Bundler::SharedHelpers do
it "sets BUNDLE_BIN_PATH to the bundle executable file" do
subject.set_bundle_environment
- expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path("../../../exe/bundle", __FILE__))
+ bundle_exe = ruby_core? ? "../../../../exe/bundle" : "../../../exe/bundle"
+ expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path(bundle_exe, __FILE__))
end
end
diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb
index 2e43193359..56606a830f 100644
--- a/spec/bundler/ssl_certs/certificate_manager_spec.rb
+++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb
@@ -11,13 +11,18 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do
# Pretend bundler root is rubygems root
before do
+ # Backing up rubygems ceriticates
+ FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ruby_core?
+
FileUtils.mkdir_p(rubygems_certs_dir)
FileUtils.touch(stub_cert)
end
after do
- rubygems_dir = File.join(root.to_s, "lib", "rubygems")
- FileUtils.rm_rf(rubygems_dir)
+ FileUtils.rm_rf(rubygems_certs_dir)
+
+ # Restore rubygems certificates
+ FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ruby_core?
end
describe "#update_from" do
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 82b40c887a..7f2e81c099 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -248,7 +248,7 @@ RSpec.describe "bundle binstubs <gem>" do
context "when requesting a different bundler version" do
before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") }
- it "attempts to load that version" do
+ it "attempts to load that version", :ruby_repo do
sys_exec bundled_app("bin/rackup").to_s
expect(exitstatus).to eq(42) if exitstatus
expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 99789f0257..158d58d67c 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -712,7 +712,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "foo-1.0"
end
- it "doesn't remove extensions artifacts from bundled git gems after clean", :rubygems => "2.2" do
+ it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo, :rubygems => "2.2" do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))
@@ -734,7 +734,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end
- it "removes extension directories", :rubygems => "2.2" do
+ it "removes extension directories", :ruby_repo, :rubygems => "2.2" do
gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 904b54d52d..76841dcff6 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe "bundle exec" do
expect(out).to eq("1.0.0")
end
- it "works when running from a random directory" do
+ it "works when running from a random directory", :ruby_repo do
install_gemfile <<-G
gem "rack"
G
@@ -226,7 +226,7 @@ RSpec.describe "bundle exec" do
expect(out).to include("bundler: exec needs a command to run")
end
- it "raises a helpful error when exec'ing to something outside of the bundle", :rubygems => ">= 2.5.2" do
+ it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do
bundle! "config clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -342,7 +342,7 @@ RSpec.describe "bundle exec" do
end
describe "with gem executables" do
- describe "run from a random directory" do
+ describe "run from a random directory", :ruby_repo do
before(:each) do
install_gemfile <<-G
gem "rack"
@@ -445,7 +445,7 @@ RSpec.describe "bundle exec" do
expect(out).to include("Installing foo 1.0")
end
- describe "with gems bundled via :path with invalid gemspecs" do
+ describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do
it "outputs the gemspec validation errors", :rubygems => ">= 1.7.2" do
build_lib "foo"
@@ -598,7 +598,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
- context "when the file uses the current ruby shebang" do
+ context "when the file uses the current ruby shebang", :ruby_repo do
let(:shebang) { "#!#{Gem.ruby}" }
it_behaves_like "it runs"
end
diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb
index a08965ec0e..a9ab8fc210 100644
--- a/spec/commands/info_spec.rb
+++ b/spec/commands/info_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe "bundle info" do
end
end
- context "given a default gem shippped in ruby" do
+ context "given a default gem shippped in ruby", :ruby_repo do
it "prints information about the default gem", :if => (RUBY_VERSION >= "2.0") do
bundle "info rdoc"
expect(out).to include("* rdoc")
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 598d68ec3a..e6d6e19122 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -211,7 +211,10 @@ RSpec.describe "bundle gem" do
end
Dir.chdir(bundled_app("newgem")) do
- system_gems ["rake-10.0.2", :bundler], :path => :bundle_path
+ gems = ["rake-10.0.2", :bundler]
+ # for Ruby core repository, Ruby 2.6+ has bundler as standard library.
+ gems.delete(:bundler) if ruby_core?
+ system_gems gems, :path => :bundle_path
bundle! "exec rake build"
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 20adb13a2c..d8761bba26 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -2,7 +2,7 @@
require "bundler/vendored_fileutils"
-RSpec.describe "bundle pristine" do
+RSpec.describe "bundle pristine", :ruby_repo do
before :each do
build_lib "baz", :path => bundled_app do |s|
s.version = "1.0.0"
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index a5c6beec1a..55bdacac98 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -86,7 +86,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
and include(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints the path to the running bundler" do
+ it "prints the path to the running bundler", :ruby_repo do
bundle "show bundler"
expect(out).to eq(root.to_s)
end
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index f3c47d7aa9..ec72ff69fc 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe "install with --deployment or --frozen" do
bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test")
end
- it "works when you bundle exec bundle" do
+ it "works when you bundle exec bundle", :ruby_repo do
bundle :install
bundle "install --deployment"
bundle! "exec bundle check"
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 1d4c68decb..fe396c7a0f 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -1099,7 +1099,7 @@ RSpec.describe "bundle install with git sources" do
end
context "with an extension" do
- it "installs the extension" do
+ it "installs the extension", :ruby_repo do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
@@ -1131,7 +1131,7 @@ RSpec.describe "bundle install with git sources" do
expect(out).to eq(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
end
- it "does not use old extension after ref changes" do
+ it "does not use old extension after ref changes", :ruby_repo do
git_reader = build_git "foo", :no_default => true do |s|
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY
@@ -1193,7 +1193,7 @@ In Gemfile:
expect(out).not_to include("gem install foo")
end
- it "does not reinstall the extension", :rubygems => ">= 2.3.0" do
+ it "does not reinstall the extension", :ruby_repo, :rubygems => ">= 2.3.0" do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index 9a848b8396..b5dbc41a33 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -102,7 +102,7 @@ RSpec.describe "bundle install across platforms" do
gem "pry"
G
- expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L)
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(strip_whitespace(<<-L))
GEM
remote: file://localhost/#{gem_repo4}/
specs:
@@ -160,7 +160,7 @@ RSpec.describe "bundle install across platforms" do
#{Bundler::VERSION}
L
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
bad_lockfile = strip_whitespace <<-L
GEM
@@ -196,23 +196,23 @@ RSpec.describe "bundle install across platforms" do
aggregate_failures do
lockfile bad_lockfile
bundle! :install
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
lockfile bad_lockfile
bundle! :update, :all => true
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
lockfile bad_lockfile
bundle! "update ffi"
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
lockfile bad_lockfile
bundle! "update empyrean"
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
lockfile bad_lockfile
bundle! :lock
- expect(the_bundle.lockfile).to read_as good_lockfile
+ expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile)
end
end
diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb
index c8252b81f1..ea616f60d3 100644
--- a/spec/install/gems/native_extensions_spec.rb
+++ b/spec/install/gems/native_extensions_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "installing a gem with native extensions" do
+RSpec.describe "installing a gem with native extensions", :ruby_repo do
it "installs" do
build_repo2 do
build_gem "c_extension" do |s|
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index e58f32836c..01c03ac793 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "bundle install with install-time dependencies" do
- it "installs gems with implicit rake dependencies" do
+ it "installs gems with implicit rake dependencies", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "with_implicit_rake_dep"
@@ -48,7 +48,7 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(the_bundle).to include_gems "net_b 1.0"
end
- it "installs plugins depended on by other plugins" do
+ it "installs plugins depended on by other plugins", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "net_a"
@@ -57,7 +57,7 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0"
end
- it "installs multiple levels of dependencies" do
+ it "installs multiple levels of dependencies", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "net_c"
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index eecf6f2e7e..fa7a3bdc27 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -67,7 +67,7 @@ RSpec.shared_examples "bundle install --standalone" do
include_examples "common functionality"
end
- describe "with gems with native extension" do
+ describe "with gems with native extension", :ruby_repo do
before do
install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
source "file://#{gem_repo1}"
diff --git a/spec/install/global_cache_spec.rb b/spec/install/global_cache_spec.rb
index 3664d3963a..e41e7e0157 100644
--- a/spec/install/global_cache_spec.rb
+++ b/spec/install/global_cache_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe "global gem caching" do
end
end
- describe "extension caching", :rubygems => "2.2" do
+ describe "extension caching", :ruby_repo, :rubygems => "2.2" do
it "works" do
build_git "very_simple_git_binary", &:add_c_extension
build_lib "very_simple_path_binary", &:add_c_extension
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 8d0961daea..94f38c9290 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -207,7 +207,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
- it "re-installs gems whose extensions have been deleted", :rubygems => ">= 2.3" do
+ it "re-installs gems whose extensions have been deleted", :ruby_repo, :rubygems => ">= 2.3" do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end
diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb
index 4d969efcb1..851fbea99a 100644
--- a/spec/lock/lockfile_bundler_1_spec.rb
+++ b/spec/lock/lockfile_bundler_1_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe "the lockfile format", :bundler => "< 3" do
G
end
- it "does not update the lockfile's bundler version if nothing changed during bundle install" do
+ it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do
version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"
lockfile <<-L
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 317c799573..812acc344f 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -108,7 +108,8 @@ RSpec.describe "The library itself" do
exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/
error_messages = []
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_tab_characters(filename)
error_messages << check_for_extra_spaces(filename)
@@ -121,7 +122,8 @@ RSpec.describe "The library itself" do
exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn}
error_messages = []
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_debugging_mechanisms(filename)
end
@@ -133,7 +135,8 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = %r{lock/lockfile_(bundler_1_)?spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
Dir.chdir(root) do
- `git ls-files -z`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_git_merge_conflicts(filename)
end
@@ -158,7 +161,8 @@ RSpec.describe "The library itself" do
error_messages = []
exempt = /vendor/
Dir.chdir(root) do
- `git ls-files -z -- lib`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
next if filename =~ exempt
error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename)
@@ -192,7 +196,8 @@ RSpec.describe "The library itself" do
Dir.chdir(root) do
key_pattern = /([a-z\._-]+)/i
- `git ls-files -z -- lib`.split("\x0").each do |filename|
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
File.readlines(filename).each_with_index do |line, number|
line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
end
@@ -220,7 +225,7 @@ RSpec.describe "The library itself" do
it "can still be built" do
Dir.chdir(root) do
begin
- gem_command! :build, "bundler.gemspec"
+ gem_command! :build, gemspec
if Bundler.rubygems.provides?(">= 2.4")
# there's no way aroudn this warning
last_command.stderr.sub!(/^YAML safe loading.*/, "")
@@ -231,7 +236,8 @@ RSpec.describe "The library itself" do
end
ensure
# clean up the .gem generated
- FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
+ path_prefix = ruby_core? ? "lib/" : "./"
+ FileUtils.rm("#{path_prefix}bundler-#{Bundler::VERSION}.gem")
end
end
end
@@ -245,7 +251,8 @@ RSpec.describe "The library itself" do
lib/bundler/vlad.rb
lib/bundler/templates/gems.rb
]
- lib_files = `git ls-files -z -- lib`.split("\x0").grep(/\.rb$/) - exclusions
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files = lib_files.split("\x0").grep(/\.rb$/) - exclusions
lib_files.reject! {|f| f.start_with?("lib/bundler/vendor") }
lib_files.map! {|f| f.chomp(".rb") }
sys_exec!("ruby -w -Ilib") do |input, _, _|
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 1cf808f35b..de72869dc3 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "require 'bundler/gem_tasks'" do
+RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
before :each do
bundled_app("foo.gemspec").open("w") do |f|
f.write <<-GEMSPEC
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 9395f0e1e4..15dd1fe190 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -119,7 +119,7 @@ RSpec.describe "Bundler.setup" do
lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s}/i, "") }
end
- it "puts loaded gems after -I and RUBYLIB" do
+ it "puts loaded gems after -I and RUBYLIB", :ruby_repo do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -828,7 +828,7 @@ end
expect(out).to eq("yay")
end
- it "should clean $LOAD_PATH properly" do
+ it "should clean $LOAD_PATH properly", :ruby_repo do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp "extenstions", full_gem_name)
@@ -864,7 +864,7 @@ end
context "with bundler is located in symlinked GEM_HOME" do
let(:gem_home) { Dir.mktmpdir }
let(:symlinked_gem_home) { Tempfile.new("gem_home") }
- let(:bundler_dir) { File.expand_path("../../..", __FILE__) }
+ let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) }
let(:bundler_lib) { File.join(bundler_dir, "lib") }
before do
@@ -876,7 +876,8 @@ end
FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
- gemspec = File.read("#{bundler_dir}/bundler.gemspec").
+ gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
+ gemspec = File.read(gemspec_file).
sub("Bundler::VERSION", %("#{Bundler::VERSION}"))
gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join
@@ -885,7 +886,7 @@ end
end
end
- it "should succesfully require 'bundler/setup'" do
+ it "should succesfully require 'bundler/setup'", :ruby_repo do
install_gemfile ""
ENV["GEM_PATH"] = symlinked_gem_home.path
diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb
index ed5f7fe3b6..da8e37b45d 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "Bundler.with_env helpers" do
end
end
- it "works with nested bundle exec invocations" do
+ it "works with nested bundle exec invocations", :ruby_repo do
create_file("exe.rb", <<-'RB')
count = ARGV.first.to_i
exit if count < 0
@@ -55,7 +55,7 @@ RSpec.describe "Bundler.with_env helpers" do
EOS
end
- it "removes variables that bundler added" do
+ it "removes variables that bundler added", :ruby_repo do
original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")', :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" })
code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
bundle! "exec '#{Gem.ruby}' -e #{code.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
@@ -84,7 +84,7 @@ RSpec.describe "Bundler.with_env helpers" do
expect(last_command.stdboth).not_to include("-rbundler/setup")
end
- it "should clean up RUBYLIB" do
+ it "should clean up RUBYLIB", :ruby_repo do
code = "print Bundler.clean_env['RUBYLIB']"
ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
bundle_exec_ruby! code.dump
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 63787168b5..8d8272e573 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -64,6 +64,12 @@ ENV["THOR_COLUMNS"] = "10000"
Spec::CodeClimate.setup
+module Gem
+ def self.ruby=(ruby)
+ @ruby = ruby
+ end
+end
+
RSpec.configure do |config|
config.include Spec::Builders
config.include Spec::Helpers
@@ -105,6 +111,7 @@ RSpec.configure do |config|
config.filter_run_excluding :git => LessThanProc.with(git_version)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join("."))
+ config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
config.filter_run_when_matching :focus unless ENV["CI"]
@@ -115,6 +122,15 @@ RSpec.configure do |config|
c.syntax = :expect
end
+ config.around :suite do |example|
+ if ENV["BUNDLE_RUBY"]
+ @orig_ruby = Gem.ruby
+ Gem.ruby = ENV["BUNDLE_RUBY"]
+ end
+ example.run
+ Gem.ruby = @orig_ruby if ENV["BUNDLE_RUBY"]
+ end
+
config.before :all do
build_repo1
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index b86f8e25c0..181dac3220 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -212,7 +212,8 @@ module Spec
args = args.gsub(/(?=")/, "\\")
args = %("#{args}")
end
- sys_exec("#{Gem.ruby} -rrubygems -S gem --backtrace #{command} #{args}")
+ gem = ENV["BUNDLE_GEM"] || "#{Gem.ruby} -rrubygems -S gem --backtrace"
+ sys_exec("#{gem} #{command} #{args}")
end
bang :gem_command
@@ -313,7 +314,11 @@ module Spec
gems.each do |g|
path = if g == :bundler
Dir.chdir(root) { gem_command! :build, gemspec.to_s }
- bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
+ bundler_path = if ruby_core?
+ root + "lib/bundler-#{Bundler::VERSION}.gem"
+ else
+ root + "bundler-#{Bundler::VERSION}.gem"
+ end
elsif g.to_s =~ %r{\A/.*\.gem\z}
g
else
diff --git a/spec/support/path.rb b/spec/support/path.rb
index a8bc50f5f4..97153226bd 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -5,19 +5,19 @@ require "pathname"
module Spec
module Path
def root
- @root ||= Pathname.new(File.expand_path("../../..", __FILE__))
+ @root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
end
def gemspec
- @gemspec ||= Pathname.new(File.expand_path(root.join("bundler.gemspec"), __FILE__))
+ @gemspec ||= root.join(ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec")
end
def bindir
- @bindir ||= Pathname.new(File.expand_path(root.join("exe"), __FILE__))
+ @bindir ||= root.join(ruby_core? ? "bin" : "exe")
end
def spec_dir
- @spec_dir ||= Pathname.new(File.expand_path(root.join("spec"), __FILE__))
+ @spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec")
end
def tmp(*path)
@@ -110,6 +110,17 @@ module Spec
tmp "tmpdir", *args
end
+ def ruby_core?
+ # avoid to wornings
+ @ruby_core ||= nil
+
+ if @ruby_core.nil?
+ @ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"])
+ else
+ @ruby_core
+ end
+ end
+
extend self
end
end