diff options
Diffstat (limited to 'spec/bundler/commands')
27 files changed, 2090 insertions, 797 deletions
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb index 5a5b534e8d..36e286793b 100644 --- a/spec/bundler/commands/add_spec.rb +++ b/spec/bundler/commands/add_spec.rb @@ -9,6 +9,7 @@ RSpec.describe "bundle add" do build_gem "bar", "0.12.3" build_gem "cat", "0.12.3.pre" build_gem "dog", "1.1.3.pre" + build_gem "lemur", "3.1.1.pre.2023.1.1" end build_git "foo", "2.0" @@ -21,7 +22,7 @@ RSpec.describe "bundle add" do context "when no gems are specified" do it "shows error" do - bundle "add", :raise_on_error => false + bundle "add", raise_on_error: false expect(err).to include("Please specify gems to add") end @@ -51,6 +52,13 @@ RSpec.describe "bundle add" do expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/) expect(the_bundle).to include_gems "dog 1.1.3.pre" end + + it "version requirement becomes ~> major.minor.pre.tail when resolved version has a very long tail pre version" do + bundle "add 'lemur'" + # the trailing pre purposely matches the release version to ensure that subbing the release doesn't change the pre.version" + expect(bundled_app_gemfile.read).to match(/gem "lemur", "~> 3.1.pre.2023.1.1"/) + expect(the_bundle).to include_gems "lemur 3.1.1.pre.2023.1.1" + end end describe "with --version" do @@ -63,7 +71,7 @@ RSpec.describe "bundle add" do it "adds multiple version constraints when specified" do requirements = ["< 3.0", "> 1.0"] bundle "add 'foo' --version='#{requirements.join(", ")}'" - expect(bundled_app_gemfile.read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/) + expect(bundled_app_gemfile.read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(", ")}/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -123,7 +131,7 @@ RSpec.describe "bundle add" do describe "with --git and --branch" do before do - update_git "foo", "2.0", :branch => "test" + update_git "foo", "2.0", branch: "test" end it "adds dependency with specified git source and branch" do @@ -147,7 +155,7 @@ RSpec.describe "bundle add" do it "adds dependency with specified github source", :realworld do bundle "add rake --github=ruby/rake" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake"}) end end @@ -155,7 +163,7 @@ RSpec.describe "bundle add" do it "adds dependency with specified github source and branch", :realworld do bundle "add rake --github=ruby/rake --branch=master" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :branch => "master"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :branch => "master"}) end end @@ -163,7 +171,62 @@ RSpec.describe "bundle add" do it "adds dependency with specified github source and ref", :realworld do bundle "add rake --github=ruby/rake --ref=5c60da8" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :ref => "5c60da8"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :ref => "5c60da8"}) + end + end + + describe "with --git and --glob" do + it "adds dependency with specified git source" do + bundle "add foo --git=#{lib_path("foo-2.0")} --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :glob => "\./\*\.gemspec"}) + expect(the_bundle).to include_gems "foo 2.0" + end + end + + describe "with --git and --branch and --glob" do + before do + update_git "foo", "2.0", branch: "test" + end + + it "adds dependency with specified git source and branch" do + bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test", :glob => "\./\*\.gemspec"}) + expect(the_bundle).to include_gems "foo 2.0" + end + end + + describe "with --git and --ref and --glob" do + it "adds dependency with specified git source and branch" do + bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))} --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2\.0", :git => "#{lib_path("foo-2.0")}", :ref => "#{revision_for(lib_path("foo-2.0"))}", :glob => "\./\*\.gemspec"}) + expect(the_bundle).to include_gems "foo 2.0" + end + end + + describe "with --github and --glob" do + it "adds dependency with specified github source", :realworld do + bundle "add rake --github=ruby/rake --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :glob => "\.\/\*\.gemspec"}) + end + end + + describe "with --github and --branch --and glob" do + it "adds dependency with specified github source and branch", :realworld do + bundle "add rake --github=ruby/rake --branch=master --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :branch => "master", :glob => "\.\/\*\.gemspec"}) + end + end + + describe "with --github and --ref and --glob" do + it "adds dependency with specified github source and ref", :realworld do + bundle "add rake --github=ruby/rake --ref=5c60da8 --glob='./*.gemspec'" + + expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", :github => "ruby\/rake", :ref => "5c60da8", :glob => "\.\/\*\.gemspec"}) end end @@ -183,24 +246,24 @@ RSpec.describe "bundle add" do end it "shows error message when version is not formatted correctly" do - bundle "add 'foo' -v='~>1 . 0'", :raise_on_error => false + bundle "add 'foo' -v='~>1 . 0'", raise_on_error: false expect(err).to match("Invalid gem requirement pattern '~>1 . 0'") end it "shows error message when gem cannot be found" do bundle "config set force_ruby_platform true" - bundle "add 'werk_it'", :raise_on_error => false + bundle "add 'werk_it'", raise_on_error: false expect(err).to match("Could not find gem 'werk_it' in") - bundle "add 'werk_it' -s='#{file_uri_for(gem_repo2)}'", :raise_on_error => false + bundle "add 'werk_it' -s='#{file_uri_for(gem_repo2)}'", raise_on_error: false expect(err).to match("Could not find gem 'werk_it' in rubygems repository") end it "shows error message when source cannot be reached" do - bundle "add 'baz' --source='http://badhostasdf'", :raise_on_error => false + bundle "add 'baz' --source='http://badhostasdf'", raise_on_error: false expect(err).to include("Could not reach host badhostasdf. Check your network connection and try again.") - bundle "add 'baz' --source='file://does/not/exist'", :raise_on_error => false + bundle "add 'baz' --source='file://does/not/exist'", raise_on_error: false expect(err).to include("Could not fetch specs from file://does/not/exist/") end @@ -230,7 +293,7 @@ RSpec.describe "bundle add" do describe "with --optimistic and --strict" do it "throws error" do - bundle "add 'foo' --strict --optimistic", :raise_on_error => false + bundle "add 'foo' --strict --optimistic", raise_on_error: false expect(err).to include("You can not specify `--strict` and `--optimistic` at the same time") end @@ -245,7 +308,7 @@ RSpec.describe "bundle add" do end it "throws error if any of the specified gems are present in the gemfile with different version" do - bundle "add weakling bar", :raise_on_error => false + bundle "add weakling bar", raise_on_error: false expect(err).to include("You cannot specify the same gem twice with different version requirements") expect(err).to include("You specified: weakling (~> 0.0.1) and weakling (>= 0).") @@ -259,7 +322,7 @@ RSpec.describe "bundle add" do gem "rack", "1.0" G - bundle "add 'rack' --version=1.1", :raise_on_error => false + bundle "add 'rack' --version=1.1", raise_on_error: false expect(err).to include("You cannot specify the same gem twice with different version requirements") expect(err).to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive") @@ -271,7 +334,7 @@ RSpec.describe "bundle add" do gem "rack", "1.0" G - bundle "add 'rack'", :raise_on_error => false + bundle "add 'rack'", raise_on_error: false expect(err).to include("Gem already added.") expect(err).to include("You cannot specify the same gem twice with different version requirements") @@ -286,7 +349,7 @@ RSpec.describe "bundle add" do gem "rack" G - bundle "add 'rack' --version=1.1", :raise_on_error => false + bundle "add 'rack' --version=1.1", raise_on_error: false expect(err).to include("You cannot specify the same gem twice with different version requirements") expect(err).to include("If you want to update the gem version, run `bundle update rack`.") diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index bfbef58181..6c3dc7bb2d 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "bundle binstubs <gem>" do gem "rails" G - bundle :binstubs, :all => true + bundle :binstubs, all: true expect(bundled_app("bin/rails")).to exist expect(bundled_app("bin/rake")).to exist @@ -69,7 +69,7 @@ RSpec.describe "bundle binstubs <gem>" do gem "rack" G - bundle "binstubs", :raise_on_error => false + bundle "binstubs", raise_on_error: false expect(exitstatus).to eq(1) expect(err).to include("`bundle binstubs` needs at least one gem to run.") end @@ -80,7 +80,7 @@ RSpec.describe "bundle binstubs <gem>" do gem "rack" G - bundle "binstubs rack", :all => true, :raise_on_error => false + bundle "binstubs rack", all: true, raise_on_error: false expect(last_command).to be_failure expect(err).to include("Cannot specify --all with specific gems") end @@ -98,7 +98,7 @@ RSpec.describe "bundle binstubs <gem>" do file.print "OMG" end - sys_exec "bin/rackup", :raise_on_error => false + sys_exec "bin/rackup", raise_on_error: false expect(err).to include("was not generated by Bundler") end @@ -132,13 +132,13 @@ RSpec.describe "bundle binstubs <gem>" do let(:system_bundler_version) { Bundler::VERSION } it "runs bundler" do - sys_exec "bin/bundle install", :env => { "DEBUG" => "1" } + sys_exec "bin/bundle install", env: { "DEBUG" => "1" } expect(out).to include %(Using bundler #{system_bundler_version}\n) end context "when BUNDLER_VERSION is set" do it "runs the correct version of bundler" do - sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.999" }, :raise_on_error => false + sys_exec "bin/bundle install", env: { "BUNDLER_VERSION" => "999.999.999" }, raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") @@ -147,7 +147,7 @@ RSpec.describe "bundle binstubs <gem>" do it "runs the correct version of bundler even if a higher version is installed" do system_gems "bundler-999.999.998", "bundler-999.999.999" - sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.998", "DEBUG" => "1" }, :raise_on_error => false + sys_exec "bin/bundle install", env: { "BUNDLER_VERSION" => "999.999.998", "DEBUG" => "1" }, raise_on_error: false expect(out).to include %(Using bundler 999.999.998\n) end end @@ -159,7 +159,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "runs the correct version of bundler" do - sys_exec "bin/bundle install", :raise_on_error => false + sys_exec "bin/bundle install", raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") @@ -173,7 +173,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "runs the correct version of bundler" do - sys_exec "bin/bundle install", :env => { "BUNDLE_GEMFILE" => "gems.rb" }, :raise_on_error => false + sys_exec "bin/bundle install", env: { "BUNDLE_GEMFILE" => "gems.rb" }, raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 999.999) failed:"). @@ -189,7 +189,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "runs the correct version of bundler" do - sys_exec "bin/bundle install", :raise_on_error => false + sys_exec "bin/bundle install", raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 44.0) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") @@ -205,7 +205,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "runs the correct version of bundler" do - sys_exec "bin/bundle install", :env => { "BUNDLE_GEMFILE" => "gems.rb" }, :raise_on_error => false + sys_exec "bin/bundle install", env: { "BUNDLE_GEMFILE" => "gems.rb" }, raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 44.0) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") @@ -219,15 +219,15 @@ RSpec.describe "bundle binstubs <gem>" do lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.3.0") end - it "installs and runs the exact version of bundler", :rubygems => ">= 3.3.0.dev", :realworld => true do - sys_exec "bin/bundle install --verbose", :artifice => "vcr" + it "installs and runs the exact version of bundler", rubygems: ">= 3.3.0.dev", realworld: true do + sys_exec "bin/bundle install --verbose", artifice: "vcr" expect(exitstatus).not_to eq(42) expect(out).to include("Bundler 2.999.999 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.") expect(out).to include("Using bundler 2.3.0") expect(err).not_to include("Activating bundler (~> 2.3.0) failed:") end - it "runs the available version of bundler", :rubygems => "< 3.3.0.dev" do + it "runs the available version of bundler", rubygems: "< 3.3.0.dev" do sys_exec "bin/bundle install --verbose" expect(exitstatus).not_to eq(42) expect(out).not_to include("Bundler 2.999.999 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.") @@ -244,7 +244,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "runs the correct version of bundler when the version is a pre-release" do - sys_exec "bin/bundle install", :raise_on_error => false + sys_exec "bin/bundle install", raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 2.12.a) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 2.12.a'`") @@ -256,7 +256,7 @@ RSpec.describe "bundle binstubs <gem>" do before { lockfile.gsub(system_bundler_version, "1.1.1") } it "calls through to the latest bundler version", :realworld do - sys_exec "bin/bundle update --bundler", :env => { "DEBUG" => "1" } + sys_exec "bin/bundle update --bundler", env: { "DEBUG" => "1" } using_bundler_line = /Using bundler ([\w\.]+)\n/.match(out) expect(using_bundler_line).to_not be_nil latest_version = using_bundler_line[1] @@ -264,7 +264,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "calls through to the explicit bundler version" do - sys_exec "bin/bundle update --bundler=999.999.999", :raise_on_error => false + sys_exec "bin/bundle update --bundler=999.999.999", raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") @@ -274,7 +274,7 @@ RSpec.describe "bundle binstubs <gem>" do context "without a lockfile" do it "falls back to the latest installed bundler" do FileUtils.rm bundled_app_lock - sys_exec "bin/bundle install", :env => { "DEBUG" => "1" } + sys_exec "bin/bundle install", env: { "DEBUG" => "1" } expect(out).to include "Using bundler #{system_bundler_version}\n" end end @@ -289,7 +289,7 @@ RSpec.describe "bundle binstubs <gem>" do before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") } it "attempts to load that version" do - sys_exec bundled_app("bin/rackup").to_s, :raise_on_error => false + sys_exec bundled_app("bin/rackup").to_s, raise_on_error: false expect(exitstatus).to eq(42) expect(err).to include("Activating bundler (~> 999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") @@ -301,7 +301,7 @@ RSpec.describe "bundle binstubs <gem>" do it "installs binstubs from git gems" do FileUtils.mkdir_p(lib_path("foo/bin")) FileUtils.touch(lib_path("foo/bin/foo")) - build_git "foo", "1.0", :path => lib_path("foo") do |s| + build_git "foo", "1.0", path: lib_path("foo") do |s| s.executables = %w[foo] end install_gemfile <<-G @@ -317,7 +317,7 @@ RSpec.describe "bundle binstubs <gem>" do it "installs binstubs from path gems" do FileUtils.mkdir_p(lib_path("foo/bin")) FileUtils.touch(lib_path("foo/bin/foo")) - build_lib "foo", "1.0", :path => lib_path("foo") do |s| + build_lib "foo", "1.0", path: lib_path("foo") do |s| s.executables = %w[foo] end install_gemfile <<-G @@ -362,7 +362,7 @@ RSpec.describe "bundle binstubs <gem>" do source "#{file_uri_for(gem_repo1)}" G - bundle "binstubs doesnt_exist", :raise_on_error => false + bundle "binstubs doesnt_exist", raise_on_error: false expect(exitstatus).to eq(7) expect(err).to include("Could not find gem 'doesnt_exist'.") @@ -381,14 +381,14 @@ RSpec.describe "bundle binstubs <gem>" do expect(bundled_app("exec/rackup")).to exist end - it "setting is saved for bundle install", :bundler => "< 3" do + it "setting is saved for bundle install", bundler: "< 3" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" gem "rails" G - bundle "binstubs rack", :path => "exec" + bundle "binstubs rack", path: "exec" bundle :install expect(bundled_app("exec/rails")).to exist @@ -549,7 +549,7 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "config set auto_install 1" - bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => "1" } + bundle "binstubs rack", env: { "BUNDLE_INSTALL" => "1" } expect(out).not_to include("Installing rack 1.0.0") end end diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index 790373be1f..37d8b3ac1a 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -158,7 +158,7 @@ RSpec.describe "bundle cache" do end end - context "with --path", :bundler => "< 3" do + context "with --path", bundler: "< 3" do it "sets root directory for gems" do gemfile <<-D source "#{file_uri_for(gem_repo1)}" @@ -211,7 +211,7 @@ RSpec.describe "bundle cache" do end context "with --all-platforms" do - it "puts the gems in vendor/cache even for other rubies", :bundler => ">= 2.4.0" do + it "puts the gems in vendor/cache even for other rubies", bundler: ">= 2.4.0" do gemfile <<-D source "#{file_uri_for(gem_repo1)}" gem 'rack', :platforms => [:ruby_20, :windows_20] @@ -221,7 +221,7 @@ RSpec.describe "bundle cache" do expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist end - it "puts the gems in vendor/cache even for legacy windows rubies", :bundler => ">= 2.4.0" do + it "puts the gems in vendor/cache even for legacy windows rubies", bundler: ">= 2.4.0" do gemfile <<-D source "#{file_uri_for(gem_repo1)}" gem 'rack', :platforms => [:ruby_20, :x64_mingw_20] @@ -272,7 +272,7 @@ RSpec.describe "bundle cache" do end G - bundle :lock, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + bundle :lock, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } bundle :cache, "all-platforms" => true, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist end @@ -289,7 +289,7 @@ RSpec.describe "bundle cache" do subject do bundle "config set --local frozen true" - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false end it "tries to install with frozen" do @@ -301,7 +301,7 @@ RSpec.describe "bundle cache" do G subject expect(exitstatus).to eq(16) - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") bundle "env" @@ -386,6 +386,66 @@ RSpec.describe "bundle install with gem sources" do expect(the_bundle).to include_gems "rack 1.0.0" end + it "uses cached gems for secondary sources when cache_all_platforms configured" do + build_repo4 do + build_gem "foo", "1.0.0" do |s| + s.platform = "x86_64-linux" + end + + build_gem "foo", "1.0.0" do |s| + s.platform = "arm64-darwin" + end + end + + gemfile <<~G + source "https://gems.repo2" + + source "https://gems.repo4" do + gem "foo" + end + G + + lockfile <<~L + GEM + remote: https://gems.repo2/ + specs: + + GEM + remote: https://gems.repo4/ + specs: + foo (1.0.0-x86_64-linux) + foo (1.0.0-arm64-darwin) + + PLATFORMS + arm64-darwin + ruby + x86_64-linux + + DEPENDENCIES + foo + + BUNDLED WITH + #{Bundler::VERSION} + L + + simulate_platform "x86_64-linux" do + bundle "config set cache_all_platforms true" + bundle "config set path vendor/bundle" + bundle :cache, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + + build_repo4 do + # simulate removal of all remote gems + end + + # delete compact index cache + FileUtils.rm_rf home(".bundle/cache/compact_index") + + bundle "install", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + + expect(the_bundle).to include_gems "foo 1.0.0 x86_64-linux" + end + end + it "does not reinstall already-installed gems" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -393,7 +453,7 @@ RSpec.describe "bundle install with gem sources" do G bundle :cache - build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s| + build_gem "rack", "1.0.0", path: bundled_app("vendor/cache") do |s| s.write "lib/rack.rb", "raise 'omg'" end diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 99a858e9e9..4bad16a55e 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -17,7 +17,7 @@ RSpec.describe "bundle check" do gem "rails" G - bundle "check --gemfile bundled_app/Gemfile", :dir => tmp + bundle "check --gemfile bundled_app/Gemfile", dir: tmp expect(out).to include("The Gemfile's dependencies are satisfied") end @@ -55,7 +55,7 @@ RSpec.describe "bundle check" do gem "rails" G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.") end @@ -65,7 +65,7 @@ RSpec.describe "bundle check" do gem "rails" G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(exitstatus).to be > 0 expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.") end @@ -88,11 +88,11 @@ RSpec.describe "bundle check" do gem "rails_pinned_to_old_activesupport" G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.") end - it "remembers --without option from install", :bundler => "< 3" do + it "remembers --without option from install", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" group :foo do @@ -132,7 +132,7 @@ RSpec.describe "bundle check" do gem "rack" G - bundle "check", :raise_on_error => false + bundle "check", raise_on_error: false expect(err).to include("* rack (1.0.0)") expect(exitstatus).to eq(1) end @@ -146,9 +146,9 @@ RSpec.describe "bundle check" do bundle "config set --local path vendor/bundle" bundle :cache - gem_command "uninstall rack", :env => { "GEM_HOME" => vendored_gems.to_s } + gem_command "uninstall rack", env: { "GEM_HOME" => vendored_gems.to_s } - bundle "check", :raise_on_error => false + bundle "check", raise_on_error: false expect(err).to include("* rack (1.0.0)") expect(exitstatus).to eq(1) end @@ -162,7 +162,7 @@ RSpec.describe "bundle check" do end G - system_gems "rack-1.0.0", :path => default_bundle_path + system_gems "rack-1.0.0", path: default_bundle_path lockfile <<-G GEM @@ -193,7 +193,7 @@ RSpec.describe "bundle check" do end G - system_gems "rack-1.0.0", :path => default_bundle_path + system_gems "rack-1.0.0", path: default_bundle_path lockfile <<-G GEM @@ -216,13 +216,13 @@ RSpec.describe "bundle check" do end it "outputs an error when the default Gemfile is not found" do - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(exitstatus).to eq(10) expect(err).to include("Could not locate Gemfile") end it "does not output fatal error message" do - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(exitstatus).to eq(10) expect(err).not_to include("Unfortunately, a fatal error has occurred. ") end @@ -237,11 +237,11 @@ RSpec.describe "bundle check" do bundle "install" FileUtils.rm(bundled_app_lock) - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(last_command).to be_failure end - context "--path", :bundler => "< 3" do + context "--path", bundler: "< 3" do context "after installing gems in the proper directory" do before do gemfile <<-G @@ -271,7 +271,7 @@ RSpec.describe "bundle check" do gem "rails" G - bundle "check --path vendor/bundle", :raise_on_error => false + bundle "check --path vendor/bundle", raise_on_error: false end it "returns false" do @@ -298,7 +298,7 @@ RSpec.describe "bundle check" do it "shows what is missing with the current Gemfile if it is not satisfied" do simulate_new_machine - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(err).to match(/The following gems are missing/) expect(err).to include("* rack (1.0") end @@ -326,7 +326,7 @@ RSpec.describe "bundle check" do end it "shows what is missing with the current Gemfile without duplications" do - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(err).to match(/The following gems are missing/) expect(err).to include("* rack (1.0").once end @@ -362,7 +362,7 @@ RSpec.describe "bundle check" do end it "shows what is missing with the current Gemfile without duplications" do - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false expect(err).to match(/The following gems are missing/) expect(err).to include("* rack (1.0").once end @@ -379,7 +379,7 @@ RSpec.describe "bundle check" do end it "returns success when the Gemfile is satisfied" do - system_gems "rack-1.0.0", :path => default_bundle_path + system_gems "rack-1.0.0", path: default_bundle_path bundle :check expect(out).to include("The Gemfile's dependencies are satisfied") end @@ -404,8 +404,14 @@ RSpec.describe "bundle check" do end it "returns success when the Gemfile is satisfied and generates a correct lockfile" do - system_gems "depends_on_rack-1.0", "rack-1.0", :gem_repo => gem_repo4, :path => default_bundle_path + system_gems "depends_on_rack-1.0", "rack-1.0", gem_repo: gem_repo4, path: default_bundle_path bundle :check + + checksums = checksums_section_when_existing do |c| + c.no_checksum "depends_on_rack", "1.0" + c.no_checksum "rack", "1.0" + end + expect(out).to include("The Gemfile's dependencies are satisfied") expect(lockfile).to eq <<~L GEM @@ -424,7 +430,7 @@ RSpec.describe "bundle check" do DEPENDENCIES depends_on_rack! - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -441,7 +447,7 @@ RSpec.describe "bundle check" do build_gem "dex-dispatch-engine" end - build_lib("bundle-check-issue", :path => tmp.join("bundle-check-issue")) do |s| + build_lib("bundle-check-issue", path: tmp("bundle-check-issue")) do |s| s.write "Gemfile", <<-G source "https://localgemserver.test" @@ -455,16 +461,22 @@ RSpec.describe "bundle check" do s.add_dependency "awesome_print" end - bundle "install", :artifice => "compact_index_extra", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, :dir => tmp.join("bundle-check-issue") + bundle "install", artifice: "compact_index_extra", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, dir: tmp("bundle-check-issue") end it "does not corrupt lockfile when changing version" do - version_file = tmp.join("bundle-check-issue/bundle-check-issue.gemspec") + version_file = tmp("bundle-check-issue/bundle-check-issue.gemspec") File.write(version_file, File.read(version_file).gsub(/s\.version = .+/, "s.version = '9999'")) - bundle "check --verbose", :dir => tmp.join("bundle-check-issue") + bundle "check --verbose", dir: tmp("bundle-check-issue") - expect(File.read(tmp.join("bundle-check-issue/Gemfile.lock"))).to eq <<~L + checksums = checksums_section_when_existing do |c| + c.checksum gem_repo4, "awesome_print", "1.0" + c.no_checksum "bundle-check-issue", "9999" + c.checksum gem_repo2, "dex-dispatch-engine", "1.0" + end + + expect(File.read(tmp("bundle-check-issue/Gemfile.lock"))).to eq <<~L PATH remote: . specs: @@ -487,7 +499,7 @@ RSpec.describe "bundle check" do DEPENDENCIES bundle-check-issue! dex-dispatch-engine! - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index 471cd6c354..0b559a87c8 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -156,7 +156,7 @@ RSpec.describe "bundle clean" do end it "removes unused git gems" do - build_git "foo", :path => lib_path("foo") + build_git "foo", path: lib_path("foo") git_path = lib_path("foo") revision = revision_for(git_path) @@ -194,7 +194,7 @@ RSpec.describe "bundle clean" do end it "keeps used git gems even if installed to a symlinked location" do - build_git "foo", :path => lib_path("foo") + build_git "foo", path: lib_path("foo") git_path = lib_path("foo") revision = revision_for(git_path) @@ -221,7 +221,7 @@ RSpec.describe "bundle clean" do end it "removes old git gems" do - build_git "foo-bar", :path => lib_path("foo-bar") + build_git "foo-bar", path: lib_path("foo-bar") revision = revision_for(lib_path("foo-bar")) gemfile <<-G @@ -236,10 +236,10 @@ RSpec.describe "bundle clean" do bundle "config set path vendor/bundle" bundle "install" - update_git "foo-bar", :path => lib_path("foo-bar") + update_git "foo-bar", path: lib_path("foo-bar") revision2 = revision_for(lib_path("foo-bar")) - bundle "update", :all => true + bundle "update", all: true bundle :clean expect(out).to include("Removing foo-bar (#{revision[0..11]})") @@ -254,8 +254,8 @@ RSpec.describe "bundle clean" do end it "does not remove nested gems in a git repo" 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 revision = revision_for(lib_path("rails")) @@ -274,7 +274,7 @@ RSpec.describe "bundle clean" do end it "does not remove git sources that are in without groups" do - build_git "foo", :path => lib_path("foo") + build_git "foo", path: lib_path("foo") git_path = lib_path("foo") revision = revision_for(git_path) @@ -326,7 +326,7 @@ RSpec.describe "bundle clean" do gem "rack", "1.0.0" G - bundle :clean, :raise_on_error => false + bundle :clean, raise_on_error: false expect(exitstatus).to eq(15) expect(err).to include("--force") @@ -383,7 +383,7 @@ RSpec.describe "bundle clean" do expect(out).to include("rack (1.0.0)").and include("thin (1.0)") end - it "--clean should override the bundle setting on install", :bundler => "< 3" do + it "--clean should override the bundle setting on install", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -405,7 +405,7 @@ RSpec.describe "bundle clean" do should_not_have_gems "thin-1.0" end - it "--clean should override the bundle setting on update", :bundler => "< 3" do + it "--clean should override the bundle setting on update", bundler: "< 3" do build_repo2 gemfile <<-G @@ -421,13 +421,13 @@ RSpec.describe "bundle clean" do build_gem "foo", "1.0.1" end - bundle "update", :all => true + bundle "update", all: true should_have_gems "foo-1.0.1" should_not_have_gems "foo-1.0" end - it "automatically cleans when path has not been set", :bundler => "3" do + it "automatically cleans when path has not been set", bundler: "3" do build_repo2 install_gemfile <<-G @@ -440,7 +440,7 @@ RSpec.describe "bundle clean" do build_gem "foo", "1.0.1" end - bundle "update", :all => true + bundle "update", all: true files = Pathname.glob(bundled_app(".bundle", Bundler.ruby_scope, "*", "*")) files.map! {|f| f.to_s.sub(bundled_app(".bundle", Bundler.ruby_scope).to_s, "") } @@ -486,7 +486,7 @@ RSpec.describe "bundle clean" do build_gem "foo", "1.0.1" end - bundle :update, :all => true + bundle :update, all: true should_have_gems "foo-1.0", "foo-1.0.1" end @@ -505,7 +505,7 @@ RSpec.describe "bundle clean" do update_repo2 do build_gem "foo", "1.0.1" end - bundle :update, :all => true + bundle :update, all: true gem_command :list expect(out).to include("foo (1.0.1, 1.0)") @@ -560,7 +560,7 @@ RSpec.describe "bundle clean" do FileUtils.chmod(0o500, system_cache_path) - bundle :clean, :force => true, :raise_on_error => false + bundle :clean, force: true, raise_on_error: false expect(err).to include(system_gem_path.to_s) expect(err).to include("grant write permissions") @@ -626,15 +626,11 @@ RSpec.describe "bundle clean" do end it "when using --force, it doesn't remove default gem binaries", :realworld do - skip "does not work on old rubies because the realworld gems that need to be installed don't support them" if RUBY_VERSION < "2.7.0" - - skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2 - - default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false + default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", raise_on_error: false skip "irb isn't a default gem" if default_irb_version.empty? # simulate executable for default gem - build_gem "irb", default_irb_version, :to_system => true, :default => true do |s| + build_gem "irb", default_irb_version, to_system: true, default: true do |s| s.executables = "irb" end @@ -644,7 +640,7 @@ RSpec.describe "bundle clean" do source "#{file_uri_for(gem_repo2)}" G - bundle "clean --force", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s } + bundle "clean --force", env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s } expect(out).not_to include("Removing irb") end @@ -905,7 +901,7 @@ RSpec.describe "bundle clean" do bundle :lock bundle "config set without development" bundle "config set path vendor/bundle" - bundle "install" + bundle "install", verbose: true bundle :clean very_simple_binary_extensions_dir = diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index ede93f99eb..d6a30eae5b 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -28,7 +28,7 @@ RSpec.describe ".bundle/config" do context "with env overwrite" do it "prints config with env" do - bundle "config list --parseable", :env => { "BUNDLE_FOO" => "bar3" } + bundle "config list --parseable", env: { "BUNDLE_FOO" => "bar3" } expect(out).to include("foo=bar3") end end @@ -64,11 +64,11 @@ RSpec.describe ".bundle/config" do ENV["BUNDLE_APP_CONFIG"] = "../foo" bundle "config set --local path vendor/bundle" - bundle "install", :dir => bundled_app("omg") + bundle "install", dir: bundled_app("omg") expect(bundled_app(".bundle")).not_to exist expect(bundled_app("../foo/config")).to exist - expect(the_bundle).to include_gems "rack 1.0.0", :dir => bundled_app("omg") + expect(the_bundle).to include_gems "rack 1.0.0", dir: bundled_app("omg") end end @@ -79,6 +79,14 @@ RSpec.describe ".bundle/config" do expect(home(".bundle/config")).to exist end + it "does not list global settings as local" do + bundle "config set --global foo bar" + bundle "config list", dir: home + + expect(out).to include("for the current user") + expect(out).not_to include("for your local app") + end + it "works with an absolute path" do ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s bundle "config set --local path vendor/bundle" @@ -96,8 +104,8 @@ RSpec.describe ".bundle/config" do end it "can be configured through BUNDLE_USER_CONFIG" do - bundle "config set path vendor", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config } - bundle "config get path", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config } + bundle "config set path vendor", env: { "BUNDLE_USER_CONFIG" => bundle_user_config } + bundle "config get path", env: { "BUNDLE_USER_CONFIG" => bundle_user_config } expect(out).to include("Set for the current user (#{bundle_user_config}): \"vendor\"") end @@ -105,8 +113,8 @@ RSpec.describe ".bundle/config" do let(:bundle_user_home) { bundled_app(".bundle").to_s } it "uses the right location" do - bundle "config set path vendor", :env => { "BUNDLE_USER_HOME" => bundle_user_home } - bundle "config get path", :env => { "BUNDLE_USER_HOME" => bundle_user_home } + bundle "config set path vendor", env: { "BUNDLE_USER_HOME" => bundle_user_home } + bundle "config get path", env: { "BUNDLE_USER_HOME" => bundle_user_home } expect(out).to include("Set for the current user (#{bundle_user_home}/config): \"vendor\"") end end @@ -350,6 +358,12 @@ end E expect(out).to eq("http://gems.example.org/ => http://gem-mirror.example.org/") end + + it "allows configuring fallback timeout for each mirror, and does not duplicate configs", rubygems: ">= 3.5.12" do + bundle "config set --global mirror.https://rubygems.org.fallback_timeout 1" + bundle "config set --global mirror.https://rubygems.org.fallback_timeout 2" + expect(File.read(home(".bundle/config"))).to include("BUNDLE_MIRROR").once + end end describe "quoting" do @@ -439,11 +453,11 @@ E it "does not make bundler crash and ignores the configuration" do bundle "config list --parseable" - expect(out).to eq("#mirror.https://rails-assets.org/=http://localhost:9292") + expect(out).to be_empty expect(err).to be_empty ruby(<<~RUBY) - require "#{entrypoint}" + require "bundler" print Bundler.settings.mirror_for("https://rails-assets.org") RUBY expect(out).to eq("https://rails-assets.org/") @@ -451,7 +465,7 @@ E bundle "config set mirror.all http://localhost:9293" ruby(<<~RUBY) - require "#{entrypoint}" + require "bundler" print Bundler.settings.mirror_for("https://rails-assets.org") RUBY expect(out).to eq("http://localhost:9293/") @@ -461,26 +475,26 @@ E describe "subcommands" do it "list" do - bundle "config list", :env => { "BUNDLE_FOO" => "bar" } + bundle "config list", env: { "BUNDLE_FOO" => "bar" } expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nfoo\nSet via BUNDLE_FOO: \"bar\"" - bundle "config list", :env => { "BUNDLE_FOO" => "bar" }, :parseable => true + bundle "config list", env: { "BUNDLE_FOO" => "bar" }, parseable: true expect(out).to eq "foo=bar" end it "list with credentials" do - bundle "config list", :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } + bundle "config list", env: { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"user:[REDACTED]\"" - bundle "config list", :parseable => true, :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } + bundle "config list", parseable: true, env: { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } expect(out).to eq "gems.myserver.com=user:password" end it "list with API token credentials" do - bundle "config list", :env => { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } + bundle "config list", env: { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"[REDACTED]:x-oauth-basic\"" - bundle "config list", :parseable => true, :env => { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } + bundle "config list", parseable: true, env: { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } expect(out).to eq "gems.myserver.com=api_token:x-oauth-basic" end @@ -515,7 +529,7 @@ E bundle "config set --local foo 4.1" expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\"" - bundle "config set --global --local foo 5", :raise_on_error => false + bundle "config set --global --local foo 5", raise_on_error: false expect(last_command).to be_failure expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time." end @@ -555,7 +569,7 @@ E expect(out).to eq "" expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" - bundle "config unset foo --local --global", :raise_on_error => false + bundle "config unset foo --local --global", raise_on_error: false expect(last_command).to be_failure expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time." end diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb index aa76096e3d..a41432b88a 100644 --- a/spec/bundler/commands/console_spec.rb +++ b/spec/bundler/commands/console_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle console", :bundler => "< 3", :readline => true do +RSpec.describe "bundle console", bundler: "< 3", readline: true do before :each do build_repo2 do # A minimal fake pry console diff --git a/spec/bundler/commands/doctor_spec.rb b/spec/bundler/commands/doctor_spec.rb index 1afac00923..666b23a141 100644 --- a/spec/bundler/commands/doctor_spec.rb +++ b/spec/bundler/commands/doctor_spec.rb @@ -38,6 +38,11 @@ RSpec.describe "bundle doctor" do allow(stat).to receive(:uid) { Process.uid } allow(File).to receive(:writable?).with(unwritable_file) { true } allow(File).to receive(:readable?).with(unwritable_file) { true } + + # The following lines are for `Gem::PathSupport#initialize`. + allow(File).to receive(:exist?).with(Gem.default_dir) + allow(File).to receive(:writable?).with(Gem.default_dir) + allow(File).to receive(:writable?).with(File.expand_path("..", Gem.default_dir)) end it "exits with no message if the installed gem has no C extensions" do @@ -59,7 +64,7 @@ RSpec.describe "bundle doctor" do expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"] expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"] allow(Fiddle).to receive(:dlopen).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_raise(Fiddle::DLError) - expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string + expect { doctor.run }.to raise_error(Bundler::ProductionError, <<~E.strip), @stdout.string The following gems are missing OS dependencies: * bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib * rack: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 95db25b358..9f5f12739a 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "bundle exec" do let(:system_gems_to_install) { %w[rack-1.0.0 rack-0.9.1] } it "works with --gemfile flag" do - system_gems(system_gems_to_install, :path => default_bundle_path) + system_gems(system_gems_to_install, path: default_bundle_path) create_file "CustomGemfile", <<-G source "#{file_uri_for(gem_repo1)}" @@ -16,7 +16,7 @@ RSpec.describe "bundle exec" do end it "activates the correct gem" do - system_gems(system_gems_to_install, :path => default_bundle_path) + system_gems(system_gems_to_install, path: default_bundle_path) gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -28,14 +28,14 @@ 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) + system_gems(system_gems_to_install, path: default_bundle_path) gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" G - bundle "exec rackup", :env => { "HOME" => "/" } + bundle "exec rackup", env: { "HOME" => "/" } expect(out).to eq("0.9.1") expect(err).to be_empty end @@ -108,7 +108,7 @@ RSpec.describe "bundle exec" do 2.1.4 L - bundle "exec bundle cache", :env => { "BUNDLER_VERSION" => Bundler::VERSION } + bundle "exec bundle cache", env: { "BUNDLER_VERSION" => Bundler::VERSION } expect(out).to include("Updating files in vendor/cache") end @@ -198,7 +198,7 @@ RSpec.describe "bundle exec" do gem "rack", "0.9.1" G - install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2 + install_gemfile bundled_app2("Gemfile"), <<-G, dir: bundled_app2 source "#{file_uri_for(gem_repo2)}" gem "rack_two", "1.0.0" G @@ -207,12 +207,12 @@ RSpec.describe "bundle exec" do expect(out).to eq("0.9.1") - bundle "exec rackup", :dir => bundled_app2 + bundle "exec rackup", dir: bundled_app2 expect(out).to eq("1.0.0") end context "with default gems" do - let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false } + let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", raise_on_error: false } context "when not specified in Gemfile" do before do @@ -299,7 +299,7 @@ RSpec.describe "bundle exec" do gem "rack", "0.9.1" G - install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2 + install_gemfile bundled_app2("Gemfile"), <<-G, dir: bundled_app2 source "#{file_uri_for(gem_repo2)}" gem "rack_two", "1.0.0" G @@ -344,7 +344,7 @@ RSpec.describe "bundle exec" do bundle "exec 'echo $RUBYOPT'" expect(out.split(" ").count(bundler_setup_opt)).to eq(1) - bundle "exec 'echo $RUBYOPT'", :env => { "RUBYOPT" => rubyopt } + bundle "exec 'echo $RUBYOPT'", env: { "RUBYOPT" => rubyopt } expect(out.split(" ").count(bundler_setup_opt)).to eq(1) end @@ -363,7 +363,7 @@ RSpec.describe "bundle exec" do bundle "exec 'echo $RUBYLIB'" expect(out).to include(rubylib) - bundle "exec 'echo $RUBYLIB'", :env => { "RUBYLIB" => rubylib } + bundle "exec 'echo $RUBYLIB'", env: { "RUBYLIB" => rubylib } expect(out).to include(rubylib) end @@ -373,7 +373,7 @@ RSpec.describe "bundle exec" do gem "rack" G - bundle "exec foobarbaz", :raise_on_error => false + bundle "exec foobarbaz", raise_on_error: false expect(exitstatus).to eq(127) expect(err).to include("bundler: command not found: foobarbaz") expect(err).to include("Install missing gem executables with `bundle install`") @@ -386,7 +386,7 @@ RSpec.describe "bundle exec" do G bundle "exec touch foo" - bundle "exec ./foo", :raise_on_error => false + bundle "exec ./foo", raise_on_error: false expect(exitstatus).to eq(126) expect(err).to include("bundler: not executable: ./foo") end @@ -397,13 +397,13 @@ RSpec.describe "bundle exec" do gem "rack" G - bundle "exec", :raise_on_error => false + bundle "exec", raise_on_error: false expect(exitstatus).to eq(128) expect(err).to include("bundler: exec needs a command to run") 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) + system_gems(system_gems_to_install, path: default_bundle_path) bundle "config set clean false" # want to keep the rackup binstub install_gemfile <<-G @@ -412,7 +412,7 @@ RSpec.describe "bundle exec" do G [true, false].each do |l| bundle "config set disable_exec_load #{l}" - bundle "exec rackup", :raise_on_error => false + bundle "exec rackup", raise_on_error: false expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?" end end @@ -531,7 +531,7 @@ RSpec.describe "bundle exec" do describe "from gems bundled via :path" do before(:each) do - build_lib "fizz", :path => home("fizz") do |s| + build_lib "fizz", path: home("fizz") do |s| s.executables = "fizz" end @@ -580,7 +580,7 @@ RSpec.describe "bundle exec" do describe "from gems bundled via :git with no gemspec" do before(:each) do - build_git "fizz_no_gemspec", :gemspec => false do |s| + build_git "fizz_no_gemspec", gemspec: false do |s| s.executables = "fizz_no_gemspec" end @@ -615,8 +615,25 @@ RSpec.describe "bundle exec" do expect(out).to include("Installing foo 1.0") end + it "performs an automatic bundle install with git gems" do + build_git "foo" do |s| + s.executables = "foo" + end + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "rack", "0.9.1" + gem "foo", :git => "#{lib_path("foo-1.0")}" + G + + bundle "config set auto_install 1" + bundle "exec foo" + expect(out).to include("Fetching rack 0.9.1") + expect(out).to include("Fetching #{lib_path("foo-1.0")}") + expect(out.lines).to end_with("1.0") + end + it "loads the correct optparse when `auto_install` is set, and optparse is a dependency" do - if Gem.ruby_version >= Gem::Version.new("3.0.0") && Gem.rubygems_version < Gem::Version.new("3.3.0.a") + if Gem.rubygems_version < Gem::Version.new("3.3.0.a") skip "optparse is a default gem, and rubygems loads it during install" end @@ -630,7 +647,7 @@ RSpec.describe "bundle exec" do build_gem "optparse", "999.999.999" end - system_gems "optparse-999.999.998", :gem_repo => gem_repo4 + system_gems "optparse-999.999.998", gem_repo: gem_repo4 bundle "config set auto_install 1" bundle "config set --local path vendor/bundle" @@ -666,7 +683,7 @@ RSpec.describe "bundle exec" do gem "foo", :path => "#{lib_path("foo-1.0")}" G - bundle "exec irb", :raise_on_error => false + bundle "exec irb", raise_on_error: false expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid") expect(err).to match('"TODO" is not a summary') @@ -689,7 +706,7 @@ RSpec.describe "bundle exec" do G bundle "config set path.system true" bundle "install" - bundle "exec ruby -e '`bundle -v`; puts $?.success?'", :env => { "BUNDLER_VERSION" => Bundler::VERSION } + bundle "exec ruby -e '`bundle -v`; puts $?.success?'", env: { "BUNDLER_VERSION" => Bundler::VERSION } expect(out).to match("true") end end @@ -709,7 +726,7 @@ RSpec.describe "bundle exec" do RUBY before do - system_gems(system_gems_to_install, :path => default_bundle_path) + system_gems(system_gems_to_install, path: default_bundle_path) bundled_app(path).open("w") {|f| f << executable } bundled_app(path).chmod(0o755) @@ -732,7 +749,7 @@ RSpec.describe "bundle exec" do let(:expected) { [exec, args, rack, process].join("\n") } let(:expected_err) { "" } - subject { bundle "exec #{path} arg1 arg2", :raise_on_error => false } + subject { bundle "exec #{path} arg1 arg2", raise_on_error: false } it "runs" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? @@ -814,8 +831,7 @@ RSpec.describe "bundle exec" do let(:executable) { super() << "\nraise 'ERROR'" } let(:exit_code) { 1 } let(:expected_err) do - "bundler: failed to load command: #{path} (#{path})" \ - "\n#{path}:10:in `<top (required)>': ERROR (RuntimeError)" + /\Abundler: failed to load command: #{Regexp.quote(path.to_s)} \(#{Regexp.quote(path.to_s)}\)\n#{Regexp.quote(path.to_s)}:10:in [`']<top \(required\)>': ERROR \(RuntimeError\)/ end it "runs like a normally executed executable" do @@ -823,7 +839,7 @@ RSpec.describe "bundle exec" do subject expect(exitstatus).to eq(exit_code) - expect(err).to start_with(expected_err) + expect(err).to match(expected_err) expect(out).to eq(expected) end end @@ -857,7 +873,7 @@ RSpec.describe "bundle exec" do end end - context "when Bundler.setup fails", :bundler => "< 3" do + context "when Bundler.setup fails", bundler: "< 3" do before do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -887,7 +903,7 @@ Run `bundle install` to install missing gems. end end - context "when Bundler.setup fails", :bundler => "3" do + context "when Bundler.setup fails", bundler: "3" do before do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -1024,7 +1040,7 @@ __FILE__: #{path.to_s.inspect} end context "signals being trapped by bundler" do - let(:executable) { strip_whitespace <<-RUBY } + let(:executable) { <<~RUBY } #{shebang} begin Thread.new do @@ -1051,7 +1067,7 @@ __FILE__: #{path.to_s.inspect} end context "signals not being trapped by bunder" do - let(:executable) { strip_whitespace <<-RUBY } + let(:executable) { <<~RUBY } #{shebang} signals = #{test_signals.inspect} @@ -1096,7 +1112,7 @@ __FILE__: #{path.to_s.inspect} puts `bundle exec echo foo` RUBY file.chmod(0o777) - bundle "exec #{file}", :env => { "PATH" => path } + bundle "exec #{file}", env: { "PATH" => path } expect(out).to eq("foo") end end @@ -1189,7 +1205,7 @@ __FILE__: #{path.to_s.inspect} 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 } + 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/rubygems/issues/3351" if Gem.win_platform? @@ -1205,7 +1221,7 @@ __FILE__: #{path.to_s.inspect} end end - system_gems("openssl-#{openssl_version}", :gem_repo => gem_repo4) + system_gems("openssl-#{openssl_version}", gem_repo: gem_repo4) file = bundled_app("require_openssl.rb") create_file(file, <<-RUBY) @@ -1218,15 +1234,15 @@ __FILE__: #{path.to_s.inspect} env = { "PATH" => path } aggregate_failures do - expect(bundle("exec #{file}", :artifice => nil, :env => env)).to eq(expected) - expect(bundle("exec bundle exec #{file}", :artifice => nil, :env => env)).to eq(expected) - expect(bundle("exec ruby #{file}", :artifice => nil, :env => env)).to eq(expected) - expect(run(file.read, :artifice => nil, :env => env)).to eq(expected) + expect(bundle("exec #{file}", artifice: nil, env: env)).to eq(expected) + expect(bundle("exec bundle exec #{file}", artifice: nil, env: env)).to eq(expected) + expect(bundle("exec ruby #{file}", artifice: nil, env: env)).to eq(expected) + expect(run(file.read, artifice: nil, env: env)).to eq(expected) end skip "ruby_core has openssl and rubygems in the same folder, and this test needs rubygems require but default openssl not in a directly added entry in $LOAD_PATH" if ruby_core? # sanity check that we get the newer, custom version without bundler - sys_exec "#{Gem.ruby} #{file}", :env => env, :raise_on_error => false + sys_exec "#{Gem.ruby} #{file}", env: env, raise_on_error: false expect(err).to include("custom openssl should not be loaded") end end diff --git a/spec/bundler/commands/help_spec.rb b/spec/bundler/commands/help_spec.rb index 409c49f9e1..0c7031e813 100644 --- a/spec/bundler/commands/help_spec.rb +++ b/spec/bundler/commands/help_spec.rb @@ -15,6 +15,13 @@ RSpec.describe "bundle help" do expect(out).to eq(%(["#{man_dir}/bundle-install.1"])) end + it "prexifes bundle commands with bundle- and resolves aliases when finding the man files" do + with_fake_man do + bundle "help package" + end + expect(out).to eq(%(["#{man_dir}/bundle-cache.1"])) + end + it "simply outputs the human readable file when there is no man on the path" do with_path_as("") do bundle "help install" @@ -71,7 +78,7 @@ RSpec.describe "bundle help" do it "has helpful output when using --help flag for a non-existent command" do with_fake_man do - bundle "instill -h", :raise_on_error => false + bundle "instill -h", raise_on_error: false end expect(err).to include('Could not find command "instill".') end diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index 851f50240f..7ddc5c2363 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -65,7 +65,7 @@ RSpec.describe "bundle info" do end it "complains if gem not in bundle" do - bundle "info missing", :raise_on_error => false + bundle "info missing", raise_on_error: false expect(err).to eq("Could not find gem 'missing'.") end @@ -74,16 +74,16 @@ RSpec.describe "bundle info" do bundle "info rails --path" - expect(err).to match(/The gem rails has been deleted/i) - expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) + expect(err).to include("The gem rails has been deleted.") + expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) bundle "info rail --path" - expect(err).to match(/The gem rails has been deleted/i) - expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) + expect(err).to include("The gem rails has been deleted.") + expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) bundle "info rails" - expect(err).to match(/The gem rails has been deleted/i) - expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) + expect(err).to include("The gem rails has been deleted.") + expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) end context "given a default gem shippped in ruby", :ruby_repo do @@ -167,7 +167,7 @@ RSpec.describe "bundle info" do end it "prints out branch names other than main" do - update_git "foo", :branch => "omg" do |s| + update_git "foo", branch: "omg" do |s| s.write "lib/foo.rb", "FOO = '1.0.omg'" end @revision = revision_for(lib_path("foo-1.0"))[0...6] @@ -194,7 +194,7 @@ RSpec.describe "bundle info" do end it "handles when a version is a '-' prerelease" do - @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo")) + @git = build_git("foo", "1.0.0-beta.1", path: lib_path("foo")) install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}" @@ -215,7 +215,7 @@ RSpec.describe "bundle info" do G bundle "info rac" - expect(out).to match(/\A1 : rack\n2 : rack-obama\n0 : - exit -(\n>.*)?\z/) + expect(out).to match(/\A1 : rack\n2 : rack-obama\n0 : - exit -(\n>|\z)/) end end @@ -228,7 +228,7 @@ RSpec.describe "bundle info" do invalid_regexp = "[]" - bundle "info #{invalid_regexp}", :raise_on_error => false + bundle "info #{invalid_regexp}", raise_on_error: false expect(err).to include("Could not find gem '#{invalid_regexp}'.") end end @@ -242,7 +242,7 @@ RSpec.describe "bundle info" do gem "rails", group: :test G - bundle "info rails", :raise_on_error => false + bundle "info rails", raise_on_error: false expect(err).to include("Could not find gem 'rails', because it's in the group 'test', configured to be ignored.") end end diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb index 6aa3e9edd1..564a4bdc2d 100644 --- a/spec/bundler/commands/init_spec.rb +++ b/spec/bundler/commands/init_spec.rb @@ -24,7 +24,7 @@ RSpec.describe "bundle init" do it "honours the current process umask when generating from a template" do FileUtils.mkdir(target_dir) - bundle :init, :dir => target_dir + bundle :init, dir: target_dir generated_mode = File.stat(File.join(target_dir, "Gemfile")).mode & 0o111 expect(generated_mode).to be_zero end @@ -38,11 +38,11 @@ RSpec.describe "bundle init" do end it "does not change existing Gemfiles" do - expect { bundle :init, :raise_on_error => false }.not_to change { File.read(bundled_app_gemfile) } + expect { bundle :init, raise_on_error: false }.not_to change { File.read(bundled_app_gemfile) } end it "notifies the user that an existing Gemfile already exists" do - bundle :init, :raise_on_error => false + bundle :init, raise_on_error: false expect(err).to include("Gemfile already exists") end end @@ -55,7 +55,7 @@ RSpec.describe "bundle init" do FileUtils.mkdir bundled_app(subdir) - bundle :init, :dir => bundled_app(subdir) + bundle :init, dir: bundled_app(subdir) expect(out).to include("Writing new Gemfile") expect(bundled_app("#{subdir}/Gemfile")).to be_file @@ -71,7 +71,7 @@ RSpec.describe "bundle init" do mode = File.stat(bundled_app(subdir)).mode ^ 0o222 FileUtils.chmod mode, bundled_app(subdir) - bundle :init, :dir => bundled_app(subdir), :raise_on_error => false + bundle :init, dir: bundled_app(subdir), raise_on_error: false expect(err).to include("directory is not writable") expect(Dir[bundled_app("#{subdir}/*")]).to be_empty @@ -79,7 +79,7 @@ RSpec.describe "bundle init" do end context "given --gemspec option" do - let(:spec_file) { tmp.join("test.gemspec") } + let(:spec_file) { tmp("test.gemspec") } it "should generate from an existing gemspec" do File.open(spec_file, "w") do |file| @@ -92,7 +92,7 @@ RSpec.describe "bundle init" do S end - bundle :init, :gemspec => spec_file + bundle :init, gemspec: spec_file gemfile = bundled_app_gemfile.read expect(gemfile).to match(%r{source 'https://rubygems.org'}) @@ -112,7 +112,7 @@ RSpec.describe "bundle init" do S end - bundle :init, :gemspec => spec_file, :raise_on_error => false + bundle :init, gemspec: spec_file, raise_on_error: false expect(err).to include("There was an error while loading `test.gemspec`") end end @@ -135,11 +135,11 @@ RSpec.describe "bundle init" do end it "does not change existing Gemfiles" do - expect { bundle :init, :raise_on_error => false }.not_to change { File.read(bundled_app("gems.rb")) } + expect { bundle :init, raise_on_error: false }.not_to change { File.read(bundled_app("gems.rb")) } end it "notifies the user that an existing gems.rb already exists" do - bundle :init, :raise_on_error => false + bundle :init, raise_on_error: false expect(err).to include("gems.rb already exists") end end @@ -152,7 +152,7 @@ RSpec.describe "bundle init" do FileUtils.mkdir bundled_app(subdir) - bundle :init, :dir => bundled_app(subdir) + bundle :init, dir: bundled_app(subdir) expect(out).to include("Writing new gems.rb") expect(bundled_app("#{subdir}/gems.rb")).to be_file @@ -160,7 +160,7 @@ RSpec.describe "bundle init" do end context "given --gemspec option" do - let(:spec_file) { tmp.join("test.gemspec") } + let(:spec_file) { tmp("test.gemspec") } before do File.open(spec_file, "w") do |file| @@ -175,7 +175,7 @@ RSpec.describe "bundle init" do end it "should generate from an existing gemspec" do - bundle :init, :gemspec => spec_file + bundle :init, gemspec: spec_file gemfile = bundled_app("gems.rb").read expect(gemfile).to match(%r{source 'https://rubygems.org'}) @@ -185,7 +185,7 @@ RSpec.describe "bundle init" do end it "prints message to user" do - bundle :init, :gemspec => spec_file + bundle :init, gemspec: spec_file expect(out).to include("Writing new gems.rb") end @@ -196,7 +196,7 @@ RSpec.describe "bundle init" do it "should use the --gemfile value to name the gemfile" do custom_gemfile_name = "NiceGemfileName" - bundle :init, :gemfile => custom_gemfile_name + 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") diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb index 92e86bd6cc..255a03c135 100644 --- a/spec/bundler/commands/inject_spec.rb +++ b/spec/bundler/commands/inject_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle inject", :bundler => "< 3" do +RSpec.describe "bundle inject", bundler: "< 3" do before :each do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -36,14 +36,14 @@ RSpec.describe "bundle inject", :bundler => "< 3" do context "with injected gems already in the Gemfile" do it "doesn't add existing gems" do - bundle "inject 'rack' '> 0'", :raise_on_error => false + bundle "inject 'rack' '> 0'", raise_on_error: false expect(err).to match(/cannot specify the same gem twice/i) end end context "incorrect arguments" do it "fails when more than 2 arguments are passed" do - bundle "inject gem_name 1 v", :raise_on_error => false + bundle "inject gem_name 1 v", raise_on_error: false expect(err).to eq(<<-E.strip) ERROR: "bundle inject" was called with arguments ["gem_name", "1", "v"] Usage: "bundle inject GEM VERSION" @@ -108,8 +108,8 @@ Usage: "bundle inject GEM VERSION" source "#{file_uri_for(gem_repo1)}" gem "rack-obama" G - bundle "inject 'rack' '> 0'", :raise_on_error => false - expect(err).to match(/trying to install in deployment mode after changing/) + bundle "inject 'rack' '> 0'", raise_on_error: false + expect(err).to match(/the lockfile can't be updated because frozen mode is set/) expect(bundled_app_lock.read).not_to match(/rack-obama/) end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index f572bdf176..83bee136fe 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "bundle install with gem sources" do end it "does not make a lockfile if the install fails" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false raise StandardError, "FAIL" G @@ -29,7 +29,7 @@ RSpec.describe "bundle install with gem sources" do expect(bundled_app_lock).to exist end - it "does not create ./.bundle by default", :bundler => "< 3" do + it "does not create ./.bundle by default", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -45,7 +45,7 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - bundle :install, :env => { "BUNDLE_PATH__SYSTEM" => "true" } # can't use install_gemfile since it sets retry + bundle :install, env: { "BUNDLE_PATH__SYSTEM" => "true" } # can't use install_gemfile since it sets retry expect(bundled_app(".bundle")).not_to exist end @@ -68,7 +68,7 @@ RSpec.describe "bundle install with gem sources" do lockfile = File.read(bundled_app_lock) - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false raise StandardError, "FAIL" G @@ -130,7 +130,7 @@ RSpec.describe "bundle install with gem sources" do end it "raises an appropriate error when gems are specified using symbols" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem :rack G @@ -197,7 +197,7 @@ RSpec.describe "bundle install with gem sources" do end it "does not reinstall any gem that is already available locally" do - system_gems "activesupport-2.3.2", :path => default_bundle_path + system_gems "activesupport-2.3.2", path: default_bundle_path build_repo2 do build_gem "activesupport", "2.3.2" do |s| @@ -214,7 +214,7 @@ RSpec.describe "bundle install with gem sources" do end it "works when the gemfile specifies gems that only exist in the system" do - build_gem "foo", :to_bundle => true + build_gem "foo", to_bundle: true install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -225,7 +225,7 @@ RSpec.describe "bundle install with gem sources" do end it "prioritizes local gems over remote gems" do - build_gem "rack", "1.0.0", :to_bundle => true do |s| + build_gem "rack", "1.0.0", to_bundle: true do |s| s.add_dependency "activesupport", "2.3.5" end @@ -241,7 +241,7 @@ RSpec.describe "bundle install with gem sources" 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 } + install_gemfile <<-G, env: { "RUBYLIB" => rubylib } source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -311,14 +311,14 @@ RSpec.describe "bundle install with gem sources" do expect(the_bundle).to include_gems "rack 1.0" end - it "allows running bundle install --system without deleting foo", :bundler => "< 3" do + it "allows running bundle install --system without deleting foo", bundler: "< 3" do bundle "install --path vendor" bundle "install --system" FileUtils.rm_rf(bundled_app("vendor")) expect(the_bundle).to include_gems "rack 1.0" end - it "allows running bundle install --system after deleting foo", :bundler => "< 3" do + it "allows running bundle install --system after deleting foo", bundler: "< 3" do bundle "install --path vendor" FileUtils.rm_rf(bundled_app("vendor")) bundle "install --system" @@ -326,7 +326,7 @@ RSpec.describe "bundle install with gem sources" do end end - it "finds gems in multiple sources", :bundler => "< 3" do + it "finds gems in multiple sources", bundler: "< 3" do build_repo2 do build_gem "rack", "1.2" do |s| s.executables = "rackup" @@ -345,7 +345,7 @@ RSpec.describe "bundle install with gem sources" do end it "gives a useful error if no sources are set" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false gem "rack" G @@ -408,7 +408,7 @@ RSpec.describe "bundle install with gem sources" do end it "does not throw a warning if a gem is added once in Gemfile and also inside a gemspec as a development dependency" do - build_lib "my-gem", :path => bundled_app do |s| + build_lib "my-gem", path: bundled_app do |s| s.add_development_dependency "my-private-gem" end @@ -430,8 +430,155 @@ RSpec.describe "bundle install with gem sources" do expect(the_bundle).to include_gems("my-private-gem 1.0") end + it "throws a warning if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with different requirements" do + build_lib "my-gem", path: bundled_app do |s| + s.add_development_dependency "rubocop", "~> 1.36.0" + end + + build_repo4 do + build_gem "rubocop", "1.36.0" + build_gem "rubocop", "1.37.1" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gemspec + + gem "rubocop", group: :development + G + + bundle :install + + expect(err).to include("A gemspec development dependency (rubocop, ~> 1.36.0) is being overridden by a Gemfile dependency (rubocop, >= 0).") + expect(err).to include("This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement") + + # This is not the best behavior I believe, it would be better if both + # requirements are considered if they are compatible, and a version + # satisfying both is chosen. But not sure about changing it right now, so + # I went with a warning for the time being. + expect(the_bundle).to include_gems("rubocop 1.37.1") + end + + it "includes the gem without warning if two gemspecs add it with the same requirement" do + gem1 = tmp("my-gem-1") + gem2 = tmp("my-gem-2") + + build_lib "my-gem", path: gem1 do |s| + s.add_development_dependency "rubocop", "~> 1.36.0" + end + + build_lib "my-gem-2", path: gem2 do |s| + s.add_development_dependency "rubocop", "~> 1.36.0" + end + + build_repo4 do + build_gem "rubocop", "1.36.0" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gemspec path: "#{gem1}" + gemspec path: "#{gem2}" + G + + bundle :install + + expect(err).to be_empty + expect(the_bundle).to include_gems("rubocop 1.36.0") + end + + it "warns when a Gemfile dependency is overriding a gemspec development dependency, with different requirements" do + build_lib "my-gem", path: bundled_app do |s| + s.add_development_dependency "rails", ">= 5" + end + + build_repo4 do + build_gem "rails", "7.0.8" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "rails", "~> 7.0.8" + + gemspec + G + + bundle :install + + expect(err).to include("A gemspec development dependency (rails, >= 5) is being overridden by a Gemfile dependency (rails, ~> 7.0.8).") + expect(err).to include("This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement") + + # This is not the best behavior I believe, it would be better if both + # requirements are considered if they are compatible, and a version + # satisfying both is chosen. But not sure about changing it right now, so + # I went with a warning for the time being. + expect(the_bundle).to include_gems("rails 7.0.8") + end + + it "does not warn if a gem is added once in Gemfile and also inside a gemspec as a development dependency, with same requirements, and different sources" do + build_lib "my-gem", path: bundled_app do |s| + s.add_development_dependency "activesupport" + end + + build_repo4 do + build_gem "activesupport" + end + + build_git "activesupport", "1.0", path: lib_path("activesupport") + + install_gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gemspec + + gem "activesupport", :git => "#{file_uri_for(lib_path("activesupport"))}" + G + + expect(err).to be_empty + expect(the_bundle).to include_gems "activesupport 1.0", source: "git@#{lib_path("activesupport")}" + + # if the Gemfile dependency is specified first + install_gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "activesupport", :git => "#{file_uri_for(lib_path("activesupport"))}" + + gemspec + G + + expect(err).to be_empty + expect(the_bundle).to include_gems "activesupport 1.0", source: "git@#{lib_path("activesupport")}" + end + + it "considers both dependencies for resolution if a gem is added once in Gemfile and also inside a local gemspec as a runtime dependency, with different requirements" do + build_lib "my-gem", path: bundled_app do |s| + s.add_dependency "rubocop", "~> 1.36.0" + end + + build_repo4 do + build_gem "rubocop", "1.36.0" + build_gem "rubocop", "1.37.1" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gemspec + + gem "rubocop" + G + + bundle :install + + expect(err).to be_empty + expect(the_bundle).to include_gems("rubocop 1.36.0") + end + it "throws an error if a gem is added twice in Gemfile when version of one dependency is not specified" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo2)}" gem "rack" gem "rack", "1.0" @@ -442,7 +589,7 @@ RSpec.describe "bundle install with gem sources" do end it "throws an error if a gem is added twice in Gemfile when different versions of both dependencies are specified" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo2)}" gem "rack", "1.0" gem "rack", "1.1" @@ -455,7 +602,7 @@ RSpec.describe "bundle install with gem sources" do it "gracefully handles error when rubygems server is unavailable" do skip "networking issue" if Gem.win_platform? - install_gemfile <<-G, :artifice => nil, :raise_on_error => false + install_gemfile <<-G, artifice: nil, raise_on_error: false source "#{file_uri_for(gem_repo1)}" source "http://0.0.0.0:9384" do gem 'foo' @@ -467,8 +614,8 @@ RSpec.describe "bundle install with gem sources" do end it "fails gracefully when downloading an invalid specification from the full index" do - build_repo2 do - build_gem "ajp-rails", "0.0.0", :gemspec => false, :skip_validation => true do |s| + build_repo2(build_compact_index: false) do + build_gem "ajp-rails", "0.0.0", gemspec: false, skip_validation: true do |s| bad_deps = [["ruby-ajp", ">= 0.2.0"], ["rails", ">= 0.14"]] s. instance_variable_get(:@spec). @@ -479,7 +626,7 @@ RSpec.describe "bundle install with gem sources" do build_gem "ruby-ajp", "1.0.0" end - install_gemfile <<-G, :full_index => true, :raise_on_error => false + install_gemfile <<-G, full_index: true, raise_on_error: false source "#{file_uri_for(gem_repo2)}" gem "ajp-rails", "0.0.0" @@ -514,11 +661,9 @@ RSpec.describe "bundle install with gem sources" do end describe "Ruby version in Gemfile.lock" do - include Bundler::GemHelpers - context "and using an unsupported Ruby version" do it "prints an error" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false ruby '~> 1.2' source "#{file_uri_for(gem_repo1)}" G @@ -535,6 +680,7 @@ RSpec.describe "bundle install with gem sources" do end it "writes current Ruby version to Gemfile.lock" do + checksums = checksums_section_when_existing expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ @@ -544,7 +690,7 @@ RSpec.describe "bundle install with gem sources" do #{lockfile_platforms} DEPENDENCIES - + #{checksums} RUBY VERSION #{Bundler::RubyVersion.system} @@ -559,6 +705,8 @@ RSpec.describe "bundle install with gem sources" do source "#{file_uri_for(gem_repo1)}" G + checksums = checksums_section_when_existing + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ @@ -568,7 +716,7 @@ RSpec.describe "bundle install with gem sources" do #{lockfile_platforms} DEPENDENCIES - + #{checksums} RUBY VERSION #{Bundler::RubyVersion.system} @@ -605,7 +753,7 @@ RSpec.describe "bundle install with gem sources" do file.puts gemfile end - bundle :install, :dir => root_dir + bundle :install, dir: root_dir end it "doesn't blow up when using the `gemspec` DSL" do @@ -613,7 +761,7 @@ RSpec.describe "bundle install with gem sources" do FileUtils.mkdir_p(root_dir) - build_lib "foo", :path => root_dir + build_lib "foo", path: root_dir gemfile = <<-G source "#{file_uri_for(gem_repo1)}" gemspec @@ -622,7 +770,7 @@ RSpec.describe "bundle install with gem sources" do file.puts gemfile end - bundle :install, :dir => root_dir + bundle :install, dir: root_dir end end @@ -635,7 +783,7 @@ RSpec.describe "bundle install with gem sources" do gem 'rack' G - bundle :install, :quiet => true + bundle :install, quiet: true expect(out).to be_empty expect(err).to be_empty end @@ -665,7 +813,7 @@ RSpec.describe "bundle install with gem sources" do gem 'non-existing-gem' G - bundle :install, :quiet => true, :raise_on_error => false, :env => { "RUBYOPT" => "-r#{bundled_app("install_with_warning.rb")}" } + bundle :install, quiet: true, raise_on_error: false, env: { "RUBYOPT" => "-r#{bundled_app("install_with_warning.rb")}" } expect(out).to be_empty expect(err).to include("Could not find gem 'non-existing-gem'") expect(err).to include("BOOOOO") @@ -687,7 +835,7 @@ RSpec.describe "bundle install with gem sources" do FileUtils.chmod(0o500, bundle_path) bundle "config set --local path vendor" - bundle :install, :raise_on_error => false + bundle :install, raise_on_error: false expect(err).to include(bundle_path.to_s) expect(err).to include("grant write permissions") end @@ -709,7 +857,7 @@ RSpec.describe "bundle install with gem sources" do bundle "config set --local path vendor" begin - bundle :install, :raise_on_error => false + bundle :install, raise_on_error: false ensure FileUtils.chmod("+x", gems_path) end @@ -723,6 +871,36 @@ RSpec.describe "bundle install with gem sources" do end end + describe "when bundle bin dir does not have write access", :permissions do + let(:bin_dir) { bundled_app("vendor/#{Bundler.ruby_scope}/bin") } + + before do + FileUtils.mkdir_p(bin_dir) + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'rack' + G + end + + it "should display a proper message to explain the problem" do + FileUtils.chmod("-x", bin_dir) + bundle "config set --local path vendor" + + begin + bundle :install, raise_on_error: false + ensure + FileUtils.chmod("+x", bin_dir) + end + + expect(err).not_to include("ERROR REPORT TEMPLATE") + + expect(err).to include( + "There was an error while trying to write to `#{bin_dir}`. " \ + "It is likely that you need to grant write permissions for that path." + ) + end + end + describe "when bundle extensions path does not have write access", :permissions do let(:extensions_path) { bundled_app("vendor/#{Bundler.ruby_scope}/extensions/#{Gem::Platform.local}/#{Gem.extension_api_version}") } @@ -739,7 +917,7 @@ RSpec.describe "bundle install with gem sources" do bundle "config set --local path vendor" begin - bundle :install, :raise_on_error => false + bundle :install, raise_on_error: false ensure FileUtils.chmod("+x", extensions_path) end @@ -779,7 +957,7 @@ RSpec.describe "bundle install with gem sources" do FileUtils.chmod("-x", foo_path) begin - bundle "install --redownload", :raise_on_error => false + bundle "install --redownload", raise_on_error: false ensure FileUtils.chmod("+x", foo_path) end @@ -790,6 +968,71 @@ RSpec.describe "bundle install with gem sources" do end end + describe "when gem home does not have the writable bit set, yet it's still writable", :permissions do + let(:gem_home) { bundled_app("vendor/#{Bundler.ruby_scope}") } + + before do + build_repo4 do + build_gem "foo", "1.0.0" do |s| + s.write "CHANGELOG.md", "foo" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'foo' + G + end + + it "should display a proper message to explain the problem" do + bundle "config set --local path vendor" + bundle :install + expect(out).to include("Bundle complete!") + expect(err).to be_empty + + FileUtils.chmod("-w", gem_home) + + begin + bundle "install --redownload" + ensure + FileUtils.chmod("+w", gem_home) + end + + expect(out).to include("Bundle complete!") + expect(err).to be_empty + end + end + + describe "when gems path is world writable (no sticky bit set)", :permissions do + let(:gems_path) { bundled_app("vendor/#{Bundler.ruby_scope}/gems") } + + before do + build_repo4 do + build_gem "foo", "1.0.0" do |s| + s.write "CHANGELOG.md", "foo" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'foo' + G + end + + it "should display a proper message to explain the problem" do + bundle "config set --local path vendor" + bundle :install + expect(out).to include("Bundle complete!") + expect(err).to be_empty + + FileUtils.chmod(0o777, gems_path) + + bundle "install --redownload", raise_on_error: false + + expect(err).to include("The installation path is insecure. Bundler cannot continue.") + end + end + describe "when bundle cache path does not have write access", :permissions do let(:cache_path) { bundled_app("vendor/#{Bundler.ruby_scope}/cache") } @@ -805,12 +1048,35 @@ RSpec.describe "bundle install with gem sources" do FileUtils.chmod(0o500, cache_path) bundle "config set --local path vendor" - bundle :install, :raise_on_error => false + bundle :install, raise_on_error: false expect(err).to include(cache_path.to_s) expect(err).to include("grant write permissions") end end + describe "when gemspecs are unreadable", :permissions do + let(:gemspec_path) { vendored_gems("specifications/rack-1.0.0.gemspec") } + + before do + gemfile <<~G + source "#{file_uri_for(gem_repo1)}" + gem 'rack' + G + bundle "config path vendor/bundle" + bundle :install + expect(out).to include("Bundle complete!") + expect(err).to be_empty + + FileUtils.chmod("-r", gemspec_path) + end + + it "shows a good error" do + bundle :install, raise_on_error: false + expect(err).to include(gemspec_path.to_s) + expect(err).to include("grant read permissions") + end + end + context "after installing with --standalone" do before do install_gemfile <<-G @@ -818,11 +1084,11 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G bundle "config set --local path bundle" - bundle "install", :standalone => true + bundle "install", standalone: true end it "includes the standalone path" do - bundle "binstubs rack", :standalone => true + bundle "binstubs rack", standalone: true standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip expect(standalone_line).to eq %($:.unshift File.expand_path "../bundle", __dir__) end @@ -837,7 +1103,7 @@ RSpec.describe "bundle install with gem sources" do end it "should display a helpful message explaining how to fix it" do - bundle :install, :env => { "BUNDLE_RUBYGEMS__ORG" => "user:pass{word" }, :raise_on_error => false + bundle :install, env: { "BUNDLE_RUBYGEMS__ORG" => "user:pass{word" }, raise_on_error: false expect(exitstatus).to eq(17) expect(err).to eq("Please CGI escape your usernames and passwords before " \ "setting them for authentication.") @@ -878,7 +1144,7 @@ RSpec.describe "bundle install with gem sources" do end it "should fail loudly if the lockfile platforms don't include the current platform" do - simulate_platform(Gem::Platform.new("x86_64-linux")) { bundle "install", :raise_on_error => false } + simulate_platform(Gem::Platform.new("x86_64-linux")) { bundle "install", raise_on_error: false } expect(err).to eq( "Your bundle only supports platforms [\"x86_64-darwin-19\"] but your local platform is x86_64-linux. " \ @@ -890,16 +1156,16 @@ RSpec.describe "bundle install with gem sources" do context "with missing platform specific gems in lockfile" do before do build_repo4 do - build_gem "racc", "1.5.2" + build_gem "racca", "1.5.2" build_gem "nokogiri", "1.12.4" do |s| s.platform = "x86_64-darwin" - s.add_runtime_dependency "racc", "~> 1.4" + s.add_runtime_dependency "racca", "~> 1.4" end build_gem "nokogiri", "1.12.4" do |s| s.platform = "x86_64-linux" - s.add_runtime_dependency "racc", "~> 1.4" + s.add_runtime_dependency "racca", "~> 1.4" end build_gem "crass", "1.0.6" @@ -918,6 +1184,13 @@ RSpec.describe "bundle install with gem sources" do gem "loofah", "~> 2.12.0" G + checksums = checksums_section do |c| + c.checksum gem_repo4, "crass", "1.0.6" + c.checksum gem_repo4, "loofah", "2.12.0" + c.checksum gem_repo4, "nokogiri", "1.12.4", "x86_64-darwin" + c.checksum gem_repo4, "racca", "1.5.2" + end + lockfile <<-L GEM remote: https://gem.repo4/ @@ -927,8 +1200,8 @@ RSpec.describe "bundle install with gem sources" do crass (~> 1.0.2) nokogiri (>= 1.5.9) nokogiri (1.12.4-x86_64-darwin) - racc (~> 1.4) - racc (1.5.2) + racca (~> 1.4) + racca (1.5.2) PLATFORMS x86_64-darwin-20 @@ -936,7 +1209,7 @@ RSpec.describe "bundle install with gem sources" do DEPENDENCIES loofah (~> 2.12.0) - + #{checksums} RUBY VERSION #{Bundler::RubyVersion.system} @@ -949,7 +1222,15 @@ RSpec.describe "bundle install with gem sources" do bundle "config set --local path vendor/bundle" simulate_platform "x86_64-linux" do - bundle "install", :artifice => "compact_index" + bundle "install", artifice: "compact_index" + end + + checksums = checksums_section_when_existing do |c| + c.checksum gem_repo4, "crass", "1.0.6" + c.checksum gem_repo4, "loofah", "2.12.0" + c.checksum gem_repo4, "nokogiri", "1.12.4", "x86_64-darwin" + c.checksum gem_repo4, "racca", "1.5.2" + c.checksum gem_repo4, "nokogiri", "1.12.4", "x86_64-linux" end expect(lockfile).to eq <<~L @@ -961,10 +1242,10 @@ RSpec.describe "bundle install with gem sources" do crass (~> 1.0.2) nokogiri (>= 1.5.9) nokogiri (1.12.4-x86_64-darwin) - racc (~> 1.4) + racca (~> 1.4) nokogiri (1.12.4-x86_64-linux) - racc (~> 1.4) - racc (1.5.2) + racca (~> 1.4) + racca (1.5.2) PLATFORMS x86_64-darwin-20 @@ -972,7 +1253,7 @@ RSpec.describe "bundle install with gem sources" do DEPENDENCIES loofah (~> 2.12.0) - + #{checksums} RUBY VERSION #{Bundler::RubyVersion.system} @@ -984,11 +1265,11 @@ RSpec.describe "bundle install with gem sources" do context "with --local flag" do before do - system_gems "rack-1.0.0", :path => default_bundle_path + system_gems "rack-1.0.0", path: default_bundle_path end it "respects installed gems without fetching any remote sources" do - install_gemfile <<-G, :local => true + install_gemfile <<-G, local: true source "#{file_uri_for(gem_repo1)}" source "https://not-existing-source" do @@ -1028,11 +1309,11 @@ RSpec.describe "bundle install with gem sources" do build_gem "bar", "1.0.0" end - system_gems "foo-1.0.0", :path => default_bundle_path, :gem_repo => gem_repo4 + system_gems "foo-1.0.0", path: default_bundle_path, gem_repo: gem_repo4 end it "fetches remote sources only when not available locally" do - install_gemfile <<-G, :"prefer-local" => true, :verbose => true + install_gemfile <<-G, "prefer-local": true, verbose: true source "#{file_uri_for(gem_repo4)}" gem "foo" @@ -1062,7 +1343,7 @@ RSpec.describe "bundle install with gem sources" do File.symlink("../../README.markdown", File.join(man_path, "README.markdown")) build_repo4 do - build_gem "binman", :path => gem_repo4("gems"), :lib_path => binman_path, :no_default => true do |s| + build_gem "binman", path: gem_repo4("gems"), lib_path: binman_path, no_default: true do |s| s.files = ["README.markdown", "man/man0/README.markdown"] end end @@ -1097,10 +1378,92 @@ RSpec.describe "bundle install with gem sources" do gem "autobuild", "1.10.rc2" G - bundle "install --jobs 1", :raise_on_error => false + bundle "install --jobs 1", raise_on_error: false expect(err).not_to include("ERROR REPORT TEMPLATE") expect(err).to include("Could not find compatible versions") end end + + context "when a lockfile has unmet dependencies, and the Gemfile has no resolution" do + before do + build_repo4 do + build_gem "aaa", "0.2.0" do |s| + s.add_dependency "zzz", "< 0.2.0" + end + + build_gem "zzz", "0.2.0" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "aaa" + gem "zzz" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + aaa (0.2.0) + zzz (< 0.2.0) + zzz (0.2.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + aaa! + zzz! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "does not install, but raises a resolution error" do + bundle "install", raise_on_error: false + expect(err).to include("Could not find compatible versions") + end + end + + context "when --jobs option given" do + before do + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"", jobs: 1 + end + + it "does not save the flag to config" do + expect(bundled_app(".bundle/config")).not_to exist + end + end + + context "when bundler installation is corrupt" do + before do + system_gems "bundler-9.99.8" + + replace_version_file("9.99.9", dir: system_gem_path("gems/bundler-9.99.8")) + end + + it "shows a proper error" do + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + + BUNDLED WITH + 9.99.8 + L + + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"", env: { "BUNDLER_VERSION" => "9.99.8" }, raise_on_error: false + + expect(err).not_to include("ERROR REPORT TEMPLATE") + expect(err).to include("The running version of Bundler (9.99.9) does not match the version of the specification installed for it (9.99.8)") + end + end end diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb index 66930ded75..660935f06f 100644 --- a/spec/bundler/commands/list_spec.rb +++ b/spec/bundler/commands/list_spec.rb @@ -3,7 +3,7 @@ RSpec.describe "bundle list" do context "with name-only and paths option" do it "raises an error" do - bundle "list --name-only --paths", :raise_on_error => false + bundle "list --name-only --paths", raise_on_error: false expect(err).to eq "The `--name-only` and `--paths` options cannot be used together" end @@ -11,7 +11,7 @@ RSpec.describe "bundle list" do context "with without-group and only-group option" do it "raises an error" do - bundle "list --without-group dev --only-group test", :raise_on_error => false + bundle "list --without-group dev --only-group test", raise_on_error: false expect(err).to eq "The `--only-group` and `--without-group` options cannot be used together" end @@ -40,7 +40,7 @@ RSpec.describe "bundle list" do context "when group is not found" do it "raises an error" do - bundle "list --without-group random", :raise_on_error => false + bundle "list --without-group random", raise_on_error: false expect(err).to eq "`random` group could not be found." end @@ -79,7 +79,7 @@ RSpec.describe "bundle list" do context "when group is not found" do it "raises an error" do - bundle "list --only-group random", :raise_on_error => false + bundle "list --only-group random", raise_on_error: false expect(err).to eq "`random` group could not be found." end @@ -124,9 +124,9 @@ RSpec.describe "bundle list" do build_gem "bar" end - build_git "git_test", "1.0.0", :path => lib_path("git_test") + build_git "git_test", "1.0.0", path: lib_path("git_test") - build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s| + build_lib("gemspec_test", path: tmp("gemspec_test")) do |s| s.add_dependency "bar", "=1.0.0" end @@ -135,7 +135,7 @@ RSpec.describe "bundle list" do gem "rack" gem "rails" gem "git_test", :git => "#{lib_path("git_test")}" - gemspec :path => "#{tmp.join("gemspec_test")}" + gemspec :path => "#{tmp("gemspec_test")}" G end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 85b3d4a075..b0d6fa9134 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -1,14 +1,6 @@ # frozen_string_literal: true RSpec.describe "bundle lock" do - def strip_lockfile(lockfile) - strip_whitespace(lockfile).sub(/\n\Z/, "") - end - - def read_lockfile(file = "Gemfile.lock") - strip_lockfile bundled_app(file).read - end - let(:repo) { gem_repo1 } before :each do @@ -19,7 +11,19 @@ RSpec.describe "bundle lock" do gem "foo" G - @lockfile = strip_lockfile(<<-L) + checksums = checksums_section_when_existing do |c| + c.checksum repo, "actionmailer", "2.3.2" + c.checksum repo, "actionpack", "2.3.2" + c.checksum repo, "activerecord", "2.3.2" + c.checksum repo, "activeresource", "2.3.2" + c.checksum repo, "activesupport", "2.3.2" + c.checksum repo, "foo", "1.0" + c.checksum repo, "rails", "2.3.2" + c.checksum repo, "rake", rake_version + c.checksum repo, "weakling", "0.0.3" + end + + @lockfile = <<~L GEM remote: #{file_uri_for(repo)}/ specs: @@ -38,8 +42,8 @@ RSpec.describe "bundle lock" do actionpack (= 2.3.2) activerecord (= 2.3.2) activeresource (= 2.3.2) - rake (= 13.0.1) - rake (13.0.1) + rake (= #{rake_version}) + rake (#{rake_version}) weakling (0.0.3) PLATFORMS @@ -49,7 +53,7 @@ RSpec.describe "bundle lock" do foo rails weakling - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -58,15 +62,23 @@ RSpec.describe "bundle lock" do it "prints a lockfile when there is no existing lockfile with --print" do bundle "lock --print" - expect(out).to eq(@lockfile) + expect(out).to eq(@lockfile.chomp) end it "prints a lockfile when there is an existing lockfile with --print" do + lockfile remove_checksums_section_from_lockfile(@lockfile) + + bundle "lock --print" + + expect(out).to eq(remove_checksums_section_from_lockfile(@lockfile).chomp) + end + + it "prints a lockfile when there is an existing checksums lockfile with --print" do lockfile @lockfile bundle "lock --print" - expect(out).to eq(@lockfile) + expect(out).to eq(@lockfile.chomp) end it "writes a lockfile when there is no existing lockfile" do @@ -75,7 +87,39 @@ RSpec.describe "bundle lock" do expect(read_lockfile).to eq(@lockfile) end + it "prints a lockfile without fetching new checksums if the existing lockfile had no checksums" do + lockfile remove_checksums_from_lockfile(@lockfile) + + bundle "lock --print" + + expect(out).to eq(remove_checksums_from_lockfile(@lockfile).chomp) + end + + it "touches the lockfile when there is an existing lockfile that does not need changes" do + lockfile @lockfile + + expect do + bundle "lock" + end.to change { bundled_app_lock.mtime } + end + + it "does not touch lockfile with --print" do + lockfile @lockfile + + expect do + bundle "lock --print" + end.not_to change { bundled_app_lock.mtime } + end + it "writes a lockfile when there is an outdated lockfile using --update" do + lockfile remove_checksums_from_lockfile(@lockfile.gsub("2.3.2", "2.3.1"), " (2.3.1)") + + bundle "lock --update" + + expect(read_lockfile).to eq(remove_checksums_from_lockfile(@lockfile)) + end + + it "writes a lockfile with checksums on --update when checksums exist" do lockfile @lockfile.gsub("2.3.2", "2.3.1") bundle "lock --update" @@ -83,18 +127,39 @@ RSpec.describe "bundle lock" do expect(read_lockfile).to eq(@lockfile) end + it "writes a lockfile when there is an outdated lockfile and bundle is frozen" do + lockfile @lockfile.gsub("2.3.2", "2.3.1") + + bundle "lock --update", env: { "BUNDLE_FROZEN" => "true" } + + expect(read_lockfile).to eq(@lockfile) + end + it "does not fetch remote specs when using the --local option" do - bundle "lock --update --local", :raise_on_error => false + bundle "lock --update --local", raise_on_error: false expect(err).to match(/locally installed gems/) end + it "does not fetch remote checksums with --local" do + lockfile remove_checksums_from_lockfile(@lockfile) + + bundle "lock --print --local" + + # No checksums because --local prevents fetching them + expect(out).to eq(remove_checksums_from_lockfile(@lockfile).chomp) + end + it "works with --gemfile flag" do create_file "CustomGemfile", <<-G source "#{file_uri_for(repo)}" gem "foo" G - lockfile = strip_lockfile(<<-L) + checksums = checksums_section_when_existing do |c| + c.no_checksum "foo", "1.0" + end + + lockfile = <<~L GEM remote: #{file_uri_for(repo)}/ specs: @@ -105,7 +170,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES foo - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -120,7 +185,7 @@ RSpec.describe "bundle lock" do bundle "lock --lockfile=lock" expect(out).to match(/Writing lockfile to.+lock/) - expect(read_lockfile("lock")).to eq(@lockfile) + expect(read_lockfile("lock")).to eq(remove_checksums_from_lockfile(@lockfile)) expect { read_lockfile }.to raise_error(Errno::ENOENT) end @@ -128,16 +193,195 @@ RSpec.describe "bundle lock" do bundle "install" bundle "lock --lockfile=lock" + checksums = checksums_section_when_existing do |c| + c.checksum repo, "actionmailer", "2.3.2" + c.checksum repo, "actionpack", "2.3.2" + c.checksum repo, "activerecord", "2.3.2" + c.checksum repo, "activeresource", "2.3.2" + c.checksum repo, "activesupport", "2.3.2" + c.checksum repo, "foo", "1.0" + c.checksum repo, "rails", "2.3.2" + c.checksum repo, "rake", rake_version + c.checksum repo, "weakling", "0.0.3" + end + + lockfile = <<~L + GEM + remote: #{file_uri_for(repo)}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + foo (1.0) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= #{rake_version}) + rake (#{rake_version}) + weakling (0.0.3) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo + rails + weakling + #{checksums} + BUNDLED WITH + #{Bundler::VERSION} + L + expect(out).to match(/Writing lockfile to.+lock/) - expect(read_lockfile("lock")).to eq(@lockfile) + expect(read_lockfile("lock")).to eq(lockfile) end it "update specific gems using --update" do - lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("13.0.1", "10.0.1") + lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub(rake_version, "10.0.1") bundle "lock --update rails rake" - expect(read_lockfile).to eq(@lockfile) + expect(read_lockfile).to eq(remove_checksums_from_lockfile(@lockfile, "(2.3.2)", "(#{rake_version})")) + end + + it "updates specific gems using --update, even if that requires unlocking other top level gems" do + build_repo4 do + build_gem "prism", "0.15.1" + build_gem "prism", "0.24.0" + + build_gem "ruby-lsp", "0.12.0" do |s| + s.add_dependency "prism", "< 0.24.0" + end + + build_gem "ruby-lsp", "0.16.1" do |s| + s.add_dependency "prism", ">= 0.24.0" + end + + build_gem "tapioca", "0.11.10" do |s| + s.add_dependency "prism", "< 0.24.0" + end + + build_gem "tapioca", "0.13.1" do |s| + s.add_dependency "prism", ">= 0.24.0" + end + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "tapioca" + gem "ruby-lsp" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)} + specs: + prism (0.15.1) + ruby-lsp (0.12.0) + prism (< 0.24.0) + tapioca (0.11.10) + prism (< 0.24.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + ruby-lsp + tapioca + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "lock --update tapioca --verbose" + + expect(lockfile).to include("tapioca (0.13.1)") + end + + it "updates specific gems using --update, even if that requires unlocking other top level gems, but only as few as possible" do + build_repo4 do + build_gem "prism", "0.15.1" + build_gem "prism", "0.24.0" + + build_gem "ruby-lsp", "0.12.0" do |s| + s.add_dependency "prism", "< 0.24.0" + end + + build_gem "ruby-lsp", "0.16.1" do |s| + s.add_dependency "prism", ">= 0.24.0" + end + + build_gem "tapioca", "0.11.10" do |s| + s.add_dependency "prism", "< 0.24.0" + end + + build_gem "tapioca", "0.13.1" do |s| + s.add_dependency "prism", ">= 0.24.0" + end + + build_gem "other-prism-dependent", "1.0.0" do |s| + s.add_dependency "prism", ">= 0.15.1" + end + + build_gem "other-prism-dependent", "1.1.0" do |s| + s.add_dependency "prism", ">= 0.15.1" + end + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "tapioca" + gem "ruby-lsp" + gem "other-prism-dependent" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)} + specs: + other-prism-dependent (1.0.0) + prism (>= 0.15.1) + prism (0.15.1) + ruby-lsp (0.12.0) + prism (< 0.24.0) + tapioca (0.11.10) + prism (< 0.24.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + ruby-lsp + tapioca + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "lock --update tapioca" + + expect(lockfile).to include("tapioca (0.13.1)") + expect(lockfile).to include("other-prism-dependent (1.0.0)") + end + + it "preserves unknown checksum algorithms" do + lockfile @lockfile.gsub(/(sha256=[a-f0-9]+)$/, "constant=true,\\1,xyz=123") + + previous_lockfile = read_lockfile + + bundle "lock" + + expect(read_lockfile).to eq(previous_lockfile) end it "does not unlock git sources when only uri shape changes" do @@ -149,7 +393,7 @@ RSpec.describe "bundle lock" do G # Change uri format to end with "/" and reinstall - install_gemfile <<-G, :verbose => true + install_gemfile <<-G, verbose: true source "#{file_uri_for(gem_repo1)}" gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}/" G @@ -193,13 +437,13 @@ RSpec.describe "bundle lock" do bundle "lock --update rake --verbose" expect(out).to match(/Writing lockfile to.+lock/) - expect(lockfile).to include("rake (13.0.1)") + expect(lockfile).to include("rake (#{rake_version})") end it "errors when updating a missing specific gems using --update" do lockfile @lockfile - bundle "lock --update blahblah", :raise_on_error => false + bundle "lock --update blahblah", raise_on_error: false expect(err).to eq("Could not find gem 'blahblah'.") expect(read_lockfile).to eq(@lockfile) @@ -214,7 +458,7 @@ RSpec.describe "bundle lock" do G bundle "config set without test" bundle "config set path vendor/bundle" - bundle "lock" + bundle "lock", verbose: true expect(bundled_app("vendor/bundle")).not_to exist end @@ -270,6 +514,22 @@ RSpec.describe "bundle lock" do expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[foo-1.5.0 bar-2.1.1 qux-1.1.0].sort) end + it "shows proper error when Gemfile changes forbid patch upgrades, and --patch --strict is given" do + # force next minor via Gemfile + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'foo', '1.5.0' + gem 'qux' + G + + bundle "lock --update foo --patch --strict", raise_on_error: false + + expect(err).to include( + "foo is locked to 1.4.3, while Gemfile is requesting foo (= 1.5.0). " \ + "--strict --patch was specified, but there are no patch level upgrades from 1.4.3 satisfying foo (= 1.5.0), so version solving has failed" + ) + end + context "pre" do it "defaults to major" do bundle "lock --update --pre" @@ -297,24 +557,68 @@ RSpec.describe "bundle lock" do end end - it "updates the bundler version in the lockfile without re-resolving", :rubygems => ">= 3.3.0.dev" do + context "conservative updates when minor update adds a new dependency" do + before do + build_repo4 do + build_gem "sequel", "5.71.0" + build_gem "sequel", "5.72.0" do |s| + s.add_dependency "bigdecimal", ">= 0" + end + build_gem "bigdecimal", %w[1.4.4 99.1.4] + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + gem 'sequel' + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + sequel (5.71.0) + + PLATFORMS + ruby + + DEPENDENCIES + sequel + + BUNDLED WITH + #{Bundler::VERSION} + L + + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) + end + + it "adds the latest version of the new dependency" do + bundle "lock --minor --update sequel" + + expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[sequel-5.72.0 bigdecimal-99.1.4].sort) + end + end + + it "updates the bundler version in the lockfile to the latest bundler version" do build_repo4 do - build_gem "rack", "1.0" + build_gem "bundler", "55" end - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "rack" + system_gems "bundler-55", gem_repo: gem_repo4 + + install_gemfile <<-G, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + source "https://gems.repo4" G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') - FileUtils.rm_r gem_repo4 + bundle "lock --update --bundler --verbose", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + expect(lockfile).to end_with("BUNDLED WITH\n 55\n") - bundle "lock --update --bundler" - expect(the_bundle).to include_gem "rack 1.0" + update_repo4 do + build_gem "bundler", "99" + end - allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION) + bundle "lock --update --bundler --verbose", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + expect(lockfile).to end_with("BUNDLED WITH\n 99\n") end it "supports adding new platforms" do @@ -322,7 +626,7 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array([java, x86_mingw32, local_platform].uniq) + expect(lockfile.platforms).to match_array(default_platform_list(java, x86_mingw32)) end it "supports adding new platforms with force_ruby_platform = true" do @@ -354,7 +658,7 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(["ruby", local_platform].uniq) + expect(lockfile.platforms).to match_array(default_platform_list("ruby")) end it "warns when adding an unknown platform" do @@ -367,12 +671,12 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array([java, x86_mingw32, local_platform].uniq) + expect(lockfile.platforms).to match_array(default_platform_list(java, x86_mingw32)) bundle "lock --remove-platform java" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array([x86_mingw32, local_platform].uniq) + expect(lockfile.platforms).to match_array(default_platform_list(x86_mingw32)) end it "also cleans up redundant platform gems when removing platforms" do @@ -383,6 +687,11 @@ RSpec.describe "bundle lock" do end end + checksums = checksums_section_when_existing do |c| + c.checksum gem_repo4, "nokogiri", "1.12.0" + c.checksum gem_repo4, "nokogiri", "1.12.0", "x86_64-darwin" + end + simulate_platform "x86_64-darwin-22" do install_gemfile <<~G source "#{file_uri_for(gem_repo4)}" @@ -404,11 +713,13 @@ RSpec.describe "bundle lock" do DEPENDENCIES nokogiri - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L + checksums.delete("nokogiri", Gem::Platform::RUBY) + simulate_platform "x86_64-darwin-22" do bundle "lock --remove-platform ruby" end @@ -424,14 +735,14 @@ RSpec.describe "bundle lock" do DEPENDENCIES nokogiri - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L end it "errors when removing all platforms" do - bundle "lock --remove-platform #{local_platform}", :raise_on_error => false + bundle "lock --remove-platform #{local_platform}", raise_on_error: false expect(err).to include("Removing all platforms from the bundle is not allowed") end @@ -472,6 +783,13 @@ RSpec.describe "bundle lock" do gem "gssapi" G + checksums = checksums_section_when_existing do |c| + c.no_checksum "ffi", "1.9.14", "x86-mingw32" + c.no_checksum "gssapi", "1.2.0" + c.no_checksum "mixlib-shellout", "2.2.6", "universal-mingw32" + c.no_checksum "win32-process", "0.8.3" + end + simulate_platform(x86_mingw32) { bundle :lock } expect(lockfile).to eq <<~G @@ -492,7 +810,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES gssapi mixlib-shellout - + #{checksums} BUNDLED WITH #{Bundler::VERSION} G @@ -500,6 +818,9 @@ RSpec.describe "bundle lock" do bundle "config set --local force_ruby_platform true" bundle :lock + checksums.no_checksum "ffi", "1.9.14" + checksums.no_checksum "mixlib-shellout", "2.2.6" + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo4)}/ @@ -521,7 +842,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES gssapi mixlib-shellout - + #{checksums} BUNDLED WITH #{Bundler::VERSION} G @@ -585,7 +906,12 @@ RSpec.describe "bundle lock" do gem "libv8" G - simulate_platform(Gem::Platform.new("x86_64-darwin")) { bundle "lock" } + simulate_platform(Gem::Platform.new("x86_64-darwin-19")) { bundle "lock" } + + checksums = checksums_section_when_existing do |c| + c.no_checksum "libv8", "8.4.255.0", "x86_64-darwin-19" + c.no_checksum "libv8", "8.4.255.0", "x86_64-darwin-20" + end expect(lockfile).to eq <<~G GEM @@ -595,11 +921,12 @@ RSpec.describe "bundle lock" do libv8 (8.4.255.0-x86_64-darwin-20) PLATFORMS - x86_64-darwin + x86_64-darwin-19 + x86_64-darwin-20 DEPENDENCIES libv8 - + #{checksums} BUNDLED WITH #{Bundler::VERSION} G @@ -616,6 +943,11 @@ RSpec.describe "bundle lock" do end end + checksums = checksums_section_when_existing do |c| + c.checksum gem_repo4, "libv8", "8.4.255.0", "x86_64-darwin-19" + c.checksum gem_repo4, "libv8", "8.4.255.0", "x86_64-darwin-20" + end + gemfile <<-G source "#{file_uri_for(gem_repo4)}" @@ -634,7 +966,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES libv8 - + #{checksums} BUNDLED WITH #{Bundler::VERSION} G @@ -697,7 +1029,7 @@ RSpec.describe "bundle lock" do #{Bundler::VERSION} L - bundle "lock --add-platform x86_64-linux", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + bundle "lock --add-platform x86_64-linux", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } end it "does not crash on conflicting ruby requirements between platform versions in two different gems" do @@ -753,7 +1085,7 @@ RSpec.describe "bundle lock" do #{Bundler::VERSION} L - bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "DEBUG_RESOLVER" => "1" } + bundle "install --verbose", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "DEBUG_RESOLVER" => "1" } end it "respects lower bound ruby requirements" do @@ -785,30 +1117,126 @@ RSpec.describe "bundle lock" do #{Bundler::VERSION} L - bundle "install", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + bundle "install", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } end context "when an update is available" do - let(:repo) { gem_repo2 } - - before do - lockfile(@lockfile) + let(:repo) do build_repo2 do build_gem "foo", "2.0" end + gem_repo2 + end + + before do + lockfile(@lockfile) end it "does not implicitly update" do bundle "lock" - expect(read_lockfile).to eq(@lockfile) + checksums = checksums_section_when_existing do |c| + c.checksum repo, "actionmailer", "2.3.2" + c.checksum repo, "actionpack", "2.3.2" + c.checksum repo, "activerecord", "2.3.2" + c.checksum repo, "activeresource", "2.3.2" + c.checksum repo, "activesupport", "2.3.2" + c.checksum repo, "foo", "1.0" + c.checksum repo, "rails", "2.3.2" + c.checksum repo, "rake", rake_version + c.checksum repo, "weakling", "0.0.3" + end + + expected_lockfile = <<~L + GEM + remote: #{file_uri_for(repo)}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + foo (1.0) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= #{rake_version}) + rake (#{rake_version}) + weakling (0.0.3) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo + rails + weakling + #{checksums} + BUNDLED WITH + #{Bundler::VERSION} + L + + expect(read_lockfile).to eq(expected_lockfile) end it "accounts for changes in the gemfile" do gemfile gemfile.gsub('"foo"', '"foo", "2.0"') bundle "lock" - expect(read_lockfile).to eq(@lockfile.sub("foo (1.0)", "foo (2.0)").sub(/foo$/, "foo (= 2.0)")) + checksums = checksums_section_when_existing do |c| + c.checksum repo, "actionmailer", "2.3.2" + c.checksum repo, "actionpack", "2.3.2" + c.checksum repo, "activerecord", "2.3.2" + c.checksum repo, "activeresource", "2.3.2" + c.checksum repo, "activesupport", "2.3.2" + c.no_checksum "foo", "2.0" + c.checksum repo, "rails", "2.3.2" + c.checksum repo, "rake", rake_version + c.checksum repo, "weakling", "0.0.3" + end + + expected_lockfile = <<~L + GEM + remote: #{file_uri_for(repo)}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + foo (2.0) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= #{rake_version}) + rake (#{rake_version}) + weakling (0.0.3) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo (= 2.0) + rails + weakling + #{checksums} + BUNDLED WITH + #{Bundler::VERSION} + L + + expect(read_lockfile).to eq(expected_lockfile) end end @@ -822,8 +1250,8 @@ RSpec.describe "bundle lock" do build_gem "irb", "1.5.0" end - system_gems "irb-1.5.0", :gem_repo => gem_repo4 - system_gems "debug-1.6.3", :gem_repo => gem_repo4 + system_gems "irb-1.5.0", gem_repo: gem_repo4 + system_gems "debug-1.6.3", gem_repo: gem_repo4 # simulate gemspec with wrong empty dependencies debug_gemspec_path = system_gem_path("specifications/debug-1.6.3.gemspec") @@ -852,7 +1280,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES debug - + #{checksums_section} BUNDLED WITH #{Bundler::VERSION} L @@ -861,6 +1289,11 @@ RSpec.describe "bundle lock" do bundle "lock" end + checksums = checksums_section do |c| + c.no_checksum "debug", "1.6.3" + c.no_checksum "irb", "1.5.0" + end + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo4)}/ @@ -875,7 +1308,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES debug - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -908,7 +1341,7 @@ RSpec.describe "bundle lock" do gem "activeadmin", "2.13.1" G - bundle "lock", :raise_on_error => false + bundle "lock", raise_on_error: false expect(err).to eq <<~ERR.strip Could not find compatible versions @@ -973,7 +1406,7 @@ RSpec.describe "bundle lock" do activemodel (>= 6.0.4) PLATFORMS - #{lockfile_platforms} + #{local_platform} DEPENDENCIES activeadmin (= 2.13.1) @@ -983,7 +1416,7 @@ RSpec.describe "bundle lock" do #{Bundler::VERSION} L - bundle "lock", :raise_on_error => false + bundle "lock", raise_on_error: false expect(err).to eq <<~ERR.strip Could not find compatible versions @@ -1009,9 +1442,9 @@ RSpec.describe "bundle lock" do version solving has failed. ERR - lockfile lockfile.gsub(/PLATFORMS\n #{lockfile_platforms}/m, "PLATFORMS\n #{lockfile_platforms("ruby")}") + lockfile lockfile.gsub(/PLATFORMS\n #{local_platform}/m, "PLATFORMS\n #{lockfile_platforms("ruby")}") - bundle "lock", :raise_on_error => false + bundle "lock", raise_on_error: false expect(err).to eq <<~ERR.strip Could not find compatible versions @@ -1104,7 +1537,7 @@ RSpec.describe "bundle lock" do G simulate_platform "universal-java-19" do - bundle "lock", :raise_on_error => false + bundle "lock", raise_on_error: false end expect(err).to include("Could not find compatible versions") @@ -1139,7 +1572,7 @@ RSpec.describe "bundle lock" do context "when resolving platform specific gems as indirect dependencies on truffleruby", :truffleruby_only do before do - build_lib "foo", :path => bundled_app do |s| + build_lib "foo", path: bundled_app do |s| s.add_dependency "nokogiri" end @@ -1157,6 +1590,11 @@ RSpec.describe "bundle lock" do end it "locks ruby specs" do + checksums = checksums_section_when_existing do |c| + c.no_checksum "foo", "1.0" + c.no_checksum "nokogiri", "1.14.2" + end + simulate_platform "x86_64-linux" do bundle "lock" end @@ -1174,11 +1612,11 @@ RSpec.describe "bundle lock" do nokogiri (1.14.2) PLATFORMS - x86_64-linux + #{lockfile_platforms} DEPENDENCIES foo! - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -1239,6 +1677,13 @@ RSpec.describe "bundle lock" do end it "does not downgrade top level dependencies" do + checksums = checksums_section_when_existing do |c| + c.no_checksum "actionpack", "7.0.4.3" + c.no_checksum "activesupport", "7.0.4.3" + c.no_checksum "govuk_app_config", "4.13.0" + c.no_checksum "railties", "7.0.4.3" + end + simulate_platform "arm64-darwin-22" do bundle "lock" end @@ -1261,7 +1706,7 @@ RSpec.describe "bundle lock" do DEPENDENCIES activesupport (= 7.0.4.3) govuk_app_config - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 970e51b8ef..9ff10158a4 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -12,14 +12,14 @@ RSpec.describe "bundle gem" do def bundle_exec_rubocop prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec")) - bundle "config set path #{rubocop_gems}", :dir => bundled_app(gem_name) - bundle "exec rubocop --debug --config .rubocop.yml", :dir => bundled_app(gem_name) + bundle "config set path #{rubocop_gems}", dir: bundled_app(gem_name) + bundle "exec rubocop --debug --config .rubocop.yml", dir: bundled_app(gem_name) end def bundle_exec_standardrb prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec")) - bundle "config set path #{standard_gems}", :dir => bundled_app(gem_name) - bundle "exec standardrb --debug", :dir => bundled_app(gem_name) + bundle "config set path #{standard_gems}", dir: bundled_app(gem_name) + bundle "exec standardrb --debug", dir: bundled_app(gem_name) end let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) } @@ -33,25 +33,28 @@ RSpec.describe "bundle gem" do let(:minitest_test_class_name) { "class TestMygem < Minitest::Test" } before do - sys_exec("git config --global user.name 'Bundler User'") - sys_exec("git config --global user.email user@example.com") - sys_exec("git config --global github.user bundleuser") + git("config --global user.name 'Bundler User'") + git("config --global user.email user@example.com") + git("config --global github.user bundleuser") + + global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false", + "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false" end describe "git repo initialization" do - it "generates a gem skeleton with a .git folder", :readline do + it "generates a gem skeleton with a .git folder" do bundle "gem #{gem_name}" gem_skeleton_assertions expect(bundled_app("#{gem_name}/.git")).to exist end - it "generates a gem skeleton with a .git folder when passing --git", :readline do + it "generates a gem skeleton with a .git folder when passing --git" do bundle "gem #{gem_name} --git" gem_skeleton_assertions expect(bundled_app("#{gem_name}/.git")).to exist end - it "generates a gem skeleton without a .git folder when passing --no-git", :readline do + it "generates a gem skeleton without a .git folder when passing --no-git" do bundle "gem #{gem_name} --no-git" gem_skeleton_assertions expect(bundled_app("#{gem_name}/.git")).not_to exist @@ -62,8 +65,10 @@ RSpec.describe "bundle gem" do Dir.mkdir(bundled_app("path with spaces")) end - it "properly initializes git repo", :readline do - bundle "gem #{gem_name}", :dir => bundled_app("path with spaces") + it "properly initializes git repo" do + skip "path with spaces needs special handling on Windows" if Gem.win_platform? + + bundle "gem #{gem_name}", dir: bundled_app("path with spaces") expect(bundled_app("path with spaces/#{gem_name}/.git")).to exist end end @@ -103,8 +108,8 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/README.md").read).to match(%r{https://github\.com/bundleuser/#{gem_name}/blob/.*/CODE_OF_CONDUCT.md}) end - it "generates the README with a section for the Code of Conduct, respecting the configured git default branch", :git => ">= 2.28.0" do - sys_exec("git config --global init.defaultBranch main") + it "generates the README with a section for the Code of Conduct, respecting the configured git default branch", git: ">= 2.28.0" do + git("config --global init.defaultBranch main") bundle "gem #{gem_name} --coc" expect(bundled_app("#{gem_name}/README.md").read).to include("## Code of Conduct") @@ -131,7 +136,7 @@ RSpec.describe "bundle gem" do before do bundle "gem #{gem_name} --changelog" end - it "generates a gem skeleton with a CHANGELOG", :readline do + it "generates a gem skeleton with a CHANGELOG" do gem_skeleton_assertions expect(bundled_app("#{gem_name}/CHANGELOG.md")).to exist end @@ -141,15 +146,16 @@ RSpec.describe "bundle gem" do before do bundle "gem #{gem_name} --no-changelog" end - it "generates a gem skeleton without a CHANGELOG", :readline do + it "generates a gem skeleton without a CHANGELOG" do gem_skeleton_assertions expect(bundled_app("#{gem_name}/CHANGELOG.md")).to_not exist end end shared_examples_for "--rubocop flag" do - context "is deprecated", :bundler => "< 3" do + context "is deprecated", bundler: "< 3" do before do + global_config "BUNDLE_GEM__LINTER" => nil bundle "gem #{gem_name} --rubocop" end @@ -179,7 +185,7 @@ RSpec.describe "bundle gem" do end shared_examples_for "--no-rubocop flag" do - context "is deprecated", :bundler => "< 3" do + context "is deprecated", bundler: "< 3" do define_negated_matcher :exclude, :include before do @@ -303,49 +309,49 @@ RSpec.describe "bundle gem" do end end - it "has no rubocop offenses when using --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --linter=rubocop" bundle_exec_rubocop expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=c and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=c and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --ext=c --linter=rubocop" bundle_exec_rubocop expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=c, --test=minitest, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=c, --test=minitest, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --ext=c --test=minitest --linter=rubocop" bundle_exec_rubocop expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=c, --test=rspec, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=c, --test=rspec, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --ext=c --test=rspec --linter=rubocop" bundle_exec_rubocop expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=c, --test=test-unit, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=c, --test=test-unit, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --ext=c --test=test-unit --linter=rubocop" bundle_exec_rubocop expect(last_command).to be_success end - it "has no standard offenses when using --linter=standard flag", :readline do + it "has no standard offenses when using --linter=standard flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? bundle "gem #{gem_name} --linter=standard" bundle_exec_standardrb expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=rust and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=rust and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version @@ -354,7 +360,7 @@ RSpec.describe "bundle gem" do expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=rust, --test=minitest, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=rust, --test=minitest, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version @@ -363,7 +369,7 @@ RSpec.describe "bundle gem" do expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=rust, --test=rspec, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=rust, --test=rspec, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version @@ -372,7 +378,7 @@ RSpec.describe "bundle gem" do expect(last_command).to be_success end - it "has no rubocop offenses when using --ext=rust, --test=test-unit, and --linter=rubocop flag", :readline do + it "has no rubocop offenses when using --ext=rust, --test=test-unit, and --linter=rubocop flag" do skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core? skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version @@ -399,7 +405,7 @@ RSpec.describe "bundle gem" do end end - context "README.md", :readline do + context "README.md" do context "git config github.user present" do before do bundle "gem #{gem_name}" @@ -413,7 +419,7 @@ RSpec.describe "bundle gem" do context "git config github.user is absent" do before do - sys_exec("git config --global --unset github.user") + git("config --global --unset github.user") bundle "gem #{gem_name}" end @@ -424,18 +430,18 @@ RSpec.describe "bundle gem" do end end - it "creates a new git repository", :readline do + it "creates a new git repository" do bundle "gem #{gem_name}" expect(bundled_app("#{gem_name}/.git")).to exist end - context "when git is not available", :readline do + context "when git is not available" do # This spec cannot have `git` available in the test env before do load_paths = [lib_dir, spec_dir] load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}" - sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", :env => { "PATH" => "" } + sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", env: { "PATH" => "" } end it "creates the gem without the need for git" do @@ -451,24 +457,24 @@ RSpec.describe "bundle gem" do end end - it "generates a valid gemspec", :readline, :ruby_repo do + it "generates a valid gemspec", :ruby_repo do bundle "gem newgem --bin" prepare_gemspec(bundled_app("newgem", "newgem.gemspec")) - gems = ["rake-13.0.1"] - path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app("newgem")) : system_gem_path - system_gems gems, :path => path - bundle "exec rake build", :dir => bundled_app("newgem") + gems = ["rake-#{rake_version}"] + path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(base: bundled_app("newgem")) : system_gem_path + system_gems gems, path: path + bundle "exec rake build", dir: bundled_app("newgem") expect(last_command.stdboth).not_to include("ERROR") end - context "gem naming with relative paths", :readline do + context "gem naming with relative paths" do it "resolves ." do create_temporary_dir("tmp") - bundle "gem .", :dir => bundled_app("tmp") + bundle "gem .", dir: bundled_app("tmp") expect(bundled_app("tmp/lib/tmp.rb")).to exist end @@ -476,7 +482,7 @@ RSpec.describe "bundle gem" do it "resolves .." do create_temporary_dir("temp/empty_dir") - bundle "gem ..", :dir => bundled_app("temp/empty_dir") + bundle "gem ..", dir: bundled_app("temp/empty_dir") expect(bundled_app("temp/lib/temp.rb")).to exist end @@ -484,7 +490,7 @@ RSpec.describe "bundle gem" do it "resolves relative directory" do create_temporary_dir("tmp/empty/tmp") - bundle "gem ../../empty", :dir => bundled_app("tmp/empty/tmp") + bundle "gem ../../empty", dir: bundled_app("tmp/empty/tmp") expect(bundled_app("tmp/empty/lib/empty.rb")).to exist end @@ -557,8 +563,12 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/bin/setup")).to exist expect(bundled_app("#{gem_name}/bin/console")).to exist - expect(bundled_app("#{gem_name}/bin/setup")).to be_executable - expect(bundled_app("#{gem_name}/bin/console")).to be_executable + + unless Gem.win_platform? + expect(bundled_app("#{gem_name}/bin/setup")).to be_executable + expect(bundled_app("#{gem_name}/bin/console")).to be_executable + end + expect(bundled_app("#{gem_name}/bin/setup").read).to start_with("#!") expect(bundled_app("#{gem_name}/bin/console").read).to start_with("#!") end @@ -591,8 +601,8 @@ RSpec.describe "bundle gem" do context "git config user.{name,email} is not set" do before do - sys_exec("git config --global --unset user.name") - sys_exec("git config --global --unset user.email") + git("config --global --unset user.name") + git("config --global --unset user.email") bundle "gem #{gem_name}" end @@ -638,12 +648,20 @@ RSpec.describe "bundle gem" do expect(bundler_gemspec.files).not_to include("#{gem_name}.gemspec") end + it "does not include the Gemfile file in files" do + bundle "gem #{gem_name}" + + bundler_gemspec = Bundler::GemHelper.new(bundled_app(gem_name), gem_name).gemspec + + expect(bundler_gemspec.files).not_to include("Gemfile") + end + it "runs rake without problems" do bundle "gem #{gem_name}" - system_gems ["rake-13.0.1"] + system_gems ["rake-#{rake_version}"] - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE task :default do puts 'SUCCESS' end @@ -652,7 +670,7 @@ RSpec.describe "bundle gem" do file.puts rakefile end - sys_exec(rake, :dir => bundled_app(gem_name)) + sys_exec(rake, dir: bundled_app(gem_name)) expect(out).to include("SUCCESS") end @@ -789,17 +807,13 @@ RSpec.describe "bundle gem" do end it "creates a default rake task to run the test suite" do - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE # frozen_string_literal: true require "bundler/gem_tasks" - require "rake/testtask" + require "minitest/test_task" - Rake::TestTask.new(:test) do |t| - t.libs << "test" - t.libs << "lib" - t.test_files = FileList["test/**/test_*.rb"] - end + Minitest::TestTask.create task default: :test RAKEFILE @@ -847,7 +861,7 @@ RSpec.describe "bundle gem" do end it "creates a default rake task to run the test suite" do - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE # frozen_string_literal: true require "bundler/gem_tasks" @@ -866,7 +880,7 @@ RSpec.describe "bundle gem" do end end - context "gem.test set to rspec and --test with no arguments", :hint_text do + context "gem.test set to rspec and --test with no arguments" do before do bundle "config set gem.test rspec" bundle "gem #{gem_name} --test" @@ -883,10 +897,12 @@ RSpec.describe "bundle gem" do end end - context "gem.test setting set to false and --test with no arguments", :hint_text do + context "gem.test setting set to false and --test with no arguments", :readline do before do bundle "config set gem.test false" - bundle "gem #{gem_name} --test" + bundle "gem #{gem_name} --test" do |input, _, _| + input.puts + end end it "asks to generate test files" do @@ -900,9 +916,12 @@ RSpec.describe "bundle gem" do it_behaves_like "test framework is absent" end - context "gem.test setting not set and --test with no arguments", :hint_text do + context "gem.test setting not set and --test with no arguments", :readline do before do - bundle "gem #{gem_name} --test" + global_config "BUNDLE_GEM__TEST" => nil + bundle "gem #{gem_name} --test" do |input, _, _| + input.puts + end end it "asks to generate test files" do @@ -928,29 +947,17 @@ RSpec.describe "bundle gem" do end end - context "--ci set to travis" do + context "--ci set to github" do it "generates a GitHub Actions config file" do - bundle "gem #{gem_name} --ci=travis", :raise_on_error => false - expect(err).to include("Support for Travis CI was removed from gem skeleton generator.") + bundle "gem #{gem_name} --ci=github" - expect(bundled_app("#{gem_name}/.travis.yml")).to_not exist + expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to exist end - end - context "--ci set to travis" do - it "generates a GitHub Actions config file" do - bundle "gem #{gem_name} --ci=travis", :raise_on_error => false - expect(err).to include("Support for Travis CI was removed from gem skeleton generator.") - - expect(bundled_app("#{gem_name}/.travis.yml")).to_not exist - end - end - - context "--ci set to github" do - it "generates a GitHub Actions config file" do + it "contained .gitlab-ci.yml into ignore list" do bundle "gem #{gem_name} --ci=github" - expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to exist + expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to include(".git .github appveyor") end end @@ -960,6 +967,12 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to exist end + + it "contained .gitlab-ci.yml into ignore list" do + bundle "gem #{gem_name} --ci=gitlab" + + expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to include(".git .gitlab-ci.yml appveyor") + end end context "--ci set to circle" do @@ -968,6 +981,12 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/.circleci/config.yml")).to exist end + + it "contained .circleci into ignore list" do + bundle "gem #{gem_name} --ci=circle" + + expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to include(".git .circleci appveyor") + end end context "gem.ci setting set to none" do @@ -978,18 +997,6 @@ RSpec.describe "bundle gem" do end end - context "gem.ci setting set to travis" do - it "errors with friendly message" do - bundle "config set gem.ci travis" - bundle "gem #{gem_name}", :raise_on_error => false - - expect(err).to include("Support for Travis CI was removed from gem skeleton generator,") - expect(err).to include("bundle config unset gem.ci") - - expect(bundled_app("#{gem_name}/.travis.yml")).to_not exist - end - end - context "gem.ci setting set to github" do it "generates a GitHub Actions config file" do bundle "config set gem.ci github" @@ -1017,7 +1024,7 @@ RSpec.describe "bundle gem" do end end - context "gem.ci set to github and --ci with no arguments", :hint_text do + context "gem.ci set to github and --ci with no arguments" do before do bundle "config set gem.ci github" bundle "gem #{gem_name} --ci" @@ -1032,10 +1039,12 @@ RSpec.describe "bundle gem" do end end - context "gem.ci setting set to false and --ci with no arguments", :hint_text do + context "gem.ci setting set to false and --ci with no arguments", :readline do before do bundle "config set gem.ci false" - bundle "gem #{gem_name} --ci" + bundle "gem #{gem_name} --ci" do |input, _, _| + input.puts "github" + end end it "asks to setup CI" do @@ -1047,9 +1056,12 @@ RSpec.describe "bundle gem" do end end - context "gem.ci setting not set and --ci with no arguments", :hint_text do + context "gem.ci setting not set and --ci with no arguments", :readline do before do - bundle "gem #{gem_name} --ci" + global_config "BUNDLE_GEM__CI" => nil + bundle "gem #{gem_name} --ci" do |input, _, _| + input.puts "github" + end end it "asks to setup CI" do @@ -1117,8 +1129,9 @@ RSpec.describe "bundle gem" do end end - context "gem.rubocop setting set to true", :bundler => "< 3" do + context "gem.rubocop setting set to true", bundler: "< 3" do before do + global_config "BUNDLE_GEM__LINTER" => nil bundle "config set gem.rubocop true" bundle "gem #{gem_name}" end @@ -1138,7 +1151,7 @@ RSpec.describe "bundle gem" do end end - context "gem.linter set to rubocop and --linter with no arguments", :hint_text do + context "gem.linter set to rubocop and --linter with no arguments" do before do bundle "config set gem.linter rubocop" bundle "gem #{gem_name} --linter" @@ -1153,10 +1166,12 @@ RSpec.describe "bundle gem" do end end - context "gem.linter setting set to false and --linter with no arguments", :hint_text do + context "gem.linter setting set to false and --linter with no arguments", :readline do before do bundle "config set gem.linter false" - bundle "gem #{gem_name} --linter" + bundle "gem #{gem_name} --linter" do |input, _, _| + input.puts "rubocop" + end end it "asks to setup a linter" do @@ -1168,9 +1183,12 @@ RSpec.describe "bundle gem" do end end - context "gem.linter setting not set and --linter with no arguments", :hint_text do + context "gem.linter setting not set and --linter with no arguments", :readline do before do - bundle "gem #{gem_name} --linter" + global_config "BUNDLE_GEM__LINTER" => nil + bundle "gem #{gem_name} --linter" do |input, _, _| + input.puts "rubocop" + end end it "asks to setup a linter" do @@ -1193,7 +1211,7 @@ RSpec.describe "bundle gem" do end end - context "testing --mit and --coc options against bundle config settings", :readline do + context "testing --mit and --coc options against bundle config settings" do let(:gem_name) { "test-gem" } let(:require_path) { "test/gem" } @@ -1296,10 +1314,10 @@ RSpec.describe "bundle gem" do end end - context "testing --github-username option against git and bundle config settings", :readline do + context "testing --github-username option against git and bundle config settings" do context "without git config set" do before do - sys_exec("git config --global --unset github.user") + git("config --global --unset github.user") end context "with github-username option in bundle config settings set to some value" do before do @@ -1333,10 +1351,10 @@ RSpec.describe "bundle gem" do end end - context "testing github_username bundle config against git config settings", :readline do + context "testing github_username bundle config against git config settings" do context "without git config set" do before do - sys_exec("git config --global --unset github.user") + git("config --global --unset github.user") end it_behaves_like "github_username configuration" @@ -1347,7 +1365,7 @@ RSpec.describe "bundle gem" do end end - context "gem naming with underscore", :readline do + context "gem naming with underscore" do let(:gem_name) { "test_gem" } let(:require_path) { "test_gem" } @@ -1369,7 +1387,7 @@ RSpec.describe "bundle gem" do include_examples "generating a gem" context "--ext parameter with no value" do - context "is deprecated", :bundler => "< 3" do + context "is deprecated", bundler: "< 3" do it "prints deprecation when used after gem name" do bundle ["gem", "--ext", gem_name].compact.join(" ") expect(err).to include "[DEPRECATED]" @@ -1411,7 +1429,7 @@ RSpec.describe "bundle gem" do end it "depends on compile task for build" do - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE # frozen_string_literal: true require "bundler/gem_tasks" @@ -1419,7 +1437,9 @@ RSpec.describe "bundle gem" do task build: :compile - Rake::ExtensionTask.new("#{gem_name}") do |ext| + GEMSPEC = Gem::Specification.load("#{gem_name}.gemspec") + + Rake::ExtensionTask.new("#{gem_name}", GEMSPEC) do |ext| ext.lib_dir = "lib/#{gem_name}" end @@ -1469,7 +1489,7 @@ RSpec.describe "bundle gem" do end it "depends on compile task for build" do - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE # frozen_string_literal: true require "bundler/gem_tasks" @@ -1477,7 +1497,9 @@ RSpec.describe "bundle gem" do task build: :compile - RbSys::ExtensionTask.new("#{gem_name}") do |ext| + GEMSPEC = Gem::Specification.load("#{gem_name}.gemspec") + + RbSys::ExtensionTask.new("#{gem_name}", GEMSPEC) do |ext| ext.lib_dir = "lib/#{gem_name}" end @@ -1489,7 +1511,7 @@ RSpec.describe "bundle gem" do end end - context "gem naming with dashed", :readline do + context "gem naming with dashed" do let(:gem_name) { "test-gem" } let(:require_path) { "test/gem" } @@ -1510,29 +1532,29 @@ RSpec.describe "bundle gem" do end describe "uncommon gem names" do - it "can deal with two dashes", :readline do + it "can deal with two dashes" do bundle "gem a--a" expect(bundled_app("a--a/a--a.gemspec")).to exist end it "fails gracefully with a ." do - bundle "gem foo.gemspec", :raise_on_error => false + bundle "gem foo.gemspec", raise_on_error: false expect(err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name") end it "fails gracefully with a ^" do - bundle "gem ^", :raise_on_error => false + bundle "gem ^", raise_on_error: false expect(err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name") end it "fails gracefully with a space" do - bundle "gem 'foo bar'", :raise_on_error => false + bundle "gem 'foo bar'", raise_on_error: false expect(err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name") end it "fails gracefully when multiple names are passed" do - bundle "gem foo bar baz", :raise_on_error => false + bundle "gem foo bar baz", raise_on_error: false expect(err).to eq(<<-E.strip) ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"] Usage: "bundle gem NAME [OPTIONS]" @@ -1540,9 +1562,9 @@ Usage: "bundle gem NAME [OPTIONS]" end end - describe "#ensure_safe_gem_name", :readline do + describe "#ensure_safe_gem_name" do before do - bundle "gem #{subject}", :raise_on_error => false + bundle "gem #{subject}", raise_on_error: false end context "with an existing const name" do @@ -1568,14 +1590,14 @@ Usage: "bundle gem NAME [OPTIONS]" context "on first run", :readline do it "asks about test framework" do - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__COC" => "false" + global_config "BUNDLE_GEM__TEST" => nil bundle "gem foobar" do |input, _, _| input.puts "rspec" end expect(bundled_app("foobar/spec/spec_helper.rb")).to exist - rakefile = strip_whitespace <<-RAKEFILE + rakefile = <<~RAKEFILE # frozen_string_literal: true require "bundler/gem_tasks" @@ -1591,7 +1613,7 @@ Usage: "bundle gem NAME [OPTIONS]" end it "asks about CI service" do - global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false" + global_config "BUNDLE_GEM__CI" => nil bundle "gem foobar" do |input, _, _| input.puts "github" @@ -1601,7 +1623,7 @@ Usage: "bundle gem NAME [OPTIONS]" end it "asks about MIT license" do - global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__LINTER" => "false" + global_config "BUNDLE_GEM__MIT" => nil bundle "config list" @@ -1613,7 +1635,7 @@ Usage: "bundle gem NAME [OPTIONS]" end it "asks about CoC" do - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__LINTER" => "false" + global_config "BUNDLE_GEM__COC" => nil bundle "gem foobar" do |input, _, _| input.puts "yes" @@ -1623,8 +1645,7 @@ Usage: "bundle gem NAME [OPTIONS]" end it "asks about CHANGELOG" do - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__LINTER" => "false", - "BUNDLE_GEM__COC" => "false" + global_config "BUNDLE_GEM__CHANGELOG" => nil bundle "gem foobar" do |input, _, _| input.puts "yes" @@ -1634,16 +1655,16 @@ Usage: "bundle gem NAME [OPTIONS]" end end - context "on conflicts with a previously created file", :readline do + context "on conflicts with a previously created file" do it "should fail gracefully" do FileUtils.touch(bundled_app("conflict-foobar")) - bundle "gem conflict-foobar", :raise_on_error => false + bundle "gem conflict-foobar", raise_on_error: false expect(err).to eq("Couldn't create a new gem named `conflict-foobar` because there's an existing file named `conflict-foobar`.") expect(exitstatus).to eql(32) end end - context "on conflicts with a previously created directory", :readline do + context "on conflicts with a previously created directory" do it "should succeed" do FileUtils.mkdir_p(bundled_app("conflict-foobar/Gemfile")) bundle "gem conflict-foobar" diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb index e30ebfea5b..18f4db38c9 100644 --- a/spec/bundler/commands/open_spec.rb +++ b/spec/bundler/commands/open_spec.rb @@ -10,27 +10,27 @@ RSpec.describe "bundle open" do end it "opens the gem with BUNDLER_EDITOR as highest priority" do - bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } + bundle "open rails", env: { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } expect(out).to include("bundler_editor #{default_bundle_path("gems", "rails-2.3.2")}") end it "opens the gem with VISUAL as 2nd highest priority" do - bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "" } + bundle "open rails", env: { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "" } expect(out).to include("visual #{default_bundle_path("gems", "rails-2.3.2")}") end it "opens the gem with EDITOR as 3rd highest priority" do - bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open rails", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "rails-2.3.2")}") end it "complains if no EDITOR is set" do - bundle "open rails", :env => { "EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open rails", env: { "EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to eq("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") end it "complains if gem not in bundle" do - bundle "open missing", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open missing", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(err).to match(/could not find gem 'missing'/i) end @@ -43,91 +43,91 @@ RSpec.describe "bundle open" do gem 'foo', :git => "#{lib_path("foo-1.0")}" G - bundle "open foo", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } - expect(out).to match("editor #{default_bundle_path.join("bundler/gems/foo-1.0-#{ref}")}") + bundle "open foo", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + expect(out).to include("editor #{default_bundle_path("bundler", "gems", "foo-1.0-#{ref}")}") end it "suggests alternatives for similar-sounding gems" do - bundle "open Rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open Rails", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(err).to match(/did you mean rails\?/i) end it "opens the gem with short words" do - bundle "open rec", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } + bundle "open rec", env: { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}") end it "opens subpath of the gem" do - bundle "open activerecord --path lib/activerecord", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open activerecord --path lib/activerecord", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/lib/activerecord") end it "opens subpath file of the gem" do - bundle "open activerecord --path lib/version.rb", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open activerecord --path lib/version.rb", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/lib/version.rb") end it "opens deep subpath of the gem" do - bundle "open activerecord --path lib/active_record", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open activerecord --path lib/active_record", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/lib/active_record") end it "requires value for --path arg" do - bundle "open activerecord --path", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open activerecord --path", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(err).to eq "Cannot specify `--path` option without a value" end it "suggests alternatives for similar-sounding gems when using subpath" do - bundle "open Rails --path README.md", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open Rails --path README.md", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(err).to match(/did you mean rails\?/i) end it "suggests alternatives for similar-sounding gems when using deep subpath" do - bundle "open Rails --path some/path/here", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open Rails --path some/path/here", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(err).to match(/did you mean rails\?/i) end it "opens subpath of the short worded gem" do - bundle "open rec --path CHANGELOG.md", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open rec --path CHANGELOG.md", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/CHANGELOG.md") end it "opens deep subpath of the short worded gem" do - bundle "open rec --path lib/activerecord", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open rec --path lib/activerecord", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/lib/activerecord") end it "opens subpath of the selected matching gem", :readline do env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - bundle "open active --path CHANGELOG.md", :env => env do |input, _, _| + bundle "open active --path CHANGELOG.md", env: env do |input, _, _| input.puts "2" end - expect(out).to match(%r{bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}/CHANGELOG\.md\z}) + expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2").join("CHANGELOG.md")}") end it "opens deep subpath of the selected matching gem", :readline do env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - bundle "open active --path lib/activerecord/version.rb", :env => env do |input, _, _| + bundle "open active --path lib/activerecord/version.rb", env: env do |input, _, _| input.puts "2" end - expect(out).to match(%r{bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}/lib/activerecord/version\.rb\z}) + expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2").join("lib", "activerecord", "version.rb")}") end it "select the gem from many match gems", :readline do env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - bundle "open active", :env => env do |input, _, _| + bundle "open active", env: env do |input, _, _| input.puts "2" end - expect(out).to match(/bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}\z/) + expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}") end it "allows selecting exit from many match gems", :readline do env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - bundle "open active", :env => env do |input, _, _| + bundle "open active", env: env do |input, _, _| input.puts "0" end end @@ -140,12 +140,12 @@ RSpec.describe "bundle open" do G bundle "config set auto_install 1" - bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + bundle "open rails", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("Installing foo 1.0") end it "opens the editor with a clean env" do - bundle "open", :env => { "EDITOR" => "sh -c 'env'", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false + bundle "open", env: { "EDITOR" => "sh -c 'env'", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, raise_on_error: false expect(out).not_to include("BUNDLE_GEMFILE=") end end @@ -164,12 +164,11 @@ RSpec.describe "bundle open" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" - gem "json" G end it "throws proper error when trying to open default gem" do - bundle "open json", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } + bundle "open json", env: { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } expect(out).to include("Unable to open json because it's a default gem, so the directory it would normally be installed to does not exist.") end end diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index bbc3cb54ae..e7edc67e57 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -4,8 +4,8 @@ RSpec.describe "bundle outdated" do describe "with no arguments" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -23,11 +23,11 @@ RSpec.describe "bundle outdated" do update_repo2 do build_gem "activesupport", "3.0" build_gem "weakling", "0.2" - update_git "foo", :path => lib_path("foo") - update_git "zebra", :path => lib_path("zebra") + update_git "foo", path: lib_path("foo") + update_git "zebra", path: lib_path("zebra") end - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip Gem Current Latest Requested Groups @@ -50,7 +50,7 @@ RSpec.describe "bundle outdated" do gem "AAA", "1.0.0" G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE Gem Current Latest Requested Groups @@ -63,10 +63,10 @@ RSpec.describe "bundle outdated" do it "returns non zero exit status if outdated gems present" do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expect(exitstatus).to_not be_zero end @@ -89,7 +89,7 @@ RSpec.describe "bundle outdated" do update_repo2 { build_gem "activesupport", "3.0" } update_repo2 { build_gem "terranova", "9" } - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -104,8 +104,8 @@ RSpec.describe "bundle outdated" do describe "with --verbose option" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -139,7 +139,7 @@ RSpec.describe "bundle outdated" do gem 'activesupport', '2.3.5' G - bundle "outdated --verbose", :raise_on_error => false + bundle "outdated --verbose", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups Path @@ -151,7 +151,7 @@ RSpec.describe "bundle outdated" do end end - describe "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do + describe "with multiple, duplicated sources, with lockfile in old format", bundler: "< 3" do before do build_repo2 do build_gem "dotenv", "2.7.6" @@ -205,8 +205,8 @@ RSpec.describe "bundle outdated" do end it "works" do - bundle :install, :artifice => "compact_index" - bundle :outdated, :artifice => "compact_index", :raise_on_error => false + bundle :install, artifice: "compact_index" + bundle :outdated, artifice: "compact_index", raise_on_error: false expected_output = <<~TABLE Gem Current Latest Requested Groups @@ -220,8 +220,8 @@ RSpec.describe "bundle outdated" do describe "with --group option" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -243,7 +243,7 @@ RSpec.describe "bundle outdated" do build_gem "duradura", "8.0" end - bundle "outdated --group #{group}", :raise_on_error => false + bundle "outdated --group #{group}", raise_on_error: false end it "works when the bundle is up to date" do @@ -290,8 +290,8 @@ RSpec.describe "bundle outdated" do describe "with --groups option and outdated transitive dependencies" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") build_gem "bar", %w[2.0.0] @@ -312,7 +312,7 @@ RSpec.describe "bundle outdated" do end it "returns a sorted list of outdated gems" do - bundle "outdated --groups", :raise_on_error => false + bundle "outdated --groups", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -326,8 +326,8 @@ RSpec.describe "bundle outdated" do describe "with --groups option" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -354,7 +354,7 @@ RSpec.describe "bundle outdated" do build_gem "duradura", "8.0" end - bundle "outdated --groups", :raise_on_error => false + bundle "outdated --groups", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -370,8 +370,8 @@ RSpec.describe "bundle outdated" do describe "with --local option" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -398,7 +398,7 @@ RSpec.describe "bundle outdated" do gem "activesupport", "2.3.4" G - bundle "outdated --local", :raise_on_error => false + bundle "outdated --local", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -420,8 +420,8 @@ RSpec.describe "bundle outdated" do context "and gems are outdated" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") build_gem "activesupport", "3.0" build_gem "weakling", "0.2" @@ -455,13 +455,13 @@ RSpec.describe "bundle outdated" do end describe "with --parseable option" do - subject { bundle "outdated --parseable", :raise_on_error => false } + subject { bundle "outdated --parseable", raise_on_error: false } it_behaves_like "a minimal output is desired" end describe "with aliased --porcelain option" do - subject { bundle "outdated --porcelain", :raise_on_error => false } + subject { bundle "outdated --porcelain", raise_on_error: false } it_behaves_like "a minimal output is desired" end @@ -469,8 +469,8 @@ RSpec.describe "bundle outdated" do describe "with specified gems" do it "returns list of outdated gems" do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -485,10 +485,10 @@ RSpec.describe "bundle outdated" do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end - bundle "outdated foo", :raise_on_error => false + bundle "outdated foo", raise_on_error: false expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip Gem Current Latest Requested Groups @@ -502,8 +502,8 @@ RSpec.describe "bundle outdated" do describe "pre-release gems" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -535,7 +535,7 @@ RSpec.describe "bundle outdated" do build_gem "activesupport", "3.0.0.beta" end - bundle "outdated --pre", :raise_on_error => false + bundle "outdated --pre", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -558,7 +558,7 @@ RSpec.describe "bundle outdated" do gem "activesupport", "3.0.0.beta.1" G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -573,8 +573,8 @@ RSpec.describe "bundle outdated" do describe "with --filter-strict option" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -594,7 +594,7 @@ RSpec.describe "bundle outdated" do build_gem "weakling", "0.0.5" end - bundle :outdated, :"filter-strict" => true, :raise_on_error => false + bundle :outdated, "filter-strict": true, raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -610,7 +610,7 @@ RSpec.describe "bundle outdated" do build_gem "weakling", "0.0.5" end - bundle :outdated, :strict => true, :raise_on_error => false + bundle :outdated, strict: true, raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -626,7 +626,7 @@ RSpec.describe "bundle outdated" do gem "activesupport", platforms: [:ruby_22] G - bundle :outdated, :"filter-strict" => true + bundle :outdated, "filter-strict": true expect(out).to end_with("Bundle up to date!") end @@ -637,7 +637,7 @@ RSpec.describe "bundle outdated" do gem "rack_middleware", "1.0" G - bundle :outdated, :"filter-strict" => true + bundle :outdated, "filter-strict": true expect(out).to end_with("Bundle up to date!") end @@ -714,8 +714,8 @@ RSpec.describe "bundle outdated" do describe "with invalid gem name" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -730,12 +730,12 @@ RSpec.describe "bundle outdated" do end it "returns could not find gem name" do - bundle "outdated invalid_gem_name", :raise_on_error => false + bundle "outdated invalid_gem_name", raise_on_error: false expect(err).to include("Could not find gem 'invalid_gem_name'.") end it "returns non-zero exit code" do - bundle "outdated invalid_gem_name", :raise_on_error => false + bundle "outdated invalid_gem_name", raise_on_error: false expect(exitstatus).to_not be_zero end end @@ -748,11 +748,11 @@ RSpec.describe "bundle outdated" do G bundle "config set auto_install 1" - bundle :outdated, :raise_on_error => false + bundle :outdated, raise_on_error: false expect(out).to include("Installing foo 1.0") end - context "after bundle install --deployment", :bundler => "< 3" do + context "after bundle install --deployment", bundler: "< 3" do before do build_repo2 @@ -763,13 +763,13 @@ RSpec.describe "bundle outdated" do gem "foo" G bundle :lock - bundle :install, :deployment => true + bundle :install, deployment: true end it "outputs a helpful message about being in deployment mode" do update_repo2 { build_gem "activesupport", "3.0" } - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expect(last_command).to be_failure expect(err).to include("You are trying to check outdated gems in deployment mode.") expect(err).to include("Run `bundle outdated` elsewhere.") @@ -781,8 +781,8 @@ RSpec.describe "bundle outdated" do context "after bundle config set --local deployment true" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -797,7 +797,7 @@ RSpec.describe "bundle outdated" do it "outputs a helpful message about being in deployment mode" do update_repo2 { build_gem "activesupport", "3.0" } - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expect(last_command).to be_failure expect(err).to include("You are trying to check outdated gems in deployment mode.") expect(err).to include("Run `bundle outdated` elsewhere.") @@ -843,7 +843,7 @@ RSpec.describe "bundle outdated" do gem "laduradura", '= 5.15.2', :platforms => [:ruby, :jruby] G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -867,8 +867,8 @@ RSpec.describe "bundle outdated" do shared_examples_for "major version updates are detected" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -893,8 +893,8 @@ RSpec.describe "bundle outdated" do context "when on a new machine" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -909,22 +909,22 @@ RSpec.describe "bundle outdated" do simulate_new_machine - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") update_repo2 do build_gem "activesupport", "3.3.5" build_gem "weakling", "0.8.0" end end - subject { bundle "outdated", :raise_on_error => false } + subject { bundle "outdated", raise_on_error: false } it_behaves_like "version update is detected" end shared_examples_for "minor version updates are detected" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -949,8 +949,8 @@ RSpec.describe "bundle outdated" do shared_examples_for "patch version updates are detected" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -982,8 +982,8 @@ RSpec.describe "bundle outdated" do shared_examples_for "major version is ignored" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -1008,8 +1008,8 @@ RSpec.describe "bundle outdated" do shared_examples_for "minor version is ignored" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -1034,8 +1034,8 @@ RSpec.describe "bundle outdated" do shared_examples_for "patch version is ignored" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") + build_git "foo", path: lib_path("foo") + build_git "zebra", path: lib_path("zebra") end install_gemfile <<-G @@ -1058,7 +1058,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-major option" do - subject { bundle "outdated --filter-major", :raise_on_error => false } + subject { bundle "outdated --filter-major", raise_on_error: false } it_behaves_like "major version updates are detected" it_behaves_like "minor version is ignored" @@ -1066,7 +1066,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-minor option" do - subject { bundle "outdated --filter-minor", :raise_on_error => false } + subject { bundle "outdated --filter-minor", raise_on_error: false } it_behaves_like "minor version updates are detected" it_behaves_like "major version is ignored" @@ -1074,7 +1074,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-patch option" do - subject { bundle "outdated --filter-patch", :raise_on_error => false } + subject { bundle "outdated --filter-patch", raise_on_error: false } it_behaves_like "patch version updates are detected" it_behaves_like "major version is ignored" @@ -1082,7 +1082,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-minor --filter-patch options" do - subject { bundle "outdated --filter-minor --filter-patch", :raise_on_error => false } + subject { bundle "outdated --filter-minor --filter-patch", raise_on_error: false } it_behaves_like "minor version updates are detected" it_behaves_like "patch version updates are detected" @@ -1090,7 +1090,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-major --filter-minor options" do - subject { bundle "outdated --filter-major --filter-minor", :raise_on_error => false } + subject { bundle "outdated --filter-major --filter-minor", raise_on_error: false } it_behaves_like "major version updates are detected" it_behaves_like "minor version updates are detected" @@ -1098,7 +1098,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-major --filter-patch options" do - subject { bundle "outdated --filter-major --filter-patch", :raise_on_error => false } + subject { bundle "outdated --filter-major --filter-patch", raise_on_error: false } it_behaves_like "major version updates are detected" it_behaves_like "patch version updates are detected" @@ -1106,7 +1106,7 @@ RSpec.describe "bundle outdated" do end describe "with --filter-major --filter-minor --filter-patch options" do - subject { bundle "outdated --filter-major --filter-minor --filter-patch", :raise_on_error => false } + subject { bundle "outdated --filter-major --filter-minor --filter-patch", raise_on_error: false } it_behaves_like "major version updates are detected" it_behaves_like "minor version updates are detected" @@ -1145,7 +1145,7 @@ RSpec.describe "bundle outdated" do end it "shows all gems when patching and filtering to patch" do - bundle "outdated --patch --filter-patch", :raise_on_error => false + bundle "outdated --patch --filter-patch", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -1158,7 +1158,7 @@ RSpec.describe "bundle outdated" do end it "shows minor and major when updating to minor and filtering to patch and minor" do - bundle "outdated --minor --filter-minor", :raise_on_error => false + bundle "outdated --minor --filter-minor", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -1170,7 +1170,7 @@ RSpec.describe "bundle outdated" do end it "shows minor when updating to major and filtering to minor with parseable" do - bundle "outdated --major --filter-minor --parseable", :raise_on_error => false + bundle "outdated --major --filter-minor --parseable", raise_on_error: false expect(out).not_to include("patch (newest") expect(out).to include("minor (newest") @@ -1212,7 +1212,7 @@ RSpec.describe "bundle outdated" do end it "shows gems updating to patch and filtering to patch" do - bundle "outdated --patch --filter-patch", :raise_on_error => false, :env => { "DEBUG_RESOLVER" => "1" } + bundle "outdated --patch --filter-patch", raise_on_error: false, env: { "DEBUG_RESOLVER" => "1" } expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -1224,7 +1224,7 @@ RSpec.describe "bundle outdated" do end it "shows gems updating to patch and filtering to patch, in debug mode" do - bundle "outdated --patch --filter-patch", :raise_on_error => false, :env => { "DEBUG" => "1" } + bundle "outdated --patch --filter-patch", raise_on_error: false, env: { "DEBUG" => "1" } expected_output = <<~TABLE.strip Gem Current Latest Requested Groups Path @@ -1256,7 +1256,7 @@ RSpec.describe "bundle outdated" do gem 'weakling' G - bundle "outdated --only-explicit", :raise_on_error => false + bundle "outdated --only-explicit", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -1306,7 +1306,7 @@ RSpec.describe "bundle outdated" do end it "reports a single entry per gem" do - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups @@ -1355,7 +1355,7 @@ RSpec.describe "bundle outdated" do end it "works" do - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.strip Gem Current Latest Requested Groups diff --git a/spec/bundler/commands/platform_spec.rb b/spec/bundler/commands/platform_spec.rb index 688bf7b6df..61e615acae 100644 --- a/spec/bundler/commands/platform_spec.rb +++ b/spec/bundler/commands/platform_spec.rb @@ -164,7 +164,7 @@ G gem "foo" G - bundle "platform", :raise_on_error => false + bundle "platform", raise_on_error: false expect(exitstatus).not_to eq(0) end @@ -177,7 +177,7 @@ G gem "foo" G - bundle "platform", :raise_on_error => false + bundle "platform", raise_on_error: false expect(exitstatus).not_to eq(0) end @@ -190,7 +190,7 @@ G gem "foo" G - bundle "platform", :raise_on_error => false + bundle "platform", raise_on_error: false expect(exitstatus).not_to eq(0) end @@ -347,7 +347,7 @@ G end it "doesn't install when the ruby version doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -359,7 +359,7 @@ G end it "doesn't install when engine doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -371,7 +371,7 @@ G end it "doesn't install when engine version doesn't match", :jruby_only do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -383,7 +383,7 @@ G end it "doesn't install when patchlevel doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -443,7 +443,7 @@ G #{ruby_version_incorrect} G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false should_be_ruby_version_incorrect end @@ -460,7 +460,7 @@ G #{engine_incorrect} G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false should_be_engine_incorrect end @@ -477,7 +477,7 @@ G #{engine_version_incorrect} G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false should_be_engine_version_incorrect end @@ -494,7 +494,7 @@ G #{patchlevel_incorrect} G - bundle :check, :raise_on_error => false + bundle :check, raise_on_error: false should_be_patchlevel_incorrect end end @@ -526,7 +526,7 @@ G build_gem "activesupport", "3.0" end - bundle "update", :all => true + bundle "update", all: true expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end @@ -546,7 +546,7 @@ G build_gem "activesupport", "3.0" end - bundle "update", :all => true + bundle "update", all: true expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end @@ -562,7 +562,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => true, :raise_on_error => false + bundle :update, all: true, raise_on_error: false should_be_ruby_version_incorrect end @@ -578,7 +578,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => true, :raise_on_error => false + bundle :update, all: true, raise_on_error: false should_be_engine_incorrect end @@ -594,7 +594,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => true, :raise_on_error => false + bundle :update, all: true, raise_on_error: false should_be_engine_version_incorrect end @@ -609,7 +609,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => true, :raise_on_error => false + bundle :update, all: true, raise_on_error: false should_be_patchlevel_incorrect end end @@ -646,7 +646,7 @@ G expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "fails if ruby version doesn't match", :bundler => "< 3" do + it "fails if ruby version doesn't match", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -654,11 +654,11 @@ G #{ruby_version_incorrect} G - bundle "show rails", :raise_on_error => false + bundle "show rails", raise_on_error: false should_be_ruby_version_incorrect end - it "fails if engine doesn't match", :bundler => "< 3" do + it "fails if engine doesn't match", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -666,11 +666,11 @@ G #{engine_incorrect} G - bundle "show rails", :raise_on_error => false + bundle "show rails", raise_on_error: false should_be_engine_incorrect end - it "fails if engine version doesn't match", :bundler => "< 3", :jruby_only => true do + it "fails if engine version doesn't match", bundler: "< 3", jruby_only: true do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -678,11 +678,11 @@ G #{engine_version_incorrect} G - bundle "show rails", :raise_on_error => false + bundle "show rails", raise_on_error: false should_be_engine_version_incorrect end - it "fails when patchlevel doesn't match", :bundler => "< 3" do + it "fails when patchlevel doesn't match", bundler: "< 3" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -693,7 +693,7 @@ G build_gem "activesupport", "3.0" end - bundle "show rails", :raise_on_error => false + bundle "show rails", raise_on_error: false should_be_patchlevel_incorrect end end @@ -738,7 +738,7 @@ G #{ruby_version_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_ruby_version_incorrect end @@ -750,7 +750,7 @@ G #{engine_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_engine_incorrect end @@ -762,7 +762,7 @@ G #{engine_version_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_engine_version_incorrect end @@ -774,7 +774,7 @@ G #{patchlevel_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_patchlevel_incorrect end end @@ -819,7 +819,7 @@ G #{ruby_version_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_ruby_version_incorrect end @@ -831,7 +831,7 @@ G #{engine_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_engine_incorrect end @@ -843,7 +843,7 @@ G #{engine_version_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_engine_version_incorrect end @@ -855,7 +855,7 @@ G #{patchlevel_incorrect} G - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false should_be_patchlevel_incorrect end end @@ -863,7 +863,7 @@ G context "bundle exec" do before do ENV["BUNDLER_FORCE_TTY"] = "true" - system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path + system_gems "rack-1.0.0", "rack-0.9.1", path: default_bundle_path end it "activates the correct gem when ruby version matches" do @@ -879,7 +879,7 @@ G end it "activates the correct gem when ruby version matches any engine", :jruby_only do - system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path + system_gems "rack-1.0.0", "rack-0.9.1", path: default_bundle_path gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" @@ -899,7 +899,7 @@ G #{ruby_version_incorrect} G - bundle "exec rackup", :raise_on_error => false + bundle "exec rackup", raise_on_error: false should_be_ruby_version_incorrect end @@ -911,7 +911,7 @@ G #{engine_incorrect} G - bundle "exec rackup", :raise_on_error => false + bundle "exec rackup", raise_on_error: false should_be_engine_incorrect end @@ -934,12 +934,12 @@ G #{patchlevel_incorrect} G - bundle "exec rackup", :raise_on_error => false + bundle "exec rackup", raise_on_error: false should_be_patchlevel_incorrect end end - context "bundle console", :bundler => "< 3" do + context "bundle console", bundler: "< 3" do before do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -993,7 +993,7 @@ G #{ruby_version_incorrect} G - bundle "console", :raise_on_error => false + bundle "console", raise_on_error: false should_be_ruby_version_incorrect end @@ -1007,7 +1007,7 @@ G #{engine_incorrect} G - bundle "console", :raise_on_error => false + bundle "console", raise_on_error: false should_be_engine_incorrect end @@ -1021,7 +1021,7 @@ G #{engine_version_incorrect} G - bundle "console", :raise_on_error => false + bundle "console", raise_on_error: false should_be_engine_version_incorrect end @@ -1035,7 +1035,7 @@ G #{patchlevel_incorrect} G - bundle "console", :raise_on_error => false + bundle "console", raise_on_error: false should_be_patchlevel_incorrect end end @@ -1082,7 +1082,7 @@ G end it "fails when ruby version doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "yard" gem "rack" @@ -1092,14 +1092,14 @@ G FileUtils.rm(bundled_app_lock) - ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }, :raise_on_error => false + ruby "require 'bundler/setup'", env: { "BUNDLER_VERSION" => Bundler::VERSION }, raise_on_error: false expect(bundled_app_lock).not_to exist should_be_ruby_version_incorrect end it "fails when engine doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "yard" gem "rack" @@ -1109,14 +1109,14 @@ G FileUtils.rm(bundled_app_lock) - ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }, :raise_on_error => false + ruby "require 'bundler/setup'", env: { "BUNDLER_VERSION" => Bundler::VERSION }, raise_on_error: false expect(bundled_app_lock).not_to exist should_be_engine_incorrect end it "fails when engine version doesn't match", :jruby_only do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "yard" gem "rack" @@ -1126,14 +1126,14 @@ G FileUtils.rm(bundled_app_lock) - ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }, :raise_on_error => false + ruby "require 'bundler/setup'", env: { "BUNDLER_VERSION" => Bundler::VERSION }, raise_on_error: false expect(bundled_app_lock).not_to exist should_be_engine_version_incorrect end it "fails when patchlevel doesn't match" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "yard" gem "rack" @@ -1143,7 +1143,7 @@ G FileUtils.rm(bundled_app_lock) - ruby "require 'bundler/setup'", :env => { "BUNDLER_VERSION" => Bundler::VERSION }, :raise_on_error => false + ruby "require 'bundler/setup'", env: { "BUNDLER_VERSION" => Bundler::VERSION }, raise_on_error: false expect(bundled_app_lock).not_to exist should_be_patchlevel_incorrect @@ -1153,7 +1153,7 @@ G context "bundle outdated" do before do build_repo2 do - build_git "foo", :path => lib_path("foo") + build_git "foo", path: lib_path("foo") end install_gemfile <<-G @@ -1166,7 +1166,7 @@ G it "returns list of outdated gems when the ruby version matches" do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1177,7 +1177,7 @@ G #{ruby_version_correct} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip Gem Current Latest Requested Groups @@ -1192,7 +1192,7 @@ G bundle :install update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1203,7 +1203,7 @@ G #{ruby_version_correct_engineless} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip Gem Current Latest Requested Groups @@ -1217,7 +1217,7 @@ G it "fails when the ruby version doesn't match" do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1228,14 +1228,14 @@ G #{ruby_version_incorrect} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false should_be_ruby_version_incorrect end it "fails when the engine doesn't match" do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1246,14 +1246,14 @@ G #{engine_incorrect} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false should_be_engine_incorrect end it "fails when the engine version doesn't match", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1264,14 +1264,14 @@ G #{engine_version_incorrect} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false should_be_engine_version_incorrect end it "fails when the patchlevel doesn't match", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1282,14 +1282,14 @@ G #{patchlevel_incorrect} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false should_be_patchlevel_incorrect end it "fails when the patchlevel is a fixnum", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") + update_git "foo", path: lib_path("foo") end gemfile <<-G @@ -1300,7 +1300,7 @@ G #{patchlevel_fixnum} G - bundle "outdated", :raise_on_error => false + bundle "outdated", raise_on_error: false should_be_patchlevel_fixnum end end diff --git a/spec/bundler/commands/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb index 3050b87754..3c7fd3486d 100644 --- a/spec/bundler/commands/post_bundle_message_spec.rb +++ b/spec/bundler/commands/post_bundle_message_spec.rb @@ -114,7 +114,7 @@ RSpec.describe "post bundle message" do end it "should report a helpful error message" do - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" gem "not-a-gem", :group => :development @@ -131,7 +131,7 @@ Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)} G bundle :cache expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - install_gemfile <<-G, :raise_on_error => false + install_gemfile <<-G, raise_on_error: false source "#{file_uri_for(gem_repo1)}" gem "rack" gem "not-a-gem", :group => :development @@ -142,7 +142,7 @@ Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)} end end - describe "for second bundle install run", :bundler => "< 3" do + describe "for second bundle install run", bundler: "< 3" do it "without any options" do 2.times { bundle :install } expect(out).to include(bundle_show_message) @@ -179,25 +179,25 @@ Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)} describe "for bundle update" do it "shows proper messages according to the configured groups" do - bundle :update, :all => true + bundle :update, all: true expect(out).not_to include("Gems in the groups") expect(out).to include(bundle_updated_message) bundle "config set --local without emo" bundle :install - bundle :update, :all => true + bundle :update, all: true expect(out).to include("Gems in the group 'emo' were not updated") expect(out).to include(bundle_updated_message) bundle "config set --local without emo test" bundle :install - bundle :update, :all => true + bundle :update, all: true expect(out).to include("Gems in the groups 'emo' and 'test' were not updated") expect(out).to include(bundle_updated_message) bundle "config set --local without emo obama test" bundle :install - bundle :update, :all => true + bundle :update, all: true expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not updated") expect(out).to include(bundle_updated_message) end diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index 9e496dc91a..1aec37f850 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -4,7 +4,7 @@ require "bundler/vendored_fileutils" RSpec.describe "bundle pristine" do before :each do - build_lib "baz", :path => bundled_app do |s| + build_lib "baz", path: bundled_app do |s| s.version = "1.0.0" s.add_development_dependency "baz-dev", "=1.0.0" end @@ -13,9 +13,9 @@ RSpec.describe "bundle pristine" do build_gem "weakling" build_gem "baz-dev", "1.0.0" build_gem "very_simple_binary", &:add_c_extension - build_git "foo", :path => lib_path("foo") - build_git "git_with_ext", :path => lib_path("git_with_ext"), &:add_c_extension - build_lib "bar", :path => lib_path("bar") + build_git "foo", path: lib_path("foo") + build_git "git_with_ext", path: lib_path("git_with_ext"), &:add_c_extension + build_lib "bar", path: lib_path("bar") end install_gemfile <<-G @@ -164,7 +164,7 @@ RSpec.describe "bundle pristine" do end it "raises when one of them is not in the lockfile" do - bundle "pristine abcabcabc", :raise_on_error => false + bundle "pristine abcabcabc", raise_on_error: false expect(err).to include("Could not find gem 'abcabcabc'.") end end @@ -181,8 +181,8 @@ RSpec.describe "bundle pristine" do bundle "pristine" makefile_contents = File.read(c_ext_dir.join("Makefile").to_s) - expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/) - expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/) + expect(makefile_contents).to match(/libpath =.*#{Regexp.escape(c_ext_dir.to_s)}/) + expect(makefile_contents).to match(/LIBPATH =.*-L#{Regexp.escape(c_ext_dir.to_s)}/) end end @@ -198,14 +198,14 @@ RSpec.describe "bundle pristine" do bundle "pristine" makefile_contents = File.read(c_ext_dir.join("Makefile").to_s) - expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/) - expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/) + expect(makefile_contents).to match(/libpath =.*#{Regexp.escape(c_ext_dir.to_s)}/) + expect(makefile_contents).to match(/LIBPATH =.*-L#{Regexp.escape(c_ext_dir.to_s)}/) end end context "when BUNDLE_GEMFILE doesn't exist" do before do - bundle "pristine", :env => { "BUNDLE_GEMFILE" => "does/not/exist" }, :raise_on_error => false + bundle "pristine", env: { "BUNDLE_GEMFILE" => "does/not/exist" }, raise_on_error: false end it "shows a meaningful error" do diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb index d757e0be4b..23ce7dde47 100644 --- a/spec/bundler/commands/remove_spec.rb +++ b/spec/bundler/commands/remove_spec.rb @@ -7,7 +7,7 @@ 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 @@ -43,7 +43,7 @@ RSpec.describe "bundle remove" do end end - context "when --install flag is specified", :bundler => "< 3" do + context "when --install flag is specified", bundler: "< 3" do it "removes gems from .bundle" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -109,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 @@ -146,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 @@ -373,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 @@ -385,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" @@ -491,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 @@ -510,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.") @@ -535,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.") @@ -560,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\"") @@ -634,14 +634,14 @@ 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("foo")) do |s| s.write("foo.gemspec", "") s.add_dependency "rack" end install_gemfile(<<-G) source "#{file_uri_for(gem_repo1)}" - gemspec :path => '#{tmp.join("foo")}', :name => 'foo' + gemspec :path => '#{tmp("foo")}', :name => 'foo' G bundle "remove foo" diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb index 1c6244be41..4f02818cef 100644 --- a/spec/bundler/commands/show_spec.rb +++ b/spec/bundler/commands/show_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle show", :bundler => "< 3" do +RSpec.describe "bundle show", bundler: "< 3" do context "with a standard Gemfile" do before :each do install_gemfile <<-G @@ -50,14 +50,14 @@ RSpec.describe "bundle show", :bundler => "< 3" do end it "complains if gem not in bundle" do - bundle "show missing", :raise_on_error => false + bundle "show missing", raise_on_error: false expect(err).to match(/could not find gem 'missing'/i) end it "prints path of all gems in bundle sorted by name" do bundle "show --paths" - expect(out).to include(default_bundle_path("gems", "rake-13.0.1").to_s) + expect(out).to include(default_bundle_path("gems", "rake-#{rake_version}").to_s) expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) # Gem names are the last component of their path. @@ -104,7 +104,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do end it "prints out branch names other than main" do - update_git "foo", :branch => "omg" do |s| + update_git "foo", branch: "omg" do |s| s.write "lib/foo.rb", "FOO = '1.0.omg'" end @revision = revision_for(lib_path("foo-1.0"))[0...6] @@ -129,7 +129,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do end it "handles when a version is a '-' prerelease" do - @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo")) + @git = build_git("foo", "1.0.0-beta.1", path: lib_path("foo")) install_gemfile <<-G gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}" G @@ -142,13 +142,13 @@ RSpec.describe "bundle show", :bundler => "< 3" do context "in a fresh gem in a blank git repo" do before :each do - build_git "foo", :path => lib_path("foo") + build_git "foo", path: lib_path("foo") File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts "gemspec" } - sys_exec "rm -rf .git && git init", :dir => lib_path("foo") + sys_exec "rm -rf .git && git init", dir: lib_path("foo") end it "does not output git errors" do - bundle :show, :dir => lib_path("foo") + bundle :show, dir: lib_path("foo") expect(err_without_deprecations).to be_empty end end @@ -173,7 +173,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do G bundle "show rac" - expect(out).to match(/\A1 : rack\n2 : rack-obama\n0 : - exit -(\n>.*)?\z/) + expect(out).to match(/\A1 : rack\n2 : rack-obama\n0 : - exit -(\n>|\z)/) end end @@ -186,7 +186,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do invalid_regexp = "[]" - bundle "show #{invalid_regexp}", :raise_on_error => false + bundle "show #{invalid_regexp}", raise_on_error: false expect(err).to include("Could not find gem '#{invalid_regexp}'.") end end @@ -219,6 +219,6 @@ RSpec.describe "bundle show", :bundler => "< 3" do end end -RSpec.describe "bundle show", :bundler => "3" do +RSpec.describe "bundle show", bundler: "3" do pending "shows a friendly error about the command removal" end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 7a0d435860..d5d38b81f1 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -34,7 +34,7 @@ RSpec.describe "bundle update" do gem "rack-obama" exit! G - bundle "update", :raise_on_error => false + bundle "update", raise_on_error: false expect(bundled_app_lock).to exist end end @@ -60,7 +60,7 @@ RSpec.describe "bundle update" do build_gem "activesupport", "3.0" end - bundle "update", :all => true + bundle "update", all: true expect(out).to include("Bundle updated!") expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end @@ -74,7 +74,7 @@ RSpec.describe "bundle update" do gem "rack-obama" exit! G - bundle "update", :all => true, :raise_on_error => false + bundle "update", all: true, raise_on_error: false expect(bundled_app_lock).to exist end end @@ -86,7 +86,7 @@ RSpec.describe "bundle update" do gem "rack", "1.0" G - bundle "update --gemfile OmgFile", :all => true + bundle "update --gemfile OmgFile", all: true expect(bundled_app("OmgFile.lock")).to exist end @@ -97,13 +97,13 @@ RSpec.describe "bundle update" do it "errors when passed nothing" do install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" - bundle :update, :raise_on_error => false + bundle :update, raise_on_error: false expect(err).to eq("To update everything, pass the `--all` flag.") end it "errors when passed --all and another option" do install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" - bundle "update --all foo", :raise_on_error => false + bundle "update --all foo", raise_on_error: false expect(err).to eq("Cannot specify --all along with specific options.") end @@ -171,11 +171,11 @@ RSpec.describe "bundle update" do end it "should inform the user" do - bundle "update halting-problem-solver", :raise_on_error => false + bundle "update halting-problem-solver", raise_on_error: false expect(err).to include "Could not find gem 'halting-problem-solver'" end it "should suggest alternatives" do - bundle "update platformspecific", :raise_on_error => false + bundle "update platformspecific", raise_on_error: false expect(err).to include "Did you mean platform_specific?" end end @@ -236,7 +236,7 @@ RSpec.describe "bundle update" do end end - bundle "update", :all => true + bundle "update", all: true expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1") end @@ -275,6 +275,11 @@ RSpec.describe "bundle update" do gem "countries" G + checksums = checksums_section_when_existing do |c| + c.checksum(gem_repo4, "countries", "3.1.0") + c.checksum(gem_repo4, "country_select", "5.1.0") + end + lockfile <<~L GEM remote: #{file_uri_for(gem_repo4)}/ @@ -289,14 +294,14 @@ RSpec.describe "bundle update" do DEPENDENCIES countries country_select - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L previous_lockfile = lockfile - bundle "lock --update" + bundle "lock --update", env: { "DEBUG" => "1" }, verbose: true expect(lockfile).to eq(previous_lockfile) end @@ -434,7 +439,7 @@ RSpec.describe "bundle update" do build_gem "c", "2.0" end - install_gemfile <<-G, :verbose => true + install_gemfile <<-G, verbose: true source "#{file_uri_for(gem_repo4)}" gem "a" G @@ -447,7 +452,7 @@ RSpec.describe "bundle update" do end end - bundle "update", :all => true, :verbose => true + bundle "update", all: true, verbose: true expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0") end @@ -505,6 +510,11 @@ RSpec.describe "bundle update" do original_lockfile = lockfile + checksums = checksums_section_when_existing do |c| + c.checksum gem_repo4, "activesupport", "6.0.4.1" + c.checksum gem_repo4, "tzinfo", "1.2.9" + end + expected_lockfile = <<~L GEM remote: #{file_uri_for(gem_repo4)}/ @@ -518,7 +528,7 @@ RSpec.describe "bundle update" do DEPENDENCIES activesupport (~> 6.0.0) - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -527,6 +537,10 @@ RSpec.describe "bundle update" do expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9") expect(lockfile).to eq(expected_lockfile) + # needed because regressing to versions already present on the system + # won't add a checksum + expected_lockfile = remove_checksums_from_lockfile(expected_lockfile) + lockfile original_lockfile bundle "update" expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9") @@ -543,12 +557,36 @@ RSpec.describe "bundle update" do before do build_repo2 - install_gemfile <<-G + gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport" gem "rack-obama" gem "platform_specific" G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + activesupport (2.3.5) + platform_specific (1.0-#{local_platform}) + rack (1.0.0) + rack-obama (1.0) + rack + + PLATFORMS + #{local_platform} + + DEPENDENCIES + activesupport + platform_specific + rack-obama + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "install" end it "doesn't hit repo2" do @@ -601,7 +639,7 @@ RSpec.describe "bundle update" do context "when there is a source with the same name as a gem in a group" do before do - build_git "foo", :path => lib_path("activesupport") + build_git "foo", path: lib_path("activesupport") install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport", :group => :development @@ -611,7 +649,7 @@ RSpec.describe "bundle update" do it "should not update the gems from that source" do update_repo2 { build_gem "activesupport", "3.0" } - update_git "foo", "2.0", :path => lib_path("activesupport") + update_git "foo", "2.0", path: lib_path("activesupport") bundle "update --group development" expect(the_bundle).to include_gems "activesupport 3.0" @@ -653,32 +691,32 @@ RSpec.describe "bundle update" do G end - it "should fail loudly", :bundler => "< 3" do + it "should fail loudly", bundler: "< 3" do bundle "install --deployment" - bundle "update", :all => true, :raise_on_error => false + bundle "update", all: true, raise_on_error: false expect(last_command).to be_failure - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m) - expect(err).to match(/freeze \nby running `bundle config set frozen false`./m) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) + expect(err).to match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when frozen is set globally" do bundle "config set --global frozen 1" - bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). - and match(/freeze \nby running `bundle config set frozen false`./m) + bundle "update", all: true, raise_on_error: false + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). + and match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when deployment is set globally" do bundle "config set --global deployment true" - bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). - and match(/freeze \nby running `bundle config set frozen false`./m) + bundle "update", all: true, raise_on_error: false + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). + and match(/freeze by running `bundle config set frozen false`./) end it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do - bundle "update", :all => true, :raise_on_error => false, :env => { "BUNDLE_FROZEN" => "true" } - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m) + bundle "update", all: true, raise_on_error: false, env: { "BUNDLE_FROZEN" => "true" } + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) expect(err).not_to match(/by running/) end end @@ -772,7 +810,7 @@ RSpec.describe "bundle update" do end end - it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do + it "shows the previous version of the gem when updated from rubygems source" do build_repo2 install_gemfile <<-G @@ -780,43 +818,38 @@ RSpec.describe "bundle update" do gem "activesupport" G - bundle "update", :all => true + bundle "update", all: true, verbose: true expect(out).to include("Using activesupport 2.3.5") update_repo2 do build_gem "activesupport", "3.0" end - bundle "update", :all => true + bundle "update", all: true expect(out).to include("Installing activesupport 3.0 (was 2.3.5)") end - context "with suppress_install_using_messages set" do - before { bundle "config set suppress_install_using_messages true" } - - it "only prints `Using` for versions that have changed" do - build_repo4 do - build_gem "bar" - build_gem "foo" - end - - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "bar" - gem "foo" - G + it "only prints `Using` for versions that have changed" do + build_repo4 do + build_gem "bar" + build_gem "foo" + end - bundle "update", :all => true - expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "bar" + gem "foo" + G - update_repo4 do - build_gem "foo", "2.0" - end + bundle "update", all: true + expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) - bundle "update", :all => true - out.sub!("Removing foo (1.0)\n", "") - expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) + update_repo4 do + build_gem "foo", "2.0" end + + bundle "update", all: true + expect(out.sub("Removing foo (1.0)\n", "")).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) end it "shows error message when Gemfile.lock is not preset and gem is specified" do @@ -825,12 +858,96 @@ RSpec.describe "bundle update" do gem "activesupport" G - bundle "update nonexisting", :raise_on_error => false + bundle "update nonexisting", raise_on_error: false expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.") expect(exitstatus).to eq(22) end - context "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do + context "with multiple sources and caching enabled" do + before do + build_repo2 do + build_gem "rack", "1.0.0" + + build_gem "request_store", "1.0.0" do |s| + s.add_dependency "rack", "1.0.0" + end + end + + build_repo4 do + # set up repo with no gems + end + + gemfile <<~G + source "#{file_uri_for(gem_repo2)}" + + gem "request_store" + + source "#{file_uri_for(gem_repo4)}" do + end + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + request_store (1.0.0) + rack (= 1.0.0) + + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + + PLATFORMS + #{local_platform} + + DEPENDENCIES + request_store + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "works" do + bundle :install + bundle :cache + + update_repo2 do + build_gem "request_store", "1.1.0" do |s| + s.add_dependency "rack", "1.0.0" + end + end + + bundle "update request_store" + + expect(out).to include("Bundle updated!") + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + request_store (1.1.0) + rack (= 1.0.0) + + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + + PLATFORMS + #{local_platform} + + DEPENDENCIES + request_store + + BUNDLED WITH + #{Bundler::VERSION} + L + end + end + + context "with multiple, duplicated sources, with lockfile in old format", bundler: "< 3" do before do build_repo2 do build_gem "dotenv", "2.7.6" @@ -884,8 +1001,8 @@ RSpec.describe "bundle update" do end it "works" do - bundle :install, :artifice => "compact_index" - bundle "update oj", :artifice => "compact_index" + bundle :install, artifice: "compact_index" + bundle "update oj", artifice: "compact_index" expect(out).to include("Bundle updated!") expect(the_bundle).to include_gems "oj 3.11.5" @@ -1021,7 +1138,7 @@ RSpec.describe "bundle update in more complicated situations" do end it "allows updating" do - bundle :update, :all => true + bundle :update, all: true expect(the_bundle).to include_gem "a 1.1" end @@ -1077,7 +1194,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do gem "rack", "1.0" G - bundle "update", :all => true + bundle "update", all: true expect(the_bundle).to include_gems "rack 1.0.0" end @@ -1100,7 +1217,7 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler" end it "should explain that bundler conflicted and how to resolve the conflict" do - bundle "update", :all => true, :raise_on_error => false + bundle "update", all: true, raise_on_error: false expect(last_command.stdboth).not_to match(/in snapshot/i) expect(err).to match(/current Bundler version/i). and match(/Install the necessary version with `gem install bundler:#{Bundler::VERSION.succ}`/i) @@ -1116,9 +1233,10 @@ RSpec.describe "bundle update --ruby" do G gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo1)}" G end + it "removes the Ruby from the Gemfile.lock" do bundle "update --ruby" @@ -1146,28 +1264,29 @@ RSpec.describe "bundle update --ruby" do G gemfile <<-G - ruby '~> #{current_ruby_minor}' - source "#{file_uri_for(gem_repo1)}" + ruby '~> #{current_ruby_minor}' + source "#{file_uri_for(gem_repo1)}" G end + it "updates the Gemfile.lock with the latest version" do bundle "update --ruby" expect(lockfile).to eq <<~L - GEM - remote: #{file_uri_for(gem_repo1)}/ - specs: + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: - PLATFORMS - #{lockfile_platforms} + PLATFORMS + #{lockfile_platforms} - DEPENDENCIES + DEPENDENCIES - RUBY VERSION - #{Bundler::RubyVersion.system} + RUBY VERSION + #{Bundler::RubyVersion.system} - BUNDLED WITH - #{Bundler::VERSION} + BUNDLED WITH + #{Bundler::VERSION} L end end @@ -1185,7 +1304,7 @@ RSpec.describe "bundle update --ruby" do G end it "shows a helpful error message" do - bundle "update --ruby", :raise_on_error => false + bundle "update --ruby", raise_on_error: false expect(err).to include("Your Ruby version is #{Bundler::RubyVersion.system.gem_version}, but your Gemfile specified ~> 2.1.0") end @@ -1203,6 +1322,8 @@ RSpec.describe "bundle update --ruby" do DEPENDENCIES + CHECKSUMS + RUBY VERSION ruby 2.1.4p222 @@ -1215,6 +1336,7 @@ RSpec.describe "bundle update --ruby" do source "#{file_uri_for(gem_repo1)}" G end + it "updates the Gemfile.lock with the latest version" do bundle "update --ruby" @@ -1228,6 +1350,8 @@ RSpec.describe "bundle update --ruby" do DEPENDENCIES + CHECKSUMS + RUBY VERSION #{Bundler::RubyVersion.system} @@ -1239,20 +1363,37 @@ RSpec.describe "bundle update --ruby" do end RSpec.describe "bundle update --bundler" do - it "updates the bundler version in the lockfile without re-resolving" do + it "updates the bundler version in the lockfile" do build_repo4 do build_gem "rack", "1.0" end + checksums = checksums_section_when_existing do |c| + c.checksum(gem_repo4, "rack", "1.0") + end + install_gemfile <<-G source "#{file_uri_for(gem_repo4)}" gem "rack" G - lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) - FileUtils.rm_r gem_repo4 + PLATFORMS + #{lockfile_platforms} - bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true + DEPENDENCIES + rack + #{checksums} + BUNDLED WITH + #{Bundler::VERSION} + L + lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') + + bundle :update, bundler: true, artifice: "compact_index", verbose: true expect(out).to include("Using bundler #{Bundler::VERSION}") expect(lockfile).to eq <<~L @@ -1266,7 +1407,7 @@ RSpec.describe "bundle update --bundler" do DEPENDENCIES rack - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -1287,7 +1428,11 @@ RSpec.describe "bundle update --bundler" do G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9") - bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true + checksums = checksums_section_when_existing do |c| + c.checksum(gem_repo4, "rack", "1.0") + end + + bundle :update, bundler: true, artifice: "compact_index", verbose: true expect(out).to include("Using bundler #{Bundler::VERSION}") expect(lockfile).to eq <<~L @@ -1301,7 +1446,7 @@ RSpec.describe "bundle update --bundler" do DEPENDENCIES rack - + #{checksums} BUNDLED WITH #{Bundler::VERSION} L @@ -1309,26 +1454,28 @@ RSpec.describe "bundle update --bundler" do expect(the_bundle).to include_gem "rack 1.0" end - it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do + it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo do pristine_system_gems "bundler-2.3.9" build_repo4 do build_gem "rack", "1.0" + + build_bundler "999.0.0" end - install_gemfile <<-G, :env => { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } + install_gemfile <<-G, artifice: nil, env: { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } source "#{file_uri_for(gem_repo4)}" gem "rack" G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9") - bundle :update, :bundler => true, :artifice => "vcr", :verbose => true, :env => { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } + bundle :update, bundler: true, artifice: "compact_index", verbose: true, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } # Only updates properly on modern RubyGems. if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") - expect(out).to include("Updating bundler to 2.3.10") - expect(out).to include("Using bundler 2.3.10") + expect(out).to include("Updating bundler to 999.0.0") + expect(out).to include("Using bundler 999.0.0") expect(out).not_to include("Installing Bundler 2.3.9 and restarting using that version.") expect(lockfile).to eq <<~L @@ -1344,29 +1491,113 @@ RSpec.describe "bundle update --bundler" do rack BUNDLED WITH - 2.3.10 + 999.0.0 L - expect(the_bundle).to include_gems "bundler 2.3.10" + expect(the_bundle).to include_gems "bundler 999.0.0" + expect(the_bundle).to include_gems "rack 1.0" + else + # Old RubyGems versions do not trampoline but they still change BUNDLED + # WITH to the latest bundler version. This means the below check fails + # because it tries to use bundler 999.0.0 which did not get installed. + # Workaround the bug by forcing the version we know is installed. + expect(the_bundle).to include_gems "rack 1.0", env: { "BUNDLER_VERSION" => "2.3.9" } + end + end + + it "does not claim to update to Bundler version to a wrong version when cached gems are present" do + pristine_system_gems "bundler-2.99.0" + + build_repo4 do + build_gem "rack", "3.0.9.1" + + build_bundler "2.99.0" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (3.0.9.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 2.99.0 + L + + bundle :cache, verbose: true + + bundle :update, bundler: true, artifice: "compact_index", verbose: true, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + + expect(out).not_to include("Updating bundler to") + end + + it "does not update the bundler version in the lockfile if the latest version is not compatible with current ruby", :ruby_repo do + pristine_system_gems "bundler-2.3.9" + + build_repo4 do + build_gem "rack", "1.0" + + build_bundler "2.3.9" + build_bundler "999.0.0" do |s| + s.required_ruby_version = "> #{Gem.ruby_version}" + end end + install_gemfile <<-G, env: { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9") + + bundle :update, bundler: true, artifice: "compact_index", verbose: true, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } + + expect(out).to include("Using bundler 2.3.9") + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 2.3.9 + L + + expect(the_bundle).to include_gems "bundler 2.3.9" expect(the_bundle).to include_gems "rack 1.0" end - it "errors if the explicit target version does not exist", :realworld do + it "errors if the explicit target version does not exist" do pristine_system_gems "bundler-2.3.9" build_repo4 do build_gem "rack", "1.0" end - install_gemfile <<-G, :env => { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } + install_gemfile <<-G, env: { "BUNDLER_IGNORE_DEFAULT_GEM" => "true" } source "#{file_uri_for(gem_repo4)}" gem "rack" G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9") - bundle :update, :bundler => "999.999.999", :artifice => "vcr", :raise_on_error => false + bundle :update, bundler: "999.999.999", artifice: "compact_index", raise_on_error: false # Only gives a meaningful error message on modern RubyGems. @@ -1388,11 +1619,14 @@ RSpec.describe "bundle update --bundler" do gem "rack" G - bundle :update, :bundler => "2.3.0.dev" + bundle :update, bundler: "2.3.0.dev", verbose: "true" # Only updates properly on modern RubyGems. - if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") + checksums = checksums_section_when_existing do |c| + c.checksum(gem_repo4, "rack", "1.0") + end + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo4)}/ @@ -1404,7 +1638,7 @@ RSpec.describe "bundle update --bundler" do DEPENDENCIES rack - + #{checksums} BUNDLED WITH 2.3.0.dev L @@ -1425,11 +1659,14 @@ RSpec.describe "bundle update --bundler" do gem "rack" G - bundle :update, :bundler => "2.3.9", :raise_on_error => false + bundle :update, bundler: "2.3.9", verbose: true expect(out).not_to include("Fetching gem metadata from https://rubygems.org/") # Only updates properly on modern RubyGems. + checksums = checksums_section_when_existing do |c| + c.checksum(gem_repo4, "rack", "1.0") + end if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") expect(lockfile).to eq <<~L @@ -1443,7 +1680,7 @@ RSpec.describe "bundle update --bundler" do DEPENDENCIES rack - + #{checksums} BUNDLED WITH 2.3.9 L @@ -1473,8 +1710,8 @@ RSpec.describe "bundle update --bundler" do 2.1.4 L - bundle "update --bundler=2.3.9", :env => { "BUNDLE_FROZEN" => "true" } - expect(err).to include("Cannot write a changed lockfile while frozen") + bundle "update --bundler=2.3.9", env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false + expect(err).to include("An update to the version of bundler itself was requested, but the lockfile can't be updated because frozen mode is set") end end @@ -1533,7 +1770,7 @@ RSpec.describe "bundle update conservative" do end it "update all" do - bundle "update --patch", :all => true + bundle "update --patch", all: true expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1" end @@ -1555,7 +1792,7 @@ RSpec.describe "bundle update conservative" do end it "minor preferred" do - bundle "update --minor --strict", :all => true + bundle "update --minor --strict", all: true expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0" end @@ -1634,6 +1871,8 @@ RSpec.describe "bundle update conservative" do shared_owner_a shared_owner_b + CHECKSUMS + BUNDLED WITH #{Bundler::VERSION} L @@ -1687,6 +1926,13 @@ RSpec.describe "bundle update conservative" do shared_owner_a shared_owner_b + CHECKSUMS + isolated_dep (2.0.1) + isolated_owner (1.0.2) + shared_dep (5.0.1) + shared_owner_a (3.0.2) + shared_owner_b (4.0.2) + BUNDLED WITH #{Bundler::VERSION} L @@ -1707,13 +1953,59 @@ RSpec.describe "bundle update conservative" do end end + context "when Gemfile dependencies have changed" do + before do + build_repo4 do + build_gem "nokogiri", "1.16.4" do |s| + s.platform = "arm64-darwin" + end + + build_gem "nokogiri", "1.16.4" do |s| + s.platform = "x86_64-linux" + end + + build_gem "prism", "0.25.0" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + gem "nokogiri", ">=1.16.4" + gem "prism", ">=0.25.0" + G + + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + nokogiri (1.16.4-arm64-darwin) + nokogiri (1.16.4-x86_64-linux) + + PLATFORMS + arm64-darwin + x86_64-linux + + DEPENDENCIES + nokogiri (>= 1.16.4) + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "still works" do + simulate_platform "arm64-darwin-23" do + bundle "update" + end + end + end + context "error handling" do before do gemfile "source \"#{file_uri_for(gem_repo1)}\"" end it "raises if too many flags are provided" do - bundle "update --patch --minor", :all => true, :raise_on_error => false + bundle "update --patch --minor", all: true, raise_on_error: false expect(err).to eq "Provide only one of the following options: minor, patch" end diff --git a/spec/bundler/commands/version_spec.rb b/spec/bundler/commands/version_spec.rb index 53d545f5fa..307058a5dd 100644 --- a/spec/bundler/commands/version_spec.rb +++ b/spec/bundler/commands/version_spec.rb @@ -4,42 +4,42 @@ require_relative "../support/path" RSpec.describe "bundle version" do if Spec::Path.ruby_core? - COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/.freeze + COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/ else - COMMIT_HASH = /[a-fA-F0-9]{7,}/.freeze + COMMIT_HASH = /[a-fA-F0-9]{7,}/ end context "with -v" do - it "outputs the version", :bundler => "< 3" do + it "outputs the version", bundler: "< 3" do bundle "-v" expect(out).to eq("Bundler version #{Bundler::VERSION}") end - it "outputs the version", :bundler => "3" do + it "outputs the version", bundler: "3" do bundle "-v" expect(out).to eq(Bundler::VERSION) end end context "with --version" do - it "outputs the version", :bundler => "< 3" do + it "outputs the version", bundler: "< 3" do bundle "--version" expect(out).to eq("Bundler version #{Bundler::VERSION}") end - it "outputs the version", :bundler => "3" do + it "outputs the version", bundler: "3" do bundle "--version" expect(out).to eq(Bundler::VERSION) end end context "with version" do - it "outputs the version with build metadata", :bundler => "< 3" do + it "outputs the version with build metadata", bundler: "< 3" do bundle "version" expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) end - it "outputs the version with build metadata", :bundler => "3" do + it "outputs the version with build metadata", bundler: "3" do bundle "version" expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) end diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb index cf612397ab..f8b5f7836e 100644 --- a/spec/bundler/commands/viz_spec.rb +++ b/spec/bundler/commands/viz_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :realworld => true do +RSpec.describe "bundle viz", bundler: "< 3", if: Bundler.which("dot"), realworld: true do before do realworld_system_gems "ruby-graphviz --version 1.2.5" end @@ -15,8 +15,8 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re bundle "viz" expect(out).to include("gem_graph.png") - bundle "viz", :format => "debug" - expect(out).to eq(strip_whitespace(<<-DOT).strip) + bundle "viz", format: "debug" + expect(out).to eq(<<~DOT.strip) digraph Gemfile { concentrate = "true"; normalize = "true"; @@ -49,8 +49,8 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re bundle "viz" expect(out).to include("gem_graph.png") - bundle "viz", :format => :debug, :version => true - expect(out).to eq(strip_whitespace(<<-EOS).strip) + bundle "viz", format: :debug, version: true + expect(out).to eq(<<~EOS.strip) digraph Gemfile { concentrate = "true"; normalize = "true"; @@ -77,7 +77,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re end end - system_gems "graphviz-999", :gem_repo => gem_repo4 + system_gems "graphviz-999", gem_repo: gem_repo4 end it "loads the correct ruby-graphviz gem" do @@ -87,8 +87,8 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re gem "rack-obama" G - bundle "viz", :format => "debug" - expect(out).to eq(strip_whitespace(<<-DOT).strip) + bundle "viz", format: "debug" + expect(out).to eq(<<~DOT.strip) digraph Gemfile { concentrate = "true"; normalize = "true"; |