diff options
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 15 | ||||
-rw-r--r-- | spec/bundler/commands/init_spec.rb | 13 | ||||
-rw-r--r-- | spec/bundler/install/gems/standalone_spec.rb | 31 | ||||
-rw-r--r-- | spec/bundler/quality_spec.rb | 1 | ||||
-rw-r--r-- | spec/bundler/resolver/basic_spec.rb | 46 | ||||
-rw-r--r-- | spec/bundler/runtime/setup_spec.rb | 25 |
6 files changed, 124 insertions, 7 deletions
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index c6947afeae..5ca11dcba2 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -2,11 +2,10 @@ RSpec.describe "bundle exec" do let(:system_gems_to_install) { %w[rack-1.0.0 rack-0.9.1] } - before :each do - system_gems(system_gems_to_install, :path => default_bundle_path) - end it "works with --gemfile flag" do + system_gems(system_gems_to_install, :path => default_bundle_path) + create_file "CustomGemfile", <<-G source "#{file_uri_for(gem_repo1)}" gem "rack", "1.0.0" @@ -17,6 +16,8 @@ RSpec.describe "bundle exec" do end it "activates the correct gem" do + system_gems(system_gems_to_install, :path => default_bundle_path) + gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" @@ -27,6 +28,8 @@ RSpec.describe "bundle exec" do end it "works and prints no warnings when HOME is not writable" do + system_gems(system_gems_to_install, :path => default_bundle_path) + gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" @@ -209,8 +212,6 @@ RSpec.describe "bundle exec" do end context "with default gems" do - let(:system_gems_to_install) { [] } - let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false } context "when not specified in Gemfile" do @@ -402,6 +403,8 @@ RSpec.describe "bundle exec" do end it "raises a helpful error when exec'ing to something outside of the bundle" do + system_gems(system_gems_to_install, :path => default_bundle_path) + bundle "config set clean false" # want to keep the rackup binstub install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -706,6 +709,8 @@ RSpec.describe "bundle exec" do RUBY before do + system_gems(system_gems_to_install, :path => default_bundle_path) + bundled_app(path).open("w") {|f| f << executable } bundled_app(path).chmod(0o755) diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb index 9c499b99a1..6aa3e9edd1 100644 --- a/spec/bundler/commands/init_spec.rb +++ b/spec/bundler/commands/init_spec.rb @@ -191,4 +191,17 @@ RSpec.describe "bundle init" do end end end + + describe "using the --gemfile" do + it "should use the --gemfile value to name the gemfile" do + custom_gemfile_name = "NiceGemfileName" + + bundle :init, :gemfile => custom_gemfile_name + + expect(out).to include("Writing new #{custom_gemfile_name}") + used_template = File.read("#{source_root}/lib/bundler/templates/Gemfile") + generated_gemfile = bundled_app(custom_gemfile_name).read + expect(generated_gemfile).to eq(used_template) + end + end end diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index ab10670fdf..4d08752256 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -170,7 +170,7 @@ RSpec.shared_examples "bundle install --standalone" do end end - describe "with Gemfiles using path sources and resulting bundle moved to a folder hierarchy with different nesting" do + describe "with Gemfiles using absolute path sources and resulting bundle moved to a folder hierarchy with different nesting" do before do build_lib "minitest", "1.0.0", :path => lib_path("minitest") @@ -200,6 +200,35 @@ RSpec.shared_examples "bundle install --standalone" do end end + describe "with Gemfiles using relative path sources and app moved to a different root" do + before do + FileUtils.mkdir_p bundled_app("app/vendor") + + build_lib "minitest", "1.0.0", :path => bundled_app("app/vendor/minitest") + + gemfile bundled_app("app/Gemfile"), <<-G + source "#{file_uri_for(gem_repo1)}" + gem "minitest", :path => "vendor/minitest" + G + + bundle "install", :standalone => true, :dir => bundled_app("app") + + FileUtils.mv(bundled_app("app"), bundled_app2("app")) + end + + it "also works" do + ruby <<-RUBY, :dir => bundled_app2("app") + require "./bundle/bundler/setup" + + require "minitest" + puts MINITEST + RUBY + + expect(out).to eq("1.0.0") + expect(err).to be_empty + end + end + describe "with gems with native extension" do before do bundle "config set --local path #{bundled_app("bundle")}" diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 1f4391d0e4..a98815158e 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -206,7 +206,6 @@ RSpec.describe "The library itself" do lib/bundler/deployment.rb lib/bundler/gem_tasks.rb lib/bundler/vlad.rb - lib/bundler/templates/gems.rb ] files_to_require = lib_tracked_files.grep(/\.rb$/) - exclusions files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") } diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb index 41c6d9972c..f739f8c02b 100644 --- a/spec/bundler/resolver/basic_spec.rb +++ b/spec/bundler/resolver/basic_spec.rb @@ -301,4 +301,50 @@ RSpec.describe "Resolving" do end end end + + it "handles versions that redundantly depend on themselves" do + @index = build_index do + gem "rack", "3.0.0" + + gem "standalone_migrations", "7.1.0" do + dep "rack", "~> 2.0" + end + + gem "standalone_migrations", "2.0.4" do + dep "standalone_migrations", ">= 0" + end + + gem "standalone_migrations", "1.0.13" do + dep "rack", ">= 0" + end + end + + dep "rack", "~> 3.0" + dep "standalone_migrations" + + should_resolve_as %w[rack-3.0.0 standalone_migrations-2.0.4] + end + + it "ignores versions that incorrectly depend on themselves" do + @index = build_index do + gem "rack", "3.0.0" + + gem "standalone_migrations", "7.1.0" do + dep "rack", "~> 2.0" + end + + gem "standalone_migrations", "2.0.4" do + dep "standalone_migrations", ">= 2.0.5" + end + + gem "standalone_migrations", "1.0.13" do + dep "rack", ">= 0" + end + end + + dep "rack", "~> 3.0" + dep "standalone_migrations" + + should_resolve_as %w[rack-3.0.0 standalone_migrations-1.0.13] + end end diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index f5b86433dc..9bfcbdaed8 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -1519,4 +1519,29 @@ end expect(err).to be_empty end end + + it "does not undo the Kernel.require decorations", :rubygems => ">= 3.4.6" do + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" + script = bundled_app("bin/script") + create_file(script, <<~RUBY) + module Kernel + module_function + + alias_method :require_before_extra_monkeypatches, :require + + def require(path) + puts "requiring \#{path} used the monkeypatch" + + require_before_extra_monkeypatches(path) + end + end + + require "bundler/setup" + + require "foo" + RUBY + + sys_exec "#{Gem.ruby} #{script}", :raise_on_error => false + expect(out).to include("requiring foo used the monkeypatch") + end end |