vagrant 0.8.10 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. data/CHANGELOG.md +77 -1
  2. data/Gemfile +0 -14
  3. data/LICENSE +1 -1
  4. data/bin/vagrant +47 -20
  5. data/config/default.rb +6 -14
  6. data/lib/vagrant.rb +132 -5
  7. data/lib/vagrant/action.rb +45 -123
  8. data/lib/vagrant/action/box/destroy.rb +7 -3
  9. data/lib/vagrant/action/box/download.rb +8 -8
  10. data/lib/vagrant/action/box/package.rb +2 -2
  11. data/lib/vagrant/action/box/unpackage.rb +13 -7
  12. data/lib/vagrant/action/box/verify.rb +5 -5
  13. data/lib/vagrant/action/builder.rb +23 -19
  14. data/lib/vagrant/action/builtin.rb +117 -79
  15. data/lib/vagrant/action/env/set.rb +7 -4
  16. data/lib/vagrant/action/environment.rb +3 -41
  17. data/lib/vagrant/action/general/package.rb +14 -29
  18. data/lib/vagrant/action/general/validate.rb +2 -2
  19. data/lib/vagrant/action/runner.rb +53 -0
  20. data/lib/vagrant/action/vm/boot.rb +9 -9
  21. data/lib/vagrant/action/vm/check_accessible.rb +2 -2
  22. data/lib/vagrant/action/vm/check_box.rb +10 -12
  23. data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
  24. data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
  25. data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
  26. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
  27. data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
  28. data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
  29. data/lib/vagrant/action/vm/customize.rb +19 -9
  30. data/lib/vagrant/action/vm/destroy.rb +4 -4
  31. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
  32. data/lib/vagrant/action/vm/discard_state.rb +4 -4
  33. data/lib/vagrant/action/vm/export.rb +13 -8
  34. data/lib/vagrant/action/vm/forward_ports.rb +55 -102
  35. data/lib/vagrant/action/vm/halt.rb +9 -6
  36. data/lib/vagrant/action/vm/host_name.rb +4 -4
  37. data/lib/vagrant/action/vm/import.rb +19 -10
  38. data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
  39. data/lib/vagrant/action/vm/network.rb +300 -94
  40. data/lib/vagrant/action/vm/nfs.rb +41 -26
  41. data/lib/vagrant/action/vm/package.rb +1 -1
  42. data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
  43. data/lib/vagrant/action/vm/provision.rb +42 -13
  44. data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
  45. data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
  46. data/lib/vagrant/action/vm/resume.rb +4 -4
  47. data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
  48. data/lib/vagrant/action/vm/share_folders.rb +63 -39
  49. data/lib/vagrant/action/vm/suspend.rb +4 -4
  50. data/lib/vagrant/action/warden.rb +13 -6
  51. data/lib/vagrant/box.rb +9 -55
  52. data/lib/vagrant/box_collection.rb +22 -17
  53. data/lib/vagrant/cli.rb +62 -47
  54. data/lib/vagrant/command.rb +18 -20
  55. data/lib/vagrant/command/base.rb +135 -90
  56. data/lib/vagrant/command/box.rb +46 -21
  57. data/lib/vagrant/command/box_add.rb +33 -0
  58. data/lib/vagrant/command/box_list.rb +25 -0
  59. data/lib/vagrant/command/box_remove.rb +23 -0
  60. data/lib/vagrant/command/box_repackage.rb +23 -0
  61. data/lib/vagrant/command/destroy.rb +16 -5
  62. data/lib/vagrant/command/halt.rb +25 -7
  63. data/lib/vagrant/command/init.rb +30 -7
  64. data/lib/vagrant/command/package.rb +49 -18
  65. data/lib/vagrant/command/provision.rb +22 -9
  66. data/lib/vagrant/command/reload.rb +18 -5
  67. data/lib/vagrant/command/resume.rb +18 -5
  68. data/lib/vagrant/command/ssh.rb +69 -31
  69. data/lib/vagrant/command/ssh_config.rb +37 -22
  70. data/lib/vagrant/command/status.rb +22 -20
  71. data/lib/vagrant/command/suspend.rb +18 -5
  72. data/lib/vagrant/command/up.rb +41 -8
  73. data/lib/vagrant/communication.rb +7 -0
  74. data/lib/vagrant/communication/base.rb +56 -0
  75. data/lib/vagrant/communication/ssh.rb +200 -0
  76. data/lib/vagrant/config.rb +29 -103
  77. data/lib/vagrant/config/base.rb +18 -26
  78. data/lib/vagrant/config/container.rb +37 -0
  79. data/lib/vagrant/config/error_recorder.rb +1 -1
  80. data/lib/vagrant/config/loader.rb +125 -0
  81. data/lib/vagrant/config/nfs.rb +1 -3
  82. data/lib/vagrant/config/package.rb +1 -3
  83. data/lib/vagrant/config/ssh.rb +31 -16
  84. data/lib/vagrant/config/top.rb +36 -25
  85. data/lib/vagrant/config/vagrant.rb +2 -5
  86. data/lib/vagrant/config/vm.rb +115 -56
  87. data/lib/vagrant/config/vm/provisioner.rb +16 -20
  88. data/lib/vagrant/config/vm/sub_vm.rb +1 -1
  89. data/lib/vagrant/data_store.rb +23 -15
  90. data/lib/vagrant/downloaders/base.rb +7 -5
  91. data/lib/vagrant/downloaders/file.rb +4 -4
  92. data/lib/vagrant/downloaders/http.rb +4 -5
  93. data/lib/vagrant/driver.rb +7 -0
  94. data/lib/vagrant/driver/virtualbox.rb +121 -0
  95. data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
  96. data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
  97. data/lib/vagrant/driver/virtualbox_base.rb +284 -0
  98. data/lib/vagrant/environment.rb +221 -240
  99. data/lib/vagrant/errors.rb +74 -25
  100. data/lib/vagrant/guest.rb +16 -0
  101. data/lib/vagrant/guest/arch.rb +48 -0
  102. data/lib/vagrant/{systems → guest}/base.rb +30 -18
  103. data/lib/vagrant/guest/debian.rb +61 -0
  104. data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
  105. data/lib/vagrant/guest/gentoo.rb +32 -0
  106. data/lib/vagrant/guest/linux.rb +78 -0
  107. data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
  108. data/lib/vagrant/guest/linux/error.rb +9 -0
  109. data/lib/vagrant/guest/redhat.rb +66 -0
  110. data/lib/vagrant/guest/solaris.rb +114 -0
  111. data/lib/vagrant/{systems → guest}/suse.rb +2 -2
  112. data/lib/vagrant/guest/ubuntu.rb +23 -0
  113. data/lib/vagrant/hosts.rb +23 -6
  114. data/lib/vagrant/hosts/arch.rb +7 -3
  115. data/lib/vagrant/hosts/base.rb +36 -46
  116. data/lib/vagrant/hosts/bsd.rb +53 -16
  117. data/lib/vagrant/hosts/fedora.rb +14 -0
  118. data/lib/vagrant/hosts/freebsd.rb +6 -36
  119. data/lib/vagrant/hosts/linux.rb +45 -20
  120. data/lib/vagrant/hosts/windows.rb +16 -0
  121. data/lib/vagrant/provisioners.rb +10 -7
  122. data/lib/vagrant/provisioners/base.rb +11 -34
  123. data/lib/vagrant/provisioners/chef.rb +30 -26
  124. data/lib/vagrant/provisioners/chef_client.rb +37 -23
  125. data/lib/vagrant/provisioners/chef_solo.rb +61 -16
  126. data/lib/vagrant/provisioners/puppet.rb +70 -38
  127. data/lib/vagrant/provisioners/puppet_server.rb +12 -13
  128. data/lib/vagrant/provisioners/shell.rb +24 -24
  129. data/lib/vagrant/registry.rb +49 -0
  130. data/lib/vagrant/ssh.rb +82 -153
  131. data/lib/vagrant/ui.rb +118 -50
  132. data/lib/vagrant/util/busy.rb +1 -1
  133. data/lib/vagrant/util/file_mode.rb +12 -0
  134. data/lib/vagrant/util/network_ip.rb +28 -0
  135. data/lib/vagrant/util/platform.rb +1 -0
  136. data/lib/vagrant/util/subprocess.rb +227 -0
  137. data/lib/vagrant/version.rb +1 -1
  138. data/lib/vagrant/vm.rb +111 -97
  139. data/tasks/acceptance.rake +3 -3
  140. data/tasks/test.rake +7 -2
  141. data/templates/commands/init/Vagrantfile.erb +11 -4
  142. data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
  143. data/templates/guests/arch/network_dhcp.erb +7 -0
  144. data/templates/guests/arch/network_static.erb +7 -0
  145. data/templates/guests/debian/network_dhcp.erb +6 -0
  146. data/templates/guests/debian/network_static.erb +7 -0
  147. data/templates/guests/gentoo/network_dhcp.erb +4 -0
  148. data/templates/guests/gentoo/network_static.erb +4 -0
  149. data/templates/guests/redhat/network_dhcp.erb +6 -0
  150. data/templates/guests/redhat/network_static.erb +7 -0
  151. data/templates/locales/en.yml +241 -122
  152. data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
  153. data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
  154. data/test/acceptance/base.rb +10 -10
  155. data/test/acceptance/box_test.rb +28 -6
  156. data/test/acceptance/destroy_test.rb +1 -1
  157. data/test/acceptance/halt_test.rb +4 -4
  158. data/test/acceptance/init_test.rb +3 -3
  159. data/test/acceptance/networking/host_only_test.rb +37 -0
  160. data/test/acceptance/networking/port_forward_test.rb +125 -0
  161. data/test/acceptance/package_test.rb +46 -0
  162. data/test/acceptance/provisioning/basic_test.rb +61 -0
  163. data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
  164. data/test/acceptance/provisioning/shell_test.rb +53 -0
  165. data/test/acceptance/resume_test.rb +1 -1
  166. data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
  167. data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
  168. data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
  169. data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
  170. data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
  171. data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
  172. data/test/acceptance/ssh_test.rb +7 -2
  173. data/test/acceptance/support/config.rb +1 -1
  174. data/test/acceptance/support/isolated_environment.rb +41 -150
  175. data/test/acceptance/support/matchers/match_output.rb +1 -1
  176. data/test/acceptance/support/matchers/succeed.rb +14 -0
  177. data/test/acceptance/support/network_tests.rb +29 -0
  178. data/test/acceptance/support/output.rb +9 -1
  179. data/test/acceptance/support/shared/base_context.rb +16 -9
  180. data/test/acceptance/support/shared/command_examples.rb +4 -4
  181. data/test/acceptance/suspend_test.rb +1 -1
  182. data/test/acceptance/up_basic_test.rb +26 -7
  183. data/test/acceptance/up_with_box_url.rb +1 -1
  184. data/test/acceptance/vagrant_test.rb +1 -1
  185. data/test/acceptance/version_test.rb +0 -5
  186. data/test/support/isolated_environment.rb +46 -0
  187. data/test/{acceptance/support → support}/tempdir.rb +0 -0
  188. data/test/unit/base.rb +21 -0
  189. data/test/unit/support/isolated_environment.rb +39 -0
  190. data/test/unit/support/shared/base_context.rb +30 -0
  191. data/test/unit/vagrant/action/builder_test.rb +126 -177
  192. data/test/unit/vagrant/action/environment_test.rb +10 -21
  193. data/test/unit/vagrant/action/runner_test.rb +65 -0
  194. data/test/unit/vagrant/action/warden_test.rb +64 -97
  195. data/test/unit/vagrant/box_collection_test.rb +44 -33
  196. data/test/unit/vagrant/box_test.rb +25 -65
  197. data/test/unit/vagrant/command/base_test.rb +141 -14
  198. data/test/unit/vagrant/config/base_test.rb +16 -43
  199. data/test/unit/vagrant/config/loader_test.rb +79 -0
  200. data/test/unit/vagrant/config/top_test.rb +69 -0
  201. data/test/unit/vagrant/config/vm_test.rb +62 -47
  202. data/test/unit/vagrant/config_test.rb +16 -151
  203. data/test/unit/vagrant/data_store_test.rb +43 -61
  204. data/test/unit/vagrant/downloaders/base_test.rb +12 -22
  205. data/test/unit/vagrant/downloaders/file_test.rb +58 -31
  206. data/test/unit/vagrant/downloaders/http_test.rb +12 -86
  207. data/test/unit/vagrant/environment_test.rb +107 -536
  208. data/test/unit/vagrant/hosts_test.rb +36 -0
  209. data/test/unit/vagrant/registry_test.rb +56 -0
  210. data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
  211. data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
  212. data/test/unit/vagrant/util/network_ip_test.rb +17 -0
  213. data/test/unit/vagrant/util/retryable_test.rb +90 -34
  214. data/test/unit/vagrant_test.rb +27 -0
  215. data/test/{unit → unit_legacy}/locales/en.yml +0 -0
  216. data/test/{unit → unit_legacy}/test_helper.rb +0 -0
  217. data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
  218. data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
  219. data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
  220. data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
  221. data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
  222. data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
  223. data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
  224. data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
  225. data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
  226. data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
  227. data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
  228. data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
  229. data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
  230. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
  231. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
  232. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
  233. data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
  234. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
  235. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
  236. data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
  237. data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
  238. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
  239. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
  240. data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
  241. data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
  242. data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
  243. data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
  244. data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
  245. data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
  246. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
  247. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
  248. data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
  249. data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
  250. data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
  251. data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
  252. data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
  253. data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
  254. data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
  255. data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
  256. data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
  257. data/test/unit_legacy/vagrant/box_test.rb +74 -0
  258. data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
  259. data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
  260. data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
  261. data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
  262. data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
  263. data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
  264. data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
  265. data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
  266. data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
  267. data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
  268. data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
  269. data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
  270. data/test/unit_legacy/vagrant/config_test.rb +148 -0
  271. data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
  272. data/test/unit_legacy/vagrant/environment_test.rb +539 -0
  273. data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
  274. data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
  275. data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
  276. data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
  277. data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
  278. data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
  279. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
  280. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
  281. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
  282. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
  283. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
  284. data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
  285. data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
  286. data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
  287. data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
  288. data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
  289. data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
  290. data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
  291. data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
  292. data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
  293. data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
  294. data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
  295. data/vagrant.gemspec +7 -9
  296. metadata +214 -216
  297. data/keys/vagrant.ppk +0 -26
  298. data/lib/vagrant/action/box.rb +0 -11
  299. data/lib/vagrant/action/env.rb +0 -7
  300. data/lib/vagrant/action/general.rb +0 -8
  301. data/lib/vagrant/action/vm.rb +0 -34
  302. data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
  303. data/lib/vagrant/action/vm/modify.rb +0 -37
  304. data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
  305. data/lib/vagrant/command/group_base.rb +0 -107
  306. data/lib/vagrant/command/helpers.rb +0 -33
  307. data/lib/vagrant/command/named_base.rb +0 -14
  308. data/lib/vagrant/command/upgrade_to_060.rb +0 -45
  309. data/lib/vagrant/command/version.rb +0 -13
  310. data/lib/vagrant/ssh/session.rb +0 -136
  311. data/lib/vagrant/systems.rb +0 -13
  312. data/lib/vagrant/systems/arch.rb +0 -34
  313. data/lib/vagrant/systems/debian.rb +0 -36
  314. data/lib/vagrant/systems/gentoo.rb +0 -27
  315. data/lib/vagrant/systems/linux.rb +0 -82
  316. data/lib/vagrant/systems/linux/error.rb +0 -9
  317. data/lib/vagrant/systems/redhat.rb +0 -48
  318. data/lib/vagrant/systems/solaris.rb +0 -113
  319. data/lib/vagrant/systems/ubuntu.rb +0 -17
  320. data/templates/network_entry_arch.erb +0 -9
  321. data/templates/network_entry_debian.erb +0 -8
  322. data/templates/network_entry_gentoo.erb +0 -5
  323. data/templates/network_entry_redhat.erb +0 -9
  324. data/test/unit/vagrant/ui_test.rb +0 -29
