vagrantup 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/README.md +2 -2
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/config/default.rb +13 -3
  7. data/lib/vagrant.rb +10 -13
  8. data/lib/vagrant/actions/base.rb +14 -2
  9. data/lib/vagrant/actions/box/download.rb +2 -7
  10. data/lib/vagrant/actions/box/verify.rb +1 -1
  11. data/lib/vagrant/actions/runner.rb +0 -1
  12. data/lib/vagrant/actions/vm/boot.rb +2 -6
  13. data/lib/vagrant/actions/vm/customize.rb +7 -5
  14. data/lib/vagrant/actions/vm/destroy.rb +4 -3
  15. data/lib/vagrant/actions/vm/down.rb +6 -3
  16. data/lib/vagrant/actions/vm/export.rb +2 -4
  17. data/lib/vagrant/actions/vm/forward_ports.rb +77 -16
  18. data/lib/vagrant/actions/vm/halt.rb +10 -2
  19. data/lib/vagrant/actions/vm/import.rb +2 -4
  20. data/lib/vagrant/actions/vm/move_hard_drive.rb +2 -2
  21. data/lib/vagrant/actions/vm/network.rb +120 -0
  22. data/lib/vagrant/actions/vm/package.rb +11 -7
  23. data/lib/vagrant/actions/vm/provision.rb +3 -3
  24. data/lib/vagrant/actions/vm/reload.rb +2 -9
  25. data/lib/vagrant/actions/vm/shared_folders.rb +19 -39
  26. data/lib/vagrant/actions/vm/start.rb +10 -2
  27. data/lib/vagrant/actions/vm/up.rb +5 -6
  28. data/lib/vagrant/active_list.rb +23 -13
  29. data/lib/vagrant/box.rb +2 -2
  30. data/lib/vagrant/busy.rb +3 -3
  31. data/lib/vagrant/command.rb +2 -2
  32. data/lib/vagrant/commands/base.rb +40 -20
  33. data/lib/vagrant/commands/destroy.rb +17 -3
  34. data/lib/vagrant/commands/halt.rb +23 -3
  35. data/lib/vagrant/commands/package.rb +54 -14
  36. data/lib/vagrant/commands/provision.rb +31 -0
  37. data/lib/vagrant/commands/reload.rb +16 -3
  38. data/lib/vagrant/commands/resume.rb +16 -3
  39. data/lib/vagrant/commands/ssh.rb +25 -3
  40. data/lib/vagrant/commands/ssh_config.rb +20 -5
  41. data/lib/vagrant/commands/status.rb +107 -40
  42. data/lib/vagrant/commands/suspend.rb +16 -3
  43. data/lib/vagrant/commands/up.rb +26 -7
  44. data/lib/vagrant/config.rb +82 -12
  45. data/lib/vagrant/downloaders/base.rb +8 -1
  46. data/lib/vagrant/downloaders/http.rb +31 -19
  47. data/lib/vagrant/environment.rb +146 -49
  48. data/lib/vagrant/provisioners/base.rb +19 -5
  49. data/lib/vagrant/provisioners/chef.rb +12 -4
  50. data/lib/vagrant/provisioners/chef_server.rb +13 -6
  51. data/lib/vagrant/provisioners/chef_solo.rb +7 -3
  52. data/lib/vagrant/resource_logger.rb +126 -0
  53. data/lib/vagrant/ssh.rb +109 -8
  54. data/lib/vagrant/systems/base.rb +70 -0
  55. data/lib/vagrant/systems/linux.rb +137 -0
  56. data/lib/vagrant/util.rb +1 -45
  57. data/lib/vagrant/util/error_helper.rb +13 -0
  58. data/lib/vagrant/util/glob_loader.rb +22 -0
  59. data/lib/vagrant/util/output_helper.rb +9 -0
  60. data/lib/vagrant/util/plain_logger.rb +12 -0
  61. data/lib/vagrant/util/platform.rb +7 -2
  62. data/lib/vagrant/util/template_renderer.rb +2 -2
  63. data/lib/vagrant/util/translator.rb +35 -0
  64. data/lib/vagrant/vm.rb +91 -10
  65. data/templates/crontab_entry.erb +1 -0
  66. data/templates/network_entry.erb +8 -0
  67. data/templates/ssh_config.erb +1 -0
  68. data/templates/{errors.yml → strings.yml} +111 -3
  69. data/templates/sync.erb +14 -0
  70. data/test/test_helper.rb +46 -3
  71. data/test/vagrant/actions/box/download_test.rb +0 -17
  72. data/test/vagrant/actions/vm/boot_test.rb +3 -10
  73. data/test/vagrant/actions/vm/customize_test.rb +6 -0
  74. data/test/vagrant/actions/vm/destroy_test.rb +6 -5
  75. data/test/vagrant/actions/vm/down_test.rb +5 -11
  76. data/test/vagrant/actions/vm/export_test.rb +1 -0
  77. data/test/vagrant/actions/vm/forward_ports_test.rb +92 -15
  78. data/test/vagrant/actions/vm/halt_test.rb +36 -4
  79. data/test/vagrant/actions/vm/import_test.rb +2 -0
  80. data/test/vagrant/actions/vm/network_test.rb +237 -0
  81. data/test/vagrant/actions/vm/package_test.rb +35 -5
  82. data/test/vagrant/actions/vm/provision_test.rb +3 -3
  83. data/test/vagrant/actions/vm/reload_test.rb +1 -1
  84. data/test/vagrant/actions/vm/shared_folders_test.rb +41 -74
  85. data/test/vagrant/actions/vm/start_test.rb +41 -3
  86. data/test/vagrant/actions/vm/up_test.rb +10 -21
  87. data/test/vagrant/active_list_test.rb +28 -43
  88. data/test/vagrant/commands/base_test.rb +25 -4
  89. data/test/vagrant/commands/destroy_test.rb +24 -12
  90. data/test/vagrant/commands/halt_test.rb +33 -11
  91. data/test/vagrant/commands/package_test.rb +77 -57
  92. data/test/vagrant/commands/provision_test.rb +50 -0
  93. data/test/vagrant/commands/reload_test.rb +27 -11
  94. data/test/vagrant/commands/resume_test.rb +25 -14
  95. data/test/vagrant/commands/ssh_config_test.rb +40 -17
  96. data/test/vagrant/commands/ssh_test.rb +52 -13
  97. data/test/vagrant/commands/status_test.rb +21 -1
  98. data/test/vagrant/commands/suspend_test.rb +25 -14
  99. data/test/vagrant/commands/up_test.rb +25 -19
  100. data/test/vagrant/config_test.rb +74 -18
  101. data/test/vagrant/downloaders/base_test.rb +2 -1
  102. data/test/vagrant/downloaders/http_test.rb +18 -8
  103. data/test/vagrant/environment_test.rb +245 -77
  104. data/test/vagrant/provisioners/base_test.rb +4 -4
  105. data/test/vagrant/provisioners/chef_server_test.rb +18 -7
  106. data/test/vagrant/provisioners/chef_solo_test.rb +17 -7
  107. data/test/vagrant/provisioners/chef_test.rb +22 -9
  108. data/test/vagrant/resource_logger_test.rb +144 -0
  109. data/test/vagrant/ssh_session_test.rb +46 -0
  110. data/test/vagrant/ssh_test.rb +42 -2
  111. data/test/vagrant/systems/linux_test.rb +174 -0
  112. data/test/vagrant/util/error_helper_test.rb +5 -0
  113. data/test/vagrant/util/output_helper_test.rb +5 -0
  114. data/test/vagrant/util/plain_logger_test.rb +17 -0
  115. data/test/vagrant/util/platform_test.rb +18 -0
  116. data/test/vagrant/util/{errors_test.rb → translator_test.rb} +25 -21
  117. data/test/vagrant/util_test.rb +12 -49
  118. data/test/vagrant/vm_test.rb +133 -11
  119. data/vagrant.gemspec +39 -15
  120. metadata +38 -14
  121. data/lib/vagrant/commands/down.rb +0 -16
  122. data/lib/vagrant/util/errors.rb +0 -36
  123. data/lib/vagrant/util/progress_meter.rb +0 -33
  124. data/test/vagrant/commands/down_test.rb +0 -17
  125. data/test/vagrant/util/progress_meter_test.rb +0 -33
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class CommandsProvisionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Commands::Provision
6
+ @env = mock_environment
7
+ @instance = @klass.new(@env)
8
+ end
9
+
10
+ context "executing" do
11
+ should "provision all if no name is given" do
12
+ @instance.expects(:all_or_single).with([], :provision).once
13
+ @instance.execute
14
+ end
15
+ end
16
+
17
+ context "provisioning a single VM" do
18
+ setup do
19
+ @foo_vm = mock("vm")
20
+ @foo_vm.stubs(:env).returns(@env)
21
+
22
+ @vm_for_real = mock("vm for real")
23
+ @foo_vm.stubs(:vm).returns(@vm_for_real)
24
+ vms = { :foo => @foo_vm }
25
+ @env.stubs(:vms).returns(vms)
26
+ end
27
+
28
+ should "error and exit if the VM doesn't exist" do
29
+ @env.stubs(:vms).returns({})
30
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => 'foo').once
31
+ @instance.execute(["foo"])
32
+ end
33
+
34
+ should "reload if it's running" do
35
+ @vm_for_real.stubs(:running?).returns(true)
36
+ @foo_vm.expects(:provision).once
37
+ @instance.execute(["foo"])
38
+ end
39
+
40
+ should "do log to info if it's not running" do
41
+ logger = mock("logger")
42
+ logger.expects(:info)
43
+ @env.stubs(:logger).returns(logger)
44
+ @vm_for_real.stubs(:running?).returns(false)
45
+ @foo_vm.expects(:provision).never
46
+ @instance.execute(["foo"])
47
+ end
48
+ end
49
+
50
+ end
@@ -4,25 +4,41 @@ class CommandsReloadTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @klass = Vagrant::Commands::Reload
6
6
 
