vagrantup 0.4.3.dev → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/config/default.rb +6 -6
  4. data/lib/vagrant.rb +6 -3
  5. data/lib/vagrant/action.rb +77 -0
  6. data/lib/vagrant/action/action_exception.rb +16 -0
  7. data/lib/vagrant/action/box/destroy.rb +19 -0
  8. data/lib/vagrant/action/box/download.rb +78 -0
  9. data/lib/vagrant/action/box/unpackage.rb +58 -0
  10. data/lib/vagrant/action/box/verify.rb +23 -0
  11. data/lib/vagrant/action/builder.rb +151 -0
  12. data/lib/vagrant/action/builtin.rb +114 -0
  13. data/lib/vagrant/action/env/error_halt.rb +16 -0
  14. data/lib/vagrant/action/env/set.rb +18 -0
  15. data/lib/vagrant/action/environment.rb +98 -0
  16. data/lib/vagrant/action/exception_catcher.rb +14 -0
  17. data/lib/vagrant/action/vm/boot.rb +54 -0
  18. data/lib/vagrant/action/vm/check_box.rb +27 -0
  19. data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
  20. data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
  21. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
  22. data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
  23. data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
  24. data/lib/vagrant/action/vm/customize.rb +21 -0
  25. data/lib/vagrant/action/vm/destroy.rb +20 -0
  26. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
  27. data/lib/vagrant/action/vm/disable_networks.rb +26 -0
  28. data/lib/vagrant/action/vm/export.rb +53 -0
  29. data/lib/vagrant/action/vm/forward_ports.rb +121 -0
  30. data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
  31. data/lib/vagrant/action/vm/halt.rb +34 -0
  32. data/lib/vagrant/action/vm/import.rb +33 -0
  33. data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
  34. data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
  35. data/lib/vagrant/action/vm/nfs.rb +161 -0
  36. data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
  37. data/lib/vagrant/action/vm/package.rb +99 -0
  38. data/lib/vagrant/action/vm/persist.rb +22 -0
  39. data/lib/vagrant/action/vm/provision.rb +50 -0
  40. data/lib/vagrant/action/vm/resume.rb +20 -0
  41. data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
  42. data/lib/vagrant/action/vm/suspend.rb +20 -0
  43. data/lib/vagrant/box.rb +3 -7
  44. data/lib/vagrant/commands/base.rb +1 -3
  45. data/lib/vagrant/commands/package.rb +4 -9
  46. data/lib/vagrant/commands/up.rb +0 -2
  47. data/lib/vagrant/config.rb +15 -1
  48. data/lib/vagrant/downloaders/file.rb +1 -1
  49. data/lib/vagrant/downloaders/http.rb +2 -1
  50. data/lib/vagrant/environment.rb +18 -14
  51. data/lib/vagrant/hosts/base.rb +77 -0
  52. data/lib/vagrant/hosts/bsd.rb +53 -0
  53. data/lib/vagrant/hosts/linux.rb +52 -0
  54. data/lib/vagrant/provisioners/base.rb +17 -9
  55. data/lib/vagrant/provisioners/chef.rb +1 -1
  56. data/lib/vagrant/provisioners/chef_server.rb +4 -8
  57. data/lib/vagrant/provisioners/chef_solo.rb +1 -2
  58. data/lib/vagrant/ssh.rb +12 -4
  59. data/lib/vagrant/systems/base.rb +4 -0
  60. data/lib/vagrant/systems/linux.rb +12 -1
  61. data/lib/vagrant/util.rb +16 -0
  62. data/lib/vagrant/util/busy.rb +59 -0
  63. data/lib/vagrant/util/plain_logger.rb +11 -0
  64. data/lib/vagrant/util/platform.rb +18 -0
  65. data/lib/vagrant/util/resource_logger.rb +128 -0
  66. data/lib/vagrant/version.rb +6 -0
  67. data/lib/vagrant/vm.rb +10 -12
  68. data/templates/chef_solo_solo.erb +2 -1
  69. data/templates/nfs/exports.erb +3 -0
  70. data/templates/nfs/exports_linux.erb +3 -0
  71. data/templates/strings.yml +23 -3
  72. metadata +121 -196
  73. data/.gitignore +0 -11
  74. data/Gemfile +0 -18
  75. data/Rakefile +0 -41
  76. data/VERSION +0 -1
  77. data/bin/.gitignore +0 -0
  78. data/lib/vagrant/actions/base.rb +0 -130
  79. data/lib/vagrant/actions/box/add.rb +0 -23
  80. data/lib/vagrant/actions/box/destroy.rb +0 -14
  81. data/lib/vagrant/actions/box/download.rb +0 -67
  82. data/lib/vagrant/actions/box/unpackage.rb +0 -42
  83. data/lib/vagrant/actions/box/verify.rb +0 -32
  84. data/lib/vagrant/actions/collection.rb +0 -36
  85. data/lib/vagrant/actions/runner.rb +0 -131
  86. data/lib/vagrant/actions/vm/boot.rb +0 -43
  87. data/lib/vagrant/actions/vm/customize.rb +0 -19
  88. data/lib/vagrant/actions/vm/destroy.rb +0 -24
  89. data/lib/vagrant/actions/vm/down.rb +0 -22
  90. data/lib/vagrant/actions/vm/export.rb +0 -45
  91. data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
  92. data/lib/vagrant/actions/vm/halt.rb +0 -24
  93. data/lib/vagrant/actions/vm/import.rb +0 -23
  94. data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
  95. data/lib/vagrant/actions/vm/package.rb +0 -94
  96. data/lib/vagrant/actions/vm/provision.rb +0 -49
  97. data/lib/vagrant/actions/vm/reload.rb +0 -17
  98. data/lib/vagrant/actions/vm/resume.rb +0 -16
  99. data/lib/vagrant/actions/vm/start.rb +0 -26
  100. data/lib/vagrant/actions/vm/suspend.rb +0 -16
  101. data/lib/vagrant/actions/vm/up.rb +0 -53
  102. data/lib/vagrant/busy.rb +0 -79
  103. data/lib/vagrant/resource_logger.rb +0 -126
  104. data/lib/vagrant/util/error_helper.rb +0 -13
  105. data/lib/vagrant/util/output_helper.rb +0 -9
  106. data/test/test_helper.rb +0 -149
  107. data/test/vagrant/actions/base_test.rb +0 -32
  108. data/test/vagrant/actions/box/add_test.rb +0 -36
  109. data/test/vagrant/actions/box/destroy_test.rb +0 -17
  110. data/test/vagrant/actions/box/download_test.rb +0 -137
  111. data/test/vagrant/actions/box/unpackage_test.rb +0 -99
  112. data/test/vagrant/actions/box/verify_test.rb +0 -44
  113. data/test/vagrant/actions/collection_test.rb +0 -113
  114. data/test/vagrant/actions/runner_test.rb +0 -268
  115. data/test/vagrant/actions/vm/boot_test.rb +0 -49
  116. data/test/vagrant/actions/vm/customize_test.rb +0 -21
  117. data/test/vagrant/actions/vm/destroy_test.rb +0 -37
  118. data/test/vagrant/actions/vm/down_test.rb +0 -39
  119. data/test/vagrant/actions/vm/export_test.rb +0 -88
  120. data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
  121. data/test/vagrant/actions/vm/halt_test.rb +0 -65
  122. data/test/vagrant/actions/vm/import_test.rb +0 -45
  123. data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
  124. data/test/vagrant/actions/vm/network_test.rb +0 -291
  125. data/test/vagrant/actions/vm/package_test.rb +0 -254
  126. data/test/vagrant/actions/vm/provision_test.rb +0 -99
  127. data/test/vagrant/actions/vm/reload_test.rb +0 -46
  128. data/test/vagrant/actions/vm/resume_test.rb +0 -26
  129. data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
  130. data/test/vagrant/actions/vm/start_test.rb +0 -73
  131. data/test/vagrant/actions/vm/suspend_test.rb +0 -26
  132. data/test/vagrant/actions/vm/up_test.rb +0 -96
  133. data/test/vagrant/active_list_test.rb +0 -173
  134. data/test/vagrant/box_test.rb +0 -154
  135. data/test/vagrant/busy_test.rb +0 -78
  136. data/test/vagrant/command_test.rb +0 -53
  137. data/test/vagrant/commands/base_test.rb +0 -139
  138. data/test/vagrant/commands/box/add_test.rb +0 -34
  139. data/test/vagrant/commands/box/list_test.rb +0 -32
  140. data/test/vagrant/commands/box/remove_test.rb +0 -41
  141. data/test/vagrant/commands/destroy_test.rb +0 -44
  142. data/test/vagrant/commands/halt_test.rb +0 -50
  143. data/test/vagrant/commands/init_test.rb +0 -55
  144. data/test/vagrant/commands/package_test.rb +0 -104
  145. data/test/vagrant/commands/provision_test.rb +0 -60
  146. data/test/vagrant/commands/reload_test.rb +0 -44
  147. data/test/vagrant/commands/resume_test.rb +0 -44
  148. data/test/vagrant/commands/ssh_config_test.rb +0 -77
  149. data/test/vagrant/commands/ssh_test.rb +0 -129
  150. data/test/vagrant/commands/status_test.rb +0 -40
  151. data/test/vagrant/commands/suspend_test.rb +0 -44
  152. data/test/vagrant/commands/up_test.rb +0 -47
  153. data/test/vagrant/config_test.rb +0 -287
  154. data/test/vagrant/downloaders/base_test.rb +0 -28
  155. data/test/vagrant/downloaders/file_test.rb +0 -33
  156. data/test/vagrant/downloaders/http_test.rb +0 -62
  157. data/test/vagrant/environment_test.rb +0 -770
  158. data/test/vagrant/provisioners/base_test.rb +0 -33
  159. data/test/vagrant/provisioners/chef_server_test.rb +0 -176
  160. data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
  161. data/test/vagrant/provisioners/chef_test.rb +0 -175
  162. data/test/vagrant/resource_logger_test.rb +0 -145
  163. data/test/vagrant/ssh_session_test.rb +0 -46
  164. data/test/vagrant/ssh_test.rb +0 -296
  165. data/test/vagrant/systems/linux_test.rb +0 -179
  166. data/test/vagrant/util/error_helper_test.rb +0 -5
  167. data/test/vagrant/util/output_helper_test.rb +0 -5
  168. data/test/vagrant/util/plain_logger_test.rb +0 -17
  169. data/test/vagrant/util/platform_test.rb +0 -18
  170. data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
  171. data/test/vagrant/util/template_renderer_test.rb +0 -144
  172. data/test/vagrant/util/translator_test.rb +0 -61
  173. data/test/vagrant/util_test.rb +0 -27
  174. data/test/vagrant/vm_test.rb +0 -235
  175. data/vagrant.gemspec +0 -291
@@ -1,32 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
-
3
- class BaseActionTest < Test::Unit::TestCase
4
- should "include the util class so subclasses have access to it" do
5
- assert Vagrant::Actions::Base.include?(Vagrant::Util)
6
- end
7
-
8
- context "base instance" do
9
- setup do
10
- @mock_vm = mock("vm")
11
- @base = Vagrant::Actions::Base.new(@mock_vm)
12
- end
13
-
14
- should "allow read-only access to the runner" do
15
- assert_equal @mock_vm, @base.runner
16
- end
17
-
18
- should "implement prepare which does nothing" do
19
- assert_nothing_raised do
20
- assert @base.respond_to?(:prepare)
21
- @base.prepare
22
- end
23
- end
24
-
25
- should "implement the execute! method which does nothing" do
26
- assert_nothing_raised do
27
- assert @base.respond_to?(:execute!)
28
- @base.execute!
29
- end
30
- end
31
- end
32
- end
@@ -1,36 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class AddBoxActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Add)
6
- end
7
-
8
- context "prepare" do
9
- setup do
10
- @default_order = [Vagrant::Actions::Box::Download, Vagrant::Actions::Box::Unpackage, Vagrant::Actions::Box::Verify]
11
- @runner.stubs(:directory).returns("foo")
12
- File.stubs(:exists?).returns(false)
13
- end
14
-
15
- def setup_action_expectations
16
- default_seq = sequence("default_seq")
17
- @default_order.each do |action|
18
- @runner.expects(:add_action).with(action).once.in_sequence(default_seq)
19
- end
20
- end
21
-
22
- should "setup the proper sequence of actions" do
23
- setup_action_expectations
24
- @action.prepare
25
- end
26
-
27
- should "result in an action exception if the box already exists" do
28
- File.expects(:exists?).once.returns(true)
29
- @runner.expects(:name).once.returns('foo')
30
- @runner.expects(:add_action).never
31
- assert_raise Vagrant::Actions::ActionException do
32
- @action.prepare
33
- end
34
- end
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class DestroyBoxActionTest < Test::Unit::TestCase
4
- setup do
5
- @name = "foo"
6
- @dir = "foo"
7
- @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Destroy)
8
- @runner.stubs(:directory).returns(@dir)
9
- end
10
-
11
- context "executing" do
12
- should "rm_rf the directory" do
13
- FileUtils.expects(:rm_rf).with(@dir).once
14
- @action.execute!
15
- end
16
- end
17
- end
@@ -1,137 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class DownloadBoxActionTest < Test::Unit::TestCase
4
- setup do
5
- @uri = "foo.com"
6
- @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Download)
7
- @runner.stubs(:uri).returns(@uri)
8
- @runner.stubs(:temp_path=)
9
-
10
- @runner.env.stubs(:tmp_path).returns("foo")
11
- end
12
-
13
- context "preparing" do
14
- setup do
15
- @downloader = mock("downloader")
16
- Vagrant::Downloaders::File.any_instance.stubs(:prepare)
17
- Vagrant::Downloaders::HTTP.any_instance.stubs(:prepare)
18
- end
19
-
20
- should "raise an exception if no URI type is matched" do\
21
- Vagrant::Downloaders::File.expects(:match?).returns(false)
22
- Vagrant::Downloaders::HTTP.expects(:match?).returns(false)
23
- assert_raises(Vagrant::Actions::ActionException) {
24
- @action.prepare
25
- }
26
- end
27
-
28
- should "call #prepare on the downloader" do
29
- @downloader.expects(:prepare).with(@runner.uri).once
30
- Vagrant::Downloaders::File.expects(:new).returns(@downloader)
31
- expect_file
32
- @action.prepare
33
- end
34
-
35
- should "set the downloader to file if the uri provided is a file" do
36
- expect_file
37
- @action.prepare
38
- assert @action.downloader.is_a?(Vagrant::Downloaders::File)
39
- end
40
-
41
- should "set the downloader to HTTP if the uri provided is a valid url" do
42
- expect_http
43
- @action.prepare
44
- assert @action.downloader.is_a?(Vagrant::Downloaders::HTTP)
45
- end
46
-
47
- def expect_file
48
- Vagrant::Downloaders::File.expects(:match?).returns(true)
49
- Vagrant::Downloaders::HTTP.expects(:match?).returns(false)
50
- end
51
-
52
- def expect_http
53
- Vagrant::Downloaders::File.expects(:match?).returns(false)
54
- Vagrant::Downloaders::HTTP.expects(:match?).returns(true)
55
- end
56
- end
57
-
58
- context "executing" do
59
- setup do
60
- @path = "foo"
61
-
62
- @tempfile = mock("tempfile")
63
- @tempfile.stubs(:path).returns(@path)
64
-
65
- @action.stubs(:with_tempfile).yields(@tempfile)
66
- @action.stubs(:download_to)
67
- end
68
-
69
- should "make a tempfile and copy the URI contents to it" do
70
- @action.expects(:with_tempfile).yields(@tempfile)
71
- @action.expects(:download_to).with(@tempfile)
72
- @action.execute!
73
- end
74
-
75
- should "save the tempfile path" do
76
- @runner.expects(:temp_path=).with(@path).once
77
- @action.execute!
78
- end
79
- end
80
-
81
- context "rescue" do
82
- should "call cleanup method" do
83
- @action.expects(:cleanup).once
84
- @action.rescue(nil)
85
- end
86
- end
87
-
88
- context "tempfile" do
89
- should "create a tempfile in the vagrant tmp directory" do
90
- File.expects(:open).with { |name, bitmask|
91
- name =~ /#{Vagrant::Actions::Box::Download::BASENAME}/ && name =~ /#{@runner.env.tmp_path}/
92
- }.once
93
- @action.with_tempfile
94
- end
95
-
96
- should "yield the tempfile object" do
97
- @tempfile = mock("tempfile")
98
- File.expects(:open).yields(@tempfile)
99
-
100
- @action.with_tempfile do |otherfile|
101
- assert @tempfile.equal?(otherfile)
102
- end
103
- end
104
- end
105
-
106
- context "cleaning up" do
107
- setup do
108
- @temp_path = "foo"
109
- @runner.stubs(:temp_path).returns(@temp_path)
110
- File.stubs(:exist?).returns(true)
111
- end
112
-
113
- should "delete the temporary file if it exists" do
114
- File.expects(:unlink).with(@temp_path).once
115
- @action.cleanup
116
- end
117
-
118
- should "not delete anything if it doesn't exist" do
119
- File.stubs(:exist?).returns(false)
120
- File.expects(:unlink).never
121
- @action.cleanup
122
- end
123
- end
124
-
125
- context "downloading" do
126
- setup do
127
- @downloader = mock("downloader")
128
- @action.stubs(:downloader).returns(@downloader)
129
- end
130
-
131
- should "call download! on the download with the URI and tempfile" do
132
- tempfile = "foo"
133
- @downloader.expects(:download!).with(@runner.uri, tempfile)
134
- @action.download_to(tempfile)
135
- end
136
- end
137
- end
@@ -1,99 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class UnpackageBoxActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Unpackage)
6
- @runner.stubs(:name).returns("foo")
7
- @runner.stubs(:temp_path).returns("bar")
8
-
9
- @runner.env.stubs(:boxes_path).returns("bar")
10
- end
11
-
12
- context "executing" do
13
- setup do
14
- @runner.stubs(:invoke_around_callback).yields
15
- end
16
-
17
- should "execute the proper actions in the proper order" do
18
- exec_seq = sequence("exec_seq")
19
- @action.expects(:setup_box_dir).in_sequence(exec_seq)
20
- @action.expects(:decompress).in_sequence(exec_seq)
21
- @action.execute!
22
- end
23
-
24
- should "execute it in a around block" do
25
- @runner.expects(:invoke_around_callback).with(:unpackage).once
26
- @action.execute!
27
- end
28
- end
29
-
30
- context "rescuing" do
31
- setup do
32
- File.stubs(:directory?).returns(false)
33
- FileUtils.stubs(:rm_rf)
34
-
35
- @box_dir = mock("foo")
36
- @action.stubs(:box_dir).returns(@box_dir)
37
- end
38
-
39
- should "do nothing if a directory doesn't exist" do
40
- FileUtils.expects(:rm_rf).never
41
- @action.rescue(nil)
42
- end
43
-
44
- should "remove the box directory if it exists" do
45
- File.expects(:directory?).returns(true)
46
- FileUtils.expects(:rm_rf).with(@box_dir).once
47
- @action.rescue(nil)
48
- end
49
- end
50
-
51
- context "box directory" do
52
- should "return the runner directory" do
53
- result = mock("object")
54
- @runner.expects(:directory).once.returns(result)
55
- assert result.equal?(@action.box_dir)
56
- end
57
- end
58
-
59
- context "setting up the box directory" do
60
- setup do
61
- File.stubs(:directory?).returns(false)
62
- FileUtils.stubs(:mkdir_p)
63
-
64
- @box_dir = "foo"
65
- @action.stubs(:box_dir).returns(@box_dir)
66
- end
67
-
68
- should "error and exit if the directory exists" do
69
- File.expects(:directory?).returns(true)
70
- @action.expects(:error_and_exit).with(:box_already_exists, :box_name => @runner.name).once
71
- @action.setup_box_dir
72
- end
73
-
74
- should "create the directory" do
75
- FileUtils.expects(:mkdir_p).with(@box_dir).once
76
- @action.setup_box_dir
77
- end
78
- end
79
-
80
- context "decompressing" do
81
- setup do
82
- @box_dir = "foo"
83
-
84
- @action.stubs(:box_dir).returns(@box_dir)
85
- Dir.stubs(:chdir).yields
86
- Archive::Tar::Minitar.stubs(:unpack)
87
- end
88
-
89
- should "change to the box directory" do
90
- Dir.expects(:chdir).with(@box_dir)
91
- @action.decompress
92
- end
93
-
94
- should "open the tar file within the new directory, and extract it all" do
95
- Archive::Tar::Minitar.expects(:unpack).with(@runner.temp_path, @box_dir).once
96
- @action.decompress
97
- end
98
- end
99
- end
@@ -1,44 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
-
3
- class VerifyBoxActionTest < Test::Unit::TestCase
4
- setup do
5
- @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Verify)
6
- @runner.stubs(:name).returns("foo")
7
- @runner.stubs(:temp_path).returns("bar")
8
- end
9
-
10
- context "executing" do
11
- should "execute the proper actions in the proper order" do
12
- exec_seq = sequence("exec_seq")
13
- @action.expects(:reload_configuration).in_sequence(exec_seq)
14
- @action.expects(:verify_appliance).in_sequence(exec_seq)
15
- @action.execute!
16
- end
17
- end
18
-
19
- context "reloading configuration" do
20
- should "set the new box, load box, then load config" do
21
- reload_seq = sequence("reload_seq")
22
- @runner.env.config.vm.expects(:box=).with(@runner.name).in_sequence(reload_seq)
23
- @runner.env.expects(:load_box!).in_sequence(reload_seq)
24
- @runner.env.expects(:load_config!).in_sequence(reload_seq)
25
- @action.reload_configuration
26
- end
27
- end
28
-
29
- context "verifying appliance" do
30
- setup do
31
- @runner.stubs(:ovf_file).returns("foo")
32
- end
33
-
34
- should "create new appliance and return true if succeeds" do
35
- VirtualBox::Appliance.expects(:new).with(@runner.ovf_file)
36
- assert_nothing_raised { @action.verify_appliance }
37
- end
38
-
39
- should "return false if an exception is raised" do
40
- VirtualBox::Appliance.expects(:new).with(@runner.ovf_file).raises(VirtualBox::Exceptions::FileErrorException)
41
- assert_raises(Vagrant::Actions::ActionException) { @action.verify_appliance }
42
- end
43
- end
44
- end
@@ -1,113 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
-
3
- class CollectionTest < Test::Unit::TestCase
4
- class MockAction; end
5
- class MockActionOther; end
6
-
7
- context "checking uniqueness" do
8
- setup do
9
- @actions = Vagrant::Actions::Collection.new([1])
10
- end
11
-
12
- should "return true if there are duplicate classes in the collection" do
13
- @actions << 1
14
- assert @actions.duplicates?
15
- end
16
-
17
- should "return false it all the classes are unique" do
18
- @actions << 1.0 << "foo"
19
- assert !@actions.duplicates?
20
- end
21
-
22
- should "raise an exception when there are duplicates" do
23
- @actions << 1
24
- assert_raise Vagrant::Actions::DuplicateActionException do
25
- @actions.duplicates!
26
- end
27
- end
28
-
29
- should "not raise an exception when there are no duplicates" do
30
- @actions << 1.0 << "foo"
31
- assert_nothing_raised do
32
- @actions.duplicates!
33
- end
34
- end
35
- end
36
-
37
- context "verifying dependencies" do
38
- setup do
39
- @mock_action = mock('action')
40
- @mock_action.stubs(:class).returns(MockAction)
41
-
42
- @mock_action2 = mock('action2')
43
- @mock_action2.stubs(:class).returns(MockActionOther)
44
- # see test_helper
45
- stub_default_action_dependecies(@mock_action)
46
- stub_default_action_dependecies(@mock_action2)
47
- end
48
-
49
- context "that come before an action" do
50
- setup do
51
- @mock_action.stubs(:follows).returns([MockActionOther])
52
- end
53
- should "raise an exception if they are not met" do
54
- assert_raise Vagrant::Actions::DependencyNotSatisfiedException do
55
- collection.new([@mock_action]).dependencies!
56
- end
57
- end
58
-
59
- should "not raise an exception if they are met" do
60
- assert_nothing_raised do
61
- collection.new([@mock_action2, @mock_action]).dependencies!
62
- end
63
- end
64
- end
65
-
66
- context "that follow an an action" do
67
- setup do
68
- @mock_action.stubs(:precedes).returns([MockActionOther])
69
- end
70
-
71
- should "raise an exception if they are not met" do
72
- assert_raise Vagrant::Actions::DependencyNotSatisfiedException do
73
- collection.new([@mock_action]).dependencies!
74
- end
75
- end
76
-
77
- should "not raise an exception if they are met" do
78
- assert_nothing_raised do
79
- collection.new([@mock_action, @mock_action2]).dependencies!
80
- end
81
- end
82
- end
83
-
84
- context "that are before and after an action" do
85
- setup do
86
- @mock_action.stubs(:precedes).returns([MockActionOther])
87
- @mock_action.stubs(:follows).returns([MockActionOther])
88
- end
89
-
90
- should "raise an exception if they are met" do
91
- assert_raise Vagrant::Actions::DependencyNotSatisfiedException do
92
- collection.new([@mock_action2, @mock_action]).dependencies!
93
- end
94
- end
95
-
96
- should "not raise and exception if they are met" do
97
- assert_nothing_raised do
98
- collection.new([@mock_action2, @mock_action, @mock_action2]).dependencies!
99
- end
100
- end
101
- end
102
- end
103
-
104
- context "klasses" do
105
- should "return a list of the collection element's classes" do
106
- @action = mock('action')
107
- assert_equal collection.new([@action]).klasses, [@action.class]
108
- assert_equal collection.new([@action, 1.0, "foo"]).klasses, [@action.class, Float, String]
109
- end
110
- end
111
-
112
- def collection; Vagrant::Actions::Collection end
113
- end