@@ -1,93 +1,19 @@
1
- require "test_helper"
1
+ require File.expand_path("../../../base", __FILE__)
2
2
 
3
- class HttpDownloaderTest < Test::Unit::TestCase
4
- setup do
5
- @downloader, @tempfile = vagrant_mock_downloader(Vagrant::Downloaders::HTTP)
6
- @downloader.stubs(:report_progress)
7
- @downloader.stubs(:complete_progress)
8
- @uri = "http://google.com/"
9
- @headers = nil
10
- end
11
-
12
- context "downloading" do
13
- setup do
14
- ENV["http_proxy"] = nil
15
-
16
- @parsed_uri = URI.parse(@uri)
17
- @http = Net::HTTP.new(@parsed_uri.host, @parsed_uri.port)
18
- Net::HTTP.stubs(:new).returns(@http)
19
- @http.stubs(:start)
20
- end
21
-
22
- should "create a proper net/http object" do
23
- Net::HTTP.expects(:new).with(@parsed_uri.host, @parsed_uri.port, nil, nil, nil, nil).once.returns(@http)
24
- @http.expects(:start)
25
- @downloader.download!(@uri, @tempfile)
26
- end
27
-
28
- should "create a proper net/http object with a proxy" do
29
- ENV["http_proxy"] = "http://user:foo@google.com"
30
- @proxy = URI.parse(ENV["http_proxy"])
31
- Net::HTTP.expects(:new).with(@parsed_uri.host, @parsed_uri.port, @proxy.host, @proxy.port, @proxy.user, @proxy.password).once.returns(@http)
32
- @http.expects(:start)
33
- @downloader.download!(@uri, @tempfile)
34
- end
35
-
36
- should "create a proper net/http object without a proxy if no_proxy defined" do
37
- @uri = "http://somewhere.direct.com/some_file"
38
- @parsed_uri = URI.parse(@uri)
39
- ENV["http_proxy"] = "http://user:foo@google.com"
40
- ENV["no_proxy"] = "direct.com"
41
- Net::HTTP.expects(:new).with(@parsed_uri.host, @parsed_uri.port, nil, nil, nil, nil).once.returns(@http)
42
- @http.expects(:start)
43
- @downloader.download!(@uri, @tempfile)
44
- end
45
-
46
- should "enable SSL if scheme is https" do
47
- @uri = "https://google.com/"
48
- @http.expects(:use_ssl=).with(true).once
49
- @downloader.download!(@uri, @tempfile)
50
- end
51
-
52
- should "read the body of the response and place each segment into the file" do
53
- h = mock("http")
54
- response = mock("response")
55
- response.stubs(:content_length)
56
- response.stubs(:is_a?).with(anything).returns(false)
57
- response.stubs(:is_a?).with(Net::HTTPOK).returns(true)
58
- segment = mock("segment")
59
- segment.stubs(:length).returns(7)
60
-
61
- @http.stubs(:start).yields(h)
62
- h.expects(:request_get).with(@parsed_uri.request_uri, @headers).once.yields(response)
63
- response.expects(:read_body).once.yields(segment)
64
- @tempfile.expects(:write).with(segment).once
65
-
66
- @downloader.download!(@uri, @tempfile)
67
- end
68
-
69
- should "error environment if invalid URL given" do
70
- Net::HTTP.expects(:new).raises(SocketError.new)
71
-
72
- assert_raises(Vagrant::Errors::DownloaderHTTPSocketError) {
73
- @downloader.download!(@uri, @tempfile)
74
- }
75
- end
76
- end
77
-
78
- context "matching the uri" do
79
- should "use extract to verify that the string is in fact a uri" do
80
- URI.expects(:extract).returns(['foo'])
81
- assert Vagrant::Downloaders::HTTP.match?('foo')
82
- end
3
+ describe Vagrant::Downloaders::HTTP do
4
+ let(:ui) { double("ui") }
5
+ let(:instance) { described_class.new(ui) }
83
6
 
