test/test_helper.rb in vagrantup-0.2.0 vs test/test_helper.rb in vagrantup-0.3.0

- old
+ new

@@ -1,12 +1,10 @@ begin require File.expand_path('../.bundle/environment', __FILE__) rescue LoadError # Fallback on doing the resolve at runtime. require "rubygems" - require "bundler" - Bundler.setup end # ruby-debug, not necessary, but useful if we have it begin require 'ruby-debug' @@ -16,14 +14,16 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'vagrant') require 'contest' require 'mocha' class Test::Unit::TestCase - # Clears the previous config and sets up the new config - def mock_config - Vagrant::Config.reset! + # Mocks an environment, setting it up with the given config. + def mock_environment + environment = Vagrant::Environment.new + Vagrant::Config.reset!(environment) + Vagrant::Config.run do |config| config.vagrant.dotfile_name = ".vagrant" config.ssh.username = "foo" config.ssh.password = "bar" @@ -47,12 +47,14 @@ # Chef config.chef.chef_server_url = "http://localhost:4000" config.chef.validation_key_path = "validation.pem" config.chef.client_key_path = "/zoo/foo/bar.pem" + config.chef.node_name = "baz" config.chef.cookbooks_path = "cookbooks" config.chef.provisioning_path = "/tmp/vagrant-chef" + config.chef.log_level = :info config.chef.json = { :recipes => ["vagrant_main"] } config.vagrant.home = '~/.home' @@ -62,17 +64,14 @@ Vagrant::Config.run do |config| yield config end end - if block_given? - Vagrant::Config.run do |config| - yield config - end - end + config = Vagrant::Config.execute! - Vagrant::Config.execute! + environment.instance_variable_set(:@config, config) + environment end # Sets up the mocks and instantiates an action for testing def mock_action(action_klass, *args) vm = mock("vboxvm") @@ -83,15 +82,16 @@ mock_vm.stubs(:vm).returns(vm) mock_vm.stubs(:vm=) mock_vm.stubs(:invoke_callback) mock_vm.stubs(:invoke_around_callback).yields mock_vm.stubs(:actions).returns([action]) + mock_vm.stubs(:env).returns(mock_environment) [mock_vm, vm, action] end - def stub_default_action_dependecies(mock, klass=MockAction) + def stub_default_action_dependecies(mock) mock.stubs(:precedes).returns([]) mock.stubs(:follows).returns([]) end # Sets up the mocks and stubs for a downloader @@ -100,9 +100,6 @@ tempfile.stubs(:write) [downloader_klass.new, tempfile] end end - -class MockAction; end -class MockActionOther; end