From 068c0e67c5d11e34f41bf15eef065d832c79a6f7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Apr 2010 01:13:25 -0700 Subject: [PATCH] Update environment to use new VirtualBox methods/attributes --- lib/vagrant/actions/vm/shared_folders.rb | 2 +- lib/vagrant/environment.rb | 6 +----- test/vagrant/actions/vm/shared_folders_test.rb | 4 ++-- test/vagrant/environment_test.rb | 16 ++++------------ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/vagrant/actions/vm/shared_folders.rb b/lib/vagrant/actions/vm/shared_folders.rb index a89b56cbb..d77138efa 100644 --- a/lib/vagrant/actions/vm/shared_folders.rb +++ b/lib/vagrant/actions/vm/shared_folders.rb @@ -43,7 +43,7 @@ module Vagrant shared_folders.each do |name, hostpath, guestpath| folder = VirtualBox::SharedFolder.new folder.name = name - folder.hostpath = hostpath + folder.host_path = hostpath @runner.vm.shared_folders << folder end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 8bc3534c9..423620c47 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -32,16 +32,12 @@ module Vagrant # VirtualBox installed is high enough. Also verifies that the # configuration path is properly set. def check_virtualbox! - version = VirtualBox::Command.version + version = VirtualBox.version if version.nil? error_and_exit(:virtualbox_not_detected) elsif version.to_f < 3.1 error_and_exit(:virtualbox_invalid_version, :version => version.to_s) end - - if !VirtualBox::Global.vboxconfig? - error_and_exit(:virtualbox_xml_not_detected) - end end end diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index 424a09779..66148dae7 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -79,8 +79,8 @@ class SharedFoldersActionTest < Test::Unit::TestCase should "add all shared folders to the VM" do share_seq = sequence("share_seq") shared_folders = mock("shared_folders") - shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "foo" && sf.hostpath == "from" } - shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "bar" && sf.hostpath == "bfrom" } + shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "foo" && sf.host_path == "from" } + shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "bar" && sf.host_path == "bfrom" } @vm.stubs(:shared_folders).returns(shared_folders) @vm.expects(:save).with(true).once diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index e5aae9bd5..800fd78e4 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -7,33 +7,25 @@ class EnvironmentTest < Test::Unit::TestCase context "class method check virtualbox version" do setup do - VirtualBox::Command.stubs(:version).returns("3.1.4") - VirtualBox::Global.stubs(:vboxconfig?).returns(true) + VirtualBox.stubs(:version).returns("3.1.4") end should "not error and exit if everything is good" do - VirtualBox::Command.expects(:version).returns("3.1.4") - VirtualBox::Global.expects(:vboxconfig?).returns(true) + VirtualBox.expects(:version).returns("3.1.4") Vagrant::Environment.expects(:error_and_exit).never Vagrant::Environment.check_virtualbox! end should "error and exit if VirtualBox is not installed or detected" do Vagrant::Environment.expects(:error_and_exit).with(:virtualbox_not_detected).once - VirtualBox::Command.expects(:version).returns(nil) + VirtualBox.expects(:version).returns(nil) Vagrant::Environment.check_virtualbox! end should "error and exit if VirtualBox is lower than version 3.1" do version = "3.0.12r1041" Vagrant::Environment.expects(:error_and_exit).with(:virtualbox_invalid_version, :version => version.to_s).once - VirtualBox::Command.expects(:version).returns(version) - Vagrant::Environment.check_virtualbox! - end - - should "error and exit if the the vboxconfig is not set" do - VirtualBox::Global.expects(:vboxconfig?).returns(false) - Vagrant::Environment.expects(:error_and_exit).with(:virtualbox_xml_not_detected).once + VirtualBox.expects(:version).returns(version) Vagrant::Environment.check_virtualbox! end end