84
- should "return false if there are no extract results" do
85
- URI.expects(:extract).returns([])
86
- assert !Vagrant::Downloaders::HTTP.match?('foo')
7
+ describe "matching" do
8
+ it "should match URLs" do
9
+ described_class.match?("http://google.com/foo.box").should be
10
+ described_class.match?("https://google.com/foo.box").should be
11
+ described_class.match?("http://foo:bar@google.com/foo.box").should be
12
+ described_class.match?("http://google.com:8500/foo.box").should be
87
13
  end
88
14
  end
89
15
 
90
- context "reporting progress" do
91
- # TODO: Testing for this, probably
16
+ describe "downloading" do
17
+ # Integration tests only.
92
18
  end
93
19
  end
@@ -1,598 +1,169 @@
1
- require "test_helper"
1
+ require File.expand_path("../../base", __FILE__)
2
2
  require "pathname"
3
- require "tempfile"
4
3
 
5
- class EnvironmentTest < Test::Unit::TestCase
6
- setup do
7
- @klass = Vagrant::Environment
4
+ require "vagrant/util/file_mode"
8
5
 
9
- clean_paths
10
- end
6
+ require "support/tempdir"
11
7
 
12
- context "class method check virtualbox version" do
13
- setup do
14
- VirtualBox.stubs(:version).returns("4.1.0")
15
- end
8
+ describe Vagrant::Environment do
9
+ include_context "unit"
16
10
 
