diff --git a/test/test_helper.rb b/test/test_helper.rb index 6b887e070..773b3b2bd 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -112,24 +112,6 @@ class Test::Unit::TestCase [app, env] end - # Returns a resource logger which is safe for tests - def quiet_logger(resource, env=nil) - logger = Vagrant::ResourceLogger.new(resource, env) - logger.stubs(:flush_progress) - logger.stubs(:cl_reset).returns("") - logger - end - - # Returns a linux system - def linux_system(vm) - Vagrant::Systems::Linux.new(vm) - end - - def stub_default_action_dependecies(mock) - mock.stubs(:precedes).returns([]) - mock.stubs(:follows).returns([]) - end - # Sets up the mocks and stubs for a downloader def mock_downloader(downloader_klass) tempfile = mock("tempfile") diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index b31537207..ce425494a 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -30,18 +30,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase end should "not raise an exception if validation_key_path is set" do - @env = mock_environment do |config| + @env = vagrant_env(vagrantfile(<<-vf)) config.chef.validation_key_path = "7" - end + config.chef.chef_server_url = "7" + vf @action.stubs(:env).returns(@env) assert_nothing_raised { @action.prepare } end should "raise an exception if validation_key_path is nil" do - @env = mock_environment do |config| + @env = vagrant_env(vagrantfile(<<-vf)) config.chef.validation_key_path = nil - end + vf @action.stubs(:env).returns(@env) @@ -51,21 +52,20 @@ class ChefServerProvisionerTest < Test::Unit::TestCase end should "not raise an exception if validation_key_path does exist" do - @env = mock_environment do |config| - config.chef.validation_key_path = "7" - end + @env = vagrant_env(vagrantfile(<<-vf)) + config.chef.validation_key_path = "#{vagrantfile(tmp_path)}" + config.chef.chef_server_url = "7" + vf @action.stubs(:env).returns(@env) - @action.stubs(:validation_key_path).returns("9") - - File.expects(:file?).with(@action.validation_key_path).returns(true) assert_nothing_raised { @action.prepare } end should "raise an exception if validation_key_path doesn't exist" do - @env = mock_environment do |config| + @env = vagrant_env(vagrantfile(<<-vf)) config.chef.validation_key_path = "7" - end + config.chef.chef_server_url = "7" + vf @action.stubs(:env).returns(@env) @action.stubs(:validation_key_path).returns("9") @@ -77,18 +77,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase end should "not raise an exception if chef_server_url is set" do - @env = mock_environment do |config| + @env = vagrant_env(vagrantfile(<<-vf)) + config.chef.validation_key_path = "#{vagrantfile(tmp_path)}" config.chef.chef_server_url = "7" - end + vf @action.stubs(:env).returns(@env) assert_nothing_raised { @action.prepare } end should "raise an exception if chef_server_url is nil" do - @env = mock_environment do |config| + @env = vagrant_env(vagrantfile(<<-vf)) config.chef.chef_server_url = nil - end + vf @action.stubs(:env).returns(@env) diff --git a/test/vagrant/ssh_test.rb b/test/vagrant/ssh_test.rb index 592ed20e5..e4106e122 100644 --- a/test/vagrant/ssh_test.rb +++ b/test/vagrant/ssh_test.rb @@ -2,11 +2,7 @@ require "test_helper" class SshTest < Test::Unit::TestCase def mock_ssh - @env = mock_environment do |config| - yield config if block_given? - end - - @forwarded_ports = [] + @env = vagrant_env @network_adapters = [] @vm = mock("vm") @vm.stubs(:network_adapters).returns(@network_adapters) @@ -18,7 +14,7 @@ class SshTest < Test::Unit::TestCase end setup do - VirtualBox.stubs(:version).returns("3.1.4") + VirtualBox.stubs(:version).returns("3.2.4") end context "connecting to external SSH" do diff --git a/test/vagrant/systems/linux_test.rb b/test/vagrant/systems/linux_test.rb index 2e3000142..dfea92d70 100644 --- a/test/vagrant/systems/linux_test.rb +++ b/test/vagrant/systems/linux_test.rb @@ -100,10 +100,10 @@ class LinuxSystemTest < Test::Unit::TestCase should "add uid AND gid to mount" do uid = "foo" gid = "bar" - env = mock_environment do |config| - config.vm.shared_folder_uid = uid - config.vm.shared_folder_gid = gid - end + env = vagrant_env(vagrantfile(<<-vf)) + config.vm.shared_folder_uid = "#{uid}" + config.vm.shared_folder_gid = "#{gid}" + vf @vm.stubs(:env).returns(env)