7
- @persisted_vm = mock("persisted_vm")
8
- @persisted_vm.stubs(:execute!)
9
-
10
7
  @env = mock_environment
11
- @env.stubs(:require_persisted_vm)
12
- @env.stubs(:vm).returns(@persisted_vm)
13
-
14
8
  @instance = @klass.new(@env)
15
9
  end
16
10
 
17
11
  context "executing" do
18
- should "require a persisted VM" do
19
- @env.expects(:require_persisted_vm).once
12
+ should "call all or single for the method" do
13
+ @instance.expects(:all_or_single).with([], :reload)
20
14
  @instance.execute
21
15
  end
16
+ end
22
17
 
23
- should "call the `reload` action on the VM" do
24
- @persisted_vm.expects(:execute!).with(Vagrant::Actions::VM::Reload).once
25
- @instance.execute
18
+ context "reloading a single VM" do
19
+ setup do
20
+ @foo_vm = mock("vm")
21
+ @foo_vm.stubs(:env).returns(@env)
22
+ vms = { :foo => @foo_vm }
23
+ @env.stubs(:vms).returns(vms)
24
+ end
25
+
26
+ should "error and exit if the VM doesn't exist" do
27
+ @env.stubs(:vms).returns({})
28
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
29
+ @instance.reload_single(:foo)
30
+ end
31
+
32
+ should "reload if its created" do
33
+ @foo_vm.stubs(:created?).returns(true)
34
+ @foo_vm.expects(:reload).once
35
+ @instance.execute(["foo"])
36
+ end
37
+
38
+ should "do nothing if its not created" do
39
+ @foo_vm.stubs(:created?).returns(false)
40
+ @foo_vm.expects(:reload).never
41
+ @instance.reload_single(:foo)
26
42
  end
