Helper method to create a new VM on an environment. Interim method.
This commit is contained in:
parent
2fef27ec8b
commit
2661845b5d
|
@ -167,9 +167,13 @@ module Vagrant
|
|||
end
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Methods to persist/unpersist VM
|
||||
# Methods to manage VM
|
||||
#---------------------------------------------------------------
|
||||
|
||||
def create_vm
|
||||
@vm = VM.new
|
||||
end
|
||||
|
||||
def persist_vm
|
||||
# Save to the dotfile for this project
|
||||
File.open(dotfile_path, 'w+') do |f|
|
||||
|
|
|
@ -429,20 +429,33 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
context "persisting/depersisting VM" do
|
||||
context "managing VM" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
|
||||
@dotfile_path = "foo"
|
||||
@env.stubs(:dotfile_path).returns(@dotfile_path)
|
||||
end
|
||||
|
||||
def mock_vm
|
||||
@vm = mock("vm")
|
||||
@vm.stubs(:uuid).returns("foo")
|
||||
@env.stubs(:vm).returns(@vm)
|
||||
end
|
||||
|
||||
context "creating a new VM" do
|
||||
should "create a new VM" do
|
||||
assert_nil @env.vm
|
||||
@env.create_vm
|
||||
assert !@env.vm.nil?
|
||||
assert @env.vm.is_a?(Vagrant::VM)
|
||||
end
|
||||
end
|
||||
|
||||
context "persisting the VM into a file" do
|
||||
setup do
|
||||
mock_vm
|
||||
|
||||
File.stubs(:open)
|
||||
Vagrant::ActiveList.stubs(:add)
|
||||
end
|
||||
|
@ -462,6 +475,8 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
|
||||
context "depersisting the VM" do
|
||||
setup do
|
||||
mock_vm
|
||||
|
||||
File.stubs(:exist?).returns(false)
|
||||
File.stubs(:delete)
|
||||
|
||||
|
|
Loading…
Reference in New Issue