vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
@@ -1,207 +1,156 @@
|
|
1
|
-
require "
|
2
|
-
require "logger"
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe Vagrant::Action::Builder do
|
4
|
+
let(:data) { { :data => [] } }
|
5
|
+
let(:instance) { described_class.new }
|
6
|
+
|
7
|
+
# This returns a proc that can be used with the builder
|
8
|
+
# that simply appends data to an array in the env.
|
9
|
+
def appender_proc(data)
|
10
|
+
Proc.new { |env| env[:data] << data }
|
7
11
|
end
|
8
12
|
|
9
|
-
context "
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
context "basic `use`" do
|
14
|
+
it "should add items to the stack and make them callable" do
|
15
|
+
data = {}
|
16
|
+
proc = Proc.new { |env| env[:data] = true }
|
17
|
+
|
18
|
+
instance.use proc
|
19
|
+
instance.call(data)
|
20
|
+
|
21
|
+
data[:data].should == true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to add multiple items" do
|
25
|
+
data = {}
|
26
|
+
proc1 = Proc.new { |env| env[:one] = true }
|
27
|
+
proc2 = Proc.new { |env| env[:two] = true }
|
28
|
+
|
29
|
+
instance.use proc1
|
30
|
+
instance.use proc2
|
31
|
+
instance.call(data)
|
32
|
+
|
33
|
+
data[:one].should == true
|
34
|
+
data[:two].should == true
|
13
35
|
end
|
14
36
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
37
|
+
it "should be able to add another builder" do
|
38
|
+
data = {}
|
39
|
+
proc1 = Proc.new { |env| env[:one] = true }
|
40
|
+
|
41
|
+
# Build the first builder
|
42
|
+
one = described_class.new
|
43
|
+
one.use proc1
|
44
|
+
|
45
|
+
# Add it to this builder
|
46
|
+
two = described_class.new
|
47
|
+
two.use one
|
48
|
+
|
49
|
+
# Call the 2nd and verify results
|
50
|
+
two.call(data)
|
51
|
+
data[:one].should == true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be able to set additional variables when using" do
|
55
|
+
data = { }
|
56
|
+
proc1 = Proc.new { |env| env[:data] += 1 }
|
57
|
+
|
58
|
+
# Build the first builder
|
59
|
+
one = described_class.new
|
60
|
+
one.use proc1, :data => 5
|
61
|
+
one.call(data)
|
20
62
|
|
21
|
-
|
22
|
-
assert_equal 2, builder.stack.length
|
63
|
+
data[:data].should == 6
|
23
64
|
end
|
24
65
|
end
|
25
66
|
|
26
|
-
context "
|
27
|
-
|
28
|
-
|
67
|
+
context "inserting" do
|
68
|
+
it "can insert at an index" do
|
69
|
+
instance.use appender_proc(1)
|
70
|
+
instance.insert(0, appender_proc(2))
|
71
|
+
instance.call(data)
|
72
|
+
|
73
|
+
data[:data].should == [2, 1]
|
29
74
|
end
|
30
75
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal [2, [], nil], @instance.stack.last
|
40
|
-
end
|
41
|
-
|
42
|
-
should "merge in other builder's stack" do
|
43
|
-
other = @klass.new do
|
44
|
-
use 2
|
45
|
-
use 3
|
46
|
-
end
|
47
|
-
|
48
|
-
@instance.use 1
|
49
|
-
@instance.use other
|
50
|
-
assert_equal 3, @instance.stack.length
|
51
|
-
end
|
52
|
-
|
53
|
-
should "prepend a set environment task for merging middlewares if given" do
|
54
|
-
other = @klass.new do
|
55
|
-
use 1
|
56
|
-
end
|
57
|
-
|
58
|
-
@instance.use 0
|
59
|
-
@instance.use(other, :foo => :bar)
|
60
|
-
assert_equal 3, @instance.stack.length
|
61
|
-
assert_equal Vagrant::Action::Env::Set, @instance.stack[1].first
|
62
|
-
end
|
76
|
+
it "can insert next to a previous object" do
|
77
|
+
proc2 = appender_proc(2)
|
78
|
+
instance.use appender_proc(1)
|
79
|
+
instance.use proc2
|
80
|
+
instance.insert(proc2, appender_proc(3))
|
81
|
+
instance.call(data)
|
82
|
+
|
83
|
+
data[:data].should == [1, 3, 2]
|
63
84
|
end
|
64
85
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
func = lambda { |x| x.foo }
|
72
|
-
@instance.use func
|
73
|
-
proc = @instance.flatten
|
74
|
-
assert proc.respond_to?(:call)
|
75
|
-
proc.call(env)
|
76
|
-
end
|
86
|
+
it "can insert before" do
|
87
|
+
instance.use appender_proc(1)
|
88
|
+
instance.insert_before 0, appender_proc(2)
|
89
|
+
instance.call(data)
|
90
|
+
|
91
|
+
data[:data].should == [2, 1]
|
77
92
|
end
|
78
93
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
should
|
86
|
-
@instance.insert(1, "3")
|
87
|
-
assert_equal "3", @instance.stack[1].first
|
88
|
-
end
|
89
|
-
|
90
|
-
should "insert next to the proper object if given" do
|
91
|
-
@instance.insert("2", "3")
|
92
|
-
assert_equal "3", @instance.stack[1].first
|
93
|
-
end
|
94
|
-
|
95
|
-
should "be able to call insert_before as well" do
|
96
|
-
@instance.insert_before("1", "0")
|
97
|
-
assert_equal "0", @instance.stack.first.first
|
98
|
-
end
|
99
|
-
|
100
|
-
should "be able to insert_after" do
|
101
|
-
@instance.insert_after("1", "0")
|
102
|
-
assert_equal "0", @instance.stack[1].first
|
103
|
-
end
|
104
|
-
|
105
|
-
should "be able to insert_after using numeric index" do
|
106
|
-
@instance.insert_after(1, "0")
|
107
|
-
assert_equal "0", @instance.stack[2].first
|
108
|
-
end
|
109
|
-
|
110
|
-
should "raise an exception if invalid index" do
|
111
|
-
assert_raises(RuntimeError) {
|
112
|
-
@instance.insert_after("15", "0")
|
113
|
-
}
|
114
|
-
end
|
94
|
+
it "can insert after" do
|
95
|
+
instance.use appender_proc(1)
|
96
|
+
instance.use appender_proc(3)
|
97
|
+
instance.insert_after 0, appender_proc(2)
|
98
|
+
instance.call(data)
|
99
|
+
|
100
|
+
data[:data].should == [1, 2, 3]
|
115
101
|
end
|
116
102
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
@instance.use "2"
|
121
|
-
end
|
122
|
-
|
123
|
-
should "be able to swap using the object" do
|
124
|
-
@instance.swap "1", "3"
|
125
|
-
assert_equal "3", @instance.stack.first.first
|
126
|
-
end
|
127
|
-
|
128
|
-
should "be able to swap using the index" do
|
129
|
-
@instance.swap 0, "3"
|
130
|
-
assert_equal "3", @instance.stack.first.first
|
131
|
-
end
|
103
|
+
it "raises an exception if an invalid object given" do
|
104
|
+
expect { instance.insert_after "object", appender_proc(1) }.
|
105
|
+
to raise_error(RuntimeError)
|
132
106
|
end
|
107
|
+
end
|
133
108
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
109
|
+
context "replace" do
|
110
|
+
it "can replace an object" do
|
111
|
+
proc1 = appender_proc(1)
|
112
|
+
proc2 = appender_proc(2)
|
138
113
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
114
|
+
instance.use proc1
|
115
|
+
instance.replace proc1, proc2
|
116
|
+
instance.call(data)
|
143
117
|
|
144
|
-
should
|
145
|
-
@instance.delete(0)
|
146
|
-
assert @instance.stack.empty?
|
147
|
-
end
|
118
|
+
data[:data].should == [2]
|
148
119
|
end
|
149
120
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
121
|
+
it "can replace by index" do
|
122
|
+
proc1 = appender_proc(1)
|
123
|
+
proc2 = appender_proc(2)
|
124
|
+
|
125
|
+
instance.use proc1
|
126
|
+
instance.replace 0, proc2
|
127
|
+
instance.call(data)
|
128
|
+
|
129
|
+
data[:data].should == [2]
|
157
130
|
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "deleting" do
|
134
|
+
it "can delete by object" do
|
135
|
+
proc1 = appender_proc(1)
|
158
136
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
func = lambda { |x| x.foo }
|
166
|
-
@instance.use func
|
167
|
-
@instance.to_app(env).call(env)
|
168
|
-
end
|
169
|
-
|
170
|
-
should "raise exception if given invalid middleware" do
|
171
|
-
@instance.use 7
|
172
|
-
assert_raises(RuntimeError) {
|
173
|
-
@instance.to_app(nil)
|
174
|
-
}
|
175
|
-
end
|
137
|
+
instance.use proc1
|
138
|
+
instance.use appender_proc(2)
|
139
|
+
instance.delete proc1
|
140
|
+
instance.call(data)
|
141
|
+
|
142
|
+
data[:data].should == [2]
|
176
143
|
end
|
177
144
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
should "convert to an app then call with the env" do
|
192
|
-
mw = mock_middleware
|
193
|
-
mw.any_instance.expects(:call).with() do |env|
|
194
|
-
assert env.has_key?(:key)
|
195
|
-
true
|
196
|
-
end
|
197
|
-
|
198
|
-
env = Vagrant::Action::Environment.new(nil)
|
199
|
-
env["logger"] = Logger.new(nil)
|
200
|
-
env[:key] = :value
|
201
|
-
|
202
|
-
@instance.use(mw)
|
203
|
-
@instance.call(env)
|
204
|
-
end
|
145
|
+
it "can delete by index" do
|
146
|
+
proc1 = appender_proc(1)
|
147
|
+
|
148
|
+
instance.use proc1
|
149
|
+
instance.use appender_proc(2)
|
150
|
+
instance.delete 0
|
151
|
+
instance.call(data)
|
152
|
+
|
153
|
+
data[:data].should == [2]
|
205
154
|
end
|
206
155
|
end
|
207
156
|
end
|
@@ -1,27 +1,16 @@
|
|
1
|
-
require "
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
@klass = Vagrant::Action::Environment
|
6
|
-
@instance = @klass.new(vagrant_env)
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be a hash with indifferent access" do
|
10
|
-
assert @instance.is_a?(Vagrant::Util::HashWithIndifferentAccess)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "default values to those on the env" do
|
14
|
-
@instance.env.stubs(:key).returns("value")
|
15
|
-
assert_equal "value", @instance["key"]
|
16
|
-
end
|
3
|
+
describe Vagrant::Action::Environment do
|
4
|
+
let(:instance) { described_class.new }
|
17
5
|
|
18
|
-
|
19
|
-
|
6
|
+
it "should be a hash" do
|
7
|
+
instance.should be_empty
|
8
|
+
instance["foo"] = "bar"
|
9
|
+
instance["foo"].should == "bar"
|
20
10
|
end
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
assert @instance.interrupted?
|
12
|
+
it "should be a hash accessible by string or symbol" do
|
13
|
+
instance["foo"] = "bar"
|
14
|
+
instance[:foo].should == "bar"
|
26
15
|
end
|
27
16
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
|
+
|
3
|
+
describe Vagrant::Action::Runner do
|
4
|
+
let(:registry) do
|
5
|
+
d = double("registry")
|
6
|
+
d.stub(:get)
|
7
|
+
d
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:instance) { described_class.new(registry) }
|
11
|
+
|
12
|
+
it "should raise an error if an invalid callable is given" do
|
13
|
+
expect { instance.run(7) }.to raise_error(ArgumentError, /must be a callable/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to use a Proc as a callable" do
|
17
|
+
callable = Proc.new { raise Exception, "BOOM" }
|
18
|
+
expect { instance.run(callable) }.to raise_error(Exception, "BOOM")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to use a Class as a callable" do
|
22
|
+
callable = Class.new do
|
23
|
+
def initialize(app, env)
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(env)
|
27
|
+
raise Exception, "BOOM"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
expect { instance.run(callable) }.to raise_error(Exception, "BOOM")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should pass options into hash given to callable" do
|
35
|
+
result = nil
|
36
|
+
callable = lambda do |env|
|
37
|
+
result = env["data"]
|
38
|
+
end
|
39
|
+
|
40
|
+
instance.run(callable, "data" => "foo")
|
41
|
+
result.should == "foo"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should pass global options into the hash" do
|
45
|
+
result = nil
|
46
|
+
callable = lambda do |env|
|
47
|
+
result = env["data"]
|
48
|
+
end
|
49
|
+
|
50
|
+
instance = described_class.new(registry, "data" => "bar")
|
51
|
+
instance.run(callable)
|
52
|
+
result.should == "bar"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should yield the block passed to the init method to get lazy loaded globals" do
|
56
|
+
result = nil
|
57
|
+
callable = lambda do |env|
|
58
|
+
result = env["data"]
|
59
|
+
end
|
60
|
+
|
61
|
+
instance = described_class.new(registry) { { "data" => "bar" } }
|
62
|
+
instance.run(callable)
|
63
|
+
result.should == "bar"
|
64
|
+
end
|
65
|
+
end
|
@@ -1,125 +1,92 @@
|
|
1
|
-
require "
|
2
|
-
require "logger"
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@instance = @klass.new([], {})
|
8
|
-
end
|
3
|
+
describe Vagrant::Action::Warden do
|
4
|
+
let(:data) { { :data => [] } }
|
5
|
+
let(:instance) { described_class.new }
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
middleware.each do |m|
|
15
|
-
@klass.any_instance.expects(:finalize_action).with(m, env).returns(m)
|
16
|
-
end
|
17
|
-
@warden = @klass.new(middleware, env)
|
18
|
-
assert_equal @warden.actions, [1,2,3]
|
19
|
-
end
|
7
|
+
# This returns a proc that can be used with the builder
|
8
|
+
# that simply appends data to an array in the env.
|
9
|
+
def appender_proc(data)
|
10
|
+
Proc.new { |env| env[:data] << data }
|
20
11
|
end
|
21
12
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
env.expects(:foo).once
|
13
|
+
it "calls the actions like normal" do
|
14
|
+
instance = described_class.new([appender_proc(1), appender_proc(2)], data)
|
15
|
+
instance.call(data)
|
26
16
|
|
27
|
-
|
28
|
-
@instance.finalize_action(func, env).call(env)
|
29
|
-
end
|
30
|
-
|
31
|
-
should "raise exception if given invalid middleware" do
|
32
|
-
assert_raises(RuntimeError) {
|
33
|
-
@instance.finalize_action(7, nil)
|
34
|
-
}
|
35
|
-
end
|
17
|
+
data[:data].should == [1, 2]
|
36
18
|
end
|
37
19
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
20
|
+
it "starts a recovery sequence when an exception is raised" do
|
21
|
+
class Action
|
22
|
+
def initialize(app, env)
|
23
|
+
@app = app
|
24
|
+
end
|
43
25
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@instance.call(new_env)
|
48
|
-
assert !@instance.stack.empty?
|
49
|
-
assert @instance.actions.empty?
|
50
|
-
end
|
26
|
+
def call(env)
|
27
|
+
@app.call(env)
|
28
|
+
end
|
51
29
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
action.expects(:call).with(env)
|
56
|
-
@instance.actions << action
|
57
|
-
@instance.call(env)
|
30
|
+
def recover(env)
|
31
|
+
env[:recover] << 1
|
32
|
+
end
|
58
33
|
end
|
59
34
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
def call(env)
|
64
|
-
raise "An exception"
|
65
|
-
end
|
35
|
+
class ActionTwo
|
36
|
+
def initialize(app, env)
|
37
|
+
@app = app
|
66
38
|
end
|
67
39
|
|
68
|
-
|
69
|
-
|
70
|
-
assert env["vagrant.error"].is_a?(RuntimeError)
|
71
|
-
true
|
40
|
+
def call(env)
|
41
|
+
@app.call(env)
|
72
42
|
end
|
73
|
-
assert_raises(RuntimeError) { @instance.call(new_env) }
|
74
|
-
end
|
75
43
|
|
76
|
-
|
77
|
-
|
78
|
-
def initialize(*args); end
|
79
|
-
def call(env)
|
80
|
-
# Raises a system exit
|
81
|
-
abort
|
82
|
-
end
|
44
|
+
def recover(env)
|
45
|
+
env[:recover] << 2
|
83
46
|
end
|
84
|
-
|
85
|
-
@instance.actions << Foo.new
|
86
|
-
@instance.expects(:begin_rescue).never
|
87
|
-
assert_raises(SystemExit) { @instance.call(new_env) }
|
88
47
|
end
|
89
48
|
|
90
|
-
|
91
|
-
env = new_env
|
92
|
-
env.expects(:interrupted?).returns(true)
|
93
|
-
@instance.actions << lambda { |env| }
|
49
|
+
error_proc = Proc.new { raise "ERROR!" }
|
94
50
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
51
|
+
data = { :recover => [] }
|
52
|
+
instance = described_class.new([Action, ActionTwo, error_proc], data)
|
53
|
+
|
54
|
+
# The error should be raised back up
|
55
|
+
expect { instance.call(data) }.
|
56
|
+
to raise_error(RuntimeError)
|
57
|
+
|
58
|
+
# Verify the recovery process goes in reverse order
|
59
|
+
data[:recover].should == [2, 1]
|
60
|
+
|
61
|
+
# Verify that the error is available in the data
|
62
|
+
data["vagrant.error"].should be_kind_of(RuntimeError)
|
99
63
|
end
|
100
64
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
65
|
+
it "does not do a recovery sequence if SystemExit is raised" do
|
66
|
+
class Action
|
67
|
+
def initialize(app, env)
|
68
|
+
@app = app
|
69
|
+
end
|
70
|
+
|
71
|
+
def call(env)
|
72
|
+
@app.call(env)
|
108
73
|
end
|
109
74
|
|
110
|
-
|
75
|
+
def recover(env)
|
76
|
+
env[:recover] = true
|
77
|
+
end
|
111
78
|
end
|
112
|
-
end
|
113
79
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
80
|
+
# Make a proc that just calls "abort" which raises a
|
81
|
+
# SystemExit exception.
|
82
|
+
error_proc = Proc.new { abort }
|
83
|
+
|
84
|
+
instance = described_class.new([Action, error_proc], data)
|
85
|
+
|
86
|
+
# The SystemExit should come through
|
87
|
+
expect { instance.call(data) }.to raise_error(SystemExit)
|
119
88
|
|
120
|
-
|
121
|
-
|
122
|
-
mock_action.stubs(:respond_to?).with(:recover).returns(true)
|
123
|
-
mock_action
|
89
|
+
# The recover should not have been called
|
90
|
+
data.has_key?(:recover).should_not be
|
124
91
|
end
|
125
92
|
end
|