27
43
  end
28
44
  end
@@ -4,30 +4,41 @@ class CommandsResumeTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @klass = Vagrant::Commands::Resume
6
6
 
7
- @persisted_vm = mock("persisted_vm")
8
- @persisted_vm.stubs(:execute!)
9
-
10
7
  @env = mock_environment
11
- @env.stubs(:require_persisted_vm)
12
- @env.stubs(:vm).returns(@persisted_vm)
13
-
14
8
  @instance = @klass.new(@env)
15
9
  end
16
10
 
17
11
  context "executing" do
12
+ should "call all or single for the method" do
13
+ @instance.expects(:all_or_single).with([], :resume)
14
+ @instance.execute
15
+ end
16
+ end
17
+
18
+ context "resuming a single VM" do
18
19
  setup do
19
- @persisted_vm.stubs(:resume)
20
- @persisted_vm.stubs(:saved?).returns(true)
20
+ @foo_vm = mock("vm")
21
+ @foo_vm.stubs(:env).returns(@env)
22
+ vms = { :foo => @foo_vm }
23
+ @env.stubs(:vms).returns(vms)
21
24
  end
22
25
 
23
- should "require a persisted VM" do
24
- @env.expects(:require_persisted_vm).once
25
- @instance.execute
26
+ should "error and exit if the VM doesn't exist" do
27
+ @env.stubs(:vms).returns({})
28
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
29
+ @instance.resume_single(:foo)
26
30
  end