17
- should "not error and exit if everything is good" do
18
- VirtualBox.expects(:version).returns("4.1.0")
19
- assert_nothing_raised { @klass.check_virtualbox! }
20
- end
11
+ let(:home_path) { Pathname.new(Tempdir.new.path) }
12
+ let(:instance) { described_class.new(:home_path => home_path) }
21
13
 
22
- should "error and exit if VirtualBox is not installed or detected" do
23
- VirtualBox.expects(:version).returns(nil)
24
- assert_raises(Vagrant::Errors::VirtualBoxNotDetected) { @klass.check_virtualbox! }
14
+ describe "current working directory" do
15
+ it "is the cwd by default" do
16
+ described_class.new.cwd.should == Pathname.new(Dir.pwd)
25
17
  end
26
18
 
27
- should "error and exit if VirtualBox is lower than version 4.0" do
28
- version = "3.2.12r1041"
29
- VirtualBox.expects(:version).returns(version)
30
- assert_raises(Vagrant::Errors::VirtualBoxInvalidVersion) { @klass.check_virtualbox! }
19
+ it "is set to the cwd given" do
20
+ instance = described_class.new(:cwd => "foobarbaz")
21
+ instance.cwd.should == Pathname.new("foobarbaz")
31
22
  end
32
23
  end
