diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-05-31 15:44:53 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-01 13:05:27 -0500 |
commit | 5100bff1c5d02e11764d289089851daeeef9808b (patch) | |
tree | fba41efa849f3623d9b646ca081b1781422f0824 | |
parent | d2d669746bc4e7f55c50f730e5fc965874ab1161 (diff) | |
download | bundler-5100bff1c5d02e11764d289089851daeeef9808b.tar.gz |
[CLI::Lock] Fail gracefully when updating a missing gem
-rw-r--r-- | lib/bundler/cli/lock.rb | 10 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb index beeb2e4633..8b14f2c7d3 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -22,7 +22,15 @@ module Bundler Bundler::Fetcher.disable_endpoint = options["full-index"] update = options[:update] - update = { :gems => update, :lock_shared_dependencies => options[:conservative] } if update.is_a?(Array) + if update.is_a?(Array) # unlocking specific gems + # cycle through the requested gems, to make sure they exist + names = Bundler.locked_gems.specs.map(&:name) + update.each do |g| + next if names.include?(g) + raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(g, names) + end + update = { :gems => update, :lock_shared_dependencies => options[:conservative] } + end definition = Bundler.definition(update) Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update] diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index a0b8abefae..11742dede6 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -105,6 +105,15 @@ RSpec.describe "bundle lock" do expect(read_lockfile).to eq(@lockfile) end + it "errors when updating a missing specific gems using --update" do + lockfile @lockfile + + bundle "lock --update blahblah" + expect(out).to eq("Could not find gem 'blahblah'.") + + expect(read_lockfile).to eq(@lockfile) + end + # see update_spec for more coverage on same options. logic is shared so it's not necessary # to repeat coverage here. context "conservative updates" do |