From e2403c093d4f230ec5fa36bb2463e221772369a5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 6 Feb 2014 20:17:24 -0800 Subject: [PATCH] core: Vagrantfile class now adheres to box_version --- lib/vagrant/vagrantfile.rb | 2 +- test/unit/vagrant/vagrantfile_test.rb | 36 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/vagrantfile.rb b/lib/vagrant/vagrantfile.rb index f6a660efc..52b5daf85 100644 --- a/lib/vagrant/vagrantfile.rb +++ b/lib/vagrant/vagrantfile.rb @@ -80,7 +80,7 @@ module Vagrant # Load the box Vagrantfile, if there is one if config.vm.box - box = boxes.find(config.vm.box, box_formats) + box = boxes.find(config.vm.box, box_formats, config.vm.box_version) if box box_vagrantfile = find_vagrantfile(box.directory) if box_vagrantfile diff --git a/test/unit/vagrant/vagrantfile_test.rb b/test/unit/vagrant/vagrantfile_test.rb index 623b2c208..3aa947046 100644 --- a/test/unit/vagrant/vagrantfile_test.rb +++ b/test/unit/vagrant/vagrantfile_test.rb @@ -94,7 +94,7 @@ describe Vagrant::Vagrantfile do config.vm.box = "base" end - iso_env.box2("base", :foo, vagrantfile: <<-VF) + iso_env.box3("base", "1.0", :foo, vagrantfile: <<-VF) Vagrant.configure("2") do |config| config.ssh.port = 123 end @@ -107,6 +107,34 @@ describe Vagrant::Vagrantfile do expect(box.name).to eq("base") end + it "configures with the proper box version" do + register_provider("foo") + + configure do |config| + config.vm.box = "base" + config.vm.box_version = "~> 1.2" + end + + iso_env.box3("base", "1.0", :foo, vagrantfile: <<-VF) + Vagrant.configure("2") do |config| + config.ssh.port = 123 + end + VF + + iso_env.box3("base", "1.3", :foo, vagrantfile: <<-VF) + Vagrant.configure("2") do |config| + config.ssh.port = 245 + end + VF + + config, _, _, box = subject.machine_config(:default, :foo, boxes) + expect(config.vm.box).to eq("base") + expect(config.ssh.port).to eq(245) + expect(box).to_not be_nil + expect(box.name).to eq("base") + expect(box.version).to eq("1.3") + end + it "configures with box config of other supported formats" do register_provider("foo", nil, box_format: "bar") @@ -114,7 +142,7 @@ describe Vagrant::Vagrantfile do config.vm.box = "base" end - iso_env.box2("base", :bar, vagrantfile: <<-VF) + iso_env.box3("base", "1.0", :bar, vagrantfile: <<-VF) Vagrant.configure("2") do |config| config.ssh.port = 123 end @@ -160,13 +188,13 @@ describe Vagrant::Vagrantfile do end end - iso_env.box2("base", :foo, vagrantfile: <<-VF) + iso_env.box3("base", "1.0", :foo, vagrantfile: <<-VF) Vagrant.configure("2") do |config| config.ssh.port = 123 end VF - iso_env.box2("foobox", :foo, vagrantfile: <<-VF) + iso_env.box3("foobox", "1.0", :foo, vagrantfile: <<-VF) Vagrant.configure("2") do |config| config.ssh.port = 234 end