boxcar 0.10005.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +48 -0
- data/.gitsetup.yml +6 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +696 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +40 -0
- data/LICENSE +21 -0
- data/README.md +91 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/bin/_bump +126 -0
- data/bin/_jason +172 -0
- data/bin/_log4sh +3840 -0
- data/bin/_meat +172 -0
- data/bin/_prime +8 -0
- data/bin/_shflags +1012 -0
- data/bin/_shunit +1048 -0
- data/bin/_sub +37 -0
- data/bin/_treadstone +8 -0
- data/bin/_versions +174 -0
- data/bin/build +15 -0
- data/bin/bump +15 -0
- data/bin/edit +15 -0
- data/bin/publish +15 -0
- data/bin/stub +15 -0
- data/bin/vagrant +60 -0
- data/boxcar.gemspec +32 -0
- data/config/default.rb +30 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.pub +1 -0
- data/lib/development.rb +25 -0
- data/lib/vagrant.rb +197 -0
- data/lib/vagrant/action.rb +63 -0
- data/lib/vagrant/action/box/destroy.rb +25 -0
- data/lib/vagrant/action/box/download.rb +84 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +61 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +128 -0
- data/lib/vagrant/action/builtin.rb +171 -0
- data/lib/vagrant/action/env/set.rb +21 -0
- data/lib/vagrant/action/environment.rb +12 -0
- data/lib/vagrant/action/general/check_virtualbox.rb +28 -0
- data/lib/vagrant/action/general/package.rb +101 -0
- data/lib/vagrant/action/general/validate.rb +18 -0
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +53 -0
- data/lib/vagrant/action/vm/check_accessible.rb +23 -0
- data/lib/vagrant/action/vm/check_box.rb +33 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +38 -0
- data/lib/vagrant/action/vm/check_port_collisions.rb +89 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +18 -0
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +18 -0
- data/lib/vagrant/action/vm/customize.rb +36 -0
- data/lib/vagrant/action/vm/default_name.rb +22 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +20 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +57 -0
- data/lib/vagrant/action/vm/forward_ports.rb +92 -0
- data/lib/vagrant/action/vm/halt.rb +32 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +48 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +403 -0
- data/lib/vagrant/action/vm/nfs.rb +196 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +36 -0
- data/lib/vagrant/action/vm/provision.rb +61 -0
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
- data/lib/vagrant/action/vm/prune_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/sane_defaults.rb +78 -0
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +114 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +92 -0
- data/lib/vagrant/box.rb +44 -0
- data/lib/vagrant/box_collection.rb +58 -0
- data/lib/vagrant/cli.rb +76 -0
- data/lib/vagrant/command.rb +24 -0
- data/lib/vagrant/command/base.rb +167 -0
- data/lib/vagrant/command/box.rb +58 -0
- data/lib/vagrant/command/box_add.rb +37 -0
- data/lib/vagrant/command/box_list.rb +28 -0
- data/lib/vagrant/command/box_remove.rb +27 -0
- data/lib/vagrant/command/box_repackage.rb +27 -0
- data/lib/vagrant/command/destroy.rb +64 -0
- data/lib/vagrant/command/gem.rb +39 -0
- data/lib/vagrant/command/halt.rb +39 -0
- data/lib/vagrant/command/init.rb +40 -0
- data/lib/vagrant/command/package.rb +75 -0
- data/lib/vagrant/command/provision.rb +40 -0
- data/lib/vagrant/command/reload.rb +39 -0
- data/lib/vagrant/command/resume.rb +33 -0
- data/lib/vagrant/command/ssh.rb +90 -0
- data/lib/vagrant/command/ssh_config.rb +51 -0
- data/lib/vagrant/command/start_mixins.rb +26 -0
- data/lib/vagrant/command/status.rb +36 -0
- data/lib/vagrant/command/suspend.rb +33 -0
- data/lib/vagrant/command/up.rb +40 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +229 -0
- data/lib/vagrant/config.rb +49 -0
- data/lib/vagrant/config/base.rb +82 -0
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/loader.rb +127 -0
- data/lib/vagrant/config/nfs.rb +8 -0
- data/lib/vagrant/config/package.rb +7 -0
- data/lib/vagrant/config/ssh.rb +27 -0
- data/lib/vagrant/config/top.rb +72 -0
- data/lib/vagrant/config/vagrant.rb +14 -0
- data/lib/vagrant/config/vm.rb +168 -0
- data/lib/vagrant/config/vm/provisioner.rb +52 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +92 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +25 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +97 -0
- data/lib/vagrant/driver.rb +8 -0
- data/lib/vagrant/driver/virtualbox.rb +134 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_2.rb +606 -0
- data/lib/vagrant/driver/virtualbox_base.rb +309 -0
- data/lib/vagrant/environment.rb +517 -0
- data/lib/vagrant/errors.rb +441 -0
- data/lib/vagrant/guest.rb +18 -0
- data/lib/vagrant/guest/arch.rb +56 -0
- data/lib/vagrant/guest/base.rb +99 -0
- data/lib/vagrant/guest/debian.rb +64 -0
- data/lib/vagrant/guest/fedora.rb +66 -0
- data/lib/vagrant/guest/freebsd.rb +86 -0
- data/lib/vagrant/guest/gentoo.rb +46 -0
- data/lib/vagrant/guest/linux.rb +118 -0
- data/lib/vagrant/guest/linux/config.rb +19 -0
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/openbsd.rb +20 -0
- data/lib/vagrant/guest/redhat.rb +67 -0
- data/lib/vagrant/guest/solaris.rb +118 -0
- data/lib/vagrant/guest/suse.rb +9 -0
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/hosts.rb +37 -0
- data/lib/vagrant/hosts/arch.rb +55 -0
- data/lib/vagrant/hosts/base.rb +66 -0
- data/lib/vagrant/hosts/bsd.rb +97 -0
- data/lib/vagrant/hosts/fedora.rb +47 -0
- data/lib/vagrant/hosts/freebsd.rb +41 -0
- data/lib/vagrant/hosts/gentoo.rb +20 -0
- data/lib/vagrant/hosts/linux.rb +94 -0
- data/lib/vagrant/hosts/opensuse.rb +30 -0
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/plugin.rb +81 -0
- data/lib/vagrant/provisioners.rb +12 -0
- data/lib/vagrant/provisioners/base.rb +44 -0
- data/lib/vagrant/provisioners/chef.rb +168 -0
- data/lib/vagrant/provisioners/chef_client.rb +132 -0
- data/lib/vagrant/provisioners/chef_solo.rb +234 -0
- data/lib/vagrant/provisioners/puppet.rb +175 -0
- data/lib/vagrant/provisioners/puppet_server.rb +78 -0
- data/lib/vagrant/provisioners/shell.rb +96 -0
- data/lib/vagrant/registry.rb +52 -0
- data/lib/vagrant/ssh.rb +126 -0
- data/lib/vagrant/test_helpers.rb +154 -0
- data/lib/vagrant/ui.rb +168 -0
- data/lib/vagrant/util.rb +12 -0
- data/lib/vagrant/util/ansi_escape_code_remover.rb +34 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/counter.rb +24 -0
- data/lib/vagrant/util/file_checksum.rb +38 -0
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/is_port_open.rb +38 -0
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +68 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/safe_exec.rb +36 -0
- data/lib/vagrant/util/safe_puts.rb +31 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/subprocess.rb +247 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +7 -0
- data/lib/vagrant/vm.rb +195 -0
- data/libexec/build +30 -0
- data/libexec/build-gem +30 -0
- data/libexec/bump +32 -0
- data/libexec/edit-gem +81 -0
- data/libexec/publish +58 -0
- data/libexec/publish-gem +58 -0
- data/libexec/stub-prepare +37 -0
- data/tasks/acceptance.rake +113 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/test.rake +20 -0
- data/templates/commands/init/Vagrantfile.erb +99 -0
- data/templates/commands/ssh_config/config.erb +15 -0
- data/templates/config/validation_failed.erb +7 -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/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -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 +747 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_freebsd.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/provisioners/chef_client/client.erb +32 -0
- data/templates/provisioners/chef_solo/solo.erb +25 -0
- data/test/acceptance/base.rb +48 -0
- data/test/acceptance/box_test.rb +99 -0
- data/test/acceptance/destroy_test.rb +37 -0
- data/test/acceptance/halt_test.rb +72 -0
- data/test/acceptance/init_test.rb +33 -0
- 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 +17 -0
- data/test/acceptance/shared_folders_test.rb +84 -0
- 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 +46 -0
- data/test/acceptance/support/config.rb +42 -0
- data/test/acceptance/support/isolated_environment.rb +117 -0
- data/test/acceptance/support/matchers/have_color.rb +9 -0
- data/test/acceptance/support/matchers/match_output.rb +14 -0
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +95 -0
- data/test/acceptance/support/shared/base_context.rb +72 -0
- data/test/acceptance/support/shared/command_examples.rb +33 -0
- data/test/acceptance/support/virtualbox.rb +36 -0
- data/test/acceptance/suspend_test.rb +56 -0
- data/test/acceptance/up_basic_test.rb +33 -0
- data/test/acceptance/up_with_box_url.rb +40 -0
- data/test/acceptance/vagrant_test.rb +47 -0
- data/test/acceptance/version_test.rb +15 -0
- data/test/buildbot/README.md +72 -0
- data/test/buildbot/buildbot_config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/loader.py +24 -0
- data/test/buildbot/buildbot_config/config/master.py +24 -0
- data/test/buildbot/buildbot_config/config/slave.py +22 -0
- data/test/buildbot/buildbot_config/master/__init__.py +6 -0
- data/test/buildbot/buildbot_config/master/builders.py +78 -0
- data/test/buildbot/buildbot_config/master/buildsteps.py +100 -0
- data/test/buildbot/buildbot_config/master/change_sources.py +8 -0
- data/test/buildbot/buildbot_config/master/schedulers.py +32 -0
- data/test/buildbot/buildbot_config/master/slaves.py +60 -0
- data/test/buildbot/buildbot_config/master/status.py +52 -0
- data/test/buildbot/master/Makefile.sample +28 -0
- data/test/buildbot/master/buildbot.tac +36 -0
- data/test/buildbot/master/master.cfg +67 -0
- data/test/buildbot/master/public_html/bg_gradient.jpg +0 -0
- data/test/buildbot/master/public_html/default.css +545 -0
- data/test/buildbot/master/public_html/favicon.ico +0 -0
- data/test/buildbot/master/public_html/robots.txt +10 -0
- data/test/buildbot/master/public_html/static/css/bootstrap-1.4.0.min.css +356 -0
- data/test/buildbot/master/public_html/static/css/prettify.css +97 -0
- data/test/buildbot/master/public_html/static/css/syntax.css +60 -0
- data/test/buildbot/master/public_html/static/css/vagrant.base.css +205 -0
- data/test/buildbot/master/public_html/static/images/base_box_mac.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/getting-started/success.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/icons/error.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_chilling.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_holding.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_looking.png +0 -0
- data/test/buildbot/master/public_html/static/images/windows/alter_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/edit_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/environment_variables_button.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/port_and_ppk_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/ppk_selection.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/putty_first_screen.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/save_result.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/vbox_manage_default_location.jpg +0 -0
- data/test/buildbot/master/public_html/static/js/bootstrap-tabs.js +80 -0
- data/test/buildbot/master/public_html/static/js/jquery-1.7.min.js +4 -0
- data/test/buildbot/master/templates/authfail.html +9 -0
- data/test/buildbot/master/templates/build.html +205 -0
- data/test/buildbot/master/templates/builder.html +118 -0
- data/test/buildbot/master/templates/builders.html +33 -0
- data/test/buildbot/master/templates/buildslave.html +72 -0
- data/test/buildbot/master/templates/buildslaves.html +70 -0
- data/test/buildbot/master/templates/change.html +15 -0
- data/test/buildbot/master/templates/layouts/base.html +58 -0
- data/test/buildbot/master/templates/macros/box.html +37 -0
- data/test/buildbot/master/templates/macros/build_line.html +50 -0
- data/test/buildbot/master/templates/macros/change.html +81 -0
- data/test/buildbot/master/templates/macros/forms.html +300 -0
- data/test/buildbot/master/templates/root.html +42 -0
- data/test/buildbot/master/templates/waterfall.html +53 -0
- data/test/buildbot/requirements.txt +4 -0
- data/test/buildbot/scripts/deploy.sh +38 -0
- data/test/buildbot/scripts/setup.sh +107 -0
- data/test/buildbot/slave/buildbot.tac +43 -0
- data/test/buildbot/slave/info/admin +1 -0
- data/test/buildbot/slave/info/host +1 -0
- data/test/buildbot/tests/__init__.py +0 -0
- data/test/buildbot/tests/master/__init__.py +0 -0
- data/test/buildbot/tests/master/test_slaves.py +41 -0
- data/test/buildbot/vendor/choices-0.4.0.tar.gz +0 -0
- data/test/config/acceptance_boxes.yml +7 -0
- data/test/support/isolated_environment.rb +46 -0
- data/test/support/tempdir.rb +34 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +47 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +156 -0
- data/test/unit/vagrant/action/environment_test.rb +16 -0
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +92 -0
- data/test/unit/vagrant/box_collection_test.rb +56 -0
- data/test/unit/vagrant/box_test.rb +34 -0
- data/test/unit/vagrant/command/base_test.rb +150 -0
- data/test/unit/vagrant/config/base_test.rb +48 -0
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/ssh_test.rb +17 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +71 -0
- data/test/unit/vagrant/config_test.rb +27 -0
- data/test/unit/vagrant/data_store_test.rb +79 -0
- data/test/unit/vagrant/downloaders/base_test.rb +18 -0
- data/test/unit/vagrant/downloaders/file_test.rb +75 -0
- data/test/unit/vagrant/downloaders/http_test.rb +19 -0
- data/test/unit/vagrant/environment_test.rb +212 -0
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +74 -0
- data/test/unit/vagrant/util/ansi_escape_code_remover_test.rb +16 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +38 -0
- data/test/unit/vagrant/util/is_port_open_test.rb +53 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +106 -0
- data/test/unit/vagrant_test.rb +27 -0
- data/test/unit_legacy/locales/en.yml +8 -0
- data/test/unit_legacy/test_helper.rb +32 -0
- data/test/unit_legacy/vagrant/action/box/destroy_test.rb +18 -0
- data/test/unit_legacy/vagrant/action/box/download_test.rb +125 -0
- data/test/unit_legacy/vagrant/action/box/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/box/verify_test.rb +30 -0
- data/test/unit_legacy/vagrant/action/env/set_test.rb +24 -0
- data/test/unit_legacy/vagrant/action/general/package_test.rb +268 -0
- data/test/unit_legacy/vagrant/action/general/validate_test.rb +31 -0
- data/test/unit_legacy/vagrant/action/vm/boot_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/check_accessible_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_box_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/unit_legacy/vagrant/action/vm/clean_machine_folder_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/vm/clear_forwarded_ports_test.rb +52 -0
- data/test/unit_legacy/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/unit_legacy/vagrant/action/vm/clear_shared_folders_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/customize_test.rb +37 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/unit_legacy/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/unit_legacy/vagrant/action/vm/export_test.rb +107 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_helpers_test.rb +77 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_test.rb +197 -0
- data/test/unit_legacy/vagrant/action/vm/halt_test.rb +79 -0
- data/test/unit_legacy/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/unit_legacy/vagrant/action/vm/import_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/match_mac_address_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/modify_test.rb +38 -0
- data/test/unit_legacy/vagrant/action/vm/network_test.rb +286 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_test.rb +260 -0
- data/test/unit_legacy/vagrant/action/vm/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/unit_legacy/vagrant/action/vm/provision_test.rb +65 -0
- data/test/unit_legacy/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
- data/test/unit_legacy/vagrant/action/vm/resume_test.rb +35 -0
- data/test/unit_legacy/vagrant/action/vm/share_folders_test.rb +144 -0
- data/test/unit_legacy/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/unit_legacy/vagrant/action_test.rb +89 -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_legacy/vagrant/cli_test.rb +35 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/unit_legacy/vagrant/command/group_base_test.rb +15 -0
- data/test/unit_legacy/vagrant/command/helpers_test.rb +88 -0
- data/test/unit_legacy/vagrant/command/init_test.rb +10 -0
- data/test/unit_legacy/vagrant/command/package_test.rb +27 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/unit_legacy/vagrant/config/error_recorder_test.rb +18 -0
- data/test/unit_legacy/vagrant/config/ssh_test.rb +12 -0
- data/test/unit_legacy/vagrant/config/vagrant_test.rb +35 -0
- data/test/unit_legacy/vagrant/config/vm/provisioner_test.rb +92 -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_legacy/vagrant/errors_test.rb +42 -0
- data/test/unit_legacy/vagrant/hosts/base_test.rb +46 -0
- data/test/unit_legacy/vagrant/hosts/bsd_test.rb +53 -0
- data/test/unit_legacy/vagrant/hosts/linux_test.rb +54 -0
- data/test/unit_legacy/vagrant/plugin_test.rb +9 -0
- data/test/unit_legacy/vagrant/provisioners/base_test.rb +63 -0
- data/test/unit_legacy/vagrant/provisioners/chef_client_test.rb +190 -0
- data/test/unit_legacy/vagrant/provisioners/chef_solo_test.rb +115 -0
- data/test/unit_legacy/vagrant/provisioners/chef_test.rb +209 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/unit_legacy/vagrant/provisioners/shell_test.rb +79 -0
- data/test/unit_legacy/vagrant/ssh/session_test.rb +40 -0
- data/test/unit_legacy/vagrant/ssh_test.rb +304 -0
- data/test/unit_legacy/vagrant/systems/base_test.rb +18 -0
- data/test/unit_legacy/vagrant/systems/linux_test.rb +104 -0
- data/test/unit_legacy/vagrant/util/busy_test.rb +106 -0
- data/test/unit_legacy/vagrant/util/counter_test.rb +29 -0
- data/test/unit_legacy/vagrant/util/platform_test.rb +18 -0
- data/test/unit_legacy/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/unit_legacy/vagrant/util/template_renderer_test.rb +145 -0
- data/test/unit_legacy/vagrant/vm_test.rb +300 -0
- data/vagrant.gemspec +39 -0
- data/vendor/cache/contest-0.1.3.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
- data/vendor/cache/erubis-2.7.0.gem +0 -0
- data/vendor/cache/i18n-0.6.1.gem +0 -0
- data/vendor/cache/json-1.5.4.gem +0 -0
- data/vendor/cache/log4r-1.1.10.gem +0 -0
- data/vendor/cache/metaclass-0.0.1.gem +0 -0
- data/vendor/cache/minitest-2.5.1.gem +0 -0
- data/vendor/cache/mocha-0.13.1.gem +0 -0
- data/vendor/cache/rake-10.0.2.gem +0 -0
- data/vendor/cache/rspec-core-2.8.0.gem +0 -0
- data/vendor/cache/rspec-expectations-2.8.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.8.0.gem +0 -0
- metadata +676 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# This shell script deploys the buildmaster by downloading an
|
4
|
+
# up-to-date tar.gz from GitHub and setting up the proper environment.
|
5
|
+
|
6
|
+
#----------------------------------------------------------------------
|
7
|
+
# Update the source
|
8
|
+
#----------------------------------------------------------------------
|
9
|
+
# Download the Vagrant source, extract it
|
10
|
+
cd /tmp
|
11
|
+
rm -rf vagrant
|
12
|
+
rm -rf mitchellh-vagrant-*
|
13
|
+
wget https://github.com/mitchellh/vagrant/tarball/master -O vagrant.tar.gz
|
14
|
+
tar xvzf vagrant.tar.gz
|
15
|
+
mv mitchellh-vagrant-* vagrant
|
16
|
+
|
17
|
+
# Move the code into place
|
18
|
+
cp -R vagrant/test/buildbot/* /srv/buildmaster/
|
19
|
+
|
20
|
+
# Setup the virtualenv
|
21
|
+
cd /srv/buildmaster
|
22
|
+
virtualenv --no-site-packages env
|
23
|
+
|
24
|
+
# Activate the environment
|
25
|
+
. env/bin/activate
|
26
|
+
|
27
|
+
# Install dependencies
|
28
|
+
pip install -r requirements.txt
|
29
|
+
|
30
|
+
#----------------------------------------------------------------------
|
31
|
+
# Update the buildmaster
|
32
|
+
#----------------------------------------------------------------------
|
33
|
+
# Setup environmental variables that are required
|
34
|
+
export BUILDBOT_CONFIG=/etc/buildmaster/master.cfg
|
35
|
+
export PYTHONPATH=/srv/buildmaster
|
36
|
+
|
37
|
+
# Restart the buildmaster
|
38
|
+
buildbot restart master/
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# This shell script installs and prepares all the software necessary
|
4
|
+
# to run the build master. This script is expected to be run as root.
|
5
|
+
# This script is made to be run only on Ubuntu 10.04 LTS at the moment.
|
6
|
+
|
7
|
+
# Update the source list
|
8
|
+
apt-get update
|
9
|
+
|
10
|
+
# Install the basic sysadmin stuff
|
11
|
+
apt-get install -y htop
|
12
|
+
|
13
|
+
# Fix the mountall bug in the AMI
|
14
|
+
sed -i -e 's/nobootwait,//' /etc/fstab
|
15
|
+
|
16
|
+
#----------------------------------------------------------------------
|
17
|
+
# Python Setup
|
18
|
+
#----------------------------------------------------------------------
|
19
|
+
# Install Python and pip
|
20
|
+
apt-get install -y python python-dev python-setuptools
|
21
|
+
easy_install pip
|
22
|
+
|
23
|
+
# Install virtualenv
|
24
|
+
pip install virtualenv
|
25
|
+
|
26
|
+
#----------------------------------------------------------------------
|
27
|
+
# Deploy Setup
|
28
|
+
#----------------------------------------------------------------------
|
29
|
+
# Install Git, which is used for all the deploys of the build master
|
30
|
+
apt-get install -y git-core
|
31
|
+
|
32
|
+
# Create the user/group for the buildmaster
|
33
|
+
groupadd buildmaster
|
34
|
+
useradd -d /home/buildmaster -g buildmaster -s /bin/bash buildmaster
|
35
|
+
mkdir /home/buildmaster
|
36
|
+
chown -R buildmaster:buildmaster /home/buildmaster
|
37
|
+
|
38
|
+
# Make the folder which will contain the buildmaster code
|
39
|
+
mkdir -p /srv/buildmaster
|
40
|
+
chown buildmaster:buildmaster /srv/buildmaster
|
41
|
+
|
42
|
+
# Make the folder which will contain the configuration for the
|
43
|
+
# buildmaster
|
44
|
+
mkdir -p /etc/buildmaster
|
45
|
+
chown buildmaster:buildmaster /etc/buildmaster
|
46
|
+
|
47
|
+
#----------------------------------------------------------------------
|
48
|
+
# Nginx Setup
|
49
|
+
#----------------------------------------------------------------------
|
50
|
+
# Install Nginx
|
51
|
+
apt-get install -y nginx
|
52
|
+
|
53
|
+
# Setup the basic directories
|
54
|
+
mkdir -p /etc/nginx/conf.d
|
55
|
+
mkdir -p /etc/nginx/sites-available
|
56
|
+
mkdir -p /etc/nginx/sites-enabled
|
57
|
+
|
58
|
+
# Setup the configuration
|
59
|
+
cat <<EOF > /etc/nginx/nginx.conf
|
60
|
+
user www-data;
|
61
|
+
worker_processes 1;
|
62
|
+
|
63
|
+
# Raise the limit on open file descriptors
|
64
|
+
worker_rlimit_nofile 30000;
|
65
|
+
|
66
|
+
error_log /var/log/nginx/error.log;
|
67
|
+
pid /var/run/nginx.pid;
|
68
|
+
|
69
|
+
events {
|
70
|
+
worker_connections 1024;
|
71
|
+
use epoll;
|
72
|
+
}
|
73
|
+
|
74
|
+
http {
|
75
|
+
include /etc/nginx/mime.types;
|
76
|
+
default_type application/octet-stream;
|
77
|
+
|
78
|
+
access_log /var/log/nginx/access.log;
|
79
|
+
|
80
|
+
sendfile on;
|
81
|
+
tcp_nopush on;
|
82
|
+
tcp_nodelay on;
|
83
|
+
|
84
|
+
keepalive_timeout 65;
|
85
|
+
|
86
|
+
include /etc/nginx/conf.d/*.conf;
|
87
|
+
include /etc/nginx/sites-enabled/*;
|
88
|
+
}
|
89
|
+
EOF
|
90
|
+
|
91
|
+
# Setup the buildbot site
|
92
|
+
cat <<EOF > /etc/nginx/sites-available/buildmaster.conf
|
93
|
+
server {
|
94
|
+
listen 80;
|
95
|
+
|
96
|
+
location / {
|
97
|
+
proxy_pass http://localhost:8000;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
EOF
|
101
|
+
|
102
|
+
# Activate the buildbot site, remove the default
|
103
|
+
rm /etc/nginx/sites-enabled/default
|
104
|
+
ln -f -s /etc/nginx/sites-available/buildmaster.conf /etc/nginx/sites-enabled/buildmaster.conf
|
105
|
+
|
106
|
+
# Restart nginx
|
107
|
+
/etc/init.d/nginx restart
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from twisted.application import service
|
4
|
+
from buildslave.bot import BuildSlave
|
5
|
+
|
6
|
+
from buildbot_config.config.slave import options
|
7
|
+
|
8
|
+
basedir = r'.'
|
9
|
+
rotateLength = 10000000
|
10
|
+
maxRotatedFiles = 10
|
11
|
+
|
12
|
+
# if this is a relocatable tac file, get the directory containing the TAC
|
13
|
+
if basedir == '.':
|
14
|
+
import os.path
|
15
|
+
basedir = os.path.abspath(os.path.dirname(__file__))
|
16
|
+
|
17
|
+
# note: this line is matched against to check that this is a buildslave
|
18
|
+
# directory; do not edit it.
|
19
|
+
application = service.Application('buildslave')
|
20
|
+
|
21
|
+
try:
|
22
|
+
from twisted.python.logfile import LogFile
|
23
|
+
from twisted.python.log import ILogObserver, FileLogObserver
|
24
|
+
logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
|
25
|
+
maxRotatedFiles=maxRotatedFiles)
|
26
|
+
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
|
27
|
+
except ImportError:
|
28
|
+
# probably not yet twisted 8.2.0 and beyond, can't set log yet
|
29
|
+
pass
|
30
|
+
|
31
|
+
buildmaster_host = options.master_host
|
32
|
+
port = options.master_port
|
33
|
+
slavename = options.name
|
34
|
+
passwd = options.password
|
35
|
+
keepalive = 600
|
36
|
+
usepty = 0
|
37
|
+
umask = None
|
38
|
+
maxdelay = 300
|
39
|
+
|
40
|
+
s = BuildSlave(buildmaster_host, port, slavename, passwd, basedir,
|
41
|
+
keepalive, usepty, umask=umask, maxdelay=maxdelay)
|
42
|
+
s.setServiceParent(application)
|
43
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Buildslave Admin <foo@bar.com>
|
@@ -0,0 +1 @@
|
|
1
|
+
Please put a description of this build host here
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
from buildbot.buildslave import BuildSlave
|
2
|
+
|
3
|
+
from buildbot_config.master.slaves import (
|
4
|
+
BuildSlavesFromSlaveConfigs,
|
5
|
+
SlaveConfig,
|
6
|
+
SlaveListFromConfig)
|
7
|
+
|
8
|
+
class TestSlaveListFromConfig(object):
|
9
|
+
Klass = SlaveListFromConfig
|
10
|
+
|
11
|
+
def test_parse_single(self):
|
12
|
+
"""
|
13
|
+
Tests that the config parser can parse a single
|
14
|
+
slave.
|
15
|
+
"""
|
16
|
+
instance = self.Klass("foo:bar")
|
17
|
+
assert 1 == len(instance)
|
18
|
+
assert SlaveConfig("foo", "bar") == instance[0]
|
19
|
+
|
20
|
+
def test_parse_multiple(self):
|
21
|
+
"""
|
22
|
+
Tests that the config parser can parse multiple
|
23
|
+
slaves.
|
24
|
+
"""
|
25
|
+
instance = self.Klass("foo:bar,bar:baz")
|
26
|
+
expected = [SlaveConfig("foo", "bar"), SlaveConfig("bar", "baz")]
|
27
|
+
|
28
|
+
assert 2 == len(instance)
|
29
|
+
assert expected == instance
|
30
|
+
|
31
|
+
class TestBuildSlavesFromSlaveConfig(object):
|
32
|
+
Klass = BuildSlavesFromSlaveConfigs
|
33
|
+
|
34
|
+
def test_returns_build_slaves(self):
|
35
|
+
"""
|
36
|
+
Tests that build slaves are properly returned for each
|
37
|
+
slave configuration.
|
38
|
+
"""
|
39
|
+
instance = self.Klass([SlaveConfig("foo", "bar")])
|
40
|
+
assert 1 == len(instance)
|
41
|
+
assert isinstance(instance[0], BuildSlave)
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This is the list of required boxes for acceptance tests, and
|
2
|
+
# their locations. The locations are used to download the boxes
|
3
|
+
# on the fly, if necessary. Additionally, a SHA1 checksum is
|
4
|
+
# given to determine if the box needs to be updated.
|
5
|
+
- name: default
|
6
|
+
url: http://files.vagrantup.com/test/boxes/default.box
|
7
|
+
checksum: 1b0a7eb6e152c5b43f45485654ff4965a7f9f604
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require "log4r"
|
5
|
+
|
6
|
+
require "support/tempdir"
|
7
|
+
|
8
|
+
# This class manages an isolated environment for Vagrant to
|
9
|
+
# run in. It creates a temporary directory to act as the
|
10
|
+
# working directory as well as sets a custom home directory.
|
11
|
+
#
|
12
|
+
# This class also provides various helpers to create Vagrantfiles,
|
13
|
+
# boxes, etc.
|
14
|
+
class IsolatedEnvironment
|
15
|
+
attr_reader :homedir
|
16
|
+
attr_reader :workdir
|
17
|
+
|
18
|
+
# Initializes an isolated environment. You can pass in some
|
19
|
+
# options here to configure runing custom applications in place
|
20
|
+
# of others as well as specifying environmental variables.
|
21
|
+
#
|
22
|
+
# @param [Hash] apps A mapping of application name (such as "vagrant")
|
23
|
+
# to an alternate full path to the binary to run.
|
24
|
+
# @param [Hash] env Additional environmental variables to inject
|
25
|
+
# into the execution environments.
|
26
|
+
def initialize
|
27
|
+
@logger = Log4r::Logger.new("test::isolated_environment")
|
28
|
+
|
29
|
+
# Create a temporary directory for our work
|
30
|
+
@tempdir = Tempdir.new("vagrant")
|
31
|
+
@logger.info("Initialize isolated environment: #{@tempdir.path}")
|
32
|
+
|
33
|
+
# Setup the home and working directories
|
34
|
+
@homedir = Pathname.new(File.join(@tempdir.path, "home"))
|
35
|
+
@workdir = Pathname.new(File.join(@tempdir.path, "work"))
|
36
|
+
|
37
|
+
@homedir.mkdir
|
38
|
+
@workdir.mkdir
|
39
|
+
end
|
40
|
+
|
41
|
+
# This closes the environment by cleaning it up.
|
42
|
+
def close
|
43
|
+
@logger.info("Removing isolated environment: #{@tempdir.path}")
|
44
|
+
FileUtils.rm_rf(@tempdir.path)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
# This class provides an easy way of creating a temporary
|
5
|
+
# directory and having it removed when the application exits.
|
6
|
+
#
|
7
|
+
# TODO: This class doesn't currently delete the temporary
|
8
|
+
# directory on exit.
|
9
|
+
class Tempdir
|
10
|
+
attr_reader :path
|
11
|
+
|
12
|
+
def initialize(basename="vagrant")
|
13
|
+
@path = nil
|
14
|
+
|
15
|
+
# Loop and attempt to create a temporary directory until
|
16
|
+
# it succeeds.
|
17
|
+
while @path.nil?
|
18
|
+
file = Tempfile.new(basename)
|
19
|
+
@path = file.path
|
20
|
+
file.unlink
|
21
|
+
|
22
|
+
begin
|
23
|
+
Dir.mkdir(@path)
|
24
|
+
rescue
|
25
|
+
@path = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# This deletes the temporary directory.
|
31
|
+
def unlink
|
32
|
+
FileUtils.rm_rf(@path)
|
33
|
+
end
|
34
|
+
end
|
data/test/unit/base.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rspec/autorun"
|
3
|
+
|
4
|
+
# Require Vagrant itself so we can reference the proper
|
5
|
+
# classes to test.
|
6
|
+
require "vagrant"
|
7
|
+
|
8
|
+
# Add the test directory to the load path
|
9
|
+
$:.unshift File.expand_path("../../", __FILE__)
|
10
|
+
|
11
|
+
# Load in helpers
|
12
|
+
require "unit/support/shared/base_context"
|
13
|
+
|
14
|
+
# Do not buffer output
|
15
|
+
$stdout.sync = true
|
16
|
+
$stderr.sync = true
|
17
|
+
|
18
|
+
# Configure RSpec
|
19
|
+
RSpec.configure do |c|
|
20
|
+
c.expect_with :rspec, :stdlib
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require "log4r"
|
5
|
+
|
6
|
+
require "support/isolated_environment"
|
7
|
+
|
8
|
+
module Unit
|
9
|
+
class IsolatedEnvironment < ::IsolatedEnvironment
|
10
|
+
def create_vagrant_env(options=nil)
|
11
|
+
options = {
|
12
|
+
:cwd => @workdir,
|
13
|
+
:home_path => @homedir
|
14
|
+
}.merge(options || {})
|
15
|
+
|
16
|
+
Vagrant::Environment.new(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# This creates a file in the isolated environment. By default this file
|
20
|
+
# will be created in the working directory of the isolated environment.
|
21
|
+
def file(name, contents)
|
22
|
+
@workdir.join(name).open("w+") do |f|
|
23
|
+
f.write(contents)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def vagrantfile(contents, root=nil)
|
28
|
+
root ||= @workdir
|
29
|
+
root.join("Vagrantfile").open("w+") do |f|
|
30
|
+
f.write(contents)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def box(name, vagrantfile_contents="")
|
35
|
+
box_dir = boxes_dir.join(name)
|
36
|
+
box_dir.mkpath
|
37
|
+
vagrantfile(vagrantfile_contents, box_dir)
|
38
|
+
box_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def boxes_dir
|
42
|
+
dir = @homedir.join("boxes")
|
43
|
+
dir.mkpath
|
44
|
+
dir
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
3
|
+
require "unit/support/isolated_environment"
|
4
|
+
|
5
|
+
shared_context "unit" do
|
6
|
+
# This creates an isolated environment so that Vagrant doesn't
|
7
|
+
# muck around with your real system during unit tests.
|
8
|
+
#
|
9
|
+
# The returned isolated environment has a variety of helper
|
10
|
+
# methods on it to easily create files, Vagrantfiles, boxes,
|
11
|
+
# etc.
|
12
|
+
def isolated_environment
|
13
|
+
env = Unit::IsolatedEnvironment.new
|
14
|
+
yield env if block_given?
|
15
|
+
env
|
16
|
+
end
|
17
|
+
|
18
|
+
# This helper creates a temporary file and returns a Pathname
|
19
|
+
# object pointed to it.
|
20
|
+
def temporary_file(contents=nil)
|
21
|
+
f = Tempfile.new("vagrant-unit")
|
22
|
+
|
23
|
+
if contents
|
24
|
+
f.write(contents)
|
25
|
+
f.flush
|
26
|
+
end
|
27
|
+
|
28
|
+
return Pathname.new(f.path)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require File.expand_path("../../../base", __FILE__)
|
2
|
+
|
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 }
|
11
|
+
end
|
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
|
35
|
+
end
|
36
|
+
|
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)
|
62
|
+
|
63
|
+
data[:data].should == 6
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
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]
|
74
|
+
end
|
75
|
+
|
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]
|
84
|
+
end
|
85
|
+
|
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]
|
92
|
+
end
|
93
|
+
|
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]
|
101
|
+
end
|
102
|
+
|
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)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "replace" do
|
110
|
+
it "can replace an object" do
|
111
|
+
proc1 = appender_proc(1)
|
112
|
+
proc2 = appender_proc(2)
|
113
|
+
|
114
|
+
instance.use proc1
|
115
|
+
instance.replace proc1, proc2
|
116
|
+
instance.call(data)
|
117
|
+
|
118
|
+
data[:data].should == [2]
|
119
|
+
end
|
120
|
+
|
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]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "deleting" do
|
134
|
+
it "can delete by object" do
|
135
|
+
proc1 = appender_proc(1)
|
136
|
+
|
137
|
+
instance.use proc1
|
138
|
+
instance.use appender_proc(2)
|
139
|
+
instance.delete proc1
|
140
|
+
instance.call(data)
|
141
|
+
|
142
|
+
data[:data].should == [2]
|
143
|
+
end
|
144
|
+
|
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]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|