2010-09-04 02:25:48 +00:00
|
|
|
# Add this folder to the load path for "test_helper"
|
|
|
|
$:.unshift(File.dirname(__FILE__))
|
2010-01-22 05:36:34 +00:00
|
|
|
|
2010-09-04 02:25:48 +00:00
|
|
|
require 'vagrant'
|
2010-09-04 03:39:44 +00:00
|
|
|
require 'mario'
|
2010-01-22 05:54:23 +00:00
|
|
|
require 'contest'
|
2010-01-22 07:57:31 +00:00
|
|
|
require 'mocha'
|
2010-07-20 03:32:07 +00:00
|
|
|
|
2010-09-07 08:19:11 +00:00
|
|
|
# Try to load ruby debug since its useful if it is available.
|
|
|
|
# But not a big deal if its not available (probably on a non-MRI
|
|
|
|
# platform)
|
|
|
|
begin
|
|
|
|
require 'ruby-debug'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
2010-09-04 03:39:44 +00:00
|
|
|
# Silence Mario by sending log output to black hole
|
|
|
|
Mario::Platform.logger(nil)
|
|
|
|
|
2010-08-27 04:56:38 +00:00
|
|
|
# Add the I18n locale for tests
|
|
|
|
I18n.load_path << File.expand_path("../locales/en.yml", __FILE__)
|
|
|
|
|
2010-01-30 04:38:36 +00:00
|
|
|
class Test::Unit::TestCase
|
2010-09-15 15:19:38 +00:00
|
|
|
include Vagrant::TestHelpers
|
2010-09-04 02:25:48 +00:00
|
|
|
|
2010-05-08 04:40:32 +00:00
|
|
|
# Sets up the mocks for a VM
|
2010-05-08 04:45:40 +00:00
|
|
|
def mock_vm(env=nil)
|
2010-09-07 18:41:52 +00:00
|
|
|
env ||= vagrant_env
|
2010-05-08 21:57:31 +00:00
|
|
|
vm = Vagrant::VM.new
|
2010-05-08 04:45:40 +00:00
|
|
|
vm.stubs(:env).returns(env)
|
2010-05-08 04:40:32 +00:00
|
|
|
vm.stubs(:ssh).returns(Vagrant::SSH.new(vm.env))
|
|
|
|
vm
|
|
|
|
end
|
|
|
|
|
2010-03-01 05:42:38 +00:00
|
|
|
# Sets up the mocks and stubs for a downloader
|
|
|
|
def mock_downloader(downloader_klass)
|
|
|
|
tempfile = mock("tempfile")
|
|
|
|
tempfile.stubs(:write)
|
|
|
|
|
2010-09-09 06:56:35 +00:00
|
|
|
_, env = action_env
|
2010-07-24 16:07:37 +00:00
|
|
|
[downloader_klass.new(env), tempfile]
|
2010-03-01 05:42:38 +00:00
|
|
|
end
|
2010-01-30 07:22:03 +00:00
|
|
|
end
|
2010-03-15 05:34:48 +00:00
|
|
|
|