33
24
 
34
- context "initialization" do
35
- should "set the cwd if given" do
36
- cwd = "foobarbaz"
37
- env = @klass.new(:cwd => cwd)
38
- assert_equal Pathname.new(cwd), env.cwd
25
+ describe "home path" do
26
+ it "is set to the home path given" do
27
+ dir = Tempdir.new.path
28
+ instance = described_class.new(:home_path => dir)
29
+ instance.home_path.should == Pathname.new(dir)
39
30
  end
40
31
 
41
- should "default to pwd if cwd is nil" do
42
- env = @klass.new
43
- assert_equal Pathname.new(Dir.pwd), env.cwd
32
+ it "is set to the environmental variable VAGRANT_HOME" do
33
+ pending "A good temporary ENV thing"
44
34
  end
45
- end
46
35
 
47
- context "paths" do
48
- setup do
49
- @env = vagrant_env
36
+ it "is set to the DEFAULT_HOME by default" do
37
+ expected = Pathname.new(File.expand_path(described_class::DEFAULT_HOME))
38
+ described_class.new.home_path.should == expected
50
39
  end
51
40
 
52
- context "dotfile path" do
53
- should "build up the dotfile out of the root path and the dotfile name" do
54
- assert_equal @env.root_path.join(@env.config.vagrant.dotfile_name), @env.dotfile_path
55
- end
56
- end
57
-
58
- context "home path" do
59
- setup do
60
- @env = @klass.new
61
-
62
- # Make a fake home directory for helping with tests
63
- @home_path = tmp_path.join("home")
64
- ENV["HOME"] = @home_path.to_s
65
- FileUtils.rm_rf(@home_path)
66
- FileUtils.mkdir_p(@home_path)
67
- end
68
-
69
- should "return the home path if it loaded" do
70
- ENV["VAGRANT_HOME"] = nil
71
-
72
- expected = Pathname.new(File.expand_path(@klass::DEFAULT_HOME))
73
- assert_equal expected, @env.home_path
74
- end
75
-
76
- should "return the home path set by the environmental variable" do
77
- ENV["VAGRANT_HOME"] = "foo"
78
-
79
- expected = Pathname.new(File.expand_path(ENV["VAGRANT_HOME"]))
80
- assert_equal expected, @env.home_path
81
- end
82
-
83
- should "move the old home directory to the new location" do
84
- new_path = @home_path.join(".vagrant.d")
85
- old_path = @home_path.join(".vagrant")
86
- old_path.mkdir
87
-
88
- # Get the home path
89
- ENV["VAGRANT_HOME"] = new_path.to_s
90
-
91
- assert !new_path.exist?
92
- assert_equal new_path, @env.home_path
93
- assert !old_path.exist?
94
- assert new_path.exist?
95
- end
96
-
97
- should "not move the old home directory if the new one already exists" do
98
- new_path = @home_path.join(".vagrant.d")
99
- new_path.mkdir
100
-
101
- old_path = @home_path.join(".vagrant")
102
- old_path.mkdir
103
-
104
- # Get the home path
105
- ENV["VAGRANT_HOME"] = new_path.to_s
106
-
107
- assert new_path.exist?
108
- assert_equal new_path, @env.home_path
109
- assert old_path.exist?
110
- assert new_path.exist?
111
- end
112
- end
113
-
114
- context "temp path" do
115
- should "return the home path joined with 'tmp'" do
116
- assert_equal @env.home_path.join("tmp"), @env.tmp_path
117
- end
118
- end
119
-
120
- context "boxes path" do
121
- should "return the home path joined with 'tmp'" do
122
- assert_equal @env.home_path.join("boxes"), @env.boxes_path
123
- end
41
+ it "throws an exception if inaccessible" do
42
+ expect {
43
+ described_class.new(:home_path => "/")
44
+ }.to raise_error(Vagrant::Errors::HomeDirectoryNotAccessible)
124
45
  end
125
46
  end
126
47
 
127
- context "resource" do
128
- setup do
129
- @env = vagrant_env
130
- end
131
-
132
- should "return 'vagrant' as a default" do
133
- assert_equal 'vagrant', @env.resource
134
- end
48
+ describe "copying the private SSH key" do
49
+ it "copies the SSH key into the home directory" do
50
+ env = isolated_environment
51
+ instance = described_class.new(:home_path => env.homedir)
135
52
 
136
- should "return the VM name if it is specified" do
137
- @env.stubs(:vm).returns(mock("vm", :name => "foo"))
138
- assert_equal "foo", @env.resource
53
+ pk = env.homedir.join("insecure_private_key")
54
+ pk.should be_exist
55
+ Vagrant::Util::FileMode.from_octal(pk.stat.mode).should == "600"
139
56
  end
140
57
  end
141
58
 
