diff options
Diffstat (limited to 'spec/bundler/update')
-rw-r--r-- | spec/bundler/update/gemfile_spec.rb | 10 | ||||
-rw-r--r-- | spec/bundler/update/gems/fund_spec.rb | 18 | ||||
-rw-r--r-- | spec/bundler/update/gems/post_install_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/update/git_spec.rb | 121 | ||||
-rw-r--r-- | spec/bundler/update/path_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/update/redownload_spec.rb | 14 |
6 files changed, 77 insertions, 94 deletions
diff --git a/spec/bundler/update/gemfile_spec.rb b/spec/bundler/update/gemfile_spec.rb index 1c5294101e..d32a7945b0 100644 --- a/spec/bundler/update/gemfile_spec.rb +++ b/spec/bundler/update/gemfile_spec.rb @@ -8,8 +8,8 @@ RSpec.describe "bundle update" do gem 'rack' G - bundle :install, :gemfile => bundled_app("NotGemfile") - bundle :update, :gemfile => bundled_app("NotGemfile"), :all => true + bundle :install, gemfile: bundled_app("NotGemfile") + bundle :update, gemfile: bundled_app("NotGemfile"), all: true # Specify BUNDLE_GEMFILE for `the_bundle` # to retrieve the proper Gemfile @@ -30,7 +30,7 @@ RSpec.describe "bundle update" do end it "uses the gemfile to update" do - bundle "update", :all => true + bundle "update", all: true bundle "list" expect(out).to include("rack (1.0.0)") @@ -38,8 +38,8 @@ RSpec.describe "bundle update" do it "uses the gemfile while in a subdirectory" do bundled_app("subdir").mkpath - bundle "update", :all => true, :dir => bundled_app("subdir") - bundle "list", :dir => bundled_app("subdir") + bundle "update", all: true, dir: bundled_app("subdir") + bundle "list", dir: bundled_app("subdir") expect(out).to include("rack (1.0.0)") end diff --git a/spec/bundler/update/gems/fund_spec.rb b/spec/bundler/update/gems/fund_spec.rb index 0dfe63d36d..4a87c16bf7 100644 --- a/spec/bundler/update/gems/fund_spec.rb +++ b/spec/bundler/update/gems/fund_spec.rb @@ -5,20 +5,20 @@ RSpec.describe "bundle update" 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", + "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", + "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", + "funding_uri" => "https://example.com/has_funding/funding", } end end @@ -40,7 +40,7 @@ RSpec.describe "bundle update" do gem 'has_funding' G - bundle :update, :all => true + bundle :update, all: true end it "displays fund message" do diff --git a/spec/bundler/update/gems/post_install_spec.rb b/spec/bundler/update/gems/post_install_spec.rb index 3aaa659d57..e3593387d4 100644 --- a/spec/bundler/update/gems/post_install_spec.rb +++ b/spec/bundler/update/gems/post_install_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "bundle update" do gem 'thin' G - bundle :update, :all => true + bundle :update, all: true end it_behaves_like "a post-install message outputter" @@ -67,7 +67,7 @@ RSpec.describe "bundle update" do gem 'thin' G - bundle :update, :all => true + bundle :update, all: true end it_behaves_like "a post-install message outputter" diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb index 26ad1b45d3..3b7bbfd979 100644 --- a/spec/bundler/update/git_spec.rb +++ b/spec/bundler/update/git_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "bundle update" do describe "git sources" do it "floats on a branch when :branch is used" do build_git "foo", "1.0" - update_git "foo", :branch => "omg" + update_git "foo", branch: "omg" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -13,18 +13,18 @@ RSpec.describe "bundle update" do end G - update_git "foo", :branch => "omg" do |s| + update_git "foo" do |s| s.write "lib/foo.rb", "FOO = '1.1'" end - bundle "update", :all => true + bundle "update", all: true expect(the_bundle).to include_gems "foo 1.1" end it "updates correctly when you have like craziness" do - build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport") - build_git "rails", "3.0", :path => lib_path("rails") do |s| + build_lib "activesupport", "3.0", path: lib_path("rails/activesupport") + build_git "rails", "3.0", path: lib_path("rails") do |s| s.add_dependency "activesupport", "= 3.0" end @@ -38,8 +38,8 @@ RSpec.describe "bundle update" do end it "floats on a branch when :branch is used and the source is specified in the update" do - build_git "foo", "1.0", :path => lib_path("foo") - update_git "foo", :branch => "omg", :path => lib_path("foo") + build_git "foo", "1.0", path: lib_path("foo") + update_git "foo", branch: "omg", path: lib_path("foo") install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -48,7 +48,7 @@ RSpec.describe "bundle update" do end G - update_git "foo", :branch => "omg", :path => lib_path("foo") do |s| + update_git "foo", path: lib_path("foo") do |s| s.write "lib/foo.rb", "FOO = '1.1'" end @@ -57,9 +57,9 @@ RSpec.describe "bundle update" do expect(the_bundle).to include_gems "foo 1.1" end - it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do - build_git "foo", :path => lib_path("foo") - build_gem "bar", :to_bundle => true do |s| + it "floats on main when updating all gems that are pinned to the source even if you have child dependencies" do + build_git "foo", path: lib_path("foo") + build_gem "bar", to_bundle: true do |s| s.add_dependency "foo" end @@ -69,7 +69,7 @@ RSpec.describe "bundle update" do gem "bar" G - update_git "foo", :path => lib_path("foo") do |s| + update_git "foo", path: lib_path("foo") do |s| s.write "lib/foo.rb", "FOO = '1.1'" end @@ -79,8 +79,8 @@ RSpec.describe "bundle update" do end it "notices when you change the repo url in the Gemfile" do - build_git "foo", :path => lib_path("foo_one") - build_git "foo", :path => lib_path("foo_two") + build_git "foo", path: lib_path("foo_one") + build_git "foo", path: lib_path("foo_two") install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -101,9 +101,9 @@ RSpec.describe "bundle update" do it "fetches tags from the remote" do build_git "foo" - @remote = build_git("bar", :bare => true) - update_git "foo", :remote => file_uri_for(@remote.path) - update_git "foo", :push => "master" + @remote = build_git("bar", bare: true) + update_git "foo", remote: file_uri_for(@remote.path) + update_git "foo", push: "main" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -111,19 +111,23 @@ RSpec.describe "bundle update" do G # Create a new tag on the remote that needs fetching - update_git "foo", :tag => "fubar" - update_git "foo", :push => "fubar" + update_git "foo", tag: "fubar" + update_git "foo", push: "fubar" gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'foo', :git => "#{@remote.path}", :tag => "fubar" G - bundle "update", :all => true + bundle "update", all: true + expect(err).to be_empty end describe "with submodules" do before :each do + # CVE-2022-39253: https://lore.kernel.org/lkml/xmqq4jw1uku5.fsf@gitster.g/ + system(*%W[git config --global protocol.file.allow always]) + build_repo4 do build_gem "submodule" do |s| s.write "lib/submodule.rb", "puts 'GEM'" @@ -138,8 +142,8 @@ RSpec.describe "bundle update" do s.add_dependency "submodule" end - sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0") - sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0") + sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0") + sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0") end it "it unlocks the source when submodules are added to a git source" do @@ -164,7 +168,7 @@ RSpec.describe "bundle update" do expect(out).to eq("GIT") end - it "unlocks the source when submodules are removed from git source", :git => ">= 2.9.0" do + it "unlocks the source when submodules are removed from git source", git: ">= 2.9.0" do install_gemfile <<-G source "#{file_uri_for(gem_repo4)}" git "#{lib_path("has_submodule-1.0")}", :submodules => true do @@ -197,7 +201,7 @@ RSpec.describe "bundle update" do lib_path("foo-1.0").join(".git").rmtree - bundle :update, :all => true, :raise_on_error => false + bundle :update, all: true, raise_on_error: false expect(err).to include(lib_path("foo-1.0").to_s). and match(/Git error: command `git fetch.+has failed/) end @@ -205,13 +209,13 @@ RSpec.describe "bundle update" do it "should not explode on invalid revision on update of gem by name" do build_git "rack", "0.8" - build_git "rack", "0.8", :path => lib_path("local-rack") do |s| + build_git "rack", "0.8", path: lib_path("local-rack") do |s| s.write "lib/rack.rb", "puts :LOCAL" end install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" - gem "rack", :git => "#{file_uri_for(lib_path("rack-0.8"))}", :branch => "master" + gem "rack", :git => "#{file_uri_for(lib_path("rack-0.8"))}", :branch => "main" G bundle %(config set local.rack #{lib_path("local-rack")}) @@ -220,24 +224,24 @@ RSpec.describe "bundle update" do end it "shows the previous version of the gem" do - build_git "rails", "2.3.2", :path => lib_path("rails") + build_git "rails", "2.3.2", path: lib_path("rails") install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails", :git => "#{file_uri_for(lib_path("rails"))}" G - update_git "rails", "3.0", :path => lib_path("rails"), :gemspec => true + update_git "rails", "3.0", path: lib_path("rails"), gemspec: true - bundle "update", :all => true - expect(out).to include("Using rails 3.0 (was 2.3.2) from #{file_uri_for(lib_path("rails"))} (at master@#{revision_for(lib_path("rails"))[0..6]})") + bundle "update", all: true + expect(out).to include("Using rails 3.0 (was 2.3.2) from #{file_uri_for(lib_path("rails"))} (at main@#{revision_for(lib_path("rails"))[0..6]})") end end describe "with --source flag" do before :each do build_repo2 - @git = build_git "foo", :path => lib_path("foo") do |s| + @git = build_git "foo", path: lib_path("foo") do |s| s.executables = "foobar" end @@ -251,7 +255,7 @@ RSpec.describe "bundle update" do end it "updates the source" do - update_git "foo", :path => @git.path + update_git "foo", path: @git.path bundle "update --source foo" @@ -264,7 +268,7 @@ RSpec.describe "bundle update" do end it "unlocks gems that were originally pulled in by the source" do - update_git "foo", "2.0", :path => @git.path + update_git "foo", "2.0", path: @git.path bundle "update --source foo" expect(the_bundle).to include_gems "foo 2.0" @@ -272,7 +276,7 @@ RSpec.describe "bundle update" do it "leaves all other gems frozen" do update_repo2 - update_git "foo", :path => @git.path + update_git "foo", path: @git.path bundle "update --source foo" expect(the_bundle).to include_gems "rack 1.0" @@ -282,7 +286,7 @@ RSpec.describe "bundle update" do context "when the gem and the repository have different names" do before :each do build_repo2 - @git = build_git "foo", :path => lib_path("bar") + @git = build_git "foo", path: lib_path("bar") install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -293,55 +297,24 @@ RSpec.describe "bundle update" do G end - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 3" do + it "the --source flag updates version of gems that were originally pulled in by the source" do spec_lines = lib_path("bar/foo.gemspec").read.split("\n") spec_lines[5] = "s.version = '2.0'" - update_git "foo", "2.0", :path => @git.path do |s| + update_git "foo", "2.0", path: @git.path do |s| s.write "foo.gemspec", spec_lines.join("\n") end - ref = @git.ref_for "master" + ref = @git.ref_for "main" bundle "update --source bar" - lockfile_should_be <<-G - GIT - remote: #{@git.path} - revision: #{ref} - specs: - foo (2.0) - - GEM - remote: #{file_uri_for(gem_repo2)}/ - specs: - rack (1.0.0) - - PLATFORMS - #{lockfile_platforms} - - DEPENDENCIES - foo! - rack - - BUNDLED WITH - #{Bundler::VERSION} - G - end - - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "3" do - spec_lines = lib_path("bar/foo.gemspec").read.split("\n") - spec_lines[5] = "s.version = '2.0'" - - update_git "foo", "2.0", :path => @git.path do |s| - s.write "foo.gemspec", spec_lines.join("\n") + checksums = checksums_section_when_existing do |c| + c.no_checksum "foo", "2.0" + c.checksum gem_repo2, "rack", "1.0.0" end - ref = @git.ref_for "master" - - bundle "update --source bar" - - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{@git.path} revision: #{ref} @@ -359,7 +332,7 @@ RSpec.describe "bundle update" do DEPENDENCIES foo! rack - + #{checksums} BUNDLED WITH #{Bundler::VERSION} G diff --git a/spec/bundler/update/path_spec.rb b/spec/bundler/update/path_spec.rb index 756770313b..1f8992b33f 100644 --- a/spec/bundler/update/path_spec.rb +++ b/spec/bundler/update/path_spec.rb @@ -3,14 +3,14 @@ RSpec.describe "path sources" do describe "bundle update --source" do it "shows the previous version of the gem when updated from path source" do - build_lib "activesupport", "2.3.5", :path => lib_path("rails/activesupport") + build_lib "activesupport", "2.3.5", path: lib_path("rails/activesupport") install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport", :path => "#{lib_path("rails/activesupport")}" G - build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport") + build_lib "activesupport", "3.0", path: lib_path("rails/activesupport") bundle "update --source activesupport" expect(out).to include("Using activesupport 3.0 (was 2.3.5) from source at `#{lib_path("rails/activesupport")}`") diff --git a/spec/bundler/update/redownload_spec.rb b/spec/bundler/update/redownload_spec.rb index 147be823f5..4a8c711bfa 100644 --- a/spec/bundler/update/redownload_spec.rb +++ b/spec/bundler/update/redownload_spec.rb @@ -9,12 +9,12 @@ RSpec.describe "bundle update" do end describe "with --force" do - it "shows a deprecation when single flag passed", :bundler => 2 do + it "shows a deprecation when single flag passed", bundler: 2 do bundle "update rack --force" expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`" end - it "shows a deprecation when multiple flags passed", :bundler => 2 do + it "shows a deprecation when multiple flags passed", bundler: 2 do bundle "update rack --no-color --force" expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`" end @@ -30,5 +30,15 @@ RSpec.describe "bundle update" do bundle "update rack --no-color --redownload" expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`" end + + it "re-installs installed gems" do + rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb") + rack_lib.open("w") {|f| f.write("blah blah blah") } + bundle :update, redownload: true + + expect(out).to include "Installing rack 1.0.0" + expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n") + expect(the_bundle).to include_gems "rack 1.0.0" + end end end |