chefspec 7.2.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +21 -13
- data/CHANGELOG.md +4 -0
- data/Gemfile +14 -10
- data/README.md +322 -1025
- data/README_old.md +1291 -0
- data/Rakefile +8 -3
- data/examples/apt_package/spec/install_spec.rb +1 -1
- data/examples/apt_package/spec/lock_spec.rb +1 -1
- data/examples/apt_package/spec/purge_spec.rb +1 -1
- data/examples/apt_package/spec/reconfig_spec.rb +1 -1
- data/examples/apt_package/spec/remove_spec.rb +1 -1
- data/examples/apt_package/spec/unlock_spec.rb +1 -1
- data/examples/apt_package/spec/upgrade_spec.rb +1 -1
- data/examples/apt_repository/spec/add_spec.rb +1 -1
- data/examples/apt_repository/spec/remove_spec.rb +1 -1
- data/examples/apt_update/spec/periodic_spec.rb +1 -1
- data/examples/apt_update/spec/update_spec.rb +1 -1
- data/examples/attributes/spec/default_spec.rb +1 -1
- data/examples/batch/spec/run_spec.rb +1 -1
- data/examples/cab_package/spec/install_spec.rb +1 -1
- data/examples/cab_package/spec/remove_spec.rb +1 -1
- data/examples/cached/spec/default_spec.rb +1 -1
- data/examples/chef_gem/spec/install_spec.rb +1 -1
- data/examples/chef_gem/spec/purge_spec.rb +1 -1
- data/examples/chef_gem/spec/reconfig_spec.rb +1 -1
- data/examples/chef_gem/spec/remove_spec.rb +1 -1
- data/examples/chef_gem/spec/upgrade_spec.rb +1 -1
- data/examples/chocolatey_package/spec/install_spec.rb +1 -1
- data/examples/chocolatey_package/spec/remove_spec.rb +1 -1
- data/examples/chocolatey_package/spec/upgrade_spec.rb +1 -1
- data/examples/compile_time/spec/default_spec.rb +1 -1
- data/examples/cookbook_file/spec/create_if_missing_spec.rb +1 -1
- data/examples/cookbook_file/spec/create_spec.rb +1 -1
- data/examples/cookbook_file/spec/delete_spec.rb +1 -1
- data/examples/cookbook_file/spec/touch_spec.rb +1 -1
- data/examples/core/recipes/default.rb +1 -0
- data/examples/core/spec/default_spec.rb +7 -0
- data/examples/core/spec/non_recipe_spec.rb +5 -0
- data/examples/cron/spec/create_spec.rb +1 -1
- data/examples/cron/spec/delete_spec.rb +1 -1
- data/examples/custom_matcher/spec/install_spec.rb +1 -1
- data/examples/custom_matcher/spec/remove_spec.rb +1 -1
- data/examples/custom_resource/spec/default_spec.rb +1 -1
- data/examples/custom_resource_block/resources/default.rb +3 -0
- data/examples/custom_resource_block/spec/default_spec.rb +10 -0
- data/examples/directory/spec/create_spec.rb +1 -1
- data/examples/directory/spec/delete_spec.rb +1 -1
- data/examples/dnf_package/spec/install_spec.rb +1 -1
- data/examples/dnf_package/spec/purge_spec.rb +1 -1
- data/examples/dnf_package/spec/remove_spec.rb +1 -1
- data/examples/dnf_package/spec/upgrade_spec.rb +1 -1
- data/examples/do_nothing/spec/default_spec.rb +1 -1
- data/examples/dpkg_package/spec/install_spec.rb +1 -1
- data/examples/dpkg_package/spec/purge_spec.rb +1 -1
- data/examples/dpkg_package/spec/remove_spec.rb +1 -1
- data/examples/dsc_resource/spec/run_spec.rb +1 -1
- data/examples/dsc_script/spec/run_spec.rb +1 -1
- data/examples/env/spec/create_spec.rb +1 -1
- data/examples/env/spec/delete_spec.rb +1 -1
- data/examples/env/spec/modify_spec.rb +1 -1
- data/examples/execute/spec/run_spec.rb +1 -1
- data/examples/expect_exception/spec/compile_error_spec.rb +1 -1
- data/examples/expect_exception/spec/converge_error_spec.rb +1 -1
- data/examples/expect_exception/spec/no_error_spec.rb +1 -1
- data/examples/file/spec/create_if_missing_spec.rb +1 -1
- data/examples/file/spec/create_spec.rb +1 -1
- data/examples/file/spec/delete_spec.rb +1 -1
- data/examples/file/spec/touch_spec.rb +1 -1
- data/examples/freebsd_package/spec/install_spec.rb +1 -1
- data/examples/freebsd_package/spec/remove_spec.rb +1 -1
- data/examples/gem_package/spec/install_spec.rb +1 -1
- data/examples/gem_package/spec/purge_spec.rb +1 -1
- data/examples/gem_package/spec/reconfig_spec.rb +1 -1
- data/examples/gem_package/spec/remove_spec.rb +1 -1
- data/examples/gem_package/spec/upgrade_spec.rb +1 -1
- data/examples/git/spec/checkout_spec.rb +1 -1
- data/examples/git/spec/export_spec.rb +1 -1
- data/examples/git/spec/sync_spec.rb +1 -1
- data/examples/group/spec/create_spec.rb +1 -1
- data/examples/group/spec/manage_spec.rb +1 -1
- data/examples/group/spec/modify_spec.rb +1 -1
- data/examples/group/spec/remove_spec.rb +1 -1
- data/examples/guards/spec/default_spec.rb +1 -1
- data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -1
- data/examples/homebrew_package/spec/install_spec.rb +1 -1
- data/examples/homebrew_package/spec/purge_spec.rb +1 -1
- data/examples/homebrew_package/spec/remove_spec.rb +1 -1
- data/examples/homebrew_package/spec/upgrade_spec.rb +1 -1
- data/examples/http_request/spec/delete_spec.rb +1 -1
- data/examples/http_request/spec/get_spec.rb +1 -1
- data/examples/http_request/spec/head_spec.rb +1 -1
- data/examples/http_request/spec/options_spec.rb +1 -1
- data/examples/http_request/spec/post_spec.rb +1 -1
- data/examples/http_request/spec/put_spec.rb +1 -1
- data/examples/ifconfig/spec/add_spec.rb +1 -1
- data/examples/ifconfig/spec/delete_spec.rb +1 -1
- data/examples/ifconfig/spec/disable_spec.rb +1 -1
- data/examples/ifconfig/spec/enable_spec.rb +1 -1
- data/examples/include_recipe/spec/default_spec.rb +1 -1
- data/examples/ips_package/spec/install_spec.rb +1 -1
- data/examples/ips_package/spec/remove_spec.rb +1 -1
- data/examples/ips_package/spec/upgrade_spec.rb +1 -1
- data/examples/launchd/spec/create_if_missing_spec.rb +1 -1
- data/examples/launchd/spec/create_spec.rb +1 -1
- data/examples/launchd/spec/delete_spec.rb +1 -1
- data/examples/launchd/spec/disable_spec.rb +1 -1
- data/examples/launchd/spec/enable_spec.rb +1 -1
- data/examples/library_patch/libraries/default.rb +5 -0
- data/examples/library_patch/recipes/default.rb +1 -0
- data/examples/library_patch/spec/default_spec.rb +14 -0
- data/examples/link/spec/create_spec.rb +1 -1
- data/examples/link/spec/delete_spec.rb +1 -1
- data/examples/link/spec/link_to_spec.rb +1 -1
- data/examples/log/spec/write_spec.rb +1 -1
- data/examples/macports_package/spec/install_spec.rb +1 -1
- data/examples/macports_package/spec/purge_spec.rb +1 -1
- data/examples/macports_package/spec/remove_spec.rb +1 -1
- data/examples/macports_package/spec/upgrade_spec.rb +1 -1
- data/examples/mdadm/spec/assemble_spec.rb +1 -1
- data/examples/mdadm/spec/create_spec.rb +1 -1
- data/examples/mdadm/spec/stop_spec.rb +1 -1
- data/examples/mount/spec/disable_spec.rb +1 -1
- data/examples/mount/spec/enable_spec.rb +1 -1
- data/examples/mount/spec/mount_spec.rb +1 -1
- data/examples/mount/spec/remount_spec.rb +1 -1
- data/examples/mount/spec/umount_spec.rb +1 -1
- data/examples/msu_package/spec/install_spec.rb +1 -1
- data/examples/msu_package/spec/remove_spec.rb +1 -1
- data/examples/multiple_actions/spec/default_spec.rb +1 -1
- data/examples/multiple_actions/spec/reversed_spec.rb +1 -1
- data/examples/multiple_actions/spec/sequential_spec.rb +1 -1
- data/examples/multiple_run_action/spec/default_spec.rb +1 -1
- data/examples/nothing_matcher/spec/default_spec.rb +1 -1
- data/examples/notifications/spec/before_spec.rb +1 -1
- data/examples/notifications/spec/chained_spec.rb +1 -1
- data/examples/notifications/spec/default_spec.rb +1 -1
- data/examples/notifications/spec/delayed_spec.rb +1 -1
- data/examples/notifications/spec/immediately_spec.rb +1 -1
- data/examples/ohai/spec/reload_spec.rb +1 -1
- data/examples/osx_profile/spec/install_spec.rb +1 -1
- data/examples/osx_profile/spec/remove_spec.rb +1 -1
- data/examples/package/spec/install_spec.rb +1 -1
- data/examples/package/spec/lock_spec.rb +1 -1
- data/examples/package/spec/purge_spec.rb +1 -1
- data/examples/package/spec/reconfig_spec.rb +1 -1
- data/examples/package/spec/remove_spec.rb +1 -1
- data/examples/package/spec/unlock_spec.rb +1 -1
- data/examples/package/spec/upgrade_spec.rb +1 -1
- data/examples/pacman_package/spec/install_spec.rb +1 -1
- data/examples/pacman_package/spec/purge_spec.rb +1 -1
- data/examples/pacman_package/spec/remove_spec.rb +1 -1
- data/examples/pacman_package/spec/upgrade_spec.rb +1 -1
- data/examples/paludis_package/spec/install_spec.rb +1 -1
- data/examples/paludis_package/spec/purge_spec.rb +1 -1
- data/examples/paludis_package/spec/remove_spec.rb +1 -1
- data/examples/paludis_package/spec/upgrade_spec.rb +1 -1
- data/examples/portage_package/spec/install_spec.rb +1 -1
- data/examples/portage_package/spec/purge_spec.rb +1 -1
- data/examples/portage_package/spec/remove_spec.rb +1 -1
- data/examples/portage_package/spec/upgrade_spec.rb +1 -1
- data/examples/powershell_script/spec/run_spec.rb +1 -1
- data/examples/reboot/spec/cancel_spec.rb +1 -1
- data/examples/reboot/spec/now_spec.rb +1 -1
- data/examples/reboot/spec/request_spec.rb +1 -1
- data/examples/recipe_block/metadata.rb +1 -0
- data/examples/recipe_block/spec/recipe_block_spec.rb +34 -0
- data/examples/recipe_block/templates/apache2.conf.erb +1 -0
- data/examples/registry_key/spec/create_if_missing_spec.rb +1 -1
- data/examples/registry_key/spec/create_spec.rb +1 -1
- data/examples/registry_key/spec/delete_key_spec.rb +1 -1
- data/examples/registry_key/spec/delete_spec.rb +1 -1
- data/examples/remote_directory/spec/create_if_missing_spec.rb +1 -1
- data/examples/remote_directory/spec/create_spec.rb +1 -1
- data/examples/remote_directory/spec/delete_spec.rb +1 -1
- data/examples/remote_file/spec/create_if_missing_spec.rb +1 -1
- data/examples/remote_file/spec/create_spec.rb +1 -1
- data/examples/remote_file/spec/delete_spec.rb +1 -1
- data/examples/remote_file/spec/touch_spec.rb +1 -1
- data/examples/render_file/spec/default_spec.rb +12 -1
- data/examples/render_file/spec/template_helpers_spec.rb +1 -1
- data/examples/roles/spec/default_spec.rb +1 -1
- data/examples/route/spec/add_spec.rb +1 -1
- data/examples/route/spec/delete_spec.rb +1 -1
- data/examples/rpm_package/spec/install_spec.rb +1 -1
- data/examples/rpm_package/spec/remove_spec.rb +1 -1
- data/examples/rpm_package/spec/upgrade_spec.rb +1 -1
- data/examples/ruby_block/spec/create_spec.rb +1 -1
- data/examples/ruby_block/spec/run_spec.rb +1 -1
- data/examples/runner/recipes/default.rb +1 -0
- data/examples/runner/spec/default_spec.rb +11 -0
- data/examples/script/spec/run_bash_spec.rb +1 -1
- data/examples/script/spec/run_csh_spec.rb +1 -1
- data/examples/script/spec/run_ksh_spec.rb +1 -1
- data/examples/script/spec/run_perl_spec.rb +1 -1
- data/examples/script/spec/run_python_spec.rb +1 -1
- data/examples/script/spec/run_ruby_spec.rb +1 -1
- data/examples/script/spec/run_script_spec.rb +1 -1
- data/examples/server/spec/client_spec.rb +1 -1
- data/examples/server/spec/data_bag_spec.rb +1 -1
- data/examples/server/spec/environment_spec.rb +1 -1
- data/examples/server/spec/exotic_port_spec.rb +1 -1
- data/examples/server/spec/node_spec.rb +4 -4
- data/examples/server/spec/render_with_cached_spec.rb +1 -1
- data/examples/server/spec/role_spec.rb +1 -1
- data/examples/server/spec/search_spec.rb +1 -1
- data/examples/service/spec/disable_spec.rb +1 -1
- data/examples/service/spec/enable_spec.rb +1 -1
- data/examples/service/spec/reload_spec.rb +1 -1
- data/examples/service/spec/restart_spec.rb +1 -1
- data/examples/service/spec/start_spec.rb +1 -1
- data/examples/service/spec/stop_spec.rb +1 -1
- data/examples/smartos_package/spec/install_spec.rb +1 -1
- data/examples/smartos_package/spec/remove_spec.rb +1 -1
- data/examples/smartos_package/spec/upgrade_spec.rb +1 -1
- data/examples/solaris_package/spec/install_spec.rb +1 -1
- data/examples/solaris_package/spec/remove_spec.rb +1 -1
- data/examples/solaris_package/spec/upgrade_spec.rb +1 -1
- data/examples/spec_attributes/attributes/default.rb +1 -0
- data/examples/spec_attributes/recipes/default.rb +5 -0
- data/examples/spec_attributes/spec/default_spec.rb +54 -0
- data/examples/spec_platform/recipes/default.rb +3 -0
- data/examples/spec_platform/spec/default_spec.rb +36 -0
- data/examples/spec_step_into/recipes/default.rb +3 -0
- data/examples/spec_step_into/resources/one.rb +3 -0
- data/examples/spec_step_into/resources/two.rb +3 -0
- data/examples/spec_step_into/spec/default_spec.rb +50 -0
- data/examples/state_attrs/spec/default_spec.rb +1 -1
- data/examples/step_into/spec/default_spec.rb +2 -2
- data/examples/stub_command/spec/default_spec.rb +1 -1
- data/examples/stub_data_bag/spec/default_spec.rb +1 -1
- data/examples/stub_data_bag_item/spec/default_spec.rb +1 -1
- data/examples/stub_node/spec/default_spec.rb +1 -1
- data/examples/stub_search/spec/block_spec.rb +1 -1
- data/examples/stub_search/spec/default_spec.rb +1 -1
- data/examples/stubs_for/resources/default.rb +20 -0
- data/examples/stubs_for/resources/old.rb +26 -0
- data/examples/stubs_for/spec/default_spec.rb +240 -0
- data/examples/subscribes/spec/before_spec.rb +1 -1
- data/examples/subscribes/spec/chained_spec.rb +1 -1
- data/examples/subscribes/spec/default_spec.rb +1 -1
- data/examples/subscribes/spec/delayed_spec.rb +1 -1
- data/examples/subscribes/spec/immediately_spec.rb +1 -1
- data/examples/subversion/spec/checkout_spec.rb +1 -1
- data/examples/subversion/spec/export_spec.rb +1 -1
- data/examples/subversion/spec/force_export_spec.rb +1 -1
- data/examples/subversion/spec/sync_spec.rb +1 -1
- data/examples/systemd_unit/spec/create_spec.rb +1 -1
- data/examples/systemd_unit/spec/delete_spec.rb +1 -1
- data/examples/systemd_unit/spec/disable_spec.rb +1 -1
- data/examples/systemd_unit/spec/enable_spec.rb +1 -1
- data/examples/systemd_unit/spec/mask_spec.rb +1 -1
- data/examples/systemd_unit/spec/reload_or_restart_spec.rb +1 -1
- data/examples/systemd_unit/spec/reload_or_try_restart_spec.rb +1 -1
- data/examples/systemd_unit/spec/restart_spec.rb +1 -1
- data/examples/systemd_unit/spec/start_spec.rb +1 -1
- data/examples/systemd_unit/spec/stop_spec.rb +1 -1
- data/examples/systemd_unit/spec/try_restart_spec.rb +1 -1
- data/examples/systemd_unit/spec/unmask_spec.rb +1 -1
- data/examples/template/spec/create_if_missing_spec.rb +1 -1
- data/examples/template/spec/create_spec.rb +1 -1
- data/examples/template/spec/delete_spec.rb +1 -1
- data/examples/template/spec/touch_spec.rb +1 -1
- data/examples/use_inline_resources/spec/default_spec.rb +1 -1
- data/examples/user/spec/create_spec.rb +1 -1
- data/examples/user/spec/lock_spec.rb +1 -1
- data/examples/user/spec/manage_spec.rb +1 -1
- data/examples/user/spec/modify_spec.rb +1 -1
- data/examples/user/spec/remove_spec.rb +1 -1
- data/examples/user/spec/unlock_spec.rb +1 -1
- data/examples/windows_package/spec/install_spec.rb +1 -1
- data/examples/windows_package/spec/remove_spec.rb +1 -1
- data/examples/windows_service/spec/configure_startup_spec.rb +1 -1
- data/examples/windows_service/spec/disable_spec.rb +1 -1
- data/examples/windows_service/spec/enable_spec.rb +1 -1
- data/examples/windows_service/spec/reload_spec.rb +1 -1
- data/examples/windows_service/spec/restart_spec.rb +1 -1
- data/examples/windows_service/spec/start_spec.rb +1 -1
- data/examples/windows_service/spec/stop_spec.rb +1 -1
- data/examples/yum_package/spec/install_spec.rb +1 -1
- data/examples/yum_package/spec/lock_spec.rb +1 -1
- data/examples/yum_package/spec/purge_spec.rb +1 -1
- data/examples/yum_package/spec/remove_spec.rb +1 -1
- data/examples/yum_package/spec/unlock_spec.rb +1 -1
- data/examples/yum_package/spec/upgrade_spec.rb +1 -1
- data/examples/yum_repository/spec/add_spec.rb +1 -1
- data/examples/yum_repository/spec/create_spec.rb +1 -1
- data/examples/yum_repository/spec/delete_spec.rb +1 -1
- data/examples/yum_repository/spec/makecache_spec.rb +1 -1
- data/examples/yum_repository/spec/remove_spec.rb +1 -1
- data/examples/zypper_package/spec/install_spec.rb +1 -1
- data/examples/zypper_package/spec/lock_spec.rb +1 -1
- data/examples/zypper_package/spec/purge_spec.rb +1 -1
- data/examples/zypper_package/spec/remove_spec.rb +1 -1
- data/examples/zypper_package/spec/unlock_spec.rb +1 -1
- data/examples/zypper_package/spec/upgrade_spec.rb +1 -1
- data/lib/chefspec.rb +1 -1
- data/lib/chefspec/api.rb +33 -14
- data/lib/chefspec/api/core.rb +195 -0
- data/lib/chefspec/api/described.rb +55 -0
- data/lib/chefspec/api/do_nothing.rb +24 -19
- data/lib/chefspec/api/include_recipe.rb +26 -21
- data/lib/chefspec/api/link.rb +26 -21
- data/lib/chefspec/api/notifications.rb +38 -33
- data/lib/chefspec/api/reboot.rb +11 -6
- data/lib/chefspec/api/render_file.rb +35 -30
- data/lib/chefspec/api/state_attrs.rb +28 -23
- data/lib/chefspec/api/stubs.rb +183 -0
- data/lib/chefspec/api/stubs_for.rb +134 -0
- data/lib/chefspec/api/subscriptions.rb +35 -30
- data/lib/chefspec/api/user.rb +222 -217
- data/lib/chefspec/berkshelf.rb +1 -1
- data/lib/chefspec/deprecations.rb +2 -11
- data/lib/chefspec/errors.rb +1 -0
- data/lib/chefspec/extensions.rb +4 -1
- data/lib/chefspec/extensions/chef/client.rb +3 -4
- data/lib/chefspec/extensions/chef/conditional.rb +3 -2
- data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +25 -28
- data/lib/chefspec/extensions/chef/cookbook_loader.rb +13 -0
- data/lib/chefspec/extensions/chef/cookbook_uploader.rb +3 -2
- data/lib/chefspec/extensions/chef/data_query.rb +5 -8
- data/lib/chefspec/extensions/chef/lwrp_base.rb +17 -21
- data/lib/chefspec/extensions/chef/provider.rb +36 -0
- data/lib/chefspec/extensions/chef/resource.rb +51 -4
- data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +13 -16
- data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +64 -0
- data/lib/chefspec/matchers/render_file_matcher.rb +36 -26
- data/lib/chefspec/matchers/resource_matcher.rb +1 -1
- data/lib/chefspec/rspec.rb +3 -8
- data/lib/chefspec/runner.rb +8 -0
- data/lib/chefspec/server_methods.rb +1 -1
- data/lib/chefspec/server_runner.rb +13 -9
- data/lib/chefspec/solo_runner.rb +136 -32
- data/lib/chefspec/version.rb +1 -1
- data/spec/unit/deprecations_spec.rb +1 -26
- data/spec/unit/macros_spec.rb +14 -14
- data/spec/unit/matchers/render_file_matcher_spec.rb +8 -1
- data/spec/unit/solo_runner_spec.rb +3 -3
- data/templates/errors/may_need_to_specify_platform.erb +1 -1
- data/templates/errors/shell_out_not_stubbed.erb +10 -0
- metadata +38 -4
- data/lib/chefspec/macros.rb +0 -222
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module IncludeRecipe
|
|
4
|
+
#
|
|
5
|
+
# Assert that a Chef run includes a certain recipe. Given a Chef Recipe
|
|
6
|
+
# that calls +include_recipe+:
|
|
7
|
+
#
|
|
8
|
+
# include_recipe 'apache2::default'
|
|
9
|
+
#
|
|
10
|
+
# The Examples section demonstrates the different ways to test an
|
|
11
|
+
# +include_recipe+ directive with ChefSpec.
|
|
12
|
+
#
|
|
13
|
+
# @example Assert the +apache2::default+ recipe is included in the Chef run
|
|
14
|
+
# expect(chef_run).to include_recipe('apache2::default')
|
|
15
|
+
#
|
|
16
|
+
#
|
|
17
|
+
# @param [String] recipe_name
|
|
18
|
+
# the name of the recipe to be included
|
|
19
|
+
#
|
|
20
|
+
# @return [ChefSpec::Matchers::IncludeRecipeMatcher]
|
|
21
|
+
#
|
|
22
|
+
def include_recipe(recipe_name)
|
|
23
|
+
ChefSpec::Matchers::IncludeRecipeMatcher.new(recipe_name)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
22
27
|
end
|
|
23
28
|
end
|
data/lib/chefspec/api/link.rb
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module Link
|
|
4
|
+
#
|
|
5
|
+
# Assert that a symlink links to a specific path. This is really
|
|
6
|
+
# syntactic sugar for the following:
|
|
7
|
+
#
|
|
8
|
+
# expect(chef_run).to create_link('/tmp/thing').with(to: '/tmp/other_thing')
|
|
9
|
+
#
|
|
10
|
+
# @example Using +link_to+ with a String path
|
|
11
|
+
# link = chef_run.link('/tmp/thing')
|
|
12
|
+
# expect(link).to link_to('/tmp/other_thing')
|
|
13
|
+
#
|
|
14
|
+
# @example Using +link_to+ with a regular expression
|
|
15
|
+
# expect(link).to link_to(/\/tmp/(.+)/)
|
|
16
|
+
#
|
|
17
|
+
# @param [String, Regex] path
|
|
18
|
+
# the path to link to
|
|
19
|
+
#
|
|
20
|
+
# @return [ChefSpec::Matchers::LinkToMatcher]
|
|
21
|
+
#
|
|
22
|
+
def link_to(path)
|
|
23
|
+
ChefSpec::Matchers::LinkToMatcher.new(path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
22
27
|
end
|
|
23
28
|
end
|
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module Notifications
|
|
4
|
+
#
|
|
5
|
+
# Assert that a resource notifies another. Given a Chef Recipe that
|
|
6
|
+
# notifies a template resource to restart apache:
|
|
7
|
+
#
|
|
8
|
+
# template '/etc/apache2/config' do
|
|
9
|
+
# notifies :restart, 'service[apache2]'
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# The Examples section demonstrates the different ways to test an
|
|
13
|
+
# notifications on a resource with ChefSpec.
|
|
14
|
+
#
|
|
15
|
+
# @example Assert the template notifies apache of something
|
|
16
|
+
# template = chef_run.template('/etc/apache2.conf')
|
|
17
|
+
# expect(template).to notify('service[apache2]')
|
|
18
|
+
#
|
|
19
|
+
# @example Assert the template notifies apache to restart
|
|
20
|
+
# expect(template).to notify('service[apache2]').to(:restart)
|
|
21
|
+
#
|
|
22
|
+
# @example Assert the template notifies apache to restart immediately
|
|
23
|
+
# expect(template).to notify('service[apache2]').to(:restart).immediately
|
|
24
|
+
#
|
|
25
|
+
# @example Assert the template notifies apache to restart delayed
|
|
26
|
+
# expect(template).to notify('service[apache2]').to(:restart).delayed
|
|
27
|
+
#
|
|
28
|
+
#
|
|
29
|
+
# @param [String] signature
|
|
30
|
+
# the signature of the notification to match
|
|
31
|
+
#
|
|
32
|
+
# @return [ChefSpec::Matchers::NotificationsMatcher]
|
|
33
|
+
#
|
|
34
|
+
def notify(signature)
|
|
35
|
+
ChefSpec::Matchers::NotificationsMatcher.new(signature)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
34
39
|
end
|
|
35
40
|
end
|
data/lib/chefspec/api/reboot.rb
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module Reboot
|
|
4
|
+
def now_reboot(resource_name)
|
|
5
|
+
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :reboot_now, resource_name)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def request_reboot(resource_name)
|
|
9
|
+
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :request_reboot, resource_name)
|
|
10
|
+
end
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :request_reboot, resource_name)
|
|
12
|
+
end
|
|
8
13
|
end
|
|
9
14
|
end
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module RenderFile
|
|
4
|
+
#
|
|
5
|
+
# Assert that a file is rendered by the Chef run. This matcher works for
|
|
6
|
+
# +template+, +file+, and +cookbook_file+ resources. The content from the
|
|
7
|
+
# resource must be convertable to a string; verifying the content of a
|
|
8
|
+
# binary file is not permissible at this time.
|
|
9
|
+
#
|
|
10
|
+
# @example Assert a template is rendered
|
|
11
|
+
# expect(chef_run).to render_file('/etc/foo')
|
|
12
|
+
#
|
|
13
|
+
# @example Assert a template is rendered with certain content
|
|
14
|
+
# expect(template).to render_file('/etc/foo').with_content('This is a file')
|
|
15
|
+
#
|
|
16
|
+
# @example Assert a template is rendered with matching content
|
|
17
|
+
# expect(template).to render_file('/etc/foo').with_content(/^This(.+)$/)
|
|
18
|
+
#
|
|
19
|
+
# @example Assert a template is rendered with content matching any RSpec matcher
|
|
20
|
+
# expect(template).to render_file('/etc/foo').with_content(starts_with('This'))
|
|
21
|
+
#
|
|
22
|
+
# @example Assert a partial path to a template is rendered with matching content
|
|
23
|
+
# expect(template).to render_file(/\/etc\/foo-(\d+)$/).with_content(/^This(.+)$/)
|
|
24
|
+
#
|
|
25
|
+
#
|
|
26
|
+
# @param [String] path
|
|
27
|
+
# the path of the file to render
|
|
28
|
+
#
|
|
29
|
+
# @return [ChefSpec::Matchers::RenderFileMatcher]
|
|
30
|
+
#
|
|
31
|
+
def render_file(path)
|
|
32
|
+
ChefSpec::Matchers::RenderFileMatcher.new(path)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
module ChefSpec
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module StateAttrs
|
|
4
|
+
#
|
|
5
|
+
# Assert that a Chef resource has certain state attributes (since Chef
|
|
6
|
+
# 11.8.0):
|
|
7
|
+
#
|
|
8
|
+
# state_attrs :time, :temperature
|
|
9
|
+
#
|
|
10
|
+
# @see https://github.com/opscode/chef/blob/e43d7ebda/lib/chef/resource/file.rb#L32-L37
|
|
11
|
+
#
|
|
12
|
+
# The Examples section demonstrates the different ways to test a
|
|
13
|
+
# resource's +state_attrs+ with ChefSpec.
|
|
14
|
+
#
|
|
15
|
+
# @example Assert the +lwrp+ resource has two state attributes
|
|
16
|
+
# expect(lwrp).to have_state_attrs(:time, :temperature)
|
|
17
|
+
#
|
|
18
|
+
#
|
|
19
|
+
# @param [Array] state_attrs
|
|
20
|
+
# the list of state attributes to assert
|
|
21
|
+
#
|
|
22
|
+
# @return [ChefSpec::Matchers::StateAttrsMatcher]
|
|
23
|
+
#
|
|
24
|
+
def have_state_attrs(*state_attrs)
|
|
25
|
+
ChefSpec::Matchers::StateAttrsMatcher.new(state_attrs)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
24
29
|
end
|
|
25
30
|
end
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
module ChefSpec
|
|
2
|
+
module API
|
|
3
|
+
module Stubs
|
|
4
|
+
#
|
|
5
|
+
# Stub a shell command to return a particular value without
|
|
6
|
+
# shelling out to the system.
|
|
7
|
+
#
|
|
8
|
+
# @example stubbing a command to return true
|
|
9
|
+
# stub_command('test -f /tmp/bacon').and_return(true)
|
|
10
|
+
#
|
|
11
|
+
# @example stubbing a block that is evaluated at runtime
|
|
12
|
+
# stub_command('test -f /tmp/bacon') { MyClass.check? }
|
|
13
|
+
#
|
|
14
|
+
# @example stubbing a command that matches a pattern
|
|
15
|
+
# stub_command(/test \-f/).and_return(true)
|
|
16
|
+
#
|
|
17
|
+
# @example stubbing a command that raises an exception
|
|
18
|
+
# stub_command('test -f /tmp/bacon').and_raise(SomeException)
|
|
19
|
+
#
|
|
20
|
+
#
|
|
21
|
+
# @param [String, Regexp] command
|
|
22
|
+
# the command to stub
|
|
23
|
+
#
|
|
24
|
+
# @return [ChefSpec::CommandStub]
|
|
25
|
+
#
|
|
26
|
+
def stub_command(command, &block)
|
|
27
|
+
ChefSpec::Stubs::CommandRegistry.register(ChefSpec::Stubs::CommandStub.new(command, &block))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Stub a Chef call to load a data_bag.
|
|
32
|
+
#
|
|
33
|
+
# @example stubbing a data_bag to return an empty Array
|
|
34
|
+
# stub_data_bag('users').and_return([])
|
|
35
|
+
#
|
|
36
|
+
# @example stubbing a data_bag with a block that is evaluated at runtime
|
|
37
|
+
# stub_data_bag('users') { JSON.parse(File.read('fixtures/data_bag.json')) }
|
|
38
|
+
#
|
|
39
|
+
# @example stubbing a data_bag to return an Array of Hashes
|
|
40
|
+
# stub_data_bag('users').and_return([
|
|
41
|
+
# { id: 'bacon', comment: 'delicious' },
|
|
42
|
+
# { id: 'ham', comment: 'also good' }
|
|
43
|
+
# ])
|
|
44
|
+
#
|
|
45
|
+
# @example stubbing a data_bag to raise an exception
|
|
46
|
+
# stub_data_bag('users').and_raise(Chef::Exceptions::PrivateKeyMissing)
|
|
47
|
+
#
|
|
48
|
+
#
|
|
49
|
+
# @param [String, Symbol] bag
|
|
50
|
+
# the name of the data bag to stub
|
|
51
|
+
#
|
|
52
|
+
# @return [ChefSpec::DataBagStub]
|
|
53
|
+
#
|
|
54
|
+
def stub_data_bag(bag, &block)
|
|
55
|
+
ChefSpec::Stubs::DataBagRegistry.register(ChefSpec::Stubs::DataBagStub.new(bag, &block))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# Stub a Chef data_bag call.
|
|
60
|
+
#
|
|
61
|
+
# @example stubbing a data_bag_item to return a Hash of data
|
|
62
|
+
# stub_data_bag_item('users', 'svargo').and_return({
|
|
63
|
+
# id: 'svargo',
|
|
64
|
+
# name: 'Seth Vargo'
|
|
65
|
+
# })
|
|
66
|
+
#
|
|
67
|
+
# @example stubbing a data_bag_item with a block that is evaluated at runtime
|
|
68
|
+
# stub_data_bag_item('users', 'svargo') { JSON.parse(File.read('fixtures/data_bag_item.json')) }
|
|
69
|
+
#
|
|
70
|
+
# @example stubbing a data_bag_item to raise an exception
|
|
71
|
+
# stub_data_bag('users', 'svargo').and_raise(Chef::Exceptions::PrivateKeyMissing)
|
|
72
|
+
#
|
|
73
|
+
#
|
|
74
|
+
# @param [String, Symbol] bag
|
|
75
|
+
# the name of the data bag to find the item in
|
|
76
|
+
# @param [String] id
|
|
77
|
+
# the id of the data bag item to stub
|
|
78
|
+
#
|
|
79
|
+
# @return [ChefSpec::DataBagItemStub]
|
|
80
|
+
#
|
|
81
|
+
def stub_data_bag_item(bag, id, &block)
|
|
82
|
+
ChefSpec::Stubs::DataBagItemRegistry.register(ChefSpec::Stubs::DataBagItemStub.new(bag, id, &block))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Creates a fake Chef::Node for use in testing.
|
|
87
|
+
#
|
|
88
|
+
# @example mocking a simple node
|
|
89
|
+
# stub_node('mynode.example')
|
|
90
|
+
#
|
|
91
|
+
# @example mocking a specific platform and version
|
|
92
|
+
# stub_node('mynode.example', platform: 'ubuntu', version: '18.04')
|
|
93
|
+
#
|
|
94
|
+
# @example overriding a specific ohai attribute
|
|
95
|
+
# stub_node('mynode.example', ohai: { ipaddress: '1.2.3.4' })
|
|
96
|
+
#
|
|
97
|
+
# @example stubbing a node based on a JSON fixture
|
|
98
|
+
# stub_node('mynode.example', path: File.join('fixtures', 'nodes', 'default.json'))
|
|
99
|
+
#
|
|
100
|
+
# @example setting specific attributes
|
|
101
|
+
# stub_node('mynode.example') do |node|
|
|
102
|
+
# node.default['attribute']['thing'] = 'value'
|
|
103
|
+
# end
|
|
104
|
+
#
|
|
105
|
+
#
|
|
106
|
+
# @param [String] name
|
|
107
|
+
# the name of the node
|
|
108
|
+
# @param [Hash] options
|
|
109
|
+
# the list of options for the node
|
|
110
|
+
#
|
|
111
|
+
# @option options [Symbol] :platform
|
|
112
|
+
# the platform to mock
|
|
113
|
+
# @option options [Symbol] :version
|
|
114
|
+
# the version of the platform to mock
|
|
115
|
+
# @option options [Symbol] :path
|
|
116
|
+
# filepath to a JSON file to pull a node from
|
|
117
|
+
# @option options [Hash] :ohai
|
|
118
|
+
# a Hash of Ohai attributes to mock on the node
|
|
119
|
+
#
|
|
120
|
+
# @return [Chef::Node]
|
|
121
|
+
#
|
|
122
|
+
def stub_node(*args, &block)
|
|
123
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
124
|
+
name = args.first || 'node.example'
|
|
125
|
+
|
|
126
|
+
fauxhai = Fauxhai.mock(options).data
|
|
127
|
+
fauxhai = fauxhai.merge(options[:ohai] || {})
|
|
128
|
+
fauxhai = Mash.new(fauxhai)
|
|
129
|
+
|
|
130
|
+
node = Chef::Node.new
|
|
131
|
+
node.name(name)
|
|
132
|
+
node.automatic_attrs = fauxhai
|
|
133
|
+
node.instance_eval(&block) if block_given?
|
|
134
|
+
node
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
#
|
|
138
|
+
# Stub a Chef search to return pre-defined data. When providing a value,
|
|
139
|
+
# the value is automatically mashified (to the best of ChefSpec's abilities)
|
|
140
|
+
# to ease in use.
|
|
141
|
+
#
|
|
142
|
+
# @example stubbing a search to return nothing
|
|
143
|
+
# stub_search(:node)
|
|
144
|
+
#
|
|
145
|
+
# @example stubbing a search with a query
|
|
146
|
+
# stub_search(:node, 'name:*')
|
|
147
|
+
#
|
|
148
|
+
# @example stubbing a search with a query as a regex
|
|
149
|
+
# stub_search(:node, /name:(.+)/)
|
|
150
|
+
#
|
|
151
|
+
# @example stubbing a search with a block that is evaluated at runtime
|
|
152
|
+
# stub_search(:node) { JSON.parse(File.read('fixtures/nodes.json')) }
|
|
153
|
+
#
|
|
154
|
+
# @example stubbing a search to return a fixed value
|
|
155
|
+
# stub_search(:node).and_return([ { a: 'b' } ])
|
|
156
|
+
#
|
|
157
|
+
# @example stubbing a search to raise an exception
|
|
158
|
+
# stub_search(:node).and_raise(Chef::Exceptions::PrivateKeyMissing)
|
|
159
|
+
#
|
|
160
|
+
#
|
|
161
|
+
# @param [String, Symbol] type
|
|
162
|
+
# the type to search to stub
|
|
163
|
+
# @param [String, Symbol, nil] query
|
|
164
|
+
# the query to stub
|
|
165
|
+
#
|
|
166
|
+
# @return [ChefSpec::SearchStub]
|
|
167
|
+
#
|
|
168
|
+
def stub_search(type, query = '*:*', &block)
|
|
169
|
+
ChefSpec::Stubs::SearchRegistry.register(ChefSpec::Stubs::SearchStub.new(type, query, &block))
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Automatically clear all stubs after each test.
|
|
173
|
+
extend RSpec::SharedContext
|
|
174
|
+
after(:each) do
|
|
175
|
+
ChefSpec::Stubs::CommandRegistry.reset!
|
|
176
|
+
ChefSpec::Stubs::DataBagRegistry.reset!
|
|
177
|
+
ChefSpec::Stubs::DataBagItemRegistry.reset!
|
|
178
|
+
ChefSpec::Stubs::SearchRegistry.reset!
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|