From 242fcbcb2d15d39c63e3441756b77fbfcc1b73b2 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 5 Dec 2016 15:44:24 -0600 Subject: [PATCH] [Lock] Fix --add-platform ruby Necessary since the ruby platform is a string instead of a platform object --- lib/bundler/cli/lock.rb | 2 +- spec/commands/lock_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb index 2ccaba86eba..beeb2e46337 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -33,7 +33,7 @@ def run options["add-platform"].each do |platform_string| platform = Gem::Platform.new(platform_string) - if platform.to_a.compact == %w(unknown) + if platform.to_s == "unknown" Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \ "and adding it will likely lead to resolution errors" end diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index 1c00aa3c1fa..b51003f2578 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -161,6 +161,12 @@ def read_lockfile(file = "Gemfile.lock") expect(lockfile.platforms).to eq([java, local, mingw]) end + it "supports adding the `ruby` platform" do + bundle! "lock --add-platform ruby" + lockfile = Bundler::LockfileParser.new(read_lockfile) + expect(lockfile.platforms).to eq([local, "ruby"].uniq) + end + it "warns when adding an unknown platform" do bundle "lock --add-platform foobarbaz" expect(out).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors")