From b353865da1b7d1b5ffd47a0f8207e602f903eadd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 Jan 2014 10:13:30 -0800 Subject: [PATCH] core: specific versions "0.1.0" don't equate to "= 0.1.0" --- lib/vagrant/plugin/manager.rb | 4 +++ test/unit/vagrant/plugin/manager_test.rb | 40 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb index 5b708c88a..b36f0b264 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -60,6 +60,10 @@ module Vagrant install_lambda.call end + # If the version constraint is just a specific version, don't + # store the constraint. + opts.delete(:version) if opts[:version] && opts[:version] =~ /^\d/ + # Add the plugin to the state file @global_file.add_plugin( result.name, diff --git a/test/unit/vagrant/plugin/manager_test.rb b/test/unit/vagrant/plugin/manager_test.rb index d44127804..70d6dbb44 100644 --- a/test/unit/vagrant/plugin/manager_test.rb +++ b/test/unit/vagrant/plugin/manager_test.rb @@ -59,6 +59,46 @@ describe Vagrant::Plugin::Manager do expect { subject.install_plugin("foo") }. to raise_error(Vagrant::Errors::BundlerError) end + + describe "installation options" do + let(:specs) do + specs = Array.new(5) { Gem::Specification.new } + specs[3].name = "foo" + specs + end + + before do + bundler.stub(:install).and_return(specs) + end + + it "installs a version with constraints" do + bundler.should_receive(:install).once.with do |plugins, local| + expect(plugins).to have_key("foo") + expect(plugins["foo"]["gem_version"]).to eql(">= 0.1.0") + expect(local).to be_false + end.and_return(specs) + + subject.install_plugin("foo", version: ">= 0.1.0") + + plugins = subject.installed_plugins + expect(plugins).to have_key("foo") + expect(plugins["foo"]["gem_version"]).to eql(">= 0.1.0") + end + + it "installs with an exact version but doesn't constrain" do + bundler.should_receive(:install).once.with do |plugins, local| + expect(plugins).to have_key("foo") + expect(plugins["foo"]["gem_version"]).to eql("0.1.0") + expect(local).to be_false + end.and_return(specs) + + subject.install_plugin("foo", version: "0.1.0") + + plugins = subject.installed_plugins + expect(plugins).to have_key("foo") + expect(plugins["foo"]["gem_version"]).to eql("") + end + end end describe "#uninstall_plugin" do