Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Restrict raising on version mismatches to after bundler 2
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Feb 27, 2019
1 parent d143d2a commit 4f8ad84
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/lockfile_parser.rb
Expand Up @@ -103,7 +103,7 @@ def warn_for_outdated_bundler_version
current_version = Gem::Version.create(Bundler::VERSION)
current_major_version = current_version.segments.first
major_bundler_version = bundler_version.segments.first
if current_major_version < major_bundler_version
if current_major_version < major_bundler_version && current_major_version > 2
raise LockfileError, "You must use Bundler #{major_bundler_version} or greater with this lockfile."
end
return unless current_version < bundler_version
Expand Down
46 changes: 6 additions & 40 deletions spec/lock/lockfile_bundler_1_spec.rb
Expand Up @@ -203,7 +203,7 @@
G
end

it "errors if the current is a major version older than lockfile's bundler version" do
it "warns if the current is a major version older than lockfile's bundler version" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
Expand All @@ -227,45 +227,11 @@
G

expect(exitstatus > 0) if exitstatus
expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
end

it "shows a friendly error when running with a new bundler 2 lockfile" do
lockfile <<-L
GEM
remote: https://rails-assets.org/
specs:
rails-assets-bootstrap (3.3.4)
rails-assets-jquery (>= 1.9.1)
rails-assets-jquery (2.1.4)
GEM
remote: https://rubygems.org/
specs:
rake (10.4.2)
PLATFORMS
ruby
DEPENDENCIES
rails-assets-bootstrap!
rake
BUNDLED WITH
9999999.0.0
L

install_gemfile <<-G
source 'https://rubygems.org'
gem 'rake'
source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap'
end
G

expect(exitstatus > 0) if exitstatus
expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
warning_message = "the running version of Bundler (#{Bundler::VERSION}) is older " \
"than the version that created the lockfile (9999999.0.0). " \
"We suggest you to upgrade to the version that created the " \
"lockfile by running `gem install bundler:9999999.0.0`."
expect(err).to include warning_message
end

it "warns when updating bundler major version" do
Expand Down
54 changes: 44 additions & 10 deletions spec/lock/lockfile_spec.rb
Expand Up @@ -154,7 +154,7 @@
G
end

it "outputs a warning if the current is older than lockfile's bundler version" do
it "outputs a warning if the current major is higher than 2 and older than lockfile's bundler version" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
Expand Down Expand Up @@ -202,7 +202,7 @@
G
end

it "errors if the current is a major version older than lockfile's bundler version" do
it "warns if the current major version is not higher that 2 and older than lockfile's bundler version" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
Expand All @@ -225,11 +225,43 @@
gem "rack"
G

warning_message = "the running version of Bundler (#{Bundler::VERSION}) is older " \
"than the version that created the lockfile (9999999.0.0). " \
"We suggest you to upgrade to the version that created the " \
"lockfile by running `gem install bundler:9999999.0.0`."
expect(err).to include warning_message
end

it "errors if the current major version is higher that 2 and older than lockfile's bundler version" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
9999999.0.0
L

simulate_bundler_version "3.0.0" do
install_gemfile <<-G
source "file://localhost#{gem_repo1}/"
gem "rack"
G
end

expect(last_command).to be_failure
expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
end

it "shows a friendly error when running with a new bundler 2 lockfile" do
it "shows a friendly error when running with a new bundler 3 lockfile" do
lockfile <<-L
GEM
remote: https://rails-assets.org/
Expand All @@ -254,14 +286,16 @@
9999999.0.0
L

install_gemfile <<-G
source 'https://rubygems.org'
gem 'rake'
simulate_bundler_version "3.0.0" do
install_gemfile <<-G
source 'https://rubygems.org'
gem 'rake'
source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap'
end
G
source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap'
end
G
end

expect(last_command).to be_failure
expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
Expand Down

0 comments on commit 4f8ad84

Please sign in to comment.