chefspec 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -0
- data/.travis.yml +39 -0
- data/CHANGELOG.md +444 -0
- data/CONTRIBUTING.md +52 -0
- data/Gemfile +2 -0
- data/ISSUES.md +41 -0
- data/LICENSE +22 -0
- data/README.md +893 -0
- data/Rakefile +29 -0
- data/chefspec.gemspec +42 -0
- data/examples/apt_package/recipes/install.rb +13 -0
- data/examples/apt_package/recipes/purge.rb +13 -0
- data/examples/apt_package/recipes/reconfig.rb +13 -0
- data/examples/apt_package/recipes/remove.rb +13 -0
- data/examples/apt_package/recipes/upgrade.rb +13 -0
- data/examples/apt_package/spec/install_spec.rb +23 -0
- data/examples/apt_package/spec/purge_spec.rb +19 -0
- data/examples/apt_package/spec/reconfig_spec.rb +19 -0
- data/examples/apt_package/spec/remove_spec.rb +19 -0
- data/examples/apt_package/spec/upgrade_spec.rb +19 -0
- data/examples/attributes/attributes/default.rb +1 -0
- data/examples/attributes/recipes/default.rb +4 -0
- data/examples/attributes/spec/default_spec.rb +20 -0
- data/examples/batch/recipes/run.rb +13 -0
- data/examples/batch/spec/run_spec.rb +23 -0
- data/examples/cached/recipes/default.rb +1 -0
- data/examples/cached/spec/default_spec.rb +13 -0
- data/examples/chef_gem/recipes/install.rb +13 -0
- data/examples/chef_gem/recipes/purge.rb +13 -0
- data/examples/chef_gem/recipes/reconfig.rb +13 -0
- data/examples/chef_gem/recipes/remove.rb +13 -0
- data/examples/chef_gem/recipes/upgrade.rb +13 -0
- data/examples/chef_gem/spec/install_spec.rb +23 -0
- data/examples/chef_gem/spec/purge_spec.rb +19 -0
- data/examples/chef_gem/spec/reconfig_spec.rb +19 -0
- data/examples/chef_gem/spec/remove_spec.rb +19 -0
- data/examples/chef_gem/spec/upgrade_spec.rb +19 -0
- data/examples/compile_time/recipes/default.rb +3 -0
- data/examples/compile_time/spec/default_spec.rb +27 -0
- data/examples/cookbook_file/recipes/create.rb +15 -0
- data/examples/cookbook_file/recipes/create_if_missing.rb +15 -0
- data/examples/cookbook_file/recipes/delete.rb +15 -0
- data/examples/cookbook_file/recipes/touch.rb +15 -0
- data/examples/cookbook_file/spec/create_if_missing_spec.rb +28 -0
- data/examples/cookbook_file/spec/create_spec.rb +32 -0
- data/examples/cookbook_file/spec/delete_spec.rb +19 -0
- data/examples/cookbook_file/spec/touch_spec.rb +19 -0
- data/examples/cron/recipes/create.rb +10 -0
- data/examples/cron/recipes/delete.rb +9 -0
- data/examples/cron/spec/create_spec.rb +19 -0
- data/examples/cron/spec/delete_spec.rb +15 -0
- data/examples/custom_matcher/libraries/matcher.rb +23 -0
- data/examples/custom_matcher/providers/thing.rb +2 -0
- data/examples/custom_matcher/recipes/install.rb +13 -0
- data/examples/custom_matcher/recipes/remove.rb +13 -0
- data/examples/custom_matcher/resources/thing.rb +5 -0
- data/examples/custom_matcher/spec/install_spec.rb +27 -0
- data/examples/custom_matcher/spec/remove_spec.rb +23 -0
- data/examples/deploy/recipes/deploy.rb +10 -0
- data/examples/deploy/recipes/force_deploy.rb +9 -0
- data/examples/deploy/recipes/rollback.rb +9 -0
- data/examples/deploy/spec/deploy_spec.rb +15 -0
- data/examples/deploy/spec/force_deploy_spec.rb +15 -0
- data/examples/deploy/spec/rollback_spec.rb +15 -0
- data/examples/directory/recipes/create.rb +14 -0
- data/examples/directory/recipes/delete.rb +14 -0
- data/examples/directory/spec/create_spec.rb +30 -0
- data/examples/directory/spec/delete_spec.rb +26 -0
- data/examples/dpkg_package/recipes/install.rb +13 -0
- data/examples/dpkg_package/recipes/purge.rb +13 -0
- data/examples/dpkg_package/recipes/remove.rb +13 -0
- data/examples/dpkg_package/spec/install_spec.rb +23 -0
- data/examples/dpkg_package/spec/purge_spec.rb +19 -0
- data/examples/dpkg_package/spec/remove_spec.rb +19 -0
- data/examples/easy_install_package/recipes/install.rb +13 -0
- data/examples/easy_install_package/recipes/purge.rb +13 -0
- data/examples/easy_install_package/recipes/remove.rb +13 -0
- data/examples/easy_install_package/recipes/upgrade.rb +13 -0
- data/examples/easy_install_package/spec/install_spec.rb +23 -0
- data/examples/easy_install_package/spec/purge_spec.rb +19 -0
- data/examples/easy_install_package/spec/remove_spec.rb +19 -0
- data/examples/easy_install_package/spec/upgrade_spec.rb +19 -0
- data/examples/env/recipes/create.rb +13 -0
- data/examples/env/recipes/delete.rb +13 -0
- data/examples/env/recipes/modify.rb +13 -0
- data/examples/env/spec/create_spec.rb +23 -0
- data/examples/env/spec/delete_spec.rb +19 -0
- data/examples/env/spec/modify_spec.rb +19 -0
- data/examples/erl_call/recipes/run.rb +13 -0
- data/examples/erl_call/spec/run_spec.rb +23 -0
- data/examples/execute/recipes/run.rb +13 -0
- data/examples/execute/spec/run_spec.rb +23 -0
- data/examples/expect_exception/recipes/compile_error.rb +1 -0
- data/examples/expect_exception/recipes/converge_error.rb +5 -0
- data/examples/expect_exception/recipes/no_error.rb +1 -0
- data/examples/expect_exception/spec/compile_error_spec.rb +10 -0
- data/examples/expect_exception/spec/converge_error_spec.rb +10 -0
- data/examples/expect_exception/spec/no_error_spec.rb +10 -0
- data/examples/file/recipes/create.rb +15 -0
- data/examples/file/recipes/create_if_missing.rb +15 -0
- data/examples/file/recipes/delete.rb +15 -0
- data/examples/file/recipes/touch.rb +15 -0
- data/examples/file/spec/create_if_missing_spec.rb +28 -0
- data/examples/file/spec/create_spec.rb +32 -0
- data/examples/file/spec/delete_spec.rb +19 -0
- data/examples/file/spec/touch_spec.rb +19 -0
- data/examples/freebsd_package/recipes/install.rb +13 -0
- data/examples/freebsd_package/recipes/remove.rb +13 -0
- data/examples/freebsd_package/spec/install_spec.rb +23 -0
- data/examples/freebsd_package/spec/remove_spec.rb +19 -0
- data/examples/gem_package/recipes/install.rb +13 -0
- data/examples/gem_package/recipes/purge.rb +13 -0
- data/examples/gem_package/recipes/reconfig.rb +13 -0
- data/examples/gem_package/recipes/remove.rb +13 -0
- data/examples/gem_package/recipes/upgrade.rb +13 -0
- data/examples/gem_package/spec/install_spec.rb +23 -0
- data/examples/gem_package/spec/purge_spec.rb +19 -0
- data/examples/gem_package/spec/reconfig_spec.rb +19 -0
- data/examples/gem_package/spec/remove_spec.rb +19 -0
- data/examples/gem_package/spec/upgrade_spec.rb +19 -0
- data/examples/git/recipes/checkout.rb +13 -0
- data/examples/git/recipes/export.rb +13 -0
- data/examples/git/recipes/sync.rb +13 -0
- data/examples/git/spec/checkout_spec.rb +19 -0
- data/examples/git/spec/export_spec.rb +19 -0
- data/examples/git/spec/sync_spec.rb +23 -0
- data/examples/group/recipes/create.rb +13 -0
- data/examples/group/recipes/manage.rb +13 -0
- data/examples/group/recipes/modify.rb +13 -0
- data/examples/group/recipes/remove.rb +13 -0
- data/examples/group/spec/create_spec.rb +23 -0
- data/examples/group/spec/manage_spec.rb +19 -0
- data/examples/group/spec/modify_spec.rb +19 -0
- data/examples/group/spec/remove_spec.rb +18 -0
- data/examples/guards/recipes/default.rb +13 -0
- data/examples/guards/spec/default_spec.rb +17 -0
- data/examples/heavy_provider_light_resource/libraries/resource_service.rb +15 -0
- data/examples/heavy_provider_light_resource/providers/service.rb +9 -0
- data/examples/heavy_provider_light_resource/recipes/default.rb +4 -0
- data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +7 -0
- data/examples/http_request/recipes/delete.rb +13 -0
- data/examples/http_request/recipes/get.rb +13 -0
- data/examples/http_request/recipes/head.rb +13 -0
- data/examples/http_request/recipes/options.rb +13 -0
- data/examples/http_request/recipes/post.rb +13 -0
- data/examples/http_request/recipes/put.rb +13 -0
- data/examples/http_request/spec/delete_spec.rb +19 -0
- data/examples/http_request/spec/get_spec.rb +23 -0
- data/examples/http_request/spec/head_spec.rb +19 -0
- data/examples/http_request/spec/options_spec.rb +19 -0
- data/examples/http_request/spec/post_spec.rb +19 -0
- data/examples/http_request/spec/put_spec.rb +19 -0
- data/examples/ifconfig/recipes/add.rb +9 -0
- data/examples/ifconfig/recipes/delete.rb +8 -0
- data/examples/ifconfig/recipes/disable.rb +8 -0
- data/examples/ifconfig/recipes/enable.rb +8 -0
- data/examples/ifconfig/spec/add_spec.rb +19 -0
- data/examples/ifconfig/spec/delete_spec.rb +15 -0
- data/examples/ifconfig/spec/disable_spec.rb +15 -0
- data/examples/ifconfig/spec/enable_spec.rb +15 -0
- data/examples/include_recipe/recipes/default.rb +1 -0
- data/examples/include_recipe/recipes/not.rb +0 -0
- data/examples/include_recipe/recipes/other.rb +0 -0
- data/examples/include_recipe/spec/default_spec.rb +13 -0
- data/examples/inherits/recipes/default.rb +5 -0
- data/examples/inherits/spec/default_spec.rb +21 -0
- data/examples/ips_package/recipes/install.rb +13 -0
- data/examples/ips_package/recipes/remove.rb +13 -0
- data/examples/ips_package/recipes/upgrade.rb +13 -0
- data/examples/ips_package/spec/install_spec.rb +23 -0
- data/examples/ips_package/spec/remove_spec.rb +19 -0
- data/examples/ips_package/spec/upgrade_spec.rb +19 -0
- data/examples/link/recipes/create.rb +13 -0
- data/examples/link/recipes/delete.rb +13 -0
- data/examples/link/recipes/link_to.rb +3 -0
- data/examples/link/spec/create_spec.rb +23 -0
- data/examples/link/spec/delete_spec.rb +19 -0
- data/examples/link/spec/link_to_spec.rb +11 -0
- data/examples/log/recipes/write.rb +14 -0
- data/examples/log/spec/write_spec.rb +24 -0
- data/examples/macports_package/recipes/install.rb +13 -0
- data/examples/macports_package/recipes/purge.rb +13 -0
- data/examples/macports_package/recipes/remove.rb +13 -0
- data/examples/macports_package/recipes/upgrade.rb +13 -0
- data/examples/macports_package/spec/install_spec.rb +23 -0
- data/examples/macports_package/spec/purge_spec.rb +19 -0
- data/examples/macports_package/spec/remove_spec.rb +19 -0
- data/examples/macports_package/spec/upgrade_spec.rb +19 -0
- data/examples/mdadm/recipes/assemble.rb +13 -0
- data/examples/mdadm/recipes/create.rb +13 -0
- data/examples/mdadm/recipes/stop.rb +13 -0
- data/examples/mdadm/spec/assemble_spec.rb +19 -0
- data/examples/mdadm/spec/create_spec.rb +23 -0
- data/examples/mdadm/spec/stop_spec.rb +19 -0
- data/examples/mount/recipes/disable.rb +8 -0
- data/examples/mount/recipes/enable.rb +8 -0
- data/examples/mount/recipes/mount.rb +9 -0
- data/examples/mount/recipes/remount.rb +8 -0
- data/examples/mount/recipes/umount.rb +8 -0
- data/examples/mount/spec/disable_spec.rb +15 -0
- data/examples/mount/spec/enable_spec.rb +15 -0
- data/examples/mount/spec/mount_spec.rb +19 -0
- data/examples/mount/spec/remount_spec.rb +15 -0
- data/examples/mount/spec/umount_spec.rb +15 -0
- data/examples/multiple_actions/recipes/default.rb +3 -0
- data/examples/multiple_actions/recipes/sequential.rb +7 -0
- data/examples/multiple_actions/spec/default_spec.rb +14 -0
- data/examples/multiple_actions/spec/sequential_spec.rb +13 -0
- data/examples/multiple_run_action/recipes/default.rb +5 -0
- data/examples/multiple_run_action/spec/default_spec.rb +18 -0
- data/examples/notifications/recipes/chained.rb +12 -0
- data/examples/notifications/recipes/default.rb +7 -0
- data/examples/notifications/recipes/delayed.rb +7 -0
- data/examples/notifications/recipes/immediately.rb +7 -0
- data/examples/notifications/spec/chained_spec.rb +21 -0
- data/examples/notifications/spec/default_spec.rb +16 -0
- data/examples/notifications/spec/delayed_spec.rb +16 -0
- data/examples/notifications/spec/immediately_spec.rb +16 -0
- data/examples/ohai/recipes/reload.rb +13 -0
- data/examples/ohai/spec/reload_spec.rb +23 -0
- data/examples/package/recipes/install.rb +13 -0
- data/examples/package/recipes/purge.rb +13 -0
- data/examples/package/recipes/reconfig.rb +13 -0
- data/examples/package/recipes/remove.rb +13 -0
- data/examples/package/recipes/upgrade.rb +13 -0
- data/examples/package/spec/install_spec.rb +23 -0
- data/examples/package/spec/purge_spec.rb +19 -0
- data/examples/package/spec/reconfig_spec.rb +19 -0
- data/examples/package/spec/remove_spec.rb +19 -0
- data/examples/package/spec/upgrade_spec.rb +19 -0
- data/examples/pacman_package/recipes/install.rb +13 -0
- data/examples/pacman_package/recipes/purge.rb +13 -0
- data/examples/pacman_package/recipes/remove.rb +13 -0
- data/examples/pacman_package/recipes/upgrade.rb +13 -0
- data/examples/pacman_package/spec/install_spec.rb +23 -0
- data/examples/pacman_package/spec/purge_spec.rb +19 -0
- data/examples/pacman_package/spec/remove_spec.rb +19 -0
- data/examples/pacman_package/spec/upgrade_spec.rb +19 -0
- data/examples/portage_package/recipes/install.rb +13 -0
- data/examples/portage_package/recipes/purge.rb +13 -0
- data/examples/portage_package/recipes/remove.rb +13 -0
- data/examples/portage_package/recipes/upgrade.rb +13 -0
- data/examples/portage_package/spec/install_spec.rb +23 -0
- data/examples/portage_package/spec/purge_spec.rb +19 -0
- data/examples/portage_package/spec/remove_spec.rb +19 -0
- data/examples/portage_package/spec/upgrade_spec.rb +19 -0
- data/examples/powershell_script/recipes/run.rb +13 -0
- data/examples/powershell_script/spec/run_spec.rb +23 -0
- data/examples/registry_key/recipes/create.rb +13 -0
- data/examples/registry_key/recipes/create_if_missing.rb +13 -0
- data/examples/registry_key/recipes/delete.rb +13 -0
- data/examples/registry_key/recipes/delete_key.rb +13 -0
- data/examples/registry_key/spec/create_if_missing_spec.rb +19 -0
- data/examples/registry_key/spec/create_spec.rb +23 -0
- data/examples/registry_key/spec/delete_key_spec.rb +19 -0
- data/examples/registry_key/spec/delete_spec.rb +19 -0
- data/examples/remote_directory/recipes/create.rb +13 -0
- data/examples/remote_directory/recipes/create_if_missing.rb +13 -0
- data/examples/remote_directory/recipes/delete.rb +13 -0
- data/examples/remote_directory/spec/create_if_missing_spec.rb +19 -0
- data/examples/remote_directory/spec/create_spec.rb +23 -0
- data/examples/remote_directory/spec/delete_spec.rb +19 -0
- data/examples/remote_file/recipes/create.rb +18 -0
- data/examples/remote_file/recipes/create_if_missing.rb +16 -0
- data/examples/remote_file/recipes/delete.rb +16 -0
- data/examples/remote_file/recipes/touch.rb +16 -0
- data/examples/remote_file/spec/create_if_missing_spec.rb +19 -0
- data/examples/remote_file/spec/create_spec.rb +23 -0
- data/examples/remote_file/spec/delete_spec.rb +19 -0
- data/examples/remote_file/spec/touch_spec.rb +19 -0
- data/examples/render_file/files/default/cookbook_file +1 -0
- data/examples/render_file/recipes/default.rb +15 -0
- data/examples/render_file/recipes/template_helpers.rb +9 -0
- data/examples/render_file/spec/default_spec.rb +73 -0
- data/examples/render_file/spec/template_helpers_spec.rb +10 -0
- data/examples/render_file/templates/default/_partial.erb +1 -0
- data/examples/render_file/templates/default/partial.erb +1 -0
- data/examples/render_file/templates/default/template.erb +1 -0
- data/examples/render_file/templates/default/template_with_helper.erb +1 -0
- data/examples/roles/recipes/another.rb +3 -0
- data/examples/roles/recipes/default.rb +1 -0
- data/examples/roles/roles/role.rb +9 -0
- data/examples/roles/spec/default_spec.rb +21 -0
- data/examples/route/recipes/add.rb +13 -0
- data/examples/route/recipes/delete.rb +13 -0
- data/examples/route/spec/add_spec.rb +23 -0
- data/examples/route/spec/delete_spec.rb +19 -0
- data/examples/rpm_package/recipes/install.rb +13 -0
- data/examples/rpm_package/recipes/remove.rb +13 -0
- data/examples/rpm_package/recipes/upgrade.rb +13 -0
- data/examples/rpm_package/spec/install_spec.rb +23 -0
- data/examples/rpm_package/spec/remove_spec.rb +19 -0
- data/examples/rpm_package/spec/upgrade_spec.rb +19 -0
- data/examples/ruby_block/recipes/run.rb +9 -0
- data/examples/ruby_block/spec/run_spec.rb +18 -0
- data/examples/script/recipes/run_bash.rb +13 -0
- data/examples/script/recipes/run_csh.rb +13 -0
- data/examples/script/recipes/run_perl.rb +13 -0
- data/examples/script/recipes/run_python.rb +13 -0
- data/examples/script/recipes/run_ruby.rb +13 -0
- data/examples/script/recipes/run_script.rb +13 -0
- data/examples/script/spec/run_bash_spec.rb +23 -0
- data/examples/script/spec/run_csh_spec.rb +23 -0
- data/examples/script/spec/run_perl_spec.rb +23 -0
- data/examples/script/spec/run_python_spec.rb +23 -0
- data/examples/script/spec/run_ruby_spec.rb +23 -0
- data/examples/script/spec/run_script_spec.rb +23 -0
- data/examples/server/recipes/client.rb +6 -0
- data/examples/server/recipes/data_bag.rb +7 -0
- data/examples/server/recipes/environment.rb +6 -0
- data/examples/server/recipes/node.rb +6 -0
- data/examples/server/recipes/role.rb +6 -0
- data/examples/server/recipes/search.rb +5 -0
- data/examples/server/spec/client_spec.rb +17 -0
- data/examples/server/spec/data_bag_spec.rb +26 -0
- data/examples/server/spec/environment_spec.rb +17 -0
- data/examples/server/spec/node_spec.rb +40 -0
- data/examples/server/spec/role_spec.rb +17 -0
- data/examples/server/spec/search_spec.rb +58 -0
- data/examples/service/recipes/disable.rb +13 -0
- data/examples/service/recipes/enable.rb +13 -0
- data/examples/service/recipes/reload.rb +13 -0
- data/examples/service/recipes/restart.rb +13 -0
- data/examples/service/recipes/start.rb +13 -0
- data/examples/service/recipes/stop.rb +13 -0
- data/examples/service/spec/disable_spec.rb +19 -0
- data/examples/service/spec/enable_spec.rb +19 -0
- data/examples/service/spec/reload_spec.rb +19 -0
- data/examples/service/spec/restart_spec.rb +19 -0
- data/examples/service/spec/start_spec.rb +19 -0
- data/examples/service/spec/stop_spec.rb +19 -0
- data/examples/smartos_package/recipes/install.rb +13 -0
- data/examples/smartos_package/recipes/remove.rb +13 -0
- data/examples/smartos_package/recipes/upgrade.rb +13 -0
- data/examples/smartos_package/spec/install_spec.rb +23 -0
- data/examples/smartos_package/spec/remove_spec.rb +19 -0
- data/examples/smartos_package/spec/upgrade_spec.rb +19 -0
- data/examples/solaris_package/recipes/install.rb +13 -0
- data/examples/solaris_package/recipes/remove.rb +13 -0
- data/examples/solaris_package/spec/install_spec.rb +23 -0
- data/examples/solaris_package/spec/remove_spec.rb +19 -0
- data/examples/state_attrs/providers/lwrp.rb +3 -0
- data/examples/state_attrs/recipes/default.rb +3 -0
- data/examples/state_attrs/resources/lwrp.rb +6 -0
- data/examples/state_attrs/spec/default_spec.rb +12 -0
- data/examples/step_into/providers/lwrp.rb +3 -0
- data/examples/step_into/recipes/default.rb +1 -0
- data/examples/step_into/resources/lwrp.rb +4 -0
- data/examples/step_into/spec/default_spec.rb +19 -0
- data/examples/stub_command/recipes/default.rb +5 -0
- data/examples/stub_command/recipes/other_recipe.rb +3 -0
- data/examples/stub_command/spec/default_spec.rb +28 -0
- data/examples/stub_data_bag/recipes/default.rb +5 -0
- data/examples/stub_data_bag/spec/default_spec.rb +27 -0
- data/examples/stub_data_bag_item/recipes/default.rb +5 -0
- data/examples/stub_data_bag_item/spec/default_spec.rb +27 -0
- data/examples/stub_node/recipes/default.rb +0 -0
- data/examples/stub_node/spec/default_spec.rb +17 -0
- data/examples/stub_search/recipes/default.rb +5 -0
- data/examples/stub_search/spec/default_spec.rb +27 -0
- data/examples/subscribes/recipes/chained.rb +10 -0
- data/examples/subscribes/recipes/default.rb +5 -0
- data/examples/subscribes/recipes/delayed.rb +5 -0
- data/examples/subscribes/recipes/immediately.rb +5 -0
- data/examples/subscribes/spec/chained_spec.rb +21 -0
- data/examples/subscribes/spec/default_spec.rb +17 -0
- data/examples/subscribes/spec/delayed_spec.rb +16 -0
- data/examples/subscribes/spec/immediately_spec.rb +16 -0
- data/examples/subversion/recipes/checkout.rb +13 -0
- data/examples/subversion/recipes/export.rb +13 -0
- data/examples/subversion/recipes/force_export.rb +13 -0
- data/examples/subversion/recipes/sync.rb +13 -0
- data/examples/subversion/spec/checkout_spec.rb +19 -0
- data/examples/subversion/spec/export_spec.rb +19 -0
- data/examples/subversion/spec/force_export_spec.rb +19 -0
- data/examples/subversion/spec/sync_spec.rb +23 -0
- data/examples/template/recipes/create.rb +15 -0
- data/examples/template/recipes/create_if_missing.rb +15 -0
- data/examples/template/recipes/delete.rb +15 -0
- data/examples/template/recipes/touch.rb +15 -0
- data/examples/template/spec/create_if_missing_spec.rb +28 -0
- data/examples/template/spec/create_spec.rb +32 -0
- data/examples/template/spec/delete_spec.rb +19 -0
- data/examples/template/spec/touch_spec.rb +19 -0
- data/examples/use_inline_resources/libraries/matchers.rb +5 -0
- data/examples/use_inline_resources/providers/lwrp.rb +7 -0
- data/examples/use_inline_resources/recipes/default.rb +1 -0
- data/examples/use_inline_resources/resources/lwrp.rb +4 -0
- data/examples/use_inline_resources/spec/default_spec.rb +15 -0
- data/examples/user/recipes/create.rb +13 -0
- data/examples/user/recipes/lock.rb +13 -0
- data/examples/user/recipes/manage.rb +13 -0
- data/examples/user/recipes/modify.rb +13 -0
- data/examples/user/recipes/remove.rb +13 -0
- data/examples/user/recipes/unlock.rb +13 -0
- data/examples/user/spec/create_spec.rb +23 -0
- data/examples/user/spec/lock_spec.rb +19 -0
- data/examples/user/spec/manage_spec.rb +19 -0
- data/examples/user/spec/modify_spec.rb +19 -0
- data/examples/user/spec/remove_spec.rb +19 -0
- data/examples/user/spec/unlock_spec.rb +19 -0
- data/examples/yum_package/recipes/install.rb +13 -0
- data/examples/yum_package/recipes/purge.rb +13 -0
- data/examples/yum_package/recipes/remove.rb +13 -0
- data/examples/yum_package/recipes/upgrade.rb +13 -0
- data/examples/yum_package/spec/install_spec.rb +23 -0
- data/examples/yum_package/spec/purge_spec.rb +19 -0
- data/examples/yum_package/spec/remove_spec.rb +19 -0
- data/examples/yum_package/spec/upgrade_spec.rb +19 -0
- data/features/apt_package.feature +14 -0
- data/features/attributes.feature +7 -0
- data/features/batch.feature +13 -0
- data/features/cached.feature +7 -0
- data/features/chef_gem.feature +14 -0
- data/features/compile_time.feature +7 -0
- data/features/cookbook_file.feature +13 -0
- data/features/cron.feature +11 -0
- data/features/custom_matcher.feature +11 -0
- data/features/deploy.feature +12 -0
- data/features/directory.feature +11 -0
- data/features/dpkg_package.feature +12 -0
- data/features/easy_install_package.feature +13 -0
- data/features/env.feature +12 -0
- data/features/erl_call.feature +10 -0
- data/features/execute.feature +10 -0
- data/features/expect_exception.feature +12 -0
- data/features/file.feature +13 -0
- data/features/freebsd_package.feature +11 -0
- data/features/gem_package.feature +14 -0
- data/features/git.feature +12 -0
- data/features/group.feature +13 -0
- data/features/guards.feature +10 -0
- data/features/heavy_provider_light_resource.feature +10 -0
- data/features/http_request.feature +15 -0
- data/features/ifconfig.feature +13 -0
- data/features/include_recipe.feature +10 -0
- data/features/inherits.feature +7 -0
- data/features/ips_package.feature +12 -0
- data/features/link.feature +12 -0
- data/features/log.feature +10 -0
- data/features/macports_package.feature +13 -0
- data/features/mdadm.feature +12 -0
- data/features/mount.feature +14 -0
- data/features/multiple_actions.feature +11 -0
- data/features/multiple_run_action.feature +7 -0
- data/features/notifications.feature +13 -0
- data/features/ohai.feature +10 -0
- data/features/package.feature +14 -0
- data/features/pacman_package.feature +13 -0
- data/features/portage_package.feature +13 -0
- data/features/powershell_script.feature +13 -0
- data/features/registry_key.feature +13 -0
- data/features/remote_directory.feature +12 -0
- data/features/remote_file.feature +13 -0
- data/features/render_file.feature +16 -0
- data/features/roles.feature +7 -0
- data/features/route.feature +11 -0
- data/features/rpm_package.feature +12 -0
- data/features/ruby_block.feature +10 -0
- data/features/script.feature +15 -0
- data/features/server.feature +21 -0
- data/features/service.feature +15 -0
- data/features/smartos_package.feature +16 -0
- data/features/solaris_package.feature +15 -0
- data/features/state_attrs.feature +11 -0
- data/features/step_definitions/background_steps.rb +4 -0
- data/features/step_into.feature +7 -0
- data/features/stub_command.feature +7 -0
- data/features/stub_data_bag.feature +7 -0
- data/features/stub_data_bag_item.feature +7 -0
- data/features/stub_node.feature +7 -0
- data/features/stub_search.feature +7 -0
- data/features/subscribes.feature +13 -0
- data/features/subversion.feature +13 -0
- data/features/support/env.rb +36 -0
- data/features/support/executor.rb +18 -0
- data/features/template.feature +13 -0
- data/features/use_inline_resources.feature +7 -0
- data/features/user.feature +15 -0
- data/features/yum_package.feature +13 -0
- data/gemfiles/chef-11.0.0.gemfile +5 -0
- data/gemfiles/chef-11.2.0.gemfile +5 -0
- data/gemfiles/chef-11.4.4.gemfile +5 -0
- data/gemfiles/chef-11.6.0.gemfile +5 -0
- data/gemfiles/chef-11.8.0.gemfile +5 -0
- data/gemfiles/chef-master.gemfile +5 -0
- data/lib/chefspec/api.rb +13 -11
- data/lib/chefspec/api/notifications.rb +3 -3
- data/lib/chefspec/api/subscriptions.rb +35 -0
- data/lib/chefspec/coverage.rb +40 -34
- data/lib/chefspec/expect_exception.rb +14 -13
- data/lib/chefspec/formatter.rb +8 -8
- data/lib/chefspec/matchers.rb +1 -0
- data/lib/chefspec/matchers/include_recipe_matcher.rb +19 -18
- data/lib/chefspec/matchers/notifications_matcher.rb +25 -24
- data/lib/chefspec/matchers/render_file_matcher.rb +32 -31
- data/lib/chefspec/matchers/resource_matcher.rb +64 -63
- data/lib/chefspec/matchers/state_attrs_matcher.rb +18 -17
- data/lib/chefspec/matchers/subscribes_matcher.rb +59 -0
- data/lib/chefspec/renderer.rb +82 -81
- data/lib/chefspec/runner.rb +66 -51
- data/lib/chefspec/server.rb +84 -39
- data/lib/chefspec/stubs/stub.rb +10 -9
- data/lib/chefspec/version.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- data/spec/support/hash.rb +35 -0
- data/spec/unit/api_spec.rb +18 -0
- data/spec/unit/cacher_spec.rb +54 -0
- data/spec/unit/expect_exception_spec.rb +32 -0
- data/spec/unit/extensions/lwrp_base_spec.rb +89 -0
- data/spec/unit/macros_spec.rb +119 -0
- data/spec/unit/matchers/include_recipe_matcher_spec.rb +38 -0
- data/spec/unit/matchers/link_to_matcher_spec.rb +39 -0
- data/spec/unit/matchers/notifications_matcher_spec.rb +5 -0
- data/spec/unit/matchers/render_file_matcher_spec.rb +41 -0
- data/spec/unit/matchers/resource_matcher_spec.rb +5 -0
- data/spec/unit/matchers/state_attrs_matcher_spec.rb +64 -0
- data/spec/unit/matchers/subscribes_matcher_spec.rb +5 -0
- data/spec/unit/renderer_spec.rb +51 -0
- data/spec/unit/runner_spec.rb +125 -0
- data/spec/unit/stubs/command_registry_spec.rb +27 -0
- data/spec/unit/stubs/command_stub_spec.rb +61 -0
- data/spec/unit/stubs/data_bag_item_registry_spec.rb +39 -0
- data/spec/unit/stubs/data_bag_item_stub_spec.rb +36 -0
- data/spec/unit/stubs/data_bag_registry_spec.rb +39 -0
- data/spec/unit/stubs/data_bag_stub_spec.rb +35 -0
- data/spec/unit/stubs/registry_spec.rb +29 -0
- data/spec/unit/stubs/search_registry_spec.rb +39 -0
- data/spec/unit/stubs/search_stub_spec.rb +36 -0
- data/spec/unit/stubs/stub_spec.rb +64 -0
- metadata +618 -5
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Matchers::IncludeRecipeMatcher do
|
4
|
+
let(:chef_run) { double('chef run', run_context: { loaded_recipes: %w(one two three) }) }
|
5
|
+
subject { described_class.new('one::default') }
|
6
|
+
|
7
|
+
describe '#failure_message_for_should' do
|
8
|
+
it 'has the right value' do
|
9
|
+
subject.matches?(chef_run)
|
10
|
+
expect(subject.failure_message_for_should)
|
11
|
+
.to eq(%q(expected ["one::default", "two::default", "three::default"] to include "one::default"))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#failure_message_for_should_not' do
|
16
|
+
it 'has the right value' do
|
17
|
+
subject.matches?(chef_run)
|
18
|
+
expect(subject.failure_message_for_should_not)
|
19
|
+
.to eq(%q(expected "one::default" to not be included))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#description' do
|
24
|
+
it 'has the right value' do
|
25
|
+
subject.matches?(chef_run)
|
26
|
+
expect(subject.description).to eq(%q(include recipe "one::default"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'matches when the recipe is included' do
|
31
|
+
expect(subject.matches?(chef_run)).to be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not match when the recipe is not included' do
|
35
|
+
failure = described_class.new('nope')
|
36
|
+
expect(failure.matches?(chef_run)).to be_false
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Matchers::LinkToMatcher do
|
4
|
+
let(:path) { '/var/www' }
|
5
|
+
let(:link) { double('link', to: path, to_s: "link[#{path}]", is_a?: true, performed_action?: true) }
|
6
|
+
subject { described_class.new(path) }
|
7
|
+
|
8
|
+
describe '#failure_message_for_should' do
|
9
|
+
it 'has the right value' do
|
10
|
+
subject.matches?(link)
|
11
|
+
expect(subject.failure_message_for_should)
|
12
|
+
.to eq(%Q(expected "link[#{path}]" to link to "#{path}" but was "#{path}"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#failure_message_for_should_not' do
|
17
|
+
it 'has the right value' do
|
18
|
+
subject.matches?(link)
|
19
|
+
expect(subject.failure_message_for_should_not)
|
20
|
+
.to eq(%Q(expected "link[#{path}]" to not link to "#{path}"))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#description' do
|
25
|
+
it 'has the right value' do
|
26
|
+
subject.matches?(link)
|
27
|
+
expect(subject.description).to eq(%Q(link to "#{path}"))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'matches when the link is correct' do
|
32
|
+
expect(subject.matches?(link)).to be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not match when the link is incorrect' do
|
36
|
+
failure = described_class.new('nope')
|
37
|
+
expect(failure.matches?(link)).to be_false
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Matchers::RenderFileMatcher do
|
4
|
+
let(:path) { '/tmp/thing' }
|
5
|
+
let(:file) { double('file', to: path, to_s: "file[#{path}]", performed_action?: true) }
|
6
|
+
let(:chef_run) { double('chef run', find_resource: file) }
|
7
|
+
subject { described_class.new(path) }
|
8
|
+
|
9
|
+
describe '#failure_message_for_should' do
|
10
|
+
it 'has the right value' do
|
11
|
+
subject.matches?(chef_run)
|
12
|
+
expect(subject.failure_message_for_should)
|
13
|
+
.to eq(%Q(expected Chef run to render "#{path}"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#failure_message_for_should_not' do
|
18
|
+
it 'has the right value' do
|
19
|
+
subject.matches?(chef_run)
|
20
|
+
expect(subject.failure_message_for_should_not)
|
21
|
+
.to eq(%Q(expected file "#{path}" to not be in Chef run))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#description' do
|
26
|
+
it 'has the right value' do
|
27
|
+
subject.matches?(chef_run)
|
28
|
+
expect(subject.description).to eq(%Q(render file "#{path}"))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'matches when the file is correct' do
|
33
|
+
expect(subject.matches?(chef_run)).to be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'does not match when the file is incorrect' do
|
37
|
+
chef_run.stub(:find_resource).and_return(nil)
|
38
|
+
failure = described_class.new('nope')
|
39
|
+
expect(failure.matches?(chef_run)).to be_false
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Matchers::StateAttrsMatcher do
|
4
|
+
subject { described_class.new([:a, :b]) }
|
5
|
+
|
6
|
+
context 'when the resource does not exist' do
|
7
|
+
let(:resource) { nil }
|
8
|
+
before { subject.matches?(resource) }
|
9
|
+
|
10
|
+
it 'does not match' do
|
11
|
+
expect(subject).to_not be_matches(resource)
|
12
|
+
end
|
13
|
+
|
14
|
+
its(:description) { should eq('have state attributes [:a, :b]') }
|
15
|
+
|
16
|
+
its(:failure_message_for_should) do
|
17
|
+
should eq "expected _something_ to have state attributes, but " \
|
18
|
+
"the _something_ you gave me was nil!" \
|
19
|
+
"\n" \
|
20
|
+
"Ensure the resource exists before making assertions:" \
|
21
|
+
"\n\n" \
|
22
|
+
" expect(resource).to be" \
|
23
|
+
"\n "
|
24
|
+
end
|
25
|
+
|
26
|
+
its(:failure_message_for_should_not) do
|
27
|
+
should eq "expected _something_ to not have state attributes, but " \
|
28
|
+
"the _something_ you gave me was nil!" \
|
29
|
+
"\n" \
|
30
|
+
"Ensure the resource exists before making assertions:" \
|
31
|
+
"\n\n" \
|
32
|
+
" expect(resource).to be" \
|
33
|
+
"\n "
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the resource exists' do
|
38
|
+
let(:klass) { double('class', state_attrs: [:a, :b]) }
|
39
|
+
let(:resource) { double('resource', class: klass) }
|
40
|
+
before { subject.matches?(resource) }
|
41
|
+
|
42
|
+
its(:description) { should eq('have state attributes [:a, :b]') }
|
43
|
+
its(:failure_message_for_should) do
|
44
|
+
should eq('expected [:a, :b] to equal [:a, :b]')
|
45
|
+
end
|
46
|
+
its(:failure_message_for_should_not) do
|
47
|
+
should eq('expected [:a, :b] to not equal [:a, :b]')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'matches when the state attributes are correct' do
|
51
|
+
expect(subject).to be_matches(resource)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'does not match when the state attributes are incorrect' do
|
55
|
+
klass.stub(:state_attrs).and_return([:c, :d])
|
56
|
+
expect(subject).to_not be_matches(resource)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'does not match when partial state attribute are incorrect' do
|
60
|
+
klass.stub(:state_attrs).and_return([:b, :c])
|
61
|
+
expect(subject).to_not be_matches(resource)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Renderer do
|
4
|
+
describe '.initialize' do
|
5
|
+
it 'accepts two arguments and assigns their instance variables' do
|
6
|
+
instance = described_class.new('runner', 'resource')
|
7
|
+
expect(instance.chef_run).to eq('runner')
|
8
|
+
expect(instance.resource).to eq('resource')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:chef_run) { double('chef_run') }
|
13
|
+
let(:resource) { double('resource') }
|
14
|
+
subject { described_class.new(chef_run, resource) }
|
15
|
+
|
16
|
+
describe '#content' do
|
17
|
+
before do
|
18
|
+
subject.stub(:content_from_cookbook_file).and_return('cookbook_file content')
|
19
|
+
subject.stub(:content_from_file).and_return('file content')
|
20
|
+
subject.stub(:content_from_template).and_return('template content')
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the resource is a cookbook_file' do
|
24
|
+
it 'renders the cookbook_file content' do
|
25
|
+
resource.stub(:resource_name).and_return('cookbook_file')
|
26
|
+
expect(subject.content).to eq('cookbook_file content')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the resource is a file' do
|
31
|
+
it 'renders the file content' do
|
32
|
+
resource.stub(:resource_name).and_return('file')
|
33
|
+
expect(subject.content).to eq('file content')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the resource is a template' do
|
38
|
+
it 'renders the template content' do
|
39
|
+
resource.stub(:resource_name).and_return('template')
|
40
|
+
expect(subject.content).to eq('template content')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the resource is not a file type' do
|
45
|
+
it 'returns nil' do
|
46
|
+
resource.stub(:resource_name).and_return('service')
|
47
|
+
expect(subject.content).to be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Runner do
|
4
|
+
before do
|
5
|
+
ChefSpec::Runner.any_instance.stub(:dry_run?).and_return(true)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
subject {} # need to explicitly control the creation
|
10
|
+
|
11
|
+
it 'defaults the log level to :warn' do
|
12
|
+
described_class.new
|
13
|
+
expect(Chef::Log.level).to eq(:warn)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets the log level' do
|
17
|
+
described_class.new(log_level: :error)
|
18
|
+
expect(Chef::Log.level).to eq(:error)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'defaults the cookbook_path to the calling spec' do
|
22
|
+
described_class.new
|
23
|
+
expect(Chef::Config.cookbook_path).to eq([File.expand_path('../../../..', __FILE__)])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets the cookbook path' do
|
27
|
+
described_class.new(cookbook_path: '/tmp/bacon')
|
28
|
+
expect(Chef::Config.cookbook_path).to eq(['/tmp/bacon'])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets the Chef::Config' do
|
32
|
+
expect(Chef::Config.cache_type).to eq('Memory')
|
33
|
+
expect(Chef::Config.force_logger).to be_true
|
34
|
+
expect(Chef::Config.solo).to be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'yields a block to set node attributes' do
|
38
|
+
expect { |block| described_class.new({}, &block) }.to yield_with_args(Chef::Node)
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'default ohai attributes' do
|
42
|
+
let(:hash) { described_class.new.node.to_hash }
|
43
|
+
|
44
|
+
it 'sets the default attributes' do
|
45
|
+
expect(hash['os']).to eq('chefspec')
|
46
|
+
expect(hash['languages']['ruby']).to eq('/usr/somewhere')
|
47
|
+
expect(hash['os_version']).to eq('0.6.1')
|
48
|
+
expect(hash['fqdn']).to eq('chefspec.local')
|
49
|
+
expect(hash['domain']).to eq('local')
|
50
|
+
expect(hash['ipaddress']).to eq('127.0.0.1')
|
51
|
+
expect(hash['hostname']).to eq('chefspec')
|
52
|
+
expect(hash['kernel']['machine']).to eq('i386')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'fauxhai attributes' do
|
57
|
+
let(:hash) { described_class.new(platform: 'ubuntu', version: '12.04').node.to_hash }
|
58
|
+
|
59
|
+
it 'sets the attributes from fauxhai' do
|
60
|
+
expect(hash['os']).to eq('linux')
|
61
|
+
expect(hash['languages']['ruby']['ruby_bin']).to eq('/usr/local/bin/ruby')
|
62
|
+
expect(hash['os_version']).to eq('3.2.0-26-generic')
|
63
|
+
expect(hash['fqdn']).to eq('fauxhai.local')
|
64
|
+
expect(hash['domain']).to eq('local')
|
65
|
+
expect(hash['ipaddress']).to eq('10.0.0.2')
|
66
|
+
expect(hash['hostname']).to eq('Fauxhai')
|
67
|
+
expect(hash['kernel']['machine']).to eq('x86_64')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'RSpec global configuration' do
|
72
|
+
before do
|
73
|
+
RSpec.configuration.stub(:cookbook_path).and_return('./path')
|
74
|
+
RSpec.configuration.stub(:log_level).and_return(:fatal)
|
75
|
+
RSpec.configuration.stub(:path).and_return('ohai.json')
|
76
|
+
RSpec.configuration.stub(:platform).and_return('ubuntu')
|
77
|
+
RSpec.configuration.stub(:version).and_return('12.04')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'uses the RSpec values' do
|
81
|
+
options = described_class.new.options
|
82
|
+
expect(options[:cookbook_path]).to eq('./path')
|
83
|
+
expect(options[:log_level]).to eq(:fatal)
|
84
|
+
expect(options[:path]).to eq('ohai.json')
|
85
|
+
expect(options[:platform]).to eq('ubuntu')
|
86
|
+
expect(options[:version]).to eq('12.04')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#node' do
|
92
|
+
it 'returns the Chef::Node' do
|
93
|
+
expect(subject.node).to be_a(Chef::Node)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'defines a #runner method that returns self' do
|
97
|
+
expect(subject.node.methods).to include(:runner)
|
98
|
+
expect(subject.node.runner).to be(subject)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'allows attributes to be set on the node' do
|
102
|
+
subject.node.set['bacon'] = 'ham'
|
103
|
+
expect(subject.node.bacon).to eq('ham')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#to_s' do
|
108
|
+
it 'overrides the default string representation to something readable' do
|
109
|
+
expect(subject.converge('apache2::default').to_s).to eq('chef_run: recipe[apache2::default]')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'is ok when a convergence has not yet taken place' do
|
113
|
+
expect(subject.to_s).to eq('chef_run')
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'includes the entire run_list' do
|
117
|
+
expect(subject.converge('apache2::default', 'apache2::mod_ssl').to_s).to eq('chef_run: recipe[apache2::default], recipe[apache2::mod_ssl]')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'has the run_list only for the last convergence' do
|
121
|
+
['mysql::client', 'mysql::server'].each { |recipe| subject.converge(recipe) }
|
122
|
+
expect(subject.to_s).to eq('chef_run: recipe[mysql::server]')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::CommandRegistry do
|
4
|
+
before { described_class.reset! }
|
5
|
+
|
6
|
+
it 'inherits from Registry' do
|
7
|
+
expect(described_class.superclass).to be(ChefSpec::Stubs::Registry)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#stub_for' do
|
11
|
+
it 'finds a stub by name' do
|
12
|
+
command = double('command', command: 'test -f /var/www')
|
13
|
+
described_class.register(command)
|
14
|
+
expect(described_class.stub_for('test -f /var/www')).to eq(command)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'finds a stub by regex' do
|
18
|
+
command = double('command', command: /test -f (.+)/)
|
19
|
+
described_class.register(command)
|
20
|
+
expect(described_class.stub_for('test -f /var/www')).to eq(command)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns nil when no commands are matched' do
|
24
|
+
expect(described_class.stub_for('which a2ensite')).to eq(nil)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::CommandStub do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'sets the command and block' do
|
6
|
+
block = Proc.new {}
|
7
|
+
stub = described_class.new('command', &block)
|
8
|
+
|
9
|
+
expect(stub.command).to eq('command')
|
10
|
+
expect(stub.block).to eq(block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#and_return' do
|
15
|
+
subject { described_class.new('command').and_return('value') }
|
16
|
+
|
17
|
+
it 'sets the value' do
|
18
|
+
expect(subject.value).to eq('value')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns an instance of the stub' do
|
22
|
+
expect(subject.and_return('value')).to be(subject)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#result' do
|
27
|
+
context 'when a value is given' do
|
28
|
+
subject { described_class.new('command').and_return('value') }
|
29
|
+
|
30
|
+
it 'returns the value' do
|
31
|
+
expect(subject.result).to eq('value')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when a block is given' do
|
36
|
+
subject { described_class.new('command') { 1 == 2 } }
|
37
|
+
|
38
|
+
it 'calls the block' do
|
39
|
+
expect(subject.result).to eq(false)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#signature' do
|
45
|
+
context 'when a value is given' do
|
46
|
+
subject { described_class.new('command').and_return(false) }
|
47
|
+
|
48
|
+
it 'includes the value' do
|
49
|
+
expect(subject.signature).to eq('stub_command("command").and_return(false)')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when a block is given' do
|
54
|
+
subject { described_class.new('command') { 1 == 2 } }
|
55
|
+
|
56
|
+
it 'includes a comment about the block' do
|
57
|
+
expect(subject.signature).to eq('stub_command("command") { # Ruby code }')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|