vagrantup 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Rakefile +3 -3
  4. data/VERSION +1 -1
  5. data/bin/vagrant +5 -13
  6. data/config/default.rb +1 -0
  7. data/keys/README.md +8 -1
  8. data/keys/vagrant.ppk +26 -0
  9. data/lib/vagrant.rb +3 -3
  10. data/lib/vagrant/actions/base.rb +15 -4
  11. data/lib/vagrant/actions/box/add.rb +1 -1
  12. data/lib/vagrant/actions/box/download.rb +72 -66
  13. data/lib/vagrant/actions/box/unpackage.rb +1 -4
  14. data/lib/vagrant/actions/runner.rb +1 -1
  15. data/lib/vagrant/actions/vm/boot.rb +5 -7
  16. data/lib/vagrant/actions/vm/customize.rb +2 -2
  17. data/lib/vagrant/actions/vm/destroy.rb +2 -2
  18. data/lib/vagrant/actions/vm/down.rb +7 -0
  19. data/lib/vagrant/actions/vm/export.rb +10 -4
  20. data/lib/vagrant/actions/vm/forward_ports.rb +5 -15
  21. data/lib/vagrant/actions/vm/halt.rb +5 -3
  22. data/lib/vagrant/actions/vm/import.rb +10 -3
  23. data/lib/vagrant/actions/vm/move_hard_drive.rb +1 -3
  24. data/lib/vagrant/actions/vm/package.rb +33 -10
  25. data/lib/vagrant/actions/vm/provision.rb +4 -4
  26. data/lib/vagrant/actions/vm/reload.rb +1 -1
  27. data/lib/vagrant/actions/vm/resume.rb +1 -1
  28. data/lib/vagrant/actions/vm/shared_folders.rb +7 -7
  29. data/lib/vagrant/actions/vm/start.rb +3 -2
  30. data/lib/vagrant/actions/vm/suspend.rb +2 -2
  31. data/lib/vagrant/actions/vm/up.rb +7 -17
  32. data/lib/vagrant/active_list.rb +52 -45
  33. data/lib/vagrant/box.rb +18 -11
  34. data/lib/vagrant/busy.rb +7 -0
  35. data/lib/vagrant/command.rb +27 -0
  36. data/lib/vagrant/commands/base.rb +163 -0
  37. data/lib/vagrant/commands/box.rb +16 -0
  38. data/lib/vagrant/commands/box/add.rb +24 -0
  39. data/lib/vagrant/commands/box/list.rb +30 -0
  40. data/lib/vagrant/commands/box/remove.rb +31 -0
  41. data/lib/vagrant/commands/destroy.rb +23 -0
  42. data/lib/vagrant/commands/down.rb +16 -0
  43. data/lib/vagrant/commands/halt.rb +23 -0
  44. data/lib/vagrant/commands/init.rb +32 -0
  45. data/lib/vagrant/commands/package.rb +46 -0
  46. data/lib/vagrant/commands/reload.rb +22 -0
  47. data/lib/vagrant/commands/resume.rb +22 -0
  48. data/lib/vagrant/commands/ssh.rb +22 -0
  49. data/lib/vagrant/commands/ssh_config.rb +30 -0
  50. data/lib/vagrant/commands/status.rb +58 -0
  51. data/lib/vagrant/commands/suspend.rb +23 -0
  52. data/lib/vagrant/commands/up.rb +26 -0
  53. data/lib/vagrant/config.rb +21 -11
  54. data/lib/vagrant/downloaders/file.rb +5 -5
  55. data/lib/vagrant/downloaders/http.rb +10 -15
  56. data/lib/vagrant/environment.rb +259 -0
  57. data/lib/vagrant/provisioners/base.rb +7 -0
  58. data/lib/vagrant/provisioners/chef.rb +24 -9
  59. data/lib/vagrant/provisioners/chef_server.rb +23 -48
  60. data/lib/vagrant/provisioners/chef_solo.rb +48 -22
  61. data/lib/vagrant/ssh.rb +95 -46
  62. data/lib/vagrant/util.rb +2 -2
  63. data/lib/vagrant/util/errors.rb +36 -0
  64. data/lib/vagrant/util/platform.rb +12 -0
  65. data/lib/vagrant/util/progress_meter.rb +33 -0
  66. data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
  67. data/lib/vagrant/util/template_renderer.rb +83 -0
  68. data/lib/vagrant/vm.rb +1 -0
  69. data/templates/{Vagrantfile → Vagrantfile.erb} +2 -2
  70. data/templates/chef_server_client.erb +16 -0
  71. data/templates/chef_solo_solo.erb +4 -0
  72. data/templates/errors.yml +157 -0
  73. data/templates/package_Vagrantfile.erb +11 -0
  74. data/templates/ssh_config.erb +7 -0
  75. data/test/test_helper.rb +12 -15
  76. data/test/vagrant/actions/box/add_test.rb +1 -2
  77. data/test/vagrant/actions/box/destroy_test.rb +0 -1
  78. data/test/vagrant/actions/box/download_test.rb +40 -15
  79. data/test/vagrant/actions/box/unpackage_test.rb +2 -3
  80. data/test/vagrant/actions/collection_test.rb +8 -5
  81. data/test/vagrant/actions/runner_test.rb +8 -6
  82. data/test/vagrant/actions/vm/boot_test.rb +12 -11
  83. data/test/vagrant/actions/vm/customize_test.rb +2 -3
  84. data/test/vagrant/actions/vm/destroy_test.rb +2 -3
  85. data/test/vagrant/actions/vm/down_test.rb +16 -3
  86. data/test/vagrant/actions/vm/export_test.rb +4 -5
  87. data/test/vagrant/actions/vm/forward_ports_test.rb +6 -5
  88. data/test/vagrant/actions/vm/halt_test.rb +8 -2
  89. data/test/vagrant/actions/vm/import_test.rb +5 -5
  90. data/test/vagrant/actions/vm/move_hard_drive_test.rb +4 -6
  91. data/test/vagrant/actions/vm/package_test.rb +60 -22
  92. data/test/vagrant/actions/vm/provision_test.rb +7 -16
  93. data/test/vagrant/actions/vm/reload_test.rb +3 -2
  94. data/test/vagrant/actions/vm/resume_test.rb +0 -1
  95. data/test/vagrant/actions/vm/shared_folders_test.rb +17 -12
  96. data/test/vagrant/actions/vm/start_test.rb +10 -3
  97. data/test/vagrant/actions/vm/suspend_test.rb +1 -2
  98. data/test/vagrant/actions/vm/up_test.rb +19 -11
  99. data/test/vagrant/active_list_test.rb +148 -129
  100. data/test/vagrant/box_test.rb +26 -14
  101. data/test/vagrant/busy_test.rb +15 -6
  102. data/test/vagrant/command_test.rb +53 -0
  103. data/test/vagrant/commands/base_test.rb +118 -0
  104. data/test/vagrant/commands/box/add_test.rb +34 -0
  105. data/test/vagrant/commands/box/list_test.rb +32 -0
  106. data/test/vagrant/commands/box/remove_test.rb +41 -0
  107. data/test/vagrant/commands/destroy_test.rb +32 -0
  108. data/test/vagrant/commands/down_test.rb +17 -0
  109. data/test/vagrant/commands/halt_test.rb +28 -0
  110. data/test/vagrant/commands/init_test.rb +55 -0
  111. data/test/vagrant/commands/package_test.rb +84 -0
  112. data/test/vagrant/commands/reload_test.rb +28 -0
  113. data/test/vagrant/commands/resume_test.rb +33 -0
  114. data/test/vagrant/commands/ssh_config_test.rb +54 -0
  115. data/test/vagrant/commands/ssh_test.rb +32 -0
  116. data/test/vagrant/commands/status_test.rb +20 -0
  117. data/test/vagrant/commands/suspend_test.rb +33 -0
  118. data/test/vagrant/commands/up_test.rb +41 -0
  119. data/test/vagrant/config_test.rb +42 -17
  120. data/test/vagrant/downloaders/file_test.rb +7 -0
  121. data/test/vagrant/downloaders/http_test.rb +12 -0
  122. data/test/vagrant/environment_test.rb +595 -0
  123. data/test/vagrant/provisioners/base_test.rb +7 -1
  124. data/test/vagrant/provisioners/chef_server_test.rb +41 -51
  125. data/test/vagrant/provisioners/chef_solo_test.rb +93 -62
  126. data/test/vagrant/provisioners/chef_test.rb +61 -15
  127. data/test/vagrant/ssh_test.rb +166 -38
  128. data/test/vagrant/util/errors_test.rb +57 -0
  129. data/test/vagrant/util/progress_meter_test.rb +33 -0
  130. data/test/vagrant/{stacked_proc_runner_test.rb → util/stacked_proc_runner_test.rb} +3 -3
  131. data/test/vagrant/util/template_renderer_test.rb +138 -0
  132. data/test/vagrant/vm_test.rb +3 -2
  133. data/vagrant.gemspec +88 -33
  134. metadata +92 -49
  135. data/bin/vagrant-box +0 -34
  136. data/bin/vagrant-down +0 -27
  137. data/bin/vagrant-halt +0 -28
  138. data/bin/vagrant-init +0 -27
  139. data/bin/vagrant-package +0 -29
  140. data/bin/vagrant-reload +0 -29
  141. data/bin/vagrant-resume +0 -27
  142. data/bin/vagrant-ssh +0 -27
  143. data/bin/vagrant-status +0 -29
  144. data/bin/vagrant-suspend +0 -27
  145. data/bin/vagrant-up +0 -29
  146. data/lib/vagrant/commands.rb +0 -234
  147. data/lib/vagrant/env.rb +0 -189
  148. data/lib/vagrant/stacked_proc_runner.rb +0 -33
  149. data/test/vagrant/commands_test.rb +0 -269
  150. data/test/vagrant/env_test.rb +0 -418
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsDestroyTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Destroy
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @persisted_vm.stubs(:destroy)
20
+ end
21
+
22
+ should "require a persisted VM" do
23
+ @env.expects(:require_persisted_vm).once
24
+ @instance.execute
25
+ end
26
+
27
+ should "destroy the persisted VM and the VM image" do
28
+ @persisted_vm.expects(:destroy).once
29
+ @instance.execute
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsDownTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Down
6
+
7
+ @env = mock_environment
8
+ @instance = @klass.new(@env)
9
+ end
10
+
11
+ context "executing" do
12
+ should "just error and exit" do
13
+ @instance.expects(:error_and_exit).with(:command_deprecation_down)
14
+ @instance.execute
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsHaltTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Halt
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ should "require a persisted VM" do
19
+ @env.expects(:require_persisted_vm).once
20
+ @instance.execute
21
+ end
22
+
23
+ should "call the `halt` action on the VM" do
24
+ @persisted_vm.expects(:execute!).with(Vagrant::Actions::VM::Halt).once
25
+ @instance.execute
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,55 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsInitTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Init
6
+
7
+ @env = mock_environment
8
+ @instance = @klass.new(@env)
9
+ end
10
+
11
+ context "execute" do
12
+ should "create the vagrantfile with the first arg" do
13
+ args = [:foo]
14
+ @instance.expects(:create_vagrantfile).with(args.first)
15
+ @instance.execute(args)
16
+ end
17
+ end
18
+
19
+ context "creating the vagrantfile" do
20
+ setup do
21
+ @file = mock("file")
22
+ @file.stubs(:write)
23
+ File.stubs(:open).yields(@file)
24
+ @rootfile_path = File.join(Dir.pwd, Vagrant::Environment::ROOTFILE_NAME)
25
+
26
+ Vagrant::Util::TemplateRenderer.stubs(:render)
27
+ end
28
+
29
+ should "error and exit if a rootfile already exists" do
30
+ File.expects(:exist?).with(@rootfile_path).returns(true)
31
+ @instance.expects(:error_and_exit).with(:rootfile_already_exists).once
32
+ @instance.create_vagrantfile
33
+ end
34
+
35
+ should "write to the rootfile path using the template renderer" do
36
+ result = "foo"
37
+ Vagrant::Util::TemplateRenderer.expects(:render).returns(result).once
38
+ @file.expects(:write).with(result).once
39
+ File.expects(:open).with(@rootfile_path, 'w+').yields(@file)
40
+
41
+ @instance.create_vagrantfile
42
+ end
43
+
44
+ should "use the given base box if given" do
45
+ box = "zooo"
46
+ Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => box)
47
+ @instance.create_vagrantfile(box)
48
+ end
49
+
50
+ should "use the default `base` if no box is given" do
51
+ Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base")
52
+ @instance.create_vagrantfile
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,84 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsPackageTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Package
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @persisted_vm.stubs(:package)
20
+ @persisted_vm.stubs(:powered_off?).returns(true)
21
+ end
22
+
23
+ context "with no base specified" do
24
+ should "require a persisted vm" do
25
+ @env.expects(:require_persisted_vm).once
26
+ @instance.execute
27
+ end
28
+ end
29
+
30
+ context "with base specified" do
31
+ setup do
32
+ @vm = mock("vm")
33
+
34
+ Vagrant::VM.stubs(:find).with(@name).returns(@vm)
35
+ @vm.stubs(:env=).with(@env)
36
+ @env.stubs(:vm=)
37
+
38
+ @name = "bar"
39
+ end
40
+
41
+ should "find the given base and set it on the env" do
42
+ Vagrant::VM.expects(:find).with(@name).returns(@vm)
43
+ @vm.expects(:env=).with(@env)
44
+ @env.expects(:vm=).with(@vm)
45
+
46
+ @instance.execute(["foo", "--base", @name])
47
+ end
48
+
49
+ should "error if the VM is not found" do
50
+ Vagrant::VM.expects(:find).with(@name).returns(nil)
51
+ @instance.expects(:error_and_exit).with(:vm_base_not_found, :name => @name).once
52
+
53
+ @instance.execute(["foo", "--base", @name])
54
+ end
55
+ end
56
+
57
+ context "shared (with and without base specified)" do
58
+ should "error and exit if the VM is not powered off" do
59
+ @persisted_vm.stubs(:powered_off?).returns(false)
60
+ @instance.expects(:error_and_exit).with(:vm_power_off_to_package).once
61
+ @persisted_vm.expects(:package).never
62
+ @instance.execute
63
+ end
64
+
65
+ should "call package on the persisted VM" do
66
+ @persisted_vm.expects(:package).once
67
+ @instance.execute
68
+ end
69
+
70
+ should "pass the out path and include_files to the package method" do
71
+ out_path = mock("out_path")
72
+ include_files = "foo"
73
+ @persisted_vm.expects(:package).with(out_path, [include_files]).once
74
+ @instance.execute([out_path, "--include", include_files])
75
+ end
76
+
77
+ should "default to an empty array when not include_files are specified" do
78
+ out_path = mock("out_path")
79
+ @persisted_vm.expects(:package).with(out_path, []).once
80
+ @instance.execute([out_path])
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsReloadTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Reload
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ should "require a persisted VM" do
19
+ @env.expects(:require_persisted_vm).once
20
+ @instance.execute
21
+ end
22
+
23
+ should "call the `reload` action on the VM" do
24
+ @persisted_vm.expects(:execute!).with(Vagrant::Actions::VM::Reload).once
25
+ @instance.execute
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsResumeTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Resume
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @persisted_vm.stubs(:resume)
20
+ @persisted_vm.stubs(:saved?).returns(true)
21
+ end
22
+
23
+ should "require a persisted VM" do
24
+ @env.expects(:require_persisted_vm).once
25
+ @instance.execute
26
+ end
27
+
28
+ should "save the state of the VM" do
29
+ @persisted_vm.expects(:resume).once
30
+ @instance.execute
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsSSHConfigTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::SSHConfig
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @ssh = mock("ssh")
20
+ @ssh.stubs(:port).returns(2197)
21
+ @env.stubs(:ssh).returns(@ssh)
22
+ @env.stubs(:require_root_path)
23
+
24
+ @instance.stubs(:puts)
25
+
26
+ @data = {
27
+ :host_key => "vagrant",
28
+ :ssh_user => @env.config.ssh.username,
29
+ :ssh_port => @env.ssh.port,
30
+ :private_key_path => @env.config.ssh.private_key_path
31
+ }
32
+ end
33
+
34
+ should "require root path" do
35
+ @env.expects(:require_root_path).once
36
+ @instance.execute
37
+ end
38
+
39
+ should "output rendered template" do
40
+ result = mock("result")
41
+ Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)
42
+
43
+ @instance.expects(:puts).with(result).once
44
+ @instance.execute
45
+ end
46
+
47
+ should "render with the given host name if given" do
48
+ host = "foo"
49
+ @data[:host_key] = host
50
+ Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
51
+ @instance.execute(["--host", host])
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsSSHTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::SSH
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @env.ssh.stubs(:connect)
20
+ end
21
+
22
+ should "require a persisted VM" do
23
+ @env.expects(:require_persisted_vm).once
24
+ @instance.execute
25
+ end
26
+
27
+ should "connect to SSH" do
28
+ @env.ssh.expects(:connect).once
29
+ @instance.execute
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsStatusTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Status
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ # TODO
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsSuspendTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Suspend
6
+
7
+ @persisted_vm = mock("persisted_vm")
8
+ @persisted_vm.stubs(:execute!)
9
+
10
+ @env = mock_environment
11
+ @env.stubs(:require_persisted_vm)
12
+ @env.stubs(:vm).returns(@persisted_vm)
13
+
14
+ @instance = @klass.new(@env)
15
+ end
16
+
17
+ context "executing" do
18
+ setup do
19
+ @persisted_vm.stubs(:suspend)
20
+ @persisted_vm.stubs(:saved?).returns(false)
21
+ end
22
+
23
+ should "require a persisted VM" do
24
+ @env.expects(:require_persisted_vm).once
25
+ @instance.execute
26
+ end
27
+
28
+ should "suspend the VM" do
29
+ @persisted_vm.expects(:suspend).once
30
+ @instance.execute
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsUpTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Up
6
+
7
+ @env = mock_environment
8
+ @instance = @klass.new(@env)
9
+
10
+ @persisted_vm = mock("persisted_vm")
11
+ @persisted_vm.stubs(:execute!)
12
+ end
13
+
14
+ context "executing" do
15
+ setup do
16
+ @new_vm = mock("vm")
17
+ @new_vm.stubs(:execute!)
18
+
19
+ @env.stubs(:vm).returns(nil)
20
+ @env.stubs(:require_box)
21
+ @env.stubs(:create_vm).returns(@new_vm)
22
+ end
23
+
24
+ should "require a box" do
25
+ @env.expects(:require_box).once
26
+ @instance.execute
27
+ end
28
+
29
+ should "call the up action on VM if it doesn't exist" do
30
+ @new_vm.expects(:execute!).with(Vagrant::Actions::VM::Up).once
31
+ @instance.execute
32
+ end
33
+
34
+ should "call start on the persisted vm if it exists" do
35
+ @env.stubs(:vm).returns(@persisted_vm)
36
+ @persisted_vm.expects(:start).once
37
+ @env.expects(:create_vm).never
38
+ @instance.execute
39
+ end
40
+ end
41
+ end