27
31
 
28
- should "save the state of the VM" do
29
- @persisted_vm.expects(:resume).once
30
- @instance.execute
32
+ should "resume if its created" do
33
+ @foo_vm.stubs(:created?).returns(true)
34
+ @foo_vm.expects(:resume).once
35
+ @instance.execute(["foo"])
36
+ end
37
+
38
+ should "do nothing if its not created" do
39
+ @foo_vm.stubs(:created?).returns(false)
40
+ @foo_vm.expects(:resume).never
41
+ @instance.resume_single(:foo)
31
42
  end
32
43
  end
33
44
  end
@@ -4,36 +4,59 @@ class CommandsSSHConfigTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @klass = Vagrant::Commands::SSHConfig
6
6
 
7
- @persisted_vm = mock("persisted_vm")
8
- @persisted_vm.stubs(:execute!)
9
-
10
7
  @env = mock_environment
11
- @env.stubs(:require_persisted_vm)
12
- @env.stubs(:vm).returns(@persisted_vm)
13
-
8
+ @env.stubs(:require_root_path)
14
9
  @instance = @klass.new(@env)
15
10
  end
16
11
 
17
12
  context "executing" do
13
+ setup do
14
+ @instance.stubs(:show_single)
15
+ end
16
+
17
+ should "require root path" do
18
+ @env.expects(:require_root_path).once
19
+ @instance.execute
20
+ end
21
+
22
+ should "call show_single with given argument" do
23
+ @instance.expects(:show_single).with("foo").once
24
+ @instance.execute(["foo"])
25
+ end
26
+ end
27
+
28
+ context "showing a single entry" do
18
29
  setup do
19
30
  @ssh = mock("ssh")
20
31
  @ssh.stubs(:port).returns(2197)
21
- @env.stubs(:ssh).returns(@ssh)
22
- @env.stubs(:require_root_path)
23
32
 
24
- @instance.stubs(:puts)
33
+ @bar = mock("vm")
34
+ @bar.stubs(:env).returns(mock_environment)
35
+ @bar.stubs(:ssh).returns(@ssh)
36
+
37
+ @vms = {:bar => @bar}
38
+ @env.stubs(:multivm?).returns(true)
39
+ @env.stubs(:vms).returns(@vms)
25
40
 
26
41
  @data = {
27
42
  :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
43
+ :ssh_user => @bar.env.config.ssh.username,
44
+ :ssh_port => @bar.ssh.port,
45
+ :private_key_path => @bar.env.config.ssh.private_key_path
31
46
  }
47
+
48
+ @instance.stubs(:puts)
32
49
  end
33
50
 
34
- should "require root path" do
35
- @env.expects(:require_root_path).once
36
- @instance.execute
51
+ should "error if name is nil and multivm" do
52
+ @env.stubs(:multivm?).returns(true)
53
+ @instance.expects(:error_and_exit).with(:ssh_config_multivm).once
54
+ @instance.show_single(nil)
55
+ end
56
+
57
+ should "error if the VM is not found" do
58
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => "foo").once
59
+ @instance.show_single("foo")
37
60
  end
38
61
 
39
62
  should "output rendered template" do
@@ -41,14 +64,14 @@ class CommandsSSHConfigTest < Test::Unit::TestCase
41
64
  Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)
42
65
 
43
66
  @instance.expects(:puts).with(result).once
44
- @instance.execute
67
+ @instance.show_single(:bar)
45
68
  end
46
69
 
47
70
  should "render with the given host name if given" do
48
71
  host = "foo"
49
72
  @data[:host_key] = host
50
73
  Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
51
- @instance.execute(["--host", host])
74
+ @instance.execute(["bar", "--host", host])
52
75
  end
53
76
  end
54
77
  end
@@ -4,29 +4,68 @@ class CommandsSSHTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @klass = Vagrant::Commands::SSH
6
6
 
7
- @persisted_vm = mock("persisted_vm")
8
- @persisted_vm.stubs(:execute!)
9
-
10
7
  @env = mock_environment
11
- @env.stubs(:require_persisted_vm)
12
- @env.stubs(:vm).returns(@persisted_vm)
13
-
14
8
  @instance = @klass.new(@env)
15
9
  end
16
10
 
17
11
  context "executing" do
18
- setup do
19
- @env.ssh.stubs(:connect)
12
+ should "connect to the given argument" do
13
+ @instance.expects(:ssh_connect).with("foo").once
14
+ @instance.execute(["foo"])
20
15
  end
21
16
 
22
- should "require a persisted VM" do
23
- @env.expects(:require_persisted_vm).once
17
+ should "connect with nil name if none is given" do
18
+ @instance.expects(:ssh_connect).with(nil).once
24
19
  @instance.execute
25
20
  end
21
+ end
26
22
 
27
- should "connect to SSH" do
28
- @env.ssh.expects(:connect).once
29
- @instance.execute
23
+ context "ssh connecting" do
24
+ setup do
25
+ @vm = mock("vm")
26
+ @vm.stubs(:created?).returns(true)
27
+
28
+ @vms = {:bar => @vm}
29
+ @env.stubs(:vms).returns(@vms)
30
+ @env.stubs(:multivm?).returns(false)
31
+ end
32
+
33
+ should "error and exit if no VM is specified and multivm and no primary VM" do
34
+ @env.stubs(:multivm?).returns(true)
35
+ @env.stubs(:primary_vm).returns(nil)
36
+ @instance.expects(:error_and_exit).with(:ssh_multivm).once
37
+ @instance.ssh_connect(nil)
38
+ end
39
+
40
+ should "use the primary VM if it exists and no name is specified" do
41
+ vm = mock("vm")
42
+ ssh = mock("ssh")
43
+ vm.stubs(:created?).returns(true)
44
+ vm.stubs(:ssh).returns(ssh)
45
+
46
+ @env.stubs(:multivm?).returns(true)
47
+ @env.stubs(:primary_vm).returns(vm)
48
+ ssh.expects(:connect).once
49
+ @instance.ssh_connect(nil)
50
+ end
51
+
52
+ should "error and exit if VM is nil" do
53
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
54
+ @instance.ssh_connect(:foo)
55
+ end
56
+
57
+ should "error and exit if VM isn't created" do
58
+ @vm.stubs(:created?).returns(false)
59
+ @instance.expects(:error_and_exit).with(:environment_not_created).once
60
+ @instance.ssh_connect(:bar)
61
+ end
62
+
63
+ should "ssh connect" do
64
+ ssh = mock("ssh")
65
+ @vm.stubs(:ssh).returns(ssh)
66
+ ssh.expects(:connect)
67
+
68
+ @instance.ssh_connect(:bar)
30
69
  end
31
70
  end
32
71
  end
@@ -15,6 +15,26 @@ class CommandsStatusTest < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  context "executing" do
18
- # TODO
18
+ should "show local status by default" do
19
+ @instance.expects(:show_local_status).once
20
+ @instance.expects(:show_global_status).never
21
+ @instance.execute
22
+ end
23
+
24
+ should "show global status if flagged" do
25
+ @instance.expects(:show_local_status).never
26
+ @instance.expects(:show_global_status).once
27
+ @instance.execute(["--global"])
28
+ end
29
+
30
+ should "show help if too many args are given" do
31
+ @instance.expects(:show_help).once
32
+ @instance.execute(["1","2","3"])
33
+ end
34
+
35
+ should "pass the VM name to local status if given" do
36
+ @instance.expects(:show_local_status).with("foo").once
37
+ @instance.execute(["foo"])
38
+ end
19
39
  end
20
40
  end
@@ -4,30 +4,41 @@ class CommandsSuspendTest < Test::Unit::TestCase
4
4
  setup do
5
5
  @klass = Vagrant::Commands::Suspend
6
6
 
7
- @persisted_vm = mock("persisted_vm")
8
- @persisted_vm.stubs(:execute!)
9
-
10
7
  @env = mock_environment
11
- @env.stubs(:require_persisted_vm)
12
- @env.stubs(:vm).returns(@persisted_vm)
13
-
14
8
  @instance = @klass.new(@env)
15
9
  end
16
10
 
17
11
  context "executing" do
12
+ should "call all or single for the method" do
13
+ @instance.expects(:all_or_single).with([], :suspend)
14
+ @instance.execute
15
+ end
16
+ end
17
+
18
+ context "suspending a single VM" do
18
19
  setup do
19
- @persisted_vm.stubs(:suspend)
20
- @persisted_vm.stubs(:saved?).returns(false)
20
+ @foo_vm = mock("vm")
21
+ @foo_vm.stubs(:env).returns(@env)
22
+ vms = { :foo => @foo_vm }
23
+ @env.stubs(:vms).returns(vms)
21
24
  end
22
25
 
23
- should "require a persisted VM" do
24
- @env.expects(:require_persisted_vm).once
25
- @instance.execute
26
+ should "error and exit if the VM doesn't exist" do
27
+ @env.stubs(:vms).returns({})
28
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
29
+ @instance.suspend_single(:foo)
26
30
  end
27
31
 
28
- should "suspend the VM" do
29
- @persisted_vm.expects(:suspend).once
30
- @instance.execute
32
+ should "suspend if its created" do
33
+ @foo_vm.stubs(:created?).returns(true)
34
+ @foo_vm.expects(:suspend).once
35
+ @instance.execute(["foo"])
36
+ end
37
+
38
+ should "do nothing if its not created" do
39
+ @foo_vm.stubs(:created?).returns(false)
40
+ @foo_vm.expects(:suspend).never
41
+ @instance.suspend_single(:foo)
31
42
  end
32
43
  end
33
44
  end
@@ -6,36 +6,42 @@ class CommandsUpTest < Test::Unit::TestCase
6
6
 
7
7
  @env = mock_environment
8
8
  @instance = @klass.new(@env)
9
-
10
- @persisted_vm = mock("persisted_vm")
11
- @persisted_vm.stubs(:execute!)
12
9
  end
13
10
 
14
11
  context "executing" do
12
+ should "call all or single for the method" do
13
+ @instance.expects(:all_or_single).with([], :up)
14
+ @instance.execute
15
+ end
16
+ end
17
+
18
+ context "upping a single VM" do
15
19
  setup do
16
- @new_vm = mock("vm")
17
- @new_vm.stubs(:execute!)
20
+ @vm = mock("vm")
21
+ @vm.stubs(:env).returns(@env)
18
22
 
19
- @env.stubs(:vm).returns(nil)
20
- @env.stubs(:require_box)
21
- @env.stubs(:create_vm).returns(@new_vm)
23
+ @vms = {:foo => @vm}
24
+ @env.stubs(:vms).returns(@vms)
22
25
  end
23
26
 
24
- should "require a box" do
25
- @env.expects(:require_box).once
26
- @instance.execute
27
+ should "error and exit if the VM doesn't exist" do
28
+ @env.stubs(:vms).returns({})
29
+ @instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
30
+ @instance.up_single(:foo)
27
31
  end
28
32
 
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
33
+ should "start created VMs" do
34
+ @vm.stubs(:created?).returns(true)
35
+ @vm.expects(:start).once
36
+ @instance.up_single(:foo)
32
37
  end
33
38
 
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
+ should "up non-created VMs" do
40
+ @vm.stubs(:created?).returns(false)
41
+ @vm.env.expects(:require_box).once
42
+ @vm.expects(:up).once
43
+ @vm.expects(:start).never
44
+ @instance.up_single(:foo)
39
45
  end
40
46
  end
41
47
  end