142
- context "primary VM helper" do
143
- should "return the first VM if not multivm" do
144
- env = vagrant_env
145
- assert_equal env.vms[@klass::DEFAULT_VM], env.primary_vm
146
- end
147
-
148
- should "call and return the primary VM from the parent if has one" do
149
- env = vagrant_env(vagrantfile(<<-vf))
150
- config.vm.define(:web, :primary => true) do; end
151
- config.vm.define :db do; end
152
- vf
153
-
154
- assert_equal :web, env.primary_vm.name
155
- end
156
-
157
- should "return nil if no VM is marked as primary" do
158
- env = vagrant_env(vagrantfile(<<-vf))
159
- config.vm.define :web
160
- config.vm.define :db
161
- config.vm.define :utility
162
- vf
163
-
164
- assert env.primary_vm.nil?
165
- end
166
- end
167
-
168
- context "multivm? helper" do
169
- should "return true if VM length greater than 1" do
170
- env = vagrant_env(vagrantfile(<<-vf))
171
- config.vm.define :web
172
- config.vm.define :db
173
- vf
174
-
175
- assert env.multivm?
176
- end
177
-
178
- should "return true if VM length is 1 and a sub-VM is defined" do
179
- env = vagrant_env(vagrantfile(<<-vf))
180
- config.vm.define :web
181
- vf
182
-
183
- assert env.multivm?
184
- end
185
-
186
- should "return false if only default VM exists" do
187
- assert !vagrant_env.multivm?
188
- end
189
- end
190
-
191
- context "local data" do
192
- should "lazy load the data store only once" do
193
- result = { :foo => :bar }
194
- Vagrant::DataStore.expects(:new).returns(result).once
195
- env = vagrant_env
196
- assert_equal result, env.local_data
197
- assert_equal result, env.local_data
198
- assert_equal result, env.local_data
199
- end
200
-
201
- should "return the parent's local data if a parent exists" do
202
- env = vagrant_env(vagrantfile(<<-vf))
203
- config.vm.define :web
204
- config.vm.define :db
205
- vf
206
-
207
- env.local_data[:foo] = :bar
208
-
209
- Vagrant::DataStore.expects(:new).never
210
- assert_equal :bar, env.vms[:web].env.local_data[:foo]
211
- end
212
- end
213
-
214
- context "accessing host" do
215
- should "load the host once" do
216
- env = @klass.new(:cwd => vagrantfile)
217
- result = mock("result")
218
- Vagrant::Hosts::Base.expects(:load).with(env, env.config.vagrant.host).once.returns(result)
219
- assert_equal result, env.host
220
- assert_equal result, env.host
221
- assert_equal result, env.host
222
- end
59
+ it "has a box collection pointed to the proper directory" do
60
+ collection = instance.boxes
61
+ collection.should be_kind_of(Vagrant::BoxCollection)
62
+ collection.directory.should == instance.boxes_path
223
63
  end
224
64
 
225
- context "accessing actions" do
226
- should "initialize the Action object with the given environment" do
227
- env = @klass.new(:cwd => vagrant_app)
228
- result = mock("result")
229
- Vagrant::Action.expects(:new).with(env).returns(result).once
230
- assert_equal result, env.actions
231
- assert_equal result, env.actions
232
- assert_equal result, env.actions
233
- end
234
- end
235
-
236
- context "global data" do
237
- should "lazy load the data store only once" do
238
- env = vagrant_env
239
- store = env.global_data
240
-
241
- assert env.global_data.equal?(store)
242
- assert env.global_data.equal?(store)
243
- assert env.global_data.equal?(store)
65
+ describe "action runner" do
66
+ it "has an action runner" do
67
+ instance.action_runner.should be_kind_of(Vagrant::Action::Runner)
244
68
  end
245
69
 
246
- should "return the parent's global data if a parent exists" do
247
- env = vagrant_env(vagrantfile(<<-vf))
248
- config.vm.define :web
249
- config.vm.define :db
250
- vf
70
+ it "has a `ui` in the globals" do
71
+ result = nil
72
+ callable = lambda { |env| result = env[:ui] }
251
73
 
252
- result = env.global_data
253
- assert env.vms[:web].env.global_data.equal?(result)
74
+ instance.action_runner.run(callable)
75
+ result.should eql(instance.ui)
254
76
  end
255
77
  end
256
78
 
257
- context "loading logger" do
258
- should "lazy load the logger only once" do
259
- env = vagrant_env
260
- result = env.logger
261
- assert result === env.logger
79
+ describe "action registry" do
80
+ it "has an action registry" do
81
+ instance.action_registry.should be_kind_of(Vagrant::Registry)
262
82
  end
263
83
 
264
- should "return the parent's logger if a parent exists" do
265
- env = vagrant_env(vagrantfile(<<-vf))
266
- config.vm.define :web
267
- config.vm.define :db
268
- vf
269
-
270
- assert env.logger === env.vms[:web].env.logger
84
+ it "should have the built-in actions in the registry" do
85
+ instance.action_registry.get(:provision).should_not be_nil
271
86
  end
272
87
  end
273
88
 
274
- context "loading the root path" do
275
- should "should walk the parent directories looking for rootfile" do
276
- paths = [Pathname.new("/foo/bar/baz"),
277
- Pathname.new("/foo/bar"),
278
- Pathname.new("/foo"),
279
- Pathname.new("/")
280
- ]
281
-
282
- rootfile = "Foo"
283
-
284
- search_seq = sequence("search_seq")
285
- paths.each do |path|
286
- File.expects(:exist?).with(path.join(rootfile).to_s).returns(false).in_sequence(search_seq)
287
- File.expects(:exist?).with(path).returns(true).in_sequence(search_seq) if !path.root?
89
+ describe "loading configuration" do
90
+ it "should load global configuration" do
91
+ environment = isolated_environment do |env|
92
+ env.vagrantfile(<<-VF)
93
+ Vagrant::Config.run do |config|
94
+ config.vagrant.dotfile_name = "foo"
95
+ end
96
+ VF
288
97
  end
289
98
 
