diff options
Diffstat (limited to 'spec/bundler/commands/remove_spec.rb')
-rw-r--r-- | spec/bundler/commands/remove_spec.rb | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb index 95d6e75e9f..197fcde091 100644 --- a/spec/bundler/commands/remove_spec.rb +++ b/spec/bundler/commands/remove_spec.rb @@ -7,13 +7,43 @@ RSpec.describe "bundle remove" do source "#{file_uri_for(gem_repo1)}" G - bundle "remove", :raise_on_error => false + bundle "remove", raise_on_error: false expect(err).to include("Please specify gems to remove.") end end - context "when --install flag is specified", :bundler => "< 3" do + context "after 'bundle install' is run" do + describe "running 'bundle remove GEM_NAME'" do + it "removes it from the lockfile" do + rack_dep = <<~L + + DEPENDENCIES + rack + + L + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + + gem "rack" + G + + bundle "install" + + expect(lockfile).to include(rack_dep) + + bundle "remove rack" + + expect(gemfile).to eq <<~G + source "#{file_uri_for(gem_repo1)}" + G + expect(lockfile).to_not include(rack_dep) + end + end + end + + context "when --install flag is specified", bundler: "< 3" do it "removes gems from .bundle" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -56,7 +86,7 @@ RSpec.describe "bundle remove" do gem 'git' gem 'rack', git: "#{lib_path("rack-1.0")}", - branch: 'master' + branch: 'main' gem 'nokogiri' G @@ -79,7 +109,7 @@ RSpec.describe "bundle remove" do source "#{file_uri_for(gem_repo1)}" G - bundle "remove rack", :raise_on_error => false + bundle "remove rack", raise_on_error: false expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") end @@ -116,7 +146,7 @@ RSpec.describe "bundle remove" do gem "rspec" G - bundle "remove rails rack minitest", :raise_on_error => false + bundle "remove rails rack minitest", raise_on_error: false expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") expect(gemfile).to eq <<~G @@ -343,7 +373,7 @@ RSpec.describe "bundle remove" do gem "rack"; gem "rails" G - bundle "remove rails", :raise_on_error => false + bundle "remove rails", raise_on_error: false expect(err).to include("Gems could not be removed. rack (>= 0) would also have been removed.") expect(gemfile).to eq <<~G @@ -355,7 +385,7 @@ RSpec.describe "bundle remove" do context "when some gems could not be removed" do it "shows warning for gems not removed and success for those removed" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem"rack" gem"rspec" @@ -461,7 +491,7 @@ RSpec.describe "bundle remove" do eval_gemfile "Gemfile-other" G - bundle "remove rack", :raise_on_error => false + bundle "remove rack", raise_on_error: false expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") end @@ -480,7 +510,7 @@ RSpec.describe "bundle remove" do gem "rack" G - bundle "remove rack", :raise_on_error => false + bundle "remove rack", raise_on_error: false expect(out).to include("rack was removed.") expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile-other")} so it could not be removed.") @@ -492,7 +522,7 @@ RSpec.describe "bundle remove" do end end - context "when gems can not be removed from other gemfile" do + context "when gems cannot be removed from other gemfile" do it "shows error" do create_file "Gemfile-other", <<-G gem "rails"; gem "rack" @@ -505,7 +535,7 @@ RSpec.describe "bundle remove" do gem "rack" G - bundle "remove rack", :raise_on_error => false + bundle "remove rack", raise_on_error: false expect(out).to include("rack was removed.") expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.") @@ -530,7 +560,7 @@ RSpec.describe "bundle remove" do gem "rails"; gem "rack" G - bundle "remove rack", :raise_on_error => false + bundle "remove rack", raise_on_error: false expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.") expect(bundled_app("Gemfile-other").read).to include("gem \"rack\"") @@ -544,7 +574,7 @@ RSpec.describe "bundle remove" do end context "when gem present in gemfiles but could not be removed from one from one of them" do - it "removes gem which can be removed and shows warning for file from which it can not be removed" do + it "removes gem which can be removed and shows warning for file from which it cannot be removed" do create_file "Gemfile-other", <<-G gem "rack" G @@ -604,7 +634,7 @@ RSpec.describe "bundle remove" do context "with gemspec" do it "should not remove the gem" do - build_lib("foo", :path => tmp.join("foo")) do |s| + build_lib("foo", path: tmp.join("foo")) do |s| s.write("foo.gemspec", "") s.add_dependency "rack" end |