diff options
Diffstat (limited to 'spec/lock/lockfile_spec.rb')
-rw-r--r-- | spec/lock/lockfile_spec.rb | 182 |
1 files changed, 170 insertions, 12 deletions
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 7f6ec77651..c07c4e1db8 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "the lockfile format", :bundler => "2" do +RSpec.describe "the lockfile format" do include Bundler::GemHelpers before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" } @@ -183,7 +183,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do "than the version that created the lockfile (9999999.1.0). " \ "We suggest you to upgrade to the version that created the " \ "lockfile by running `gem install bundler:9999999.1.0`." - expect(last_command.bundler_err).to include warning_message + expect(last_command.stderr).to include warning_message lockfile_should_be <<-G GEM @@ -192,7 +192,8 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{lockfile_platforms} + #{generic_local_platform} + #{specific_local_platform} DEPENDENCIES rack @@ -202,7 +203,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end - it "errors if the current is a major version older than lockfile's bundler version" do + it "errors if the current is a major version older than lockfile's bundler version", :bundler => "2" do lockfile <<-L GEM remote: file://localhost#{gem_repo1}/ @@ -267,7 +268,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.") end - it "warns when updating bundler major version" do + it "warns when updating bundler major version", :bundler => "< 2" do lockfile <<-L GEM remote: file://localhost#{gem_repo1}/ @@ -292,8 +293,10 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end - expect(err).to include("Warning: the lockfile is being updated to Bundler " \ - "9999999, after which you will be unable to return to Bundler 1.") + expect(last_command.stderr).to include( + "Warning: the lockfile is being updated to Bundler " \ + "9999999, after which you will be unable to return to Bundler 1." + ) lockfile_should_be <<-G GEM @@ -302,7 +305,8 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{lockfile_platforms} + #{generic_local_platform} + #{specific_local_platform} DEPENDENCIES rack @@ -312,6 +316,53 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end + it "warns when updating bundler major version", :bundler => "2" do + lockfile <<-L + GEM + remote: file://localhost#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 1.10.0 + L + + simulate_bundler_version "9999999.0.0" do + install_gemfile <<-G + source "file://localhost#{gem_repo1}/" + + gem "rack" + G + + expect(last_command.stderr).to include( + "Warning: the lockfile is being updated to Bundler " \ + "9999999, after which you will be unable to return to Bundler 1." + ) + + lockfile_should_be <<-G + GEM + remote: file://localhost#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 9999999.0.0 + G + end + end + it "generates a simple lockfile for a single source, gem with dependencies" do install_gemfile <<-G source "file://localhost#{gem_repo1}/" @@ -364,7 +415,40 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end - it "generates a lockfile without credentials for a configured source" do + it "generates a lockfile without credentials for a configured source", :bundler => "< 2" do + bundle "config set http://localgemserver.test/ user:pass" + + install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true) + source "http://localgemserver.test/" do + + end + + source "http://user:pass@othergemserver.test/" do + gem "rack-obama", ">= 1.0" + end + G + + lockfile_should_be <<-G + GEM + remote: http://localgemserver.test/ + remote: http://user:pass@othergemserver.test/ + specs: + rack (1.0.0) + rack-obama (1.0) + rack + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack-obama (>= 1.0)! + + BUNDLED WITH + #{Bundler::VERSION} + G + end + + it "generates a lockfile without credentials for a configured source", :bundler => "2" do bundle "config set http://localgemserver.test/ user:pass" install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true) @@ -980,7 +1064,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end - it "keeps existing platforms in the lockfile" do + it "keeps existing platforms in the lockfile", :bundler => "< 2" do lockfile <<-G GEM remote: file://localhost#{gem_repo1}/ @@ -1010,7 +1094,8 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{lockfile_platforms "java", generic_local_platform, specific_local_platform} + java + #{generic_local_platform} DEPENDENCIES rack @@ -1020,7 +1105,80 @@ RSpec.describe "the lockfile format", :bundler => "2" do G end - it "persists the spec's platform to the lockfile" do + it "keeps existing platforms in the lockfile", :bundler => "2" do + lockfile <<-G + GEM + remote: file://localhost#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + java + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + G + + install_gemfile <<-G + source "file://localhost#{gem_repo1}/" + + gem "rack" + G + + lockfile_should_be <<-G + GEM + remote: file://localhost#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + java + #{generic_local_platform} + #{specific_local_platform} + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + G + end + + it "persists the spec's platform to the lockfile", :bundler => "< 2" do + build_repo2 do + build_gem "platform_specific", "1.0" do |s| + s.platform = Gem::Platform.new("universal-java-16") + end + end + + simulate_platform "universal-java-16" + + install_gemfile! <<-G + source "file://localhost#{gem_repo2}" + gem "platform_specific" + G + + lockfile_should_be <<-G + GEM + remote: file://localhost#{gem_repo2}/ + specs: + platform_specific (1.0-java) + + PLATFORMS + java + + DEPENDENCIES + platform_specific + + BUNDLED WITH + #{Bundler::VERSION} + G + end + + it "persists the spec's platform and specific platform to the lockfile", :bundler => "2" do build_repo2 do build_gem "platform_specific", "1.0" do |s| s.platform = Gem::Platform.new("universal-java-16") |