290
- assert !@klass.new(:cwd => paths.first, :vagrantfile_name => rootfile).root_path
291
- end
292
-
293
- should "should set the path for the rootfile" do
294
- rootfile = "Foo"
295
- path = Pathname.new(File.expand_path("/foo"))
296
- File.expects(:exist?).with(path.join(rootfile).to_s).returns(true)
297
-
298
- assert_equal path, @klass.new(:cwd => path, :vagrantfile_name => rootfile).root_path
299
- end
300
-
301
- should "not infinite loop on relative paths" do
302
- assert @klass.new(:cwd => "../test").root_path.nil?
303
- end
304
-
305
- should "only load the root path once" do
306
- rootfile = "foo"
307
- env = @klass.new(:vagrantfile_name => rootfile)
308
- File.expects(:exist?).with(env.cwd.join(rootfile).to_s).returns(true).once
309
-
310
- assert_equal env.cwd, env.root_path
311
- assert_equal env.cwd, env.root_path
312
- assert_equal env.cwd, env.root_path
313
- end
314
-
315
- should "only load the root path once even if nil" do
316
- File.stubs(:exist?).returns(false)
317
-
318
- env = @klass.new
319
- assert env.root_path.nil?
320
- assert env.root_path.nil?
321
- assert env.root_path.nil?
322
- end
323
- end
324
-
325
- context "locking" do
326
- setup do
327
- @instance = @klass.new(:lock_path => Tempfile.new('vagrant-test').path)
328
- end
329
-
330
- should "allow nesting locks" do
331
- assert_nothing_raised do
332
- @instance.lock do
333
- @instance.lock do
334
- # Nothing
335
- end
336
- end
337
- end
99
+ env = environment.create_vagrant_env
100
+ env.config.global.vagrant.dotfile_name.should == "foo"
338
101
  end
339
102
 
340
- should "raise an exception if an environment already has a lock" do
341
- @another = @klass.new(:lock_path => @instance.lock_path)
342
-
343
- # Create first locked thread which should succeed
344
- first = Thread.new do
345
- begin
346
- @instance.lock do
347
- Thread.current[:locked] = true
348
- loop { sleep 1000 }
349
- end
350
- rescue Vagrant::Errors::EnvironmentLockedError
351
- Thread.current[:locked] = false
352
- end
353
- end
354
-
355
- # Wait until the first thread has acquired the lock
356
- loop do
357
- break if first[:locked] || !first.alive?
358
- Thread.pass
359
- end
360
-
361
- # Verify that the fist got the lock
362
- assert first[:locked]
363
-
364
- # Create second locked thread which should fail
365
- second = Thread.new do
366
- begin
367
- @another.lock do
368
- Thread.current[:error] = false
369
- end
370
- rescue Vagrant::Errors::EnvironmentLockedError
371
- Thread.current[:error] = true
372
- end
103
+ it "should load VM configuration" do
104
+ environment = isolated_environment do |env|
105
+ env.vagrantfile(<<-VF)
106
+ Vagrant::Config.run do |config|
107
+ config.vagrant.dotfile_name = "foo"
108
+ end
109
+ VF
373
110
  end
374
111
 
375
- # Wait for the second to end and verify it failed
376
- second.join
377
- assert second[:error]
378
-
379
- # Make sure both threads are killed
380
- first.kill
381
- second.kill
382
- end
383
- end
384
-
385
- context "accessing the configuration" do
386
- should "load the environment if its not already loaded" do
387
- env = @klass.new(:cwd => vagrantfile)
388
- env.expects(:load!).once
389
- env.config
112
+ env = environment.create_vagrant_env
113
+ env.config.for_vm(:default).vm.name.should == :default
390
114
  end
391
115
 
392
- should "not load the environment if its already loaded" do
393
- env = vagrant_env
394
- env.expects(:load!).never
395
- env.config
396
- end
116
+ it "should load VM configuration with multiple VMs" do
117
+ environment = isolated_environment do |env|
118
+ env.vagrantfile(<<-VF)
119
+ Vagrant::Config.run do |config|
120
+ config.vm.define :foo do |vm|
121
+ vm.ssh.port = 100
397
122
  end
398
123
 
399
- context "accessing the box collection" do
400
- should "create a box collection representing the environment" do
401
- env = vagrant_env
402
- assert env.boxes.is_a?(Vagrant::BoxCollection)
403
- assert_equal env, env.boxes.env
404
- end
405
-
406
- should "not load the environment if its already loaded" do
407
- env = vagrant_env
408
- env.expects(:load!).never
409
- env.boxes
410
- end
411
-
412
- should "return the parent's box collection if it has one" do
413
- env = vagrant_env(vagrantfile(<<-vf))
414
- config.vm.define :web
415
- config.vm.define :db
416
- vf
417
-
418
- assert env.vms[:web].env.boxes.equal?(env.boxes)
419
- end
124
+ config.vm.define :bar do |vm|
125
+ vm.ssh.port = 200
420
126
  end
