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
data/lib/chefspec/server.rb
CHANGED
@@ -40,16 +40,16 @@ class ChefSpec::Runner
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
#
|
44
|
+
# Upload the cookbooks to the Chef Server.
|
45
|
+
#
|
46
|
+
def upload_cookbooks!
|
47
|
+
loader = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
|
48
|
+
loader.load_cookbooks
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
uploader = Chef::CookbookUploader.new(loader.cookbooks, loader.cookbook_paths)
|
51
|
+
uploader.upload_cookbooks
|
52
|
+
end
|
53
53
|
end
|
54
54
|
|
55
55
|
module ChefSpec
|
@@ -99,13 +99,11 @@ module ChefSpec
|
|
99
99
|
def self.entity(method, klass, key)
|
100
100
|
class_eval <<-EOH, __FILE__, __LINE__ + 1
|
101
101
|
def create_#{method}(name, data = {})
|
102
|
-
|
103
|
-
|
104
|
-
data[:name] ||= name
|
102
|
+
# Automatically set the "name" if no explicit one was given
|
103
|
+
data[:name] ||= name
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
end
|
105
|
+
# Convert it to JSON
|
106
|
+
data = JSON.fast_generate(data)
|
109
107
|
|
110
108
|
@server.load_data('#{key}' => { name => data })
|
111
109
|
end
|
@@ -155,6 +153,53 @@ module ChefSpec
|
|
155
153
|
entity :node, Chef::Node, 'nodes'
|
156
154
|
entity :role, Chef::Role, 'roles'
|
157
155
|
|
156
|
+
#
|
157
|
+
# Create a new data_bag on the Chef Server. This overrides the method
|
158
|
+
# created by {entity}
|
159
|
+
#
|
160
|
+
# @param [String] name
|
161
|
+
# the name of the data bag
|
162
|
+
# @param [Hash] data
|
163
|
+
# the data to load into the data bag
|
164
|
+
#
|
165
|
+
def create_data_bag(name, data = {})
|
166
|
+
@server.load_data('data' => { name => data })
|
167
|
+
end
|
168
|
+
|
169
|
+
#
|
170
|
+
# Create a new node on the Chef Server. This overrides the method created
|
171
|
+
# by {entity}, permitting users to pass a raw +Chef::Node+ object in
|
172
|
+
# addition to a hash.
|
173
|
+
#
|
174
|
+
# @example Create a node from a hash
|
175
|
+
#
|
176
|
+
# create_node('bacon', attribute: 'value')
|
177
|
+
#
|
178
|
+
# @example Create a node from a +Chef::Node+ object
|
179
|
+
#
|
180
|
+
# node = stub_node('bacon', platform: 'ubuntu', version: '12.04')
|
181
|
+
# create_node(node)
|
182
|
+
#
|
183
|
+
# @param [String, Chef::Node] object
|
184
|
+
# the object to create; this can be the name of the node, or an actual
|
185
|
+
# +Chef::Node+ object
|
186
|
+
# @param [Hash] data
|
187
|
+
# the list of data to populate the node with; this is ignored if an
|
188
|
+
# actual node object is given
|
189
|
+
#
|
190
|
+
def create_node(object, data = {})
|
191
|
+
if object.is_a?(Chef::Node)
|
192
|
+
name = object.name
|
193
|
+
data = object.to_json
|
194
|
+
else
|
195
|
+
name = object.to_s
|
196
|
+
data[:name] ||= name
|
197
|
+
data = JSON.fast_generate(data)
|
198
|
+
end
|
199
|
+
|
200
|
+
@server.load_data('nodes' => { name => data })
|
201
|
+
end
|
202
|
+
|
158
203
|
#
|
159
204
|
# The path to the insecure Chef Zero private key on disk. Because Chef
|
160
205
|
# requires the path to a file instead of the contents of the key (why),
|
@@ -201,31 +246,31 @@ module ChefSpec
|
|
201
246
|
|
202
247
|
private
|
203
248
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
249
|
+
#
|
250
|
+
# The directory where any cache information (such as private keys) should
|
251
|
+
# be stored. This cache is destroyed at the end of the run.
|
252
|
+
#
|
253
|
+
# @return [String]
|
254
|
+
# the path to the cache directory on disk
|
255
|
+
#
|
256
|
+
def cache_dir
|
257
|
+
@cache_dir ||= Dir.mktmpdir(['chefspec', 'cache'])
|
258
|
+
end
|
214
259
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
260
|
+
#
|
261
|
+
# Shortcut method for loading data into Chef Zero.
|
262
|
+
#
|
263
|
+
# @param [String, Symbol] key
|
264
|
+
# the key to load
|
265
|
+
# @param [String] name
|
266
|
+
# the name or id of the item to load
|
267
|
+
# @param [Hash] data
|
268
|
+
# the data for the object, which will be converted to JSON and uploaded
|
269
|
+
# to the server
|
270
|
+
#
|
271
|
+
def load_data(key, name, data = {})
|
272
|
+
@server.load_data(key.to_s => { name => JSON.fast_generate(data) })
|
273
|
+
end
|
229
274
|
end
|
230
275
|
end
|
231
276
|
|
data/lib/chefspec/stubs/stub.rb
CHANGED
@@ -22,16 +22,17 @@ module ChefSpec
|
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
|
26
|
+
def recursively_mashify(thing)
|
27
|
+
case thing
|
28
|
+
when Array
|
29
|
+
thing.collect { |item| recursively_mashify(item) }
|
30
|
+
when Hash
|
31
|
+
Mash.from_hash(thing)
|
32
|
+
else
|
33
|
+
thing
|
34
34
|
end
|
35
|
+
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
data/lib/chefspec/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# An extension of a Hash that allows mash-style like lookups.
|
3
|
+
#
|
4
|
+
# @private
|
5
|
+
#
|
6
|
+
class Hash
|
7
|
+
# Like, seriously Windows?
|
8
|
+
undef_method(:timeout)
|
9
|
+
|
10
|
+
#
|
11
|
+
# Monkey-patch to allow mash-style look ups for tests
|
12
|
+
#
|
13
|
+
def method_missing(m, *args, &block)
|
14
|
+
if has_key?(m.to_sym)
|
15
|
+
self[m.to_sym]
|
16
|
+
elsif has_key?(m.to_s)
|
17
|
+
self[m.to_s]
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Monkey-patch to stdlib Hash to correspond to Mash-style lookup
|
25
|
+
#
|
26
|
+
# @see Hash#respond_to?
|
27
|
+
#
|
28
|
+
def respond_to?(m, include_private = false)
|
29
|
+
if has_key?(m.to_sym) || has_key?(m.to_s)
|
30
|
+
true
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::API do
|
4
|
+
before do
|
5
|
+
module ChefSpec::API
|
6
|
+
module CustomSubmodule
|
7
|
+
def custom_method; end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { Class.new { include ChefSpec::API }.new }
|
13
|
+
|
14
|
+
it 'includes all submodules in the including class' do
|
15
|
+
expect(subject).to be_a(ChefSpec::API::CustomSubmodule)
|
16
|
+
expect(subject).to respond_to(:custom_method)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'chefspec/cacher'
|
3
|
+
|
4
|
+
describe ChefSpec::Cacher do
|
5
|
+
let(:klass) do
|
6
|
+
Class.new(RSpec::Core::ExampleGroup) do
|
7
|
+
extend ChefSpec::Cacher
|
8
|
+
|
9
|
+
def self.metadata
|
10
|
+
{ example_group: { location: 'spec' } }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:cache) { described_class.class_variable_get(:@@cache) }
|
16
|
+
|
17
|
+
before(:each) { described_class.class_variable_set(:@@cache, {}) }
|
18
|
+
|
19
|
+
describe 'cached' do
|
20
|
+
it 'lazily defines the results for the cache' do
|
21
|
+
klass.cached(:chef_run)
|
22
|
+
expect(klass).to be_method_defined(:chef_run)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'adds the item to the cache when called' do
|
26
|
+
runner = double(:runner)
|
27
|
+
klass.cached(:chef_run) { runner }
|
28
|
+
klass.new.chef_run
|
29
|
+
|
30
|
+
expect(cache[Thread.current.object_id]).to have_key('spec.chef_run')
|
31
|
+
expect(cache[Thread.current.object_id]['spec.chef_run']).to eq(runner)
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when multithreaded environment' do
|
35
|
+
it 'is thread safe' do
|
36
|
+
(1..2).each do |n|
|
37
|
+
Thread.new do
|
38
|
+
klass.cached(:chef_run) { n }
|
39
|
+
expect(klass.new.chef_run).to eq(n)
|
40
|
+
end.join
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'cached!' do
|
47
|
+
it 'loads the value at runtime' do
|
48
|
+
expect(klass).to receive(:cached).with(:chef_run).once
|
49
|
+
expect(klass).to receive(:before).once
|
50
|
+
|
51
|
+
klass.cached!(:chef_run) { }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::ExpectException do
|
4
|
+
context 'when there have been no `raise_error` matchers' do
|
5
|
+
subject { described_class.new(Exception) }
|
6
|
+
|
7
|
+
it 'does not match' do
|
8
|
+
RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(nil)
|
9
|
+
expect(subject.expected?).to be_false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when the last error does not match the expected type' do
|
14
|
+
subject { described_class.new(RuntimeError) }
|
15
|
+
|
16
|
+
it 'does not match' do
|
17
|
+
last_error = double('last error', expected_error: ArgumentError)
|
18
|
+
RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(last_error)
|
19
|
+
expect(subject.expected?).to be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the last error matches the expected type' do
|
24
|
+
subject { described_class.new(RuntimeError) }
|
25
|
+
|
26
|
+
it 'does not match' do
|
27
|
+
last_error = double('last error', expected_error: RuntimeError)
|
28
|
+
RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(last_error)
|
29
|
+
expect(subject.expected?).to be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Don't run this test on older versions of Chef
|
4
|
+
if Chef::VERSION >= '11.0.0'
|
5
|
+
|
6
|
+
module ChefSpec
|
7
|
+
module Extensions
|
8
|
+
describe :LWRPBase do
|
9
|
+
describe '#remove_existing_lwrp' do
|
10
|
+
before do
|
11
|
+
Chef::Provider::MysqlDatabase = nil
|
12
|
+
Chef::Resource::MysqlDatabase = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
[Chef::Provider, Chef::Resource].each do |mod|
|
17
|
+
next unless mod.const_defined?(:MysqlDatabase, false)
|
18
|
+
mod.send(:remove_const, :MysqlDatabase)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context Chef::Provider do
|
23
|
+
before do
|
24
|
+
Chef::Provider::LWRPBase.remove_existing_lwrp('MysqlDatabase')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'removes the provider if it already exists' do
|
28
|
+
expect(Chef::Provider.constants).to_not include(:MysqlDatabase)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not remove resource' do
|
32
|
+
expect(Chef::Resource.constants).to include(:MysqlDatabase)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not throw an error if the resource does not already exist' do
|
36
|
+
expect {
|
37
|
+
Chef::Provider::LWRPBase.remove_existing_lwrp 'Human'
|
38
|
+
}.to_not raise_error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context Chef::Resource do
|
43
|
+
before do
|
44
|
+
Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'removes the resource if it already exists' do
|
48
|
+
expect(Chef::Resource.constants).to_not include(:MysqlDatabase)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not remove the provider' do
|
52
|
+
Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase')
|
53
|
+
expect(Chef::Provider.constants).to include(:MysqlDatabase)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does not throw an error if the resource does not already exist' do
|
57
|
+
expect {
|
58
|
+
Chef::Resource::LWRPBase.remove_existing_lwrp 'Human'
|
59
|
+
}.to_not raise_error
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#build_from_file' do
|
66
|
+
let(:args){ %w{mycookbook thisfile context} }
|
67
|
+
|
68
|
+
shared_context "wrapping" do
|
69
|
+
it 'wraps the existing chef build_from_file method' do
|
70
|
+
klass = mod::LWRPBase
|
71
|
+
allow(klass).to receive(:build_from_file_without_removal)
|
72
|
+
expect(klass).to receive(:build_from_file_without_removal).with(*args)
|
73
|
+
klass.build_from_file(*args)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context Chef::Provider do
|
78
|
+
let(:mod){ Chef::Provider }
|
79
|
+
include_context "wrapping"
|
80
|
+
end
|
81
|
+
|
82
|
+
context Chef::Resource do
|
83
|
+
let(:mod){ Chef::Resource }
|
84
|
+
include_context "wrapping"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Macros do
|
4
|
+
describe '#stub_command' do
|
5
|
+
let(:command_stub) { double('command') }
|
6
|
+
|
7
|
+
it 'adds the command to the command registry' do
|
8
|
+
ChefSpec::Stubs::CommandStub.stub(:new).and_return(command_stub)
|
9
|
+
described_class.stub_command('echo "hello"')
|
10
|
+
|
11
|
+
expect(ChefSpec::Stubs::CommandRegistry.stubs).to include(command_stub)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#stub_search' do
|
16
|
+
let(:search_stub) { double('search') }
|
17
|
+
|
18
|
+
it 'adds the query to the search registry' do
|
19
|
+
ChefSpec::Stubs::SearchStub.stub(:new).and_return(search_stub)
|
20
|
+
described_class.stub_search(:node, '*:*')
|
21
|
+
|
22
|
+
expect(ChefSpec::Stubs::SearchRegistry.stubs).to include(search_stub)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#stub_data_bag' do
|
27
|
+
let(:data_bag_stub) { double('data_bag') }
|
28
|
+
|
29
|
+
it 'adds the query to the data_bag registry' do
|
30
|
+
ChefSpec::Stubs::DataBagStub.stub(:new).and_return(data_bag_stub)
|
31
|
+
described_class.stub_data_bag(:users)
|
32
|
+
|
33
|
+
expect(ChefSpec::Stubs::DataBagRegistry.stubs).to include(data_bag_stub)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#stub_data_bag_item' do
|
38
|
+
let(:data_bag_item_stub) { double('data_bag_item') }
|
39
|
+
|
40
|
+
it 'adds the query to the data_bag_item registry' do
|
41
|
+
ChefSpec::Stubs::DataBagItemStub.stub(:new).and_return(data_bag_item_stub)
|
42
|
+
described_class.stub_data_bag_item(:users, 'id')
|
43
|
+
|
44
|
+
expect(ChefSpec::Stubs::DataBagItemRegistry.stubs).to include(data_bag_item_stub)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#stub_node' do
|
49
|
+
it 'returns a Chef::Node' do
|
50
|
+
expect(described_class.stub_node).to be_a(Chef::Node)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'defaults the node name to `node.example`' do
|
54
|
+
node = described_class.stub_node
|
55
|
+
expect(node.name).to eq('node.example')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'sets the node name when given' do
|
59
|
+
node = described_class.stub_node('example.com')
|
60
|
+
expect(node.name).to eq('example.com')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'sets the automatic attributes' do
|
64
|
+
node = described_class.stub_node
|
65
|
+
expect(node.automatic).to eq(Fauxhai.mock.data)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'sets the automatic attributes with ohai overrides' do
|
69
|
+
node = described_class.stub_node('node.example', ohai: { ipaddress: '1.2.3.4' })
|
70
|
+
expect(node['ipaddress']).to eq('1.2.3.4')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'sets the automatic attributes for a specific platform and version' do
|
74
|
+
node = described_class.stub_node('node.example', platform: 'ubuntu', version: '12.04')
|
75
|
+
expect(node.automatic).to eq(Fauxhai.mock(platform: 'ubuntu', version: '12.04').data)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'sets the automatic attributes from a JSON data path' do
|
79
|
+
File.stub(:exists?).with('/path/to/json').and_return(true)
|
80
|
+
File.stub(:read).with('/path/to/json').and_return('{ "ipaddress": "1.2.3.4" }')
|
81
|
+
node = described_class.stub_node('node.example', path: '/path/to/json')
|
82
|
+
expect(node['ipaddress']).to eq('1.2.3.4')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'yields a block' do
|
86
|
+
expect { |block| described_class.stub_node(&block) }.to yield_with_args(Chef::Node)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'nginx::source' do
|
92
|
+
describe '#described_cookbook' do
|
93
|
+
describe 'nginx::source' do
|
94
|
+
it 'returns the name of the cookbook' do
|
95
|
+
expect(described_cookbook).to eq('nginx')
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'in a nested context' do
|
99
|
+
it 'still returns the name of the cookbook' do
|
100
|
+
expect(described_cookbook).to eq('nginx')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#described_recipe' do
|
107
|
+
describe 'nginx::source' do
|
108
|
+
it 'returns the cookbook::recipe' do
|
109
|
+
expect(described_recipe).to eq('nginx::source')
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'in a nested context' do
|
113
|
+
it 'still retrns the cookbook::recipe' do
|
114
|
+
expect(described_recipe).to eq('nginx::source')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|