aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/commands
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-08 16:36:29 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-08 17:30:02 +0900
commit473f9d2df0ddd7fdb5cc73fa3ad49b2f19f22b06 (patch)
tree6b39312502d32474da0157f5d55620fabd6454ea /spec/bundler/commands
parent4aca77edde91f826aa243e268bf1ef5214530583 (diff)
downloadruby-473f9d2df0ddd7fdb5cc73fa3ad49b2f19f22b06.tar.gz
Merge prepare version of Bundler 2.2.0
Diffstat (limited to 'spec/bundler/commands')
-rw-r--r--spec/bundler/commands/binstubs_spec.rb34
-rw-r--r--spec/bundler/commands/check_spec.rb10
-rw-r--r--spec/bundler/commands/clean_spec.rb5
-rw-r--r--spec/bundler/commands/console_spec.rb41
-rw-r--r--spec/bundler/commands/exec_spec.rb87
-rw-r--r--spec/bundler/commands/fund_spec.rb43
-rw-r--r--spec/bundler/commands/info_spec.rb17
-rw-r--r--spec/bundler/commands/install_spec.rb27
-rw-r--r--spec/bundler/commands/licenses_spec.rb10
-rw-r--r--spec/bundler/commands/list_spec.rb4
-rw-r--r--spec/bundler/commands/lock_spec.rb6
-rw-r--r--spec/bundler/commands/newgem_spec.rb7
-rw-r--r--spec/bundler/commands/remove_spec.rb84
-rw-r--r--spec/bundler/commands/update_spec.rb31
14 files changed, 356 insertions, 50 deletions
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
index 632c521caa..3b177b32ea 100644
--- a/spec/bundler/commands/binstubs_spec.rb
+++ b/spec/bundler/commands/binstubs_spec.rb
@@ -51,6 +51,18 @@ RSpec.describe "bundle binstubs <gem>" do
expect(bundled_app("bin/rake")).to exist
end
+ it "allows installing binstubs for all platforms" do
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ G
+
+ bundle "binstubs rack --all-platforms"
+
+ expect(bundled_app("bin/rackup")).to exist
+ expect(bundled_app("bin/rackup.cmd")).to exist
+ end
+
it "displays an error when used without any gem" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -96,6 +108,10 @@ RSpec.describe "bundle binstubs <gem>" do
before do
pristine_system_gems "bundler-#{system_bundler_version}"
build_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "prints_loaded_gems", "1.0" do |s|
s.executables = "print_loaded_gems"
s.bindir = "exe"
@@ -262,7 +278,7 @@ RSpec.describe "bundle binstubs <gem>" do
end
it "sets correct permissions for binstubs" do
- skip "https://github.com/rubygems/bundler/issues/6895" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3352" if Gem.win_platform?
with_umask(0o002) do
install_gemfile <<-G
@@ -352,6 +368,14 @@ RSpec.describe "bundle binstubs <gem>" do
expect(bundled_app("foo/rackup")).to exist
end
end
+
+ context "when specified --all-platforms option" do
+ it "generates standalone binstubs for all platforms" do
+ bundle "binstubs rack --standalone --all-platforms"
+ expect(bundled_app("bin/rackup")).to exist
+ expect(bundled_app("bin/rackup.cmd")).to exist
+ end
+ end
end
context "when the bin already exists" do
@@ -417,8 +441,14 @@ RSpec.describe "bundle binstubs <gem>" do
end
it "works if the gem has development dependencies" do
+ build_repo2 do
+ build_gem "with_development_dependency" do |s|
+ s.add_development_dependency "activesupport", "= 2.3.5"
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "with_development_dependency"
G
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
index dd69172677..5a746591b3 100644
--- a/spec/bundler/commands/check_spec.rb
+++ b/spec/bundler/commands/check_spec.rb
@@ -71,13 +71,19 @@ RSpec.describe "bundle check" do
end
it "prints a generic message if you changed your lockfile" do
+ build_repo2 do
+ build_gem "rails_pinned_to_old_activesupport" do |s|
+ s.add_dependency "activesupport", "= 1.2.3"
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem 'rails'
G
gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rails"
gem "rails_pinned_to_old_activesupport"
G
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index bd8e7f16c7..7c43aaabc4 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -603,8 +603,7 @@ RSpec.describe "bundle clean" do
it "when using --force on system gems, it doesn't remove binaries" do
bundle "config set path.system true"
- build_repo2
- update_repo2 do
+ build_repo2 do
build_gem "bindir" do |s|
s.bindir = "exe"
s.executables = "foo"
@@ -640,7 +639,7 @@ RSpec.describe "bundle clean" do
end
end
- realworld_system_gems "fiddle"
+ realworld_system_gems "fiddle --version 1.0.0"
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
index 3092184f45..6f1e96261e 100644
--- a/spec/bundler/commands/console_spec.rb
+++ b/spec/bundler/commands/console_spec.rb
@@ -2,8 +2,43 @@
RSpec.describe "bundle console", :bundler => "< 3", :readline => true do
before :each do
+ build_repo2 do
+ # A minimal fake pry console
+ build_gem "pry" do |s|
+ s.write "lib/pry.rb", <<-RUBY
+ class Pry
+ class << self
+ def toplevel_binding
+ unless defined?(@toplevel_binding) && @toplevel_binding
+ TOPLEVEL_BINDING.eval %{
+ def self.__pry__; binding; end
+ Pry.instance_variable_set(:@toplevel_binding, __pry__)
+ class << self; undef __pry__; end
+ }
+ end
+ @toplevel_binding.eval('private')
+ @toplevel_binding
+ end
+
+ def __pry__
+ while line = gets
+ begin
+ puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1')
+ rescue Exception => e
+ puts "\#{e.class}: \#{e.message}"
+ puts e.backtrace.first
+ end
+ end
+ end
+ alias start __pry__
+ end
+ end
+ RUBY
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rack"
gem "activesupport", :group => :test
gem "rack_middleware", :group => :development
@@ -28,7 +63,7 @@ RSpec.describe "bundle console", :bundler => "< 3", :readline => true do
it "starts another REPL if configured as such" do
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "pry"
G
bundle "config set console pry"
@@ -87,7 +122,7 @@ RSpec.describe "bundle console", :bundler => "< 3", :readline => true do
it "performs an automatic bundle install" do
gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rack"
gem "activesupport", :group => :test
gem "rack_middleware", :group => :development
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index fbce4b7bc1..4c34964053 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -68,7 +68,7 @@ RSpec.describe "bundle exec" do
end
it "respects custom process title when loading through ruby" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY'
Process.setproctitle("1-2-3-4-5-6-7")
@@ -93,7 +93,7 @@ RSpec.describe "bundle exec" do
end
it "handles --keep-file-descriptors" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
require "tempfile"
@@ -126,7 +126,7 @@ RSpec.describe "bundle exec" do
end
it "can run a command named --verbose" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
install_gemfile 'gem "rack"'
File.open(bundled_app("--verbose"), "w") do |f|
@@ -286,7 +286,7 @@ RSpec.describe "bundle exec" do
end
it "does not duplicate already exec'ed RUBYOPT" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
install_gemfile <<-G
gem "rack"
@@ -304,7 +304,7 @@ RSpec.describe "bundle exec" do
end
it "does not duplicate already exec'ed RUBYLIB" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
install_gemfile <<-G
gem "rack"
@@ -357,7 +357,7 @@ RSpec.describe "bundle exec" do
bundle "config set clean false" # want to keep the rackup binstub
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- gem "with_license"
+ gem "foo"
G
[true, false].each do |l|
bundle "config set disable_exec_load #{l}"
@@ -373,7 +373,7 @@ RSpec.describe "bundle exec" do
each_prefix.call("exec") do |exec|
describe "when #{exec} is used" do
before(:each) do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
install_gemfile <<-G
gem "rack"
@@ -588,7 +588,7 @@ RSpec.describe "bundle exec" do
describe "with gems bundled for deployment" do
it "works when calling bundler from another script" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
gemfile <<-G
module Monkey
@@ -644,7 +644,7 @@ RSpec.describe "bundle exec" do
shared_examples_for "it runs" do
it "like a normally executed executable" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
subject
expect(exitstatus).to eq(exit_code)
@@ -698,15 +698,23 @@ RSpec.describe "bundle exec" do
let(:exit_code) { 1 }
let(:expected_err) do
"bundler: failed to load command: #{path} (#{path})" \
- "\nRuntimeError: ERROR\n #{path}:10:in `<top (required)>'"
+ "\n#{path}:10:in `<top (required)>': ERROR (RuntimeError)"
+ end
+
+ it "runs like a normally executed executable" do
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
+
+ subject
+ expect(exitstatus).to eq(exit_code)
+ expect(err).to start_with(expected_err)
+ expect(out).to eq(expected)
end
- it_behaves_like "it runs"
end
context "the executable raises an error without a backtrace" do
let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
let(:exit_code) { 1 }
- let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" }
+ let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\n#{system_gem_path("bin/bundle")}: Err (Err)" }
let(:expected) { super() }
it_behaves_like "it runs"
@@ -747,7 +755,7 @@ RSpec.describe "bundle exec" do
let(:expected) { "" }
let(:expected_err) { <<-EOS.strip }
\e[31mCould not find gem 'rack (= 2)' in locally installed gems.
-The source contains 'rack' at: 1.0.0\e[0m
+The source contains the following versions of 'rack': 1.0.0\e[0m
\e[33mRun `bundle install` to install missing gems.\e[0m
EOS
@@ -825,7 +833,7 @@ __FILE__: #{path.to_s.inspect}
RUBY
it "receives the signal" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
bundle("exec #{path}") do |_, o, thr|
o.gets # Consumes 'Started' and ensures that thread has started
@@ -848,7 +856,7 @@ __FILE__: #{path.to_s.inspect}
RUBY
it "makes sure no unexpected signals are restored to DEFAULT" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
test_signals.each do |n|
Signal.trap(n, "IGNORE")
@@ -865,6 +873,8 @@ __FILE__: #{path.to_s.inspect}
context "nested bundle exec" do
context "when bundle in a local path" do
before do
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
+
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@@ -874,8 +884,6 @@ __FILE__: #{path.to_s.inspect}
end
it "correctly shells out" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
-
file = bundled_app("file_that_bundle_execs.rb")
create_file(file, <<-RUBY)
#!#{Gem.ruby}
@@ -887,12 +895,55 @@ __FILE__: #{path.to_s.inspect}
end
end
+ context "when Kernel.require uses extra monkeypatches" do
+ before do
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
+
+ install_gemfile ""
+ end
+
+ it "does not undo the monkeypatches" do
+ karafka = bundled_app("bin/karafka")
+ create_file(karafka, <<~RUBY)
+ #!#{Gem.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
+
+ Bundler.setup(:default)
+
+ require "foo"
+ RUBY
+ karafka.chmod(0o777)
+
+ foreman = bundled_app("bin/foreman")
+ create_file(foreman, <<~RUBY)
+ #!#{Gem.ruby}
+
+ puts `bundle exec bin/karafka`
+ RUBY
+ foreman.chmod(0o777)
+
+ bundle "exec #{foreman}"
+ expect(out).to eq("requiring foo used the monkeypatch")
+ end
+ end
+
context "with a system gem that shadows a default gem" do
let(:openssl_version) { "99.9.9" }
let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil, :raise_on_error => false }
it "only leaves the default gem in the stdlib available" do
- skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+ skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform?
skip "openssl isn't a default gem" if expected.empty?
install_gemfile "" # must happen before installing the broken system gem
diff --git a/spec/bundler/commands/fund_spec.rb b/spec/bundler/commands/fund_spec.rb
index ee3aff3a29..5a0c5411da 100644
--- a/spec/bundler/commands/fund_spec.rb
+++ b/spec/bundler/commands/fund_spec.rb
@@ -1,24 +1,51 @@
# frozen_string_literal: true
RSpec.describe "bundle fund" do
+ before do
+ build_repo2 do
+ build_gem "has_funding_and_other_metadata" do |s|
+ s.metadata = {
+ "bug_tracker_uri" => "https://example.com/user/bestgemever/issues",
+ "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md",
+ "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
+ "homepage_uri" => "https://bestgemever.example.io",
+ "mailing_list_uri" => "https://groups.example.com/bestgemever",
+ "funding_uri" => "https://example.com/has_funding_and_other_metadata/funding",
+ "source_code_uri" => "https://example.com/user/bestgemever",
+ "wiki_uri" => "https://example.com/user/bestgemever/wiki",
+ }
+ end
+
+ build_gem "has_funding", "1.2.3" do |s|
+ s.metadata = {
+ "funding_uri" => "https://example.com/has_funding/funding",
+ }
+ end
+
+ build_gem "gem_with_dependent_funding", "1.0" do |s|
+ s.add_dependency "has_funding"
+ end
+ end
+ end
+
it "prints fund information for all gems in the bundle" do
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'has_metadata'
+ source "#{file_uri_for(gem_repo2)}"
+ gem 'has_funding_and_other_metadata'
gem 'has_funding'
gem 'rack-obama'
G
bundle "fund"
- expect(out).to include("* has_metadata (1.0)\n Funding: https://example.com/has_metadata/funding")
+ expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding")
expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
expect(out).to_not include("rack-obama")
end
it "does not consider fund information for gem dependencies" do
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem 'gem_with_dependent_funding'
G
@@ -30,7 +57,7 @@ RSpec.describe "bundle fund" do
it "prints message if none of the gems have fund information" do
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem 'rack-obama'
G
@@ -42,13 +69,13 @@ RSpec.describe "bundle fund" do
describe "with --group option" do
it "prints fund message for only specified group gems" do
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'has_metadata', :group => :development
+ source "#{file_uri_for(gem_repo2)}"
+ gem 'has_funding_and_other_metadata', :group => :development
gem 'has_funding'
G
bundle "fund --group development"
- expect(out).to include("* has_metadata (1.0)\n Funding: https://example.com/has_metadata/funding")
+ expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding")
expect(out).to_not include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
end
end
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
index eec9c773bc..6bc07ea399 100644
--- a/spec/bundler/commands/info_spec.rb
+++ b/spec/bundler/commands/info_spec.rb
@@ -3,8 +3,22 @@
RSpec.describe "bundle info" do
context "with a standard Gemfile" do
before do
+ build_repo2 do
+ build_gem "has_metadata" do |s|
+ s.metadata = {
+ "bug_tracker_uri" => "https://example.com/user/bestgemever/issues",
+ "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md",
+ "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
+ "homepage_uri" => "https://bestgemever.example.io",
+ "mailing_list_uri" => "https://groups.example.com/bestgemever",
+ "source_code_uri" => "https://example.com/user/bestgemever",
+ "wiki_uri" => "https://example.com/user/bestgemever/wiki",
+ }
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rails"
gem "has_metadata"
G
@@ -66,7 +80,6 @@ RSpec.describe "bundle info" do
\tHomepage: http://example.com
\tDocumentation: https://www.example.info/gems/bestgemever/0.0.1
\tSource Code: https://example.com/user/bestgemever
-\tFunding: https://example.com/has_metadata/funding
\tWiki: https://example.com/user/bestgemever/wiki
\tChangelog: https://example.com/user/bestgemever/CHANGELOG.md
\tBug Tracker: https://example.com/user/bestgemever/issues
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index d1b8585114..a8b174a547 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -141,8 +141,14 @@ RSpec.describe "bundle install with gem sources" do
end
it "does not install the development dependency" do
+ build_repo2 do
+ build_gem "with_development_dependency" do |s|
+ s.add_development_dependency "activesupport", "= 2.3.5"
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "with_development_dependency"
G
@@ -216,6 +222,18 @@ RSpec.describe "bundle install with gem sources" do
expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
+ it "loads env plugins" do
+ plugin_msg = "hello from an env plugin!"
+ create_file "plugins/rubygems_plugin.rb", "puts '#{plugin_msg}'"
+ rubylib = ENV["RUBYLIB"].to_s.split(File::PATH_SEPARATOR).unshift(bundled_app("plugins").to_s).join(File::PATH_SEPARATOR)
+ install_gemfile <<-G, :env => { "RUBYLIB" => rubylib }
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ G
+
+ expect(last_command.stdboth).to include(plugin_msg)
+ end
+
describe "with a gem that installs multiple platforms" do
it "installs gems for the local platform as first choice" do
skip "version is 1.0, not 1.0.0" if Gem.win_platform?
@@ -294,8 +312,11 @@ RSpec.describe "bundle install with gem sources" do
end
it "finds gems in multiple sources", :bundler => "< 3" do
- build_repo2
- update_repo2
+ build_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+ end
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb
index d4fa02d0a7..a203984890 100644
--- a/spec/bundler/commands/licenses_spec.rb
+++ b/spec/bundler/commands/licenses_spec.rb
@@ -2,8 +2,14 @@
RSpec.describe "bundle licenses" do
before :each do
+ build_repo2 do
+ build_gem "with_license" do |s|
+ s.license = "MIT"
+ end
+ end
+
install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rails"
gem "with_license"
G
@@ -18,7 +24,7 @@ RSpec.describe "bundle licenses" do
it "performs an automatic bundle install" do
gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
+ source "#{file_uri_for(gem_repo2)}"
gem "rails"
gem "with_license"
gem "foo"
diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb
index ed3edad163..66930ded75 100644
--- a/spec/bundler/commands/list_spec.rb
+++ b/spec/bundler/commands/list_spec.rb
@@ -117,6 +117,10 @@ RSpec.describe "bundle list" do
context "with paths option" do
before do
build_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "bar"
end
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index c97358c62d..cc56c34952 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe "bundle lock" do
gemfile <<-G
source "#{file_uri_for(repo)}"
gem "rails"
- gem "with_license"
+ gem "weakling"
gem "foo"
G
@@ -40,7 +40,7 @@ RSpec.describe "bundle lock" do
activeresource (= 2.3.2)
rake (= 13.0.1)
rake (13.0.1)
- with_license (1.0)
+ weakling (0.0.3)
PLATFORMS
#{lockfile_platforms}
@@ -48,7 +48,7 @@ RSpec.describe "bundle lock" do
DEPENDENCIES
foo
rails
- with_license
+ weakling
BUNDLED WITH
#{Bundler::VERSION}
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index beee2b0fdc..421ffa80c6 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe "bundle gem" do
prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec"))
rubocop_version = RUBY_VERSION > "2.4" ? "0.90.0" : "0.80.1"
gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"]
+ gems.unshift "parallel -v 1.19.2" if RUBY_VERSION < "2.5"
gems += ["rubocop-ast -v 0.4.0"] if rubocop_version == "0.90.0"
path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path
realworld_system_gems gems, :path => path
@@ -423,7 +424,7 @@ RSpec.describe "bundle gem" do
it "requires the version file" do
bundle "gem #{gem_name}"
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(%r{require "#{require_path}/version"})
+ expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(%r{require_relative "#{require_relative_path}/version"})
end
it "creates a base error class" do
@@ -910,6 +911,8 @@ RSpec.describe "bundle gem" do
let(:require_path) { "test_gem" }
+ let(:require_relative_path) { "test_gem" }
+
let(:flags) { nil }
it "does not nest constants" do
@@ -963,6 +966,8 @@ RSpec.describe "bundle gem" do
let(:require_path) { "test/gem" }
+ let(:require_relative_path) { "gem" }
+
it "nests constants so they work" do
bundle "gem #{gem_name}"
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module Test\n module Gem/)
diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb
index bee4490a8d..46c42fea10 100644
--- a/spec/bundler/commands/remove_spec.rb
+++ b/spec/bundler/commands/remove_spec.rb
@@ -83,7 +83,7 @@ RSpec.describe "bundle remove" do
end
end
- describe "remove mutiple gems from gemfile" do
+ describe "remove multiple gems from gemfile" do
context "when all gems are present in gemfile" do
it "shows success fir all removed gems" do
gemfile <<-G
@@ -210,7 +210,7 @@ RSpec.describe "bundle remove" do
end
end
- context "when the gem belongs to mutiple groups" do
+ context "when the gem belongs to multiple groups" do
it "removes the groups" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -616,4 +616,84 @@ RSpec.describe "bundle remove" do
expect(out).to include("foo could not be removed.")
end
end
+
+ describe "with comments that mention gems" do
+ context "when comment is a separate line comment" do
+ it "does not remove the line comment" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+
+ # gem "rack" might be used in the future
+ gem "rack"
+ G
+
+ bundle "remove rack"
+
+ expect(out).to include("rack was removed.")
+ gemfile_should_be <<-G
+ source "#{file_uri_for(gem_repo1)}"
+
+ # gem "rack" might be used in the future
+ G
+ end
+ end
+
+ context "when gem specified for removal has an inline comment" do
+ it "removes the inline comment" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+
+ gem "rack" # this can be removed
+ G
+
+ bundle "remove rack"
+
+ expect(out).to include("rack was removed.")
+ gemfile_should_be <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ G
+ end
+ end
+
+ context "when gem specified for removal is mentioned in other gem's comment" do
+ it "does not remove other gem" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "puma" # implements interface provided by gem "rack"
+
+ gem "rack"
+ G
+
+ bundle "remove rack"
+
+ expect(out).to_not include("puma was removed.")
+ expect(out).to include("rack was removed.")
+ gemfile_should_be <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "puma" # implements interface provided by gem "rack"
+ G
+ end
+ end
+
+ context "when gem specified for removal has a comment that mentions other gem" do
+ it "does not remove other gem" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "puma" # implements interface provided by gem "rack"
+
+ gem "rack"
+ G
+
+ bundle "remove puma"
+
+ expect(out).to include("puma was removed.")
+ expect(out).to_not include("rack was removed.")
+ gemfile_should_be <<-G
+ source "#{file_uri_for(gem_repo1)}"
+
+ gem "rack"
+ G
+ end
+ end
+ end
end
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 5ab932e5d7..b8de6507f6 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -15,6 +15,10 @@ RSpec.describe "bundle update" do
describe "with no arguments", :bundler => "< 3" do
it "updates the entire bundle" do
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "activesupport", "3.0"
end
@@ -38,6 +42,10 @@ RSpec.describe "bundle update" do
describe "with --all", :bundler => "3" do
it "updates the entire bundle" do
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "activesupport", "3.0"
end
@@ -103,6 +111,10 @@ RSpec.describe "bundle update" do
describe "with a top level dependency" do
it "unlocks all child dependencies that are unrelated to other locked dependencies" do
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "activesupport", "3.0"
end
@@ -124,7 +136,12 @@ RSpec.describe "bundle update" do
describe "with a child dependency" do
it "should update the child dependency" do
- update_repo2
+ update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+ end
+
bundle "update rack"
expect(the_bundle).to include_gems "rack 1.2"
end
@@ -217,6 +234,10 @@ RSpec.describe "bundle update" do
gem "rack"
G
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "activesupport", "3.0"
end
bundle "update --group development"
@@ -269,6 +290,10 @@ RSpec.describe "bundle update" do
gem "rack"
G
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "activesupport", "3.0"
end
bundle "update --group development"
@@ -446,6 +471,10 @@ RSpec.describe "bundle update in more complicated situations" do
G
update_repo2 do
+ build_gem "rack", "1.2" do |s|
+ s.executables = "rackup"
+ end
+
build_gem "thin", "2.0" do |s|
s.add_dependency "rack"
end