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
@@ -71,9 +71,9 @@ module ChefSpec::Matchers
|
|
71
71
|
" to include :#{@expected_action}"
|
72
72
|
end
|
73
73
|
else
|
74
|
-
%Q{expected "#{@resource_name}[#{@expected_identity}]
|
75
|
-
" action :#{@expected_action} to be in Chef run.
|
76
|
-
" #{@resource_name} resources:" \
|
74
|
+
%Q{expected "#{@resource_name}[#{@expected_identity}]"} \
|
75
|
+
" with action :#{@expected_action} to be in Chef run." \
|
76
|
+
" Other #{@resource_name} resources:" \
|
77
77
|
"\n\n" \
|
78
78
|
" " + similar_resources.map(&:to_s).join("\n ") + "\n "
|
79
79
|
end
|
@@ -92,77 +92,78 @@ module ChefSpec::Matchers
|
|
92
92
|
end
|
93
93
|
|
94
94
|
private
|
95
|
-
def unmatched_parameters
|
96
|
-
return @_unmatched_parameters if @_unmatched_parameters
|
97
95
|
|
98
|
-
|
96
|
+
def unmatched_parameters
|
97
|
+
return @_unmatched_parameters if @_unmatched_parameters
|
99
98
|
|
100
|
-
|
101
|
-
unless matches_parameter?(parameter, expected)
|
102
|
-
@_unmatched_parameters[parameter] = {
|
103
|
-
expected: expected,
|
104
|
-
actual: safe_send(parameter),
|
105
|
-
}
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
@_unmatched_parameters
|
110
|
-
end
|
99
|
+
@_unmatched_parameters = {}
|
111
100
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
101
|
+
params.each do |parameter, expected|
|
102
|
+
unless matches_parameter?(parameter, expected)
|
103
|
+
@_unmatched_parameters[parameter] = {
|
104
|
+
expected: expected,
|
105
|
+
actual: safe_send(parameter),
|
106
|
+
}
|
118
107
|
end
|
119
108
|
end
|
120
109
|
|
121
|
-
|
122
|
-
|
123
|
-
resource.performed_action(@expected_action)[:compile_time]
|
124
|
-
elsif @converge_time
|
125
|
-
resource.performed_action(@expected_action)[:converge_time]
|
126
|
-
else
|
127
|
-
true
|
128
|
-
end
|
129
|
-
end
|
110
|
+
@_unmatched_parameters
|
111
|
+
end
|
130
112
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
113
|
+
def matches_parameter?(parameter, expected)
|
114
|
+
# Chef 11+ stores the source parameter internally as an Array
|
115
|
+
if parameter == :source
|
116
|
+
Array(expected) == Array(safe_send(parameter))
|
117
|
+
else
|
118
|
+
expected === safe_send(parameter)
|
135
119
|
end
|
120
|
+
end
|
136
121
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
@_similar_resources ||= @runner.find_resources(@resource_name)
|
122
|
+
def correct_phase?
|
123
|
+
if @compile_time
|
124
|
+
resource.performed_action(@expected_action)[:compile_time]
|
125
|
+
elsif @converge_time
|
126
|
+
resource.performed_action(@expected_action)[:converge_time]
|
127
|
+
else
|
128
|
+
true
|
145
129
|
end
|
130
|
+
end
|
146
131
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
#
|
153
|
-
# @return [Chef::Resource, nil]
|
154
|
-
#
|
155
|
-
def resource
|
156
|
-
@_resource ||= @runner.find_resource(@resource_name, @expected_identity)
|
157
|
-
end
|
132
|
+
def safe_send(parameter)
|
133
|
+
resource.send(parameter)
|
134
|
+
rescue NoMethodError
|
135
|
+
nil
|
136
|
+
end
|
158
137
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
138
|
+
#
|
139
|
+
# Any other resources in the Chef run that have the same resource
|
140
|
+
# type. Used by {failure_message} to be ultra helpful.
|
141
|
+
#
|
142
|
+
# @return [Array<Chef::Resource>]
|
143
|
+
#
|
144
|
+
def similar_resources
|
145
|
+
@_similar_resources ||= @runner.find_resources(@resource_name)
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
# Find the resource in the Chef run by the given class name and
|
150
|
+
# resource identity/name.
|
151
|
+
#
|
152
|
+
# @see ChefSpec::Runner#find_resource
|
153
|
+
#
|
154
|
+
# @return [Chef::Resource, nil]
|
155
|
+
#
|
156
|
+
def resource
|
157
|
+
@_resource ||= @runner.find_resource(@resource_name, @expected_identity)
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# The list of parameters passed to the {with} matcher.
|
162
|
+
#
|
163
|
+
# @return [Hash]
|
164
|
+
#
|
165
|
+
def params
|
166
|
+
@_params ||= {}
|
167
|
+
end
|
167
168
|
end
|
168
169
|
end
|
@@ -48,23 +48,24 @@ module ChefSpec::Matchers
|
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
|
-
#
|
52
|
-
# Determine if all the expected state attributes are present on the
|
53
|
-
# given resource.
|
54
|
-
#
|
55
|
-
# @return [Boolean]
|
56
|
-
#
|
57
|
-
def matches_state_attrs?
|
58
|
-
@expected_attrs == state_attrs
|
59
|
-
end
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
#
|
53
|
+
# Determine if all the expected state attributes are present on the
|
54
|
+
# given resource.
|
55
|
+
#
|
56
|
+
# @return [Boolean]
|
57
|
+
#
|
58
|
+
def matches_state_attrs?
|
59
|
+
@expected_attrs == state_attrs
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# The list of state attributes declared on the given resource.
|
64
|
+
#
|
65
|
+
# @return [Array<Symbol>]
|
66
|
+
#
|
67
|
+
def state_attrs
|
68
|
+
@resource.class.state_attrs.map(&:to_sym)
|
69
|
+
end
|
69
70
|
end
|
70
71
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ChefSpec::Matchers
|
2
|
+
class SubscribesMatcher
|
3
|
+
include ChefSpec::Normalize
|
4
|
+
|
5
|
+
def initialize(signature)
|
6
|
+
signature.match(/^([^\[]*)\[(.*)\]$/)
|
7
|
+
@expected_resource_type = $1
|
8
|
+
@expected_resource_name = $2
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches?(resource)
|
12
|
+
@instance = ChefSpec::Matchers::NotificationsMatcher.new(resource.to_s)
|
13
|
+
|
14
|
+
if @action
|
15
|
+
@instance.to(@action)
|
16
|
+
end
|
17
|
+
|
18
|
+
if @immediately
|
19
|
+
@instance.immediately
|
20
|
+
end
|
21
|
+
|
22
|
+
if @delayed
|
23
|
+
@instance.delayed
|
24
|
+
end
|
25
|
+
|
26
|
+
if resource
|
27
|
+
runner = resource.run_context.node.runner
|
28
|
+
expected = runner.find_resource(@expected_resource_type, @expected_resource_name)
|
29
|
+
|
30
|
+
@instance.matches?(expected)
|
31
|
+
else
|
32
|
+
@instance.matches?(nil)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def on(action)
|
37
|
+
@action = action
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def immediately
|
42
|
+
@immediately = true
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def delayed
|
47
|
+
@delayed = true
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def description
|
52
|
+
@instance.description
|
53
|
+
end
|
54
|
+
|
55
|
+
def failure_message_for_should
|
56
|
+
@instance.failure_message_for_should
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/chefspec/renderer.rb
CHANGED
@@ -49,96 +49,97 @@ module ChefSpec
|
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
52
|
-
#
|
53
|
-
# Compute the contents of a template using Chef's templating logic.
|
54
|
-
#
|
55
|
-
# @param [Chef::RunContext] chef_run
|
56
|
-
# the run context for the node
|
57
|
-
# @param [Chef::Provider::Template] template
|
58
|
-
# the template resource
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
#
|
62
|
-
def content_from_template(chef_run, template)
|
63
|
-
cookbook_name = template.cookbook || template.cookbook_name
|
64
|
-
template_location = cookbook_collection(chef_run.node)[cookbook_name].preferred_filename_on_disk_location(chef_run.node, :templates, template.source)
|
65
52
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
53
|
+
#
|
54
|
+
# Compute the contents of a template using Chef's templating logic.
|
55
|
+
#
|
56
|
+
# @param [Chef::RunContext] chef_run
|
57
|
+
# the run context for the node
|
58
|
+
# @param [Chef::Provider::Template] template
|
59
|
+
# the template resource
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
#
|
63
|
+
def content_from_template(chef_run, template)
|
64
|
+
cookbook_name = template.cookbook || template.cookbook_name
|
65
|
+
template_location = cookbook_collection(chef_run.node)[cookbook_name].preferred_filename_on_disk_location(chef_run.node, :templates, template.source)
|
66
|
+
|
67
|
+
if Chef::Mixin::Template.const_defined?(:TemplateContext) # Chef 11+
|
68
|
+
template_context = Chef::Mixin::Template::TemplateContext.new([])
|
69
|
+
template_context.update({
|
70
|
+
:node => chef_run.node,
|
71
|
+
:template_finder => template_finder(chef_run, cookbook_name),
|
72
|
+
}.merge(template.variables))
|
73
|
+
if template.respond_to?(:helper_modules) # Chef 11.4+
|
74
|
+
template.helper_modules.each do |helper_module|
|
75
|
+
template_context.extend(helper_module)
|
81
76
|
end
|
82
77
|
end
|
78
|
+
template_context.render_template(template_location)
|
79
|
+
else
|
80
|
+
template.provider.new(template, chef_run.run_context).send(:render_with_context, template_location) do |file|
|
81
|
+
File.read(file.path)
|
82
|
+
end
|
83
83
|
end
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
86
|
+
#
|
87
|
+
# Get the contents of a file resource.
|
88
|
+
#
|
89
|
+
# @param [Chef::RunContext] chef_run
|
90
|
+
# the run context for the node
|
91
|
+
# @param [Chef::Provider::File] file
|
92
|
+
# the file resource
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
#
|
96
|
+
def content_from_file(chef_run, file)
|
97
|
+
file.content
|
98
|
+
end
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
100
|
+
#
|
101
|
+
# Get the contents of a cookbook file using Chef.
|
102
|
+
#
|
103
|
+
# @param [Chef::RunContext] chef_run
|
104
|
+
# the run context for the node
|
105
|
+
# @param [Chef::Provider::CookbookFile] cookbook_file
|
106
|
+
# the file resource
|
107
|
+
#
|
108
|
+
def content_from_cookbook_file(chef_run, cookbook_file)
|
109
|
+
cookbook_name = cookbook_file.cookbook || cookbook_file.cookbook_name
|
110
|
+
cookbook = cookbook_collection(chef_run.node)[cookbook_name]
|
111
|
+
File.read(cookbook.preferred_filename_on_disk_location(chef_run.node, :files, cookbook_file.source, cookbook_file.path))
|
112
|
+
end
|
112
113
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
114
|
+
# The cookbook collection for the current Chef run context. Handles
|
115
|
+
# the differing cases between Chef 10 and Chef 11.
|
116
|
+
#
|
117
|
+
# @param [Chef::Node] node
|
118
|
+
# the Chef node to get the cookbook collection from
|
119
|
+
#
|
120
|
+
# @return [Array<Chef::Cookbook>]
|
121
|
+
def cookbook_collection(node)
|
122
|
+
if node.respond_to?(:run_context)
|
123
|
+
node.run_context.cookbook_collection # Chef 11+
|
124
|
+
else
|
125
|
+
node.cookbook_collection # Chef 10
|
126
126
|
end
|
127
|
+
end
|
127
128
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
129
|
+
# Return a new instance of the TemplateFinder if we are running on Chef 11.
|
130
|
+
#
|
131
|
+
# @param [Chef::RunContext] chef_run
|
132
|
+
# the run context for the noe
|
133
|
+
# @param [String] cookbook_name
|
134
|
+
# the name of the cookbook
|
135
|
+
#
|
136
|
+
# @return [Chef::Provider::TemplateFinder, nil]
|
137
|
+
def template_finder(chef_run, cookbook_name)
|
138
|
+
if Chef::Provider.const_defined?(:TemplateFinder) # Chef 11+
|
139
|
+
Chef::Provider::TemplateFinder.new(chef_run.run_context, cookbook_name, chef_run.node)
|
140
|
+
else
|
141
|
+
nil
|
142
142
|
end
|
143
|
+
end
|
143
144
|
end
|
144
145
|
end
|
data/lib/chefspec/runner.rb
CHANGED
@@ -257,66 +257,81 @@ module ChefSpec
|
|
257
257
|
end
|
258
258
|
|
259
259
|
private
|
260
|
-
#
|
261
|
-
# The inferred path from the calling spec.
|
262
|
-
#
|
263
|
-
# @param [Array<String>] kaller
|
264
|
-
# the calling trace
|
265
|
-
#
|
266
|
-
# @return [String]
|
267
|
-
#
|
268
|
-
def calling_cookbook_path(kaller)
|
269
|
-
calling_spec = kaller.find { |line| line =~ /\/spec/ }
|
270
|
-
raise Error::CookbookPathNotFound if calling_spec.nil?
|
271
|
-
|
272
|
-
bits = calling_spec.split(':', 2).first.split(File::SEPARATOR)
|
273
|
-
spec_dir = bits.index('spec') || 0
|
274
|
-
|
275
|
-
File.expand_path(File.join(bits.slice(0, spec_dir), '..'))
|
276
|
-
end
|
277
260
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
261
|
+
#
|
262
|
+
# The inferred path from the calling spec.
|
263
|
+
#
|
264
|
+
# @param [Array<String>] kaller
|
265
|
+
# the calling trace
|
266
|
+
#
|
267
|
+
# @return [String]
|
268
|
+
#
|
269
|
+
def calling_cookbook_path(kaller)
|
270
|
+
calling_spec = kaller.find { |line| line =~ /\/spec/ }
|
271
|
+
raise Error::CookbookPathNotFound if calling_spec.nil?
|
288
272
|
|
289
|
-
|
290
|
-
|
273
|
+
bits = calling_spec.split(':', 2).first.split(File::SEPARATOR)
|
274
|
+
spec_dir = bits.index('spec') || 0
|
275
|
+
|
276
|
+
File.expand_path(File.join(bits.slice(0, spec_dir), '..'))
|
277
|
+
end
|
291
278
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
@client.ohai.data = Mash.from_hash(Fauxhai.mock(options).data)
|
302
|
-
@client.load_node
|
303
|
-
@client.build_node
|
304
|
-
@client.save_updated_node
|
305
|
-
@client
|
279
|
+
#
|
280
|
+
# The inferred path to roles.
|
281
|
+
#
|
282
|
+
# @return [String, nil]
|
283
|
+
#
|
284
|
+
def default_role_path
|
285
|
+
Pathname.new(Dir.pwd).ascend do |path|
|
286
|
+
possible = File.join(path, 'roles')
|
287
|
+
return possible if File.exists?(possible)
|
306
288
|
end
|
307
289
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
290
|
+
nil
|
291
|
+
end
|
292
|
+
|
293
|
+
#
|
294
|
+
# The +Chef::Client+ for this runner.
|
295
|
+
#
|
296
|
+
# @return [Chef::Runner]
|
297
|
+
#
|
298
|
+
def client
|
299
|
+
return @client if @client
|
300
|
+
|
301
|
+
@client = Chef::Client.new
|
302
|
+
@client.ohai.data = Mash.from_hash(Fauxhai.mock(options).data)
|
303
|
+
@client.load_node
|
304
|
+
@client.build_node
|
305
|
+
@client.save_updated_node
|
306
|
+
@client
|
307
|
+
end
|
308
|
+
|
309
|
+
#
|
310
|
+
# We really need a way to just expand the run_list, but that's done by
|
311
|
+
# +Chef::Client#build_node+. However, that same method also resets the
|
312
|
+
# automatic attributes, making it impossible to mock them. So we are
|
313
|
+
# stuck +instance_eval+ing against the client and manually expanding
|
314
|
+
# the mode object.
|
315
|
+
#
|
316
|
+
# @todo Remove in Chef 13
|
317
|
+
#
|
318
|
+
def expand_run_list!
|
319
|
+
# Recent versions of Chef include a method to expand the +run_list+,
|
320
|
+
# setting the correct instance variables on the policy builder. We use
|
321
|
+
# that, unless the user is running an older version of Chef which
|
322
|
+
# doesn't include this method.
|
323
|
+
if client.respond_to?(:expanded_run_list)
|
324
|
+
client.expanded_run_list
|
325
|
+
else
|
326
|
+
# Sadly, if we got this far, it means that the current Chef version
|
327
|
+
# does not include the +expanded_run_list+ method, so we need to
|
328
|
+
# manually expand the +run_list+. The following code has been known
|
329
|
+
# to make kittens cry, so please read with extreme caution.
|
316
330
|
client.instance_eval do
|
317
331
|
@run_list_expansion = expand_run_list
|
318
332
|
@expanded_run_list_with_versions = @run_list_expansion.recipes.with_version_constraints_strings
|
319
333
|
end
|
320
334
|
end
|
335
|
+
end
|
321
336
|
end
|
322
337
|
end
|