421
-
422
- context "accessing the current box" do
423
- should "return the box that is specified in the config" do
424
- vagrant_box("foo")
425
- env = vagrant_env(vagrantfile(<<-vf))
426
- config.vm.box = "foo"
427
- vf
428
-
429
- assert env.box
430
- assert_equal "foo", env.box.name
431
- end
432
- end
433
-
434
- context "accessing the VMs hash" do
435
- should "load the environment if its not already loaded" do
436
- env = @klass.new(:cwd => vagrantfile)
437
- assert !env.loaded?
438
- env.vms
439
- assert env.loaded?
440
- end
441
-
442
- should "not load the environment if its already loaded" do
443
- env = vagrant_env
444
- env.expects(:load!).never
445
- env.vms
446
- end
447
-
448
- should "return the parent's VMs hash if it has one" do
449
- env = vagrant_env(vagrantfile(<<-vf))
450
- config.vm.define :web
451
- config.vm.define :db
452
- vf
453
-
454
- assert env.vms[:web].env.vms.equal?(env.vms)
455
- end
456
- end
457
-
458
- context "loading" do
459
- context "overall load method" do
460
- should "load! should call proper sequence and return itself" do
461
- env = @klass.new(:cwd => vagrantfile)
462
- call_seq = sequence("call_sequence")
463
- @klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
464
- env.expects(:load_config!).once.in_sequence(call_seq)
465
- assert_equal env, env.load!
466
- end
467
- end
468
-
469
- context "loading config" do
470
- setup do
471
- clean_paths
472
- @env = @klass.new(:cwd => vagrantfile)
473
- end
474
-
475
- def create_box_vagrantfile
476
- vagrantfile(vagrant_box("box"), <<-FILE)
477
- config.package.name = "box.box"
478
- config.vm.base_mac = "set"
479
- FILE
480
- end
481
-
482
- def create_home_vagrantfile
483
- vagrantfile(home_path, 'config.package.name = "home.box"')
484
- end
485
-
486
- def create_root_vagrantfile
487
- vagrantfile(@env.root_path, 'config.package.name = "root.box"')
488
- end
489
-
490
- should "load from the project root" do
491
- assert_equal "package.box", @env.config.package.name
492
- end
493
-
494
- should "load from box if specified" do
495
- create_box_vagrantfile
496
- vagrantfile(@env.root_path, "config.vm.box = 'box'")
497
-
498
- assert_equal "box.box", @env.primary_vm.env.config.package.name
499
- end
500
-
501
- should "load from home path if exists" do
502
- create_home_vagrantfile
503
- assert_equal "home.box", @env.config.package.name
504
- end
505
-
506
- should "load from root path" do
507
- create_home_vagrantfile
508
- create_root_vagrantfile
509
- assert_equal "root.box", @env.config.package.name
510
- end
511
-
512
- should "load from a sub-vm configuration if environment represents a VM" do
513
- create_home_vagrantfile
514
- create_box_vagrantfile
515
- vagrantfile(@env.root_path, <<-vf)
516
- config.package.name = "root.box"
517
- config.vm.define :web do |web|
518
- web.vm.box = "box"
519
- web.package.name = "web.box"
520
- end
521
- vf
522
-
523
- assert_equal "root.box", @env.config.package.name
524
- assert_equal "web.box", @env.vms[:web].env.config.package.name
525
- assert_equal "set", @env.vms[:web].env.config.vm.base_mac
127
+ end
128
+ VF
526
129
  end
527
130
 
528
- should "be able to reload config" do
529
- vagrantfile(@env.root_path, "config.vm.box = 'box'")
530
-
531
- # First load the config normally
532
- @env.load_config!
533
- assert_equal "box", @env.config.vm.box
534
- assert_not_equal "set", @env.config.vm.base_mac
535
-
536
- # Modify the Vagrantfile and reload it, then verify new results
537
- # are available
538
- vagrantfile(@env.root_path, "config.vm.base_mac = 'set'")
539
- @env.reload_config!
540
- assert_equal "set", @env.config.vm.base_mac
541
- end
131
+ env = environment.create_vagrant_env
132
+ env.config.for_vm(:foo).ssh.port.should == 100
133
+ env.config.for_vm(:bar).ssh.port.should == 200
542
134
  end
543
135
 
544
- context "loading home directory" do
545
- setup do
546
- @env = vagrant_env
547
-
548
- File.stubs(:directory?).returns(true)
549
- FileUtils.stubs(:mkdir_p)
550
- end
551
-
552
- should "create each directory if it doesn't exist" do
553
- create_seq = sequence("create_seq")
554
- File.stubs(:directory?).returns(false)
555
- @klass::HOME_SUBDIRS.each do |subdir|
556
- FileUtils.expects(:mkdir_p).with(@env.home_path.join(subdir)).in_sequence(create_seq)
557
- end
136
+ it "should load box configuration" do
137
+ environment = isolated_environment do |env|
138
+ env.vagrantfile(<<-VF)
139
+ Vagrant::Config.run do |config|
140
+ config.vm.box = "base"
141
+ end
142
+ VF
558
143
 
559
- @env.load_home_directory!
144
+ env.box("base", <<-VF)
145
+ Vagrant::Config.run do |config|
146
+ config.ssh.port = 100
147
+ end
148
+ VF
560
149
  end
561
150
 
562
- should "not create directories if they exist" do
563
- File.stubs(:directory?).returns(true)
564
- FileUtils.expects(:mkdir_p).never
565
- @env.load_home_directory!
566
- end
151
+ env = environment.create_vagrant_env
152
+ env.config.for_vm(:default).ssh.port.should == 100
567
153
  end
154
+ end
568
155
 
569
- context "loading the UUID out from the persisted dotfile" do
570
- setup do
571
- @env = vagrant_env
572
- end
573
-
574
- should "load all the VMs from the dotfile" do
575
- @env.local_data[:active] = { "foo" => "bar", "bar" => "baz" }
576
-
577
- results = {}
578
- @env.local_data[:active].each do |key, value|
579
- vm = mock("vm#{key}")
580
- Vagrant::VM.expects(:find).with(value, @env, key.to_sym).returns(vm)
581
- results[key.to_sym] = vm
582
- end
583
-
584
- returned = @env.load_vms!
156
+ describe "ui" do
157
+ it "should be a silent UI by default" do
158
+ described_class.new.ui.should be_kind_of(Vagrant::UI::Silent)
159
+ end
585
160
 
586
- results.each do |key, value|
587
- assert_equal value, returned[key]
588
- end
589
- end
161
+ it "should be a UI given in the constructor" do
162
+ # Create a custom UI for our test
163
+ class CustomUI < Vagrant::UI::Interface; end
590
164
 
591
- should "uuid should be nil if local data contains nothing" do
592
- assert @env.local_data.empty? # sanity
593
- @env.load_vms!
594
- assert_nil @env.vm
595
- end
165
+ instance = described_class.new(:ui_class => CustomUI)
166
+ instance.ui.should be_kind_of(CustomUI)
596
167
  end
597
168
  end
598
169
  end