summaryrefslogtreecommitdiff
path: root/spec/bundler/runtime
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-10-15 13:20:25 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-10-15 17:19:02 +0900
commitd386a58f6f1865aaa35eda5af55cff3ff3cca4ca (patch)
tree0665fe806540deae7f8e52095af6dba70f940aa3 /spec/bundler/runtime
parent7ffd14a18c341565afaf80d259f9fe5df8a13d29 (diff)
Merge bundler-2.2.0.rc.2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3659
Diffstat (limited to 'spec/bundler/runtime')
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb12
-rw-r--r--spec/bundler/runtime/inline_spec.rb30
-rw-r--r--spec/bundler/runtime/setup_spec.rb20
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb16
4 files changed, 76 insertions, 2 deletions
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index b2f9ae725e..b0ef0cc144 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -67,6 +67,18 @@ RSpec.describe "require 'bundler/gem_tasks'" do
end
end
+ context "rake build when path has brackets", :ruby_repo do
+ before do
+ bracketed_bundled_app = tmp.join("bundled[app")
+ FileUtils.cp_r bundled_app, bracketed_bundled_app
+ bundle "exec rake build", :dir => bracketed_bundled_app
+ end
+
+ it "still runs successfully" do
+ expect(err).to be_empty
+ end
+ end
+
context "bundle path configured locally" do
before do
bundle "config set path vendor/bundle"
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index 86ac3f4bb6..1ba50c0e97 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -339,4 +339,34 @@ RSpec.describe "bundler/inline#gemfile" do
expect(last_command).to be_success
expect(out).to include("BUNDLE_GEMFILE is empty")
end
+
+ it "does not error out if library requires optional dependencies" do
+ Dir.mkdir tmp("path_without_gemfile")
+
+ foo_code = <<~RUBY
+ begin
+ gem "bar"
+ rescue LoadError
+ end
+
+ puts "WIN"
+ RUBY
+
+ build_lib "foo", "1.0.0" do |s|
+ s.write "lib/foo.rb", foo_code
+ end
+
+ script <<-RUBY, :dir => tmp("path_without_gemfile")
+ gemfile do
+ path "#{lib_path}" do
+ gem "foo", require: false
+ end
+ end
+
+ require "foo"
+ RUBY
+
+ expect(out).to eq("WIN")
+ expect(err).to be_empty
+ end
end
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index 22c07f0be0..ffa909e269 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -623,6 +623,26 @@ RSpec.describe "Bundler.setup" do
expect(the_bundle).to include_gems "activesupport 2.3.2"
end
+ it "remembers --without and does not bail on bare Bundler.setup, even in the case of path gems no longer available" do
+ bundle "config --local without development"
+
+ path = bundled_app(File.join("vendor", "foo"))
+ build_lib "foo", :path => path
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "activesupport", "2.3.2"
+ gem 'foo', :path => 'vendor/foo', :group => :development
+ G
+
+ FileUtils.rm_rf(path)
+
+ ruby "require 'bundler'; Bundler.setup", :env => { "DEBUG" => "1" }
+ expect(out).to include("Assuming that source at `vendor/foo` has not changed since fetching its specs errored")
+ expect(out).to include("Found no changes, using resolution from the lockfile")
+ expect(err).to be_empty
+ end
+
it "remembers --without and does not include groups passed to Bundler.setup" do
bundle "config --local without rails"
install_gemfile <<-G
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
index 67a25f6ff2..03de830ea0 100644
--- a/spec/bundler/runtime/with_unbundled_env_spec.rb
+++ b/spec/bundler/runtime/with_unbundled_env_spec.rb
@@ -84,11 +84,23 @@ RSpec.describe "Bundler.with_env helpers" do
expect(last_command.stdboth).to include "false"
end
- it "should remove '-rbundler/setup' from RUBYOPT" do
+ it "should remove absolute path to 'bundler/setup' from RUBYOPT even if it was present in original env" do
create_file("source.rb", <<-RUBY)
print #{modified_env}['RUBYOPT']
RUBY
- ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
+ setup_require = "-r#{lib_dir}/bundler/setup"
+ ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 #{setup_require} #{ENV["RUBYOPT"]}"
+ simulate_bundler_version_when_missing_prerelease_default_gem_activation do
+ bundle_exec_ruby bundled_app("source.rb")
+ end
+ expect(last_command.stdboth).not_to include(setup_require)
+ end
+
+ it "should remove relative path to 'bundler/setup' from RUBYOPT even if it was present in original env" do
+ create_file("source.rb", <<-RUBY)
+ print #{modified_env}['RUBYOPT']
+ RUBY
+ ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
bundle_exec_ruby bundled_app("source.rb")
end