From a0ed4d0da850fd70a6f6de2d143c772dc99206ad Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 8 Sep 2010 23:56:35 -0700 Subject: [PATCH] Get rid of "mock_action_data" use "action_env" instead --- test/test_helper.rb | 10 +--------- test/vagrant/action/env/set_test.rb | 2 +- test/vagrant/action/general/package_test.rb | 2 +- test/vagrant/action/vm/boot_test.rb | 2 +- test/vagrant/action/vm/clean_machine_folder_test.rb | 2 +- test/vagrant/action/vm/clear_forwarded_ports_test.rb | 2 +- test/vagrant/action/vm/clear_nfs_exports_test.rb | 2 +- test/vagrant/action/vm/clear_shared_folders_test.rb | 2 +- test/vagrant/action/vm/customize_test.rb | 2 +- test/vagrant/action/vm/destroy_test.rb | 2 +- .../vm/destroy_unused_network_interfaces_test.rb | 2 +- test/vagrant/action/vm/disable_networks_test.rb | 2 +- test/vagrant/action/vm/discard_state_test.rb | 2 +- test/vagrant/action/vm/export_test.rb | 2 +- test/vagrant/action/vm/forward_ports_helpers_test.rb | 4 ++-- test/vagrant/action/vm/forward_ports_test.rb | 2 +- test/vagrant/action/vm/halt_test.rb | 2 +- test/vagrant/action/vm/import_test.rb | 2 +- test/vagrant/action/vm/match_mac_address_test.rb | 2 +- test/vagrant/action/vm/network_test.rb | 2 +- test/vagrant/action/vm/nfs_helpers_test.rb | 8 +++++--- test/vagrant/action/vm/package_test.rb | 2 +- test/vagrant/action/vm/package_vagrantfile_test.rb | 2 +- test/vagrant/action/vm/provision_test.rb | 2 +- test/vagrant/action/vm/resume_test.rb | 2 +- test/vagrant/action/vm/share_folders_test.rb | 2 +- test/vagrant/action/vm/suspend_test.rb | 2 +- 27 files changed, 32 insertions(+), 38 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 14622dd95..e42ff6692 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -37,20 +37,12 @@ class Test::Unit::TestCase vm end - def mock_action_data(v_env=nil) - v_env ||= vagrant_env - app = lambda { |env| } - env = Vagrant::Action::Environment.new(v_env) - env["vagrant.test"] = true - [app, env] - end - # Sets up the mocks and stubs for a downloader def mock_downloader(downloader_klass) tempfile = mock("tempfile") tempfile.stubs(:write) - _, env = mock_action_data + _, env = action_env [downloader_klass.new(env), tempfile] end end diff --git a/test/vagrant/action/env/set_test.rb b/test/vagrant/action/env/set_test.rb index 4beaa07b7..8aea4c2b6 100644 --- a/test/vagrant/action/env/set_test.rb +++ b/test/vagrant/action/env/set_test.rb @@ -3,7 +3,7 @@ require "test_helper" class SetEnvActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::Env::Set - @app, @env = mock_action_data + @app, @env = action_env @env.clear end diff --git a/test/vagrant/action/general/package_test.rb b/test/vagrant/action/general/package_test.rb index 1ca225d2f..bd376ef45 100644 --- a/test/vagrant/action/general/package_test.rb +++ b/test/vagrant/action/general/package_test.rb @@ -3,7 +3,7 @@ require "test_helper" class PackageGeneralActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::General::Package - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/boot_test.rb b/test/vagrant/action/vm/boot_test.rb index 6fbb0e30b..481770e4e 100644 --- a/test/vagrant/action/vm/boot_test.rb +++ b/test/vagrant/action/vm/boot_test.rb @@ -3,7 +3,7 @@ require "test_helper" class BootVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Boot - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:ssh).returns(mock("ssh")) diff --git a/test/vagrant/action/vm/clean_machine_folder_test.rb b/test/vagrant/action/vm/clean_machine_folder_test.rb index 3bd3f15ca..809714faa 100644 --- a/test/vagrant/action/vm/clean_machine_folder_test.rb +++ b/test/vagrant/action/vm/clean_machine_folder_test.rb @@ -3,7 +3,7 @@ require "test_helper" class CleanMachineFolderVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::CleanMachineFolder - @app, @env = mock_action_data + @app, @env = action_env @instance = @klass.new(@app, @env) end diff --git a/test/vagrant/action/vm/clear_forwarded_ports_test.rb b/test/vagrant/action/vm/clear_forwarded_ports_test.rb index 53b9b5819..46e0fc27c 100644 --- a/test/vagrant/action/vm/clear_forwarded_ports_test.rb +++ b/test/vagrant/action/vm/clear_forwarded_ports_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ClearForwardedPortsVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::ClearForwardedPorts - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/clear_nfs_exports_test.rb b/test/vagrant/action/vm/clear_nfs_exports_test.rb index c789268fb..f2ab8da04 100644 --- a/test/vagrant/action/vm/clear_nfs_exports_test.rb +++ b/test/vagrant/action/vm/clear_nfs_exports_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ClearNFSExportsActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::ClearNFSExports - @app, @env = mock_action_data + @app, @env = action_env @env.env.stubs(:host).returns(Vagrant::Hosts::Base.new(@env)) @instance = @klass.new(@app, @env) diff --git a/test/vagrant/action/vm/clear_shared_folders_test.rb b/test/vagrant/action/vm/clear_shared_folders_test.rb index 468b8cd0b..dab4ea7fe 100644 --- a/test/vagrant/action/vm/clear_shared_folders_test.rb +++ b/test/vagrant/action/vm/clear_shared_folders_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ClearSharedFoldersVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::ClearSharedFolders - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/customize_test.rb b/test/vagrant/action/vm/customize_test.rb index 328bc77c5..7c53476fd 100644 --- a/test/vagrant/action/vm/customize_test.rb +++ b/test/vagrant/action/vm/customize_test.rb @@ -3,7 +3,7 @@ require "test_helper" class CustomizeVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Customize - @app, @env = mock_action_data + @app, @env = action_env @instance = @klass.new(@app, @env) @vm = mock("vm") diff --git a/test/vagrant/action/vm/destroy_test.rb b/test/vagrant/action/vm/destroy_test.rb index 9d091e497..9b4a382bf 100644 --- a/test/vagrant/action/vm/destroy_test.rb +++ b/test/vagrant/action/vm/destroy_test.rb @@ -3,7 +3,7 @@ require "test_helper" class DestroyVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Destroy - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb b/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb index ec314c8ed..95cc12f8d 100644 --- a/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +++ b/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb @@ -3,7 +3,7 @@ require "test_helper" class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::DestroyUnusedNetworkInterfaces - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/disable_networks_test.rb b/test/vagrant/action/vm/disable_networks_test.rb index 6fafc6691..63c9e6fae 100644 --- a/test/vagrant/action/vm/disable_networks_test.rb +++ b/test/vagrant/action/vm/disable_networks_test.rb @@ -3,7 +3,7 @@ require "test_helper" class DisableNetworksVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::DisableNetworks - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env.env.stubs(:vm).returns(@vm) diff --git a/test/vagrant/action/vm/discard_state_test.rb b/test/vagrant/action/vm/discard_state_test.rb index 3e710b2e6..cc1807553 100644 --- a/test/vagrant/action/vm/discard_state_test.rb +++ b/test/vagrant/action/vm/discard_state_test.rb @@ -3,7 +3,7 @@ require "test_helper" class DiscardStateVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::DiscardState - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/export_test.rb b/test/vagrant/action/vm/export_test.rb index 1560159ea..ae3d2af3c 100644 --- a/test/vagrant/action/vm/export_test.rb +++ b/test/vagrant/action/vm/export_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ExportVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Export - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/forward_ports_helpers_test.rb b/test/vagrant/action/vm/forward_ports_helpers_test.rb index 3f9678835..d4aefcabc 100644 --- a/test/vagrant/action/vm/forward_ports_helpers_test.rb +++ b/test/vagrant/action/vm/forward_ports_helpers_test.rb @@ -3,11 +3,11 @@ require "test_helper" class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase setup do @klass = Class.new do + include Vagrant::Action::VM::ForwardPortsHelpers def initialize(env); @env = env; end end - @klass.send(:include, Vagrant::Action::VM::ForwardPortsHelpers) - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/forward_ports_test.rb b/test/vagrant/action/vm/forward_ports_test.rb index 4fe4ceb4a..31378443a 100644 --- a/test/vagrant/action/vm/forward_ports_test.rb +++ b/test/vagrant/action/vm/forward_ports_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ForwardPortsVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::ForwardPorts - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/halt_test.rb b/test/vagrant/action/vm/halt_test.rb index 32f3903c1..47087f2e4 100644 --- a/test/vagrant/action/vm/halt_test.rb +++ b/test/vagrant/action/vm/halt_test.rb @@ -3,7 +3,7 @@ require "test_helper" class HaltVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Halt - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/import_test.rb b/test/vagrant/action/vm/import_test.rb index d1344f2b0..a7ef57726 100644 --- a/test/vagrant/action/vm/import_test.rb +++ b/test/vagrant/action/vm/import_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ImportVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Import - @app, @env = mock_action_data + @app, @env = action_env @instance = @klass.new(@app, @env) ovf_file = "foo" diff --git a/test/vagrant/action/vm/match_mac_address_test.rb b/test/vagrant/action/vm/match_mac_address_test.rb index bb44d9615..a4a6f5384 100644 --- a/test/vagrant/action/vm/match_mac_address_test.rb +++ b/test/vagrant/action/vm/match_mac_address_test.rb @@ -3,7 +3,7 @@ require "test_helper" class MatchMACAddressVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::MatchMACAddress - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/network_test.rb b/test/vagrant/action/vm/network_test.rb index bce96d70e..924d50b02 100644 --- a/test/vagrant/action/vm/network_test.rb +++ b/test/vagrant/action/vm/network_test.rb @@ -3,7 +3,7 @@ require "test_helper" class NetworkVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Network - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/nfs_helpers_test.rb b/test/vagrant/action/vm/nfs_helpers_test.rb index 0456e9c4d..f8f4c702f 100644 --- a/test/vagrant/action/vm/nfs_helpers_test.rb +++ b/test/vagrant/action/vm/nfs_helpers_test.rb @@ -2,9 +2,11 @@ require "test_helper" class NFSHelpersVMActionTest < Test::Unit::TestCase setup do - @klass = Class.new - @klass.send(:include, Vagrant::Action::VM::NFSHelpers) - @app, @env = mock_action_data + @klass = Class.new do + include Vagrant::Action::VM::NFSHelpers + end + + @app, @env = action_env @instance = @klass.new end diff --git a/test/vagrant/action/vm/package_test.rb b/test/vagrant/action/vm/package_test.rb index 2f79bf729..b5350c426 100644 --- a/test/vagrant/action/vm/package_test.rb +++ b/test/vagrant/action/vm/package_test.rb @@ -3,7 +3,7 @@ require "test_helper" class PackageVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Package - @app, @env = mock_action_data + @app, @env = action_env @env["export.temp_dir"] = "foo" @instance = @klass.new(@app, @env) diff --git a/test/vagrant/action/vm/package_vagrantfile_test.rb b/test/vagrant/action/vm/package_vagrantfile_test.rb index b35b59862..f918d5de2 100644 --- a/test/vagrant/action/vm/package_vagrantfile_test.rb +++ b/test/vagrant/action/vm/package_vagrantfile_test.rb @@ -3,7 +3,7 @@ require "test_helper" class PackageVagrantfileVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::PackageVagrantfile - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/provision_test.rb b/test/vagrant/action/vm/provision_test.rb index a43a9fbfe..6a683df43 100644 --- a/test/vagrant/action/vm/provision_test.rb +++ b/test/vagrant/action/vm/provision_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ProvisionVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Provision - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/resume_test.rb b/test/vagrant/action/vm/resume_test.rb index 942628d77..95a33020c 100644 --- a/test/vagrant/action/vm/resume_test.rb +++ b/test/vagrant/action/vm/resume_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ResumeVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Resume - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm diff --git a/test/vagrant/action/vm/share_folders_test.rb b/test/vagrant/action/vm/share_folders_test.rb index 704747147..d33b6f49d 100644 --- a/test/vagrant/action/vm/share_folders_test.rb +++ b/test/vagrant/action/vm/share_folders_test.rb @@ -3,7 +3,7 @@ require "test_helper" class ShareFoldersVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::ShareFolders - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:name).returns("foo") diff --git a/test/vagrant/action/vm/suspend_test.rb b/test/vagrant/action/vm/suspend_test.rb index bd4f7f5d3..2f94cdf0a 100644 --- a/test/vagrant/action/vm/suspend_test.rb +++ b/test/vagrant/action/vm/suspend_test.rb @@ -3,7 +3,7 @@ require "test_helper" class SuspendVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Suspend - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm