vagrant 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/.gitignore +10 -0
  2. data/CHANGELOG.md +48 -0
  3. data/Gemfile +16 -0
  4. data/Gemfile.lock +49 -0
  5. data/README.md +2 -2
  6. data/Rakefile +22 -0
  7. data/bin/.gitignore +0 -0
  8. data/lib/vagrant/provisioners/chef_solo.rb +1 -1
  9. data/lib/vagrant/util/template_renderer.rb +2 -2
  10. data/lib/vagrant/version.rb +1 -1
  11. data/templates/Vagrantfile.erb +1 -1
  12. data/templates/nfs/exports.erb +4 -2
  13. data/test/test_helper.rb +128 -0
  14. data/test/vagrant/action/box/destroy_test.rb +30 -0
  15. data/test/vagrant/action/box/download_test.rb +141 -0
  16. data/test/vagrant/action/box/package_test.rb +25 -0
  17. data/test/vagrant/action/box/unpackage_test.rb +103 -0
  18. data/test/vagrant/action/box/verify_test.rb +39 -0
  19. data/test/vagrant/action/builder_test.rb +218 -0
  20. data/test/vagrant/action/env/error_halt_test.rb +21 -0
  21. data/test/vagrant/action/env/set_test.rb +24 -0
  22. data/test/vagrant/action/environment_test.rb +45 -0
  23. data/test/vagrant/action/exception_catcher_test.rb +30 -0
  24. data/test/vagrant/action/general/package_test.rb +254 -0
  25. data/test/vagrant/action/vm/boot_test.rb +83 -0
  26. data/test/vagrant/action/vm/check_box_test.rb +48 -0
  27. data/test/vagrant/action/vm/check_guest_additions_test.rb +9 -0
  28. data/test/vagrant/action/vm/clean_machine_folder_test.rb +82 -0
  29. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +72 -0
  30. data/test/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
  31. data/test/vagrant/action/vm/clear_shared_folders_test.rb +49 -0
  32. data/test/vagrant/action/vm/customize_test.rb +29 -0
  33. data/test/vagrant/action/vm/destroy_test.rb +26 -0
  34. data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +46 -0
  35. data/test/vagrant/action/vm/disable_networks_test.rb +39 -0
  36. data/test/vagrant/action/vm/discard_state_test.rb +36 -0
  37. data/test/vagrant/action/vm/export_test.rb +135 -0
  38. data/test/vagrant/action/vm/forward_ports_helpers_test.rb +70 -0
  39. data/test/vagrant/action/vm/forward_ports_test.rb +191 -0
  40. data/test/vagrant/action/vm/halt_test.rb +69 -0
  41. data/test/vagrant/action/vm/import_test.rb +50 -0
  42. data/test/vagrant/action/vm/match_mac_address_test.rb +28 -0
  43. data/test/vagrant/action/vm/network_test.rb +246 -0
  44. data/test/vagrant/action/vm/nfs_helpers_test.rb +23 -0
  45. data/test/vagrant/action/vm/nfs_test.rb +269 -0
  46. data/test/vagrant/action/vm/package_test.rb +25 -0
  47. data/test/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
  48. data/test/vagrant/action/vm/persist_test.rb +50 -0
  49. data/test/vagrant/action/vm/provision_test.rb +134 -0
  50. data/test/vagrant/action/vm/resume_test.rb +35 -0
  51. data/test/vagrant/action/vm/share_folders_test.rb +215 -0
  52. data/test/vagrant/action/vm/suspend_test.rb +35 -0
  53. data/test/vagrant/action_test.rb +111 -0
  54. data/test/vagrant/active_list_test.rb +173 -0
  55. data/test/vagrant/box_test.rb +166 -0
  56. data/test/vagrant/command_test.rb +53 -0
  57. data/test/vagrant/commands/base_test.rb +139 -0
  58. data/test/vagrant/commands/box/add_test.rb +34 -0
  59. data/test/vagrant/commands/box/list_test.rb +32 -0
  60. data/test/vagrant/commands/box/remove_test.rb +41 -0
  61. data/test/vagrant/commands/box/repackage_test.rb +52 -0
  62. data/test/vagrant/commands/destroy_test.rb +44 -0
  63. data/test/vagrant/commands/halt_test.rb +50 -0
  64. data/test/vagrant/commands/init_test.rb +71 -0
  65. data/test/vagrant/commands/package_test.rb +97 -0
  66. data/test/vagrant/commands/provision_test.rb +60 -0
  67. data/test/vagrant/commands/reload_test.rb +47 -0
  68. data/test/vagrant/commands/resume_test.rb +44 -0
  69. data/test/vagrant/commands/ssh_config_test.rb +77 -0
  70. data/test/vagrant/commands/ssh_test.rb +129 -0
  71. data/test/vagrant/commands/status_test.rb +40 -0
  72. data/test/vagrant/commands/suspend_test.rb +44 -0
  73. data/test/vagrant/commands/up_test.rb +49 -0
  74. data/test/vagrant/config_test.rb +307 -0
  75. data/test/vagrant/downloaders/base_test.rb +28 -0
  76. data/test/vagrant/downloaders/file_test.rb +33 -0
  77. data/test/vagrant/downloaders/http_test.rb +70 -0
  78. data/test/vagrant/environment_test.rb +770 -0
  79. data/test/vagrant/hosts/base_test.rb +46 -0
  80. data/test/vagrant/hosts/bsd_test.rb +56 -0
  81. data/test/vagrant/hosts/linux_test.rb +56 -0
  82. data/test/vagrant/provisioners/base_test.rb +36 -0
  83. data/test/vagrant/provisioners/chef_server_test.rb +182 -0
  84. data/test/vagrant/provisioners/chef_solo_test.rb +197 -0
  85. data/test/vagrant/provisioners/chef_test.rb +178 -0
  86. data/test/vagrant/ssh_session_test.rb +46 -0
  87. data/test/vagrant/ssh_test.rb +317 -0
  88. data/test/vagrant/systems/linux_test.rb +179 -0
  89. data/test/vagrant/util/busy_test.rb +106 -0
  90. data/test/vagrant/util/plain_logger_test.rb +17 -0
  91. data/test/vagrant/util/platform_test.rb +18 -0
  92. data/test/vagrant/util/resource_logger_test.rb +145 -0
  93. data/test/vagrant/util/stacked_proc_runner_test.rb +43 -0
  94. data/test/vagrant/util/template_renderer_test.rb +145 -0
  95. data/test/vagrant/util/translator_test.rb +61 -0
  96. data/test/vagrant/util_test.rb +27 -0
  97. data/test/vagrant/vm_test.rb +228 -0
  98. data/vagrant.gemspec +34 -0
  99. metadata +158 -43
@@ -0,0 +1,30 @@
1
+ require "test_helper"
2
+
3
+ class ExceptionCatcherTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Class.new
6
+ @klass.send(:include, Vagrant::Action::ExceptionCatcher)
7
+ @env = Vagrant::Action::Environment.new(mock_environment)
8
+
9
+ @instance = @klass.new
10
+ end
11
+
12
+ should "run block and return result if no exception" do
13
+ result = @instance.catch_action_exception(@env) do
14
+ true
15
+ end
16
+
17
+ assert result
18
+ assert !@env.error?
19
+ end
20
+
21
+ should "run block and return false with error environment on exception" do
22
+ result = @instance.catch_action_exception(@env) do
23
+ raise Vagrant::Action::ActionException.new(:foo, :foo => :bar)
24
+ end
25
+
26
+ assert !result
27
+ assert @env.error?
28
+ assert_equal :foo, @env.error.first
29
+ end
30
+ end
@@ -0,0 +1,254 @@
1
+ require "test_helper"
2
+
3
+ class PackageGeneralActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::General::Package
6
+ @app, @env = mock_action_data
7
+
8
+ @vm = mock("vm")
9
+ @env["vm"] = @vm
10
+ end
11
+
12
+ context "initializing" do
13
+ setup do
14
+ @tar_path = "foo"
15
+ File.stubs(:exist?).returns(false)
16
+ @klass.any_instance.stubs(:tar_path).returns(@tar_path)
17
+ end
18
+
19
+ should "initialize fine" do
20
+ @klass.new(@app, @env)
21
+ assert !@env.error?
22
+ end
23
+
24
+ should "set the output path to configured by default" do
25
+ @klass.new(@app, @env)
26
+ assert_equal @env["config"].package.name, @env["package.output"]
27
+ end
28
+
29
+ should "not set the output path if it is already set" do
30
+ @env["package.output"] = "foo"
31
+ @klass.new(@app, @env)
32
+ assert_equal "foo", @env["package.output"]
33
+ end
34
+
35
+ should "set the included files to empty by default" do
36
+ @klass.new(@app, @env)
37
+ assert_equal [], @env["package.include"]
38
+ end
39
+
40
+ should "not set the output path if it is already set" do
41
+ @env["package.include"] = "foo"
42
+ @klass.new(@app, @env)
43
+ assert_equal "foo", @env["package.include"]
44
+ end
45
+ end
46
+
47
+ context "with an instance" do
48
+ setup do
49
+ File.stubs(:exist?).returns(false)
50
+ File.stubs(:directory?).returns(true)
51
+ @instance = @klass.new(@app, @env)
52
+
53
+ @env["package.directory"] = "foo"
54
+ end
55
+
56
+ context "calling" do
57
+ should "call the proper methods then continue chain" do
58
+ seq = sequence("seq")
59
+ @instance.expects(:verify_included_files).in_sequence(seq).returns(true)
60
+ @instance.expects(:compress).in_sequence(seq)
61
+ @app.expects(:call).with(@env).in_sequence(seq)
62
+ @instance.expects(:cleanup).never
63
+
64
+ @instance.call(@env)
65
+ end
66
+
67
+ should "halt the chain if verify failed" do
68
+ @instance.expects(:verify_included_files).returns(false)
69
+ @instance.expects(:compress).never
70
+ @app.expects(:call).never
71
+
72
+ @instance.call(@env)
73
+ end
74
+
75
+ should "halt the chain if the output file already exists" do
76
+ File.expects(:exist?).returns(true)
77
+ @app.expects(:call).never
78
+ @instance.call(@env)
79
+
80
+ assert @env.error?
81
+ assert_equal :package_output_exists, @env.error.first
82
+ end
83
+
84
+ should "halt the chain if directory isn't set" do
85
+ @env["package.directory"] = nil
86
+ @app.expects(:call).never
87
+ @instance.call(@env)
88
+
89
+ assert @env.error?
90
+ assert_equal :package_requires_directory, @env.error.first
91
+ end
92
+
93
+ should "halt the chain if directory doesn't exist" do
94
+ File.expects(:directory?).with(@env["package.directory"]).returns(false)
95
+ @app.expects(:call).never
96
+ @instance.call(@env)
97
+
98
+ assert @env.error?
99
+ assert_equal :package_requires_directory, @env.error.first
100
+ end
101
+
102
+ should "run cleanup if environment errors" do
103
+ seq = sequence("seq")
104
+ @instance.expects(:verify_included_files).in_sequence(seq).returns(true)
105
+ @instance.expects(:compress).in_sequence(seq)
106
+ @app.expects(:call).with(@env).in_sequence(seq)
107
+ @instance.expects(:cleanup).in_sequence(seq)
108
+
109
+ @env.error!(:foo)
110
+ @instance.call(@env)
111
+ end
112
+ end
113
+
114
+ context "cleaning up" do
115
+ setup do
116
+ File.stubs(:exist?).returns(false)
117
+ File.stubs(:delete)
118
+
119
+ @instance.stubs(:tar_path).returns("foo")
120
+ end
121
+
122
+ should "do nothing if the file doesn't exist" do
123
+ File.expects(:exist?).with(@instance.tar_path).returns(false)
124
+ File.expects(:delete).never
125
+
126
+ @instance.cleanup
127
+ end
128
+
129
+ should "delete the packaged box if it exists" do
130
+ File.expects(:exist?).returns(true)
131
+ File.expects(:delete).with(@instance.tar_path).once
132
+
133
+ @instance.cleanup
134
+ end
135
+ end
136
+
137
+ context "verifying included files" do
138
+ setup do
139
+ @env["package.include"] = ["foo"]
140
+ File.stubs(:exist?).returns(true)
141
+ end
142
+
143
+ should "error if included file is not found" do
144
+ File.expects(:exist?).with("foo").returns(false)
145
+ assert !@instance.verify_included_files
146
+ assert @env.error?
147
+ assert_equal :package_include_file_doesnt_exist, @env.error.first
148
+ end
149
+
150
+ should "return true if all exist" do
151
+ assert @instance.verify_included_files
152
+ assert !@env.error?
153
+ end
154
+ end
155
+
156
+ context "copying include files" do
157
+ setup do
158
+ @env["package.include"] = []
159
+ end
160
+
161
+ should "do nothing if no include files are specified" do
162
+ assert @env["package.include"].empty?
163
+ FileUtils.expects(:mkdir_p).never
164
+ FileUtils.expects(:cp).never
165
+ @instance.copy_include_files
166
+ end
167
+
168
+ should "create the include directory and copy files to it" do
169
+ include_dir = File.join(@env["package.directory"], "include")
170
+ copy_seq = sequence("copy_seq")
171
+ FileUtils.expects(:mkdir_p).with(include_dir).once.in_sequence(copy_seq)
172
+
173
+ 5.times do |i|
174
+ file = mock("f#{i}")
175
+ @env["package.include"] << file
176
+ FileUtils.expects(:cp).with(file, include_dir).in_sequence(copy_seq)
177
+ end
178
+
179
+ @instance.copy_include_files
180
+ end
181
+ end
182
+
183
+ context "compression" do
184
+ setup do
185
+ @env["package.include"] = []
186
+
187
+ @tar_path = "foo"
188
+ @instance.stubs(:tar_path).returns(@tar_path)
189
+
190
+ @pwd = "bar"
191
+ FileUtils.stubs(:pwd).returns(@pwd)
192
+ FileUtils.stubs(:cd)
193
+
194
+ @file = mock("file")
195
+ File.stubs(:open).yields(@file)
196
+
197
+ @output = mock("output")
198
+ @tar = Archive::Tar::Minitar
199
+ Archive::Tar::Minitar::Output.stubs(:open).yields(@output)
200
+ @tar.stubs(:pack_file)
201
+
202
+ @instance.stubs(:copy_include_files)
203
+ end
204
+
205
+ should "open the tar file with the tar path properly" do
206
+ File.expects(:open).with(@tar_path, Vagrant::Util::Platform.tar_file_options).once
207
+ @instance.compress
208
+ end
209
+
210
+ should "open tar file" do
211
+ Archive::Tar::Minitar::Output.expects(:open).with(@file).once
212
+ @instance.compress
213
+ end
214
+
215
+ #----------------------------------------------------------------
216
+ # Methods below this comment test the block yielded by Minitar open
217
+ #----------------------------------------------------------------
218
+ should "cd to the directory and append the directory" do
219
+ @files = []
220
+ compress_seq = sequence("compress_seq")
221
+
222
+ FileUtils.expects(:pwd).once.returns(@pwd).in_sequence(compress_seq)
223
+ @instance.expects(:copy_include_files).once.in_sequence(compress_seq)
224
+ FileUtils.expects(:cd).with(@env["package.directory"]).in_sequence(compress_seq)
225
+ Dir.expects(:glob).returns(@files).in_sequence(compress_seq)
226
+
227
+ 5.times do |i|
228
+ file = mock("file#{i}")
229
+ @tar.expects(:pack_file).with(file, @output).once.in_sequence(compress_seq)
230
+ @files << file
231
+ end
232
+
233
+ FileUtils.expects(:cd).with(@pwd).in_sequence(compress_seq)
234
+ @instance.compress
235
+ end
236
+
237
+ should "pop back to the current directory even if an exception is raised" do
238
+ cd_seq = sequence("cd_seq")
239
+ FileUtils.expects(:cd).with(@env["package.directory"]).raises(Exception).in_sequence(cd_seq)
240
+ FileUtils.expects(:cd).with(@pwd).in_sequence(cd_seq)
241
+
242
+ assert_raises(Exception) {
243
+ @instance.compress
244
+ }
245
+ end
246
+ end
247
+
248
+ context "tar path" do
249
+ should "return proper path" do
250
+ assert_equal File.join(FileUtils.pwd, @env["package.output"]), @instance.tar_path
251
+ end
252
+ end
253
+ end
254
+ end
@@ -0,0 +1,83 @@
1
+ require "test_helper"
2
+
3
+ class BootVMActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::VM::Boot
6
+ @app, @env = mock_action_data
7
+
8
+ @vm = mock("vm")
9
+ @vm.stubs(:ssh).returns(mock("ssh"))
10
+ @env["vm"] = @vm
11
+
12
+ @internal_vm = mock("internal")
13
+ @vm.stubs(:vm).returns(@internal_vm)
14
+
15
+ @instance = @klass.new(@app, @env)
16
+ end
17
+
18
+ context "calling" do
19
+ should "do nothing if environment is erroneous" do
20
+ @env.error!(:foo)
21
+ @instance.expects(:boot).never
22
+ @app.expects(:call).never
23
+
24
+ @instance.call(@env)
25
+ end
26
+
27
+ should "run the proper methods on success" do
28
+ boot_seq = sequence("boot_seq")
29
+ @instance.expects(:boot).in_sequence(boot_seq)
30
+ @instance.expects(:wait_for_boot).returns(true).in_sequence(boot_seq)
31
+ @app.expects(:call).with(@env).once.in_sequence(boot_seq)
32
+ @instance.call(@env)
33
+ end
34
+
35
+ should "error and halt chain if boot failed" do
36
+ boot_seq = sequence("boot_seq")
37
+ @instance.expects(:boot).in_sequence(boot_seq)
38
+ @instance.expects(:wait_for_boot).returns(false).in_sequence(boot_seq)
39
+ @app.expects(:call).never
40
+ @instance.call(@env)
41
+ end
42
+
43
+ should "not continue chain if error occured" do
44
+ boot_seq = sequence("boot_seq")
45
+ @instance.expects(:boot).in_sequence(boot_seq)
46
+ @instance.expects(:wait_for_boot).returns(true).in_sequence(boot_seq).with() do
47
+ @env.error!(:interrupt)
48
+ true
49
+ end
50
+ @app.expects(:call).never
51
+ @instance.call(@env)
52
+ end
53
+ end
54
+
55
+ context "booting" do
56
+ should "start the VM in specified mode" do
57
+ mode = mock("boot_mode")
58
+ @env.env.config.vm.boot_mode = mode
59
+ @internal_vm.expects(:start).with(mode).once
60
+ @instance.boot
61
+ end
62
+ end
63
+
64
+ context "waiting for boot" do
65
+ should "repeatedly ping the SSH port and return false with no response" do
66
+ seq = sequence('pings')
67
+ @vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i - 1).returns(false).in_sequence(seq)
68
+ @vm.ssh.expects(:up?).once.returns(true).in_sequence(seq)
69
+ assert @instance.wait_for_boot
70
+ end
71
+
72
+ should "return right away if interrupted" do
73
+ @env.error!(:interrupt)
74
+ @vm.ssh.expects(:up?).times(1).returns(false)
75
+ assert @instance.wait_for_boot
76
+ end
77
+
78
+ should "ping the max number of times then just return" do
79
+ @vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i).returns(false)
80
+ assert !@instance.wait_for_boot
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ class CheckBoxVMActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::VM::CheckBox
6
+ @app, @env = mock_action_data
7
+ @instance = @klass.new(@app, @env)
8
+ end
9
+
10
+ context "calling" do
11
+ setup do
12
+ Vagrant::Box.stubs(:find)
13
+ end
14
+
15
+ should "return error if box not specified" do
16
+ @env.env.config.vm.box = nil
17
+
18
+ @app.expects(:call).never
19
+ @instance.call(@env)
20
+
21
+ assert @env.error?
22
+ assert_equal :box_not_specified, @env.error.first
23
+ end
24
+
25
+ should "error if box does not exist and URL not specified" do
26
+ @env.env.config.vm.box_url = nil
27
+ Vagrant::Box.expects(:find).with(@env.env, @env["config"].vm.box).returns(nil)
28
+
29
+ @app.expects(:call).never
30
+ @instance.call(@env)
31
+
32
+ assert @env.error?
33
+ assert_equal :box_specified_doesnt_exist, @env.error.first
34
+ end
35
+
36
+ should "attempt to download box and continue if URL specified" do
37
+ seq = sequence("seq")
38
+ @env.env.config.vm.box_url = "bar"
39
+ Vagrant::Box.expects(:find).returns(nil)
40
+ Vagrant::Box.expects(:add).with(@env.env, @env["config"].vm.box, @env["config"].vm.box_url).in_sequence(seq)
41
+ @env.env.expects(:load_box!).in_sequence(seq)
42
+ @app.expects(:call).with(@env).once.in_sequence(seq)
43
+
44
+ @instance.call(@env)
45
+ assert !@env.error?
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ class CheckGuestAdditionsVMActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::VM::CheckGuestAdditions
6
+ end
7
+
8
+ # TODO: This isn't tested.
9
+ end
@@ -0,0 +1,82 @@
1
+ require "test_helper"
2
+
3
+ class CleanMachineFolderVMActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::VM::CleanMachineFolder
6
+ @app, @env = mock_action_data
7
+
8
+ @instance = @klass.new(@app, @env)
9
+ end
10
+
11
+ context "calling" do
12
+ should "clean machine folder then continue chain" do
13
+ seq = sequence("seq")
14
+ @instance.expects(:clean_machine_folder).in_sequence(seq)
15
+ @app.expects(:call).with(@env).in_sequence(seq)
16
+ @instance.call(@env)
17
+ end
18
+ end
19
+
20
+ context "cleaning the folder" do
21
+ setup do
22
+ @machine_folder = "/foo/bar/baz"
23
+ @folder = File.join(@machine_folder, "*")
24
+ VirtualBox::Global.global.system_properties.stubs(:default_machine_folder).returns(@machine_folder)
25
+ File.stubs(:file?).returns(true)
26
+ end
27
+
28
+ should "ignore all non-directories" do
29
+ folders = %W[foo bar baz]
30
+ Dir.expects(:[]).with(@folder).returns(folders)
31
+ folders.each do |f|
32
+ File.expects(:directory?).with(f).returns(false)
33
+ end
34
+
35
+ FileUtils.expects(:rm_rf).never
36
+
37
+ @instance.clean_machine_folder
38
+ end
39
+
40
+ should "delete directories with only .xml-prev files" do
41
+ folders = {
42
+ "sfoo" => %W[foo bar baz.xml-prev],
43
+ "sbar" => %W[foo.xml-prev]
44
+ }
45
+
46
+ Dir.expects(:[]).with(@folder).returns(folders.keys)
47
+ folders.each do |folder, subfolders|
48
+ File.expects(:directory?).with(folder).returns(true)
49
+ Dir.expects(:[]).with("#{folder}/**/*").returns(subfolders)
50
+ end
51
+
52
+ FileUtils.expects(:rm_rf).never
53
+ FileUtils.expects(:rm_rf).with("sbar").once
54
+ @instance.clean_machine_folder
55
+ end
56
+
57
+ should "delete directories with only subdirectories" do
58
+ folders = {
59
+ "sfoo" => %W[foo bar],
60
+ "sbar" => %W[foo.xml-prev]
61
+ }
62
+
63
+ File.stubs(:file?).returns(false)
64
+ Dir.expects(:[]).with(@folder).returns(folders.keys)
65
+ folders.each do |folder, subfolders|
66
+ File.expects(:directory?).with(folder).returns(true)
67
+ Dir.expects(:[]).with("#{folder}/**/*").returns(subfolders)
68
+ end
69
+
70
+ FileUtils.expects(:rm_rf).never
71
+ FileUtils.expects(:rm_rf).with("sfoo").once
72
+ FileUtils.expects(:rm_rf).with("sbar").once
73
+
74
+ @instance.clean_machine_folder
75
+ end
76
+
77
+ should "do nothing if folder is < 10 characters" do
78
+ VirtualBox::Global.global.system_properties.stubs(:default_machine_folder).returns("foo")
79
+ Dir.expects(:[]).never
80
+ end
81
+ end
82
+ end