vagrant/test/unit/base.rb

70 lines
1.8 KiB
Ruby
Raw Normal View History

require "tmpdir"
require "rubygems"
2014-09-01 22:06:51 +00:00
# Gems
require "checkpoint"
2014-12-09 01:42:00 +00:00
require "webmock/rspec"
require "rspec/its"
# Require Vagrant itself so we can reference the proper
# classes to test.
require "vagrant"
require "vagrant/util/platform"
2011-12-11 23:53:11 +00:00
# Add the test directory to the load path
2011-12-04 03:05:50 +00:00
$:.unshift File.expand_path("../../", __FILE__)
# Load in helpers
require "unit/support/dummy_communicator"
2012-12-23 04:03:39 +00:00
require "unit/support/dummy_provider"
2011-12-11 23:53:11 +00:00
require "unit/support/shared/base_context"
require "unit/support/shared/action_synced_folders_context"
require "unit/support/shared/capability_helpers_context"
require "unit/support/shared/plugin_command_context"
require "unit/support/shared/virtualbox_context"
# Do not buffer output
$stdout.sync = true
$stderr.sync = true
# Create a temporary directory where test vagrant will run. The reason we save
# this to a constant is so we can clean it up later.
VAGRANT_TEST_CWD = Dir.mktmpdir("vagrant-test-cwd")
# Configure RSpec
RSpec.configure do |c|
c.formatter = :documentation
if Vagrant::Util::Platform.windows?
c.filter_run_excluding :skip_windows
else
c.filter_run_excluding :windows
end
if !Vagrant::Util::Which.which("bsdtar")
c.filter_run_excluding :bsdtar
end
c.after(:suite) do
FileUtils.rm_rf(VAGRANT_TEST_CWD)
end
end
# Configure VAGRANT_CWD so that the tests never find an actual
# Vagrantfile anywhere, or at least this minimizes those chances.
ENV["VAGRANT_CWD"] = VAGRANT_TEST_CWD
2014-01-08 03:26:03 +00:00
# Set the dummy provider to the default for tests
ENV["VAGRANT_DEFAULT_PROVIDER"] = "dummy"
2014-01-08 03:26:03 +00:00
# Unset all host plugins so that we aren't executing subprocess things
# to detect a host for every test.
Vagrant.plugin("2").manager.registered.dup.each do |plugin|
if plugin.components.hosts.to_hash.length > 0
Vagrant.plugin("2").manager.unregister(plugin)
end
end
2014-09-01 22:06:51 +00:00
# Disable checkpoint
Checkpoint.disable!