chefspec 7.2.1 → 7.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/chefspec/berkshelf.rb
CHANGED
@@ -27,7 +27,7 @@ module ChefSpec
|
|
27
27
|
raise InvalidBerkshelfOptions(value: opts.inspect)
|
28
28
|
end
|
29
29
|
|
30
|
-
berksfile = ::Berkshelf::Berksfile.
|
30
|
+
berksfile = ::Berkshelf::Berksfile.from_options(opts)
|
31
31
|
|
32
32
|
# Grab a handle to tmpdir, since Berkshelf 2 modifies it a bit
|
33
33
|
tmpdir = File.join(@tmpdir, 'cookbooks')
|
@@ -19,7 +19,7 @@ module Kernel
|
|
19
19
|
end
|
20
20
|
|
21
21
|
module ChefSpec
|
22
|
-
class
|
22
|
+
class SoloRunner
|
23
23
|
# @deprecated {ChefSpec::Runner.define_runner_method} is deprecated. Please
|
24
24
|
# use {ChefSpec.define_matcher} instead.
|
25
25
|
def self.define_runner_method(resource_name)
|
@@ -29,21 +29,12 @@ module ChefSpec
|
|
29
29
|
|
30
30
|
ChefSpec.define_matcher(resource_name)
|
31
31
|
end
|
32
|
-
|
33
|
-
# @deprecated {ChefSpec::Runner.new} is deprecated. Please use
|
34
|
-
# {ChefSpec::SoloRunner} or {ChefSpec::ServerRunner} instead.
|
35
|
-
def self.new(*args, &block)
|
36
|
-
deprecated "`ChefSpec::Runner' is deprecated. Please use" \
|
37
|
-
" `ChefSpec::SoloRunner' or `ChefSpec::ServerRunner' instead."
|
38
|
-
|
39
|
-
ChefSpec::SoloRunner.new(*args, &block)
|
40
|
-
end
|
41
32
|
end
|
42
33
|
|
43
34
|
class Server
|
44
35
|
def self.method_missing(m, *args, &block)
|
45
36
|
deprecated "`ChefSpec::Server.#{m}' is deprecated. There is no longer" \
|
46
|
-
" a global Chef Server instance. Please use a ChefSpec::
|
37
|
+
" a global Chef Server instance. Please use a ChefSpec::SoloRunner" \
|
47
38
|
" instead. More documentation can be found in the ChefSpec README."
|
48
39
|
raise ChefSpec::Error::NoConversionError
|
49
40
|
end
|
data/lib/chefspec/errors.rb
CHANGED
@@ -33,6 +33,7 @@ module ChefSpec
|
|
33
33
|
class SearchNotStubbed < NotStubbed; end
|
34
34
|
class DataBagNotStubbed < NotStubbed; end
|
35
35
|
class DataBagItemNotStubbed < NotStubbed; end
|
36
|
+
class ShellOutNotStubbed < ChefSpecError; end
|
36
37
|
|
37
38
|
class CookbookPathNotFound < ChefSpecError; end
|
38
39
|
class GemLoadError < ChefSpecError; end
|
data/lib/chefspec/extensions.rb
CHANGED
@@ -6,12 +6,15 @@ module ChefSpec::Extensions
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# STOP! DO NOT ALPHABETIZE!
|
9
|
+
require_relative 'extensions/chef/data_query' # must be before Chef::Resource loads
|
9
10
|
require_relative 'extensions/chef/resource' # must come before client extensions or anything that winds up loading resources
|
11
|
+
require_relative 'extensions/chef/provider'
|
10
12
|
require_relative 'extensions/chef/securable'
|
11
13
|
require_relative 'extensions/chef/client'
|
12
14
|
require_relative 'extensions/chef/conditional'
|
13
15
|
require_relative 'extensions/chef/cookbook_uploader'
|
14
16
|
require_relative 'extensions/chef/cookbook/gem_installer'
|
15
|
-
require_relative 'extensions/chef/data_query'
|
16
17
|
require_relative 'extensions/chef/lwrp_base'
|
17
18
|
require_relative 'extensions/chef/resource/freebsd_package'
|
19
|
+
require_relative 'extensions/chef/run_context/cookbook_compiler'
|
20
|
+
require_relative 'extensions/chef/cookbook_loader'
|
@@ -8,15 +8,14 @@ require 'chef/providers'
|
|
8
8
|
require 'chef/client'
|
9
9
|
|
10
10
|
# @private
|
11
|
-
|
12
|
-
attr_reader :events
|
13
|
-
|
11
|
+
Chef::Client.prepend(Module.new do
|
14
12
|
#
|
15
13
|
# Don't actually run ohai (we have fake data for that)
|
16
14
|
#
|
17
15
|
# @see Chef::Client#run_ohai
|
18
16
|
#
|
19
17
|
def run_ohai
|
18
|
+
return super unless $CHEFSPEC_MODE
|
20
19
|
# noop
|
21
20
|
end
|
22
|
-
end
|
21
|
+
end)
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'chef/resource/conditional'
|
2
2
|
|
3
|
-
|
3
|
+
Chef::Resource::Conditional.prepend(Module.new do
|
4
4
|
# @see Chef::Resource::Conditional#evaluate_command
|
5
5
|
def evaluate_command
|
6
|
+
return super unless $CHEFSPEC_MODE
|
6
7
|
stub = ChefSpec::Stubs::CommandRegistry.stub_for(@command)
|
7
8
|
|
8
9
|
if stub.nil?
|
@@ -11,4 +12,4 @@ class Chef::Resource::Conditional
|
|
11
12
|
|
12
13
|
stub.result
|
13
14
|
end
|
14
|
-
end
|
15
|
+
end)
|
@@ -1,35 +1,32 @@
|
|
1
1
|
require 'chef/cookbook/gem_installer'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
cookbook_gems = Hash.new { |h, k| h[k] = [] }
|
3
|
+
Chef::Cookbook::GemInstaller.prepend(Module.new do
|
4
|
+
# Installs the gems into the omnibus gemset.
|
5
|
+
def install
|
6
|
+
return super unless $CHEFSPEC_MODE
|
7
|
+
cookbook_gems = Hash.new { |h, k| h[k] = [] }
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
events.cookbook_gem_start(cookbook_gems)
|
17
|
-
cookbook_gems.each { |gem_name, gem_requirements| locate_gem(gem_name, gem_requirements) }
|
18
|
-
events.cookbook_gem_finished
|
9
|
+
cookbook_collection.each do |cookbook_name, cookbook_version|
|
10
|
+
cookbook_version.metadata.gems.each do |args|
|
11
|
+
cookbook_gems[args.first] += args[1..-1]
|
19
12
|
end
|
13
|
+
end
|
14
|
+
|
15
|
+
events.cookbook_gem_start(cookbook_gems)
|
16
|
+
cookbook_gems.each { |gem_name, gem_requirements| locate_gem(gem_name, gem_requirements) }
|
17
|
+
events.cookbook_gem_finished
|
18
|
+
end
|
20
19
|
|
21
|
-
|
20
|
+
private
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
22
|
+
def locate_gem(gem_name, gem_requirements)
|
23
|
+
::Gem::Specification::find_by_name(gem_name, gem_requirements)
|
24
|
+
rescue ::Gem::MissingSpecError
|
25
|
+
gem_cmd = "gem install #{gem_name} --version '#{gem_requirements.join(', ')}'"
|
26
|
+
gemfile_line = "gem '#{[gem_name, *gem_requirements].join('\', \'')}'"
|
27
|
+
warn "No matching version found for '#{gem_name}' in your gem environment.\n" \
|
28
|
+
" - if you are using ChefDK, run the following command: \"chef #{gem_cmd}\"\n" \
|
29
|
+
" - if you are using bundler, append \"#{gemfile_line}\" to your Gemfile and run \"bundle install\"\n" \
|
30
|
+
" - otherwise run: \"#{gem_cmd}\""
|
34
31
|
end
|
35
|
-
end
|
32
|
+
end)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "chef/cookbook_loader"
|
2
|
+
|
3
|
+
Chef::CookbookLoader.prepend(Module.new do
|
4
|
+
def all_directories_in_repo_paths
|
5
|
+
return super unless $CHEFSPEC_MODE
|
6
|
+
if Chef::Config[:chefspec_cookbook_root]
|
7
|
+
# Hax.
|
8
|
+
[Chef::Config[:chefspec_cookbook_root]]
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'chef/cookbook_uploader'
|
2
2
|
|
3
|
-
|
3
|
+
Chef::CookbookUploader.prepend(Module.new do |variable|
|
4
4
|
#
|
5
5
|
# Don't validate uploaded cookbooks. Validating a cookbook takes *forever*
|
6
6
|
# to complete. It's just not worth it...
|
7
7
|
#
|
8
8
|
def validate_cookbooks
|
9
|
+
return super unless $CHEFSPEC_MODE
|
9
10
|
# noop
|
10
11
|
end
|
11
|
-
end
|
12
|
+
end)
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'chef/dsl/data_query'
|
2
2
|
|
3
|
-
|
3
|
+
Chef::DSL::DataQuery.prepend(Module.new do
|
4
4
|
# @see Chef::DSL::DataQuery#search
|
5
|
-
alias_method :old_search, :search
|
6
5
|
def search(*args, &block)
|
7
|
-
return
|
6
|
+
return super unless Chef::Config[:solo] && $CHEFSPEC_MODE
|
8
7
|
|
9
8
|
type = args[0]
|
10
9
|
query = args[1] || '*:*'
|
@@ -23,9 +22,8 @@ module Chef::DSL::DataQuery
|
|
23
22
|
end
|
24
23
|
|
25
24
|
# @see Chef::DSL::DataQuery#data_bag
|
26
|
-
alias_method :old_data_bag, :data_bag
|
27
25
|
def data_bag(bag)
|
28
|
-
return
|
26
|
+
return super unless Chef::Config[:solo] && $CHEFSPEC_MODE
|
29
27
|
|
30
28
|
stub = ChefSpec::Stubs::DataBagRegistry.stub_for(bag)
|
31
29
|
|
@@ -37,9 +35,8 @@ module Chef::DSL::DataQuery
|
|
37
35
|
end
|
38
36
|
|
39
37
|
# @see Chef::DSL::DataQuery#data_bag_item
|
40
|
-
alias_method :old_data_bag_item, :data_bag_item
|
41
38
|
def data_bag_item(bag, id, secret = nil)
|
42
|
-
return
|
39
|
+
return super unless Chef::Config[:solo] && $CHEFSPEC_MODE
|
43
40
|
|
44
41
|
stub = ChefSpec::Stubs::DataBagItemRegistry.stub_for(bag, id)
|
45
42
|
|
@@ -49,4 +46,4 @@ module Chef::DSL::DataQuery
|
|
49
46
|
|
50
47
|
stub.result
|
51
48
|
end
|
52
|
-
end
|
49
|
+
end)
|
@@ -4,29 +4,25 @@
|
|
4
4
|
# sub-resource collections.
|
5
5
|
|
6
6
|
if defined?(Chef::Provider::InlineResources)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
7
|
+
Chef::Provider::InlineResources.prepend(Module.new do
|
8
|
+
def initialize(resource, run_context)
|
9
|
+
super
|
10
|
+
@run_context = run_context
|
11
|
+
@resource_collection = run_context.resource_collection
|
12
|
+
end
|
13
|
+
end)
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
15
|
+
Chef::Provider::InlineResources::ClassMethods.prepend(Module.new do
|
16
|
+
def action(name, &block)
|
17
|
+
# Note: This does not check $CHEFSPEC_MODE.
|
18
|
+
define_method("action_#{name}", &block)
|
22
19
|
end
|
23
|
-
end
|
20
|
+
end)
|
24
21
|
else # >= 13.0
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
22
|
+
Chef::Provider.prepend(Module.new do
|
23
|
+
def compile_and_converge_action(&block)
|
24
|
+
return super unless $CHEFSPEC_MODE
|
25
|
+
instance_eval(&block)
|
30
26
|
end
|
31
|
-
end
|
27
|
+
end)
|
32
28
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'chef/provider'
|
2
|
+
require 'chefspec/api'
|
3
|
+
|
4
|
+
Chef::Provider.prepend(Module.new do
|
5
|
+
def self.name
|
6
|
+
"ChefSpec extensions for Chef::Provider"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.inspect
|
10
|
+
"#<Module: #{name}>"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Hook for the stubs_for system.
|
14
|
+
def initialize(*args, &block)
|
15
|
+
super(*args, &block)
|
16
|
+
ChefSpec::API::StubsFor.setup_stubs_for(self, :provider) if $CHEFSPEC_MODE
|
17
|
+
end
|
18
|
+
|
19
|
+
# Defang shell_out and friends so it can never run.
|
20
|
+
if ChefSpec::API::StubsFor::HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
|
21
|
+
def shell_out_compacted(*args)
|
22
|
+
return super unless $CHEFSPEC_MODE
|
23
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: 'provider', resource: new_resource)
|
24
|
+
end
|
25
|
+
|
26
|
+
def shell_out_compacted!(*args)
|
27
|
+
return super unless $CHEFSPEC_MODE
|
28
|
+
shell_out_compacted(*args).tap {|c| c.error! }
|
29
|
+
end
|
30
|
+
else
|
31
|
+
def shell_out(*args)
|
32
|
+
return super unless $CHEFSPEC_MODE
|
33
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: 'provider', resource: new_resource)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'chef/resource'
|
2
|
+
require 'chef/version'
|
2
3
|
require 'chefspec/api'
|
3
4
|
|
4
5
|
#
|
@@ -10,8 +11,35 @@ require 'chefspec/api'
|
|
10
11
|
|
11
12
|
module ChefSpec::Extensions::Chef::Resource
|
12
13
|
|
14
|
+
#
|
15
|
+
# Hooks for the stubs_for system
|
16
|
+
#
|
17
|
+
def initialize(*args, &block)
|
18
|
+
super(*args, &block)
|
19
|
+
if $CHEFSPEC_MODE
|
20
|
+
# Here be dragons.
|
21
|
+
# If we're directly inside a `load_current_resource`, this is probably
|
22
|
+
# something like `new_resource.class.new` so we want to call this a current_resource,
|
23
|
+
# Otherwise it's probably a normal resource instantiation.
|
24
|
+
mode = caller[1].include?("`load_current_resource'") ? :current_resource : :resource
|
25
|
+
ChefSpec::API::StubsFor.setup_stubs_for(self, mode)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def dup
|
30
|
+
return super unless $CHEFSPEC_MODE
|
31
|
+
# Also here be dragons.
|
32
|
+
stack = caller
|
33
|
+
super.tap do |dup_resource|
|
34
|
+
# We're directly inside a load_current_resource, which is probably via
|
35
|
+
# the load_current_value DSL system, so call this a current resource.
|
36
|
+
ChefSpec::API::StubsFor.setup_stubs_for(dup_resource, :current_resource) if stack.first.include?("`load_current_resource'")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
13
40
|
# mix of no-op and tracking concerns
|
14
41
|
def run_action(action, notification_type = nil, notifying_resource = nil)
|
42
|
+
return super unless $CHEFSPEC_MODE
|
15
43
|
resolve_notification_references
|
16
44
|
validate_action(action)
|
17
45
|
|
@@ -34,20 +62,37 @@ module ChefSpec::Extensions::Chef::Resource
|
|
34
62
|
end
|
35
63
|
|
36
64
|
#
|
37
|
-
#
|
65
|
+
# Defang shell_out and friends so it can never run.
|
38
66
|
#
|
67
|
+
if ChefSpec::API::StubsFor::HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
|
68
|
+
def shell_out_compacted(*args)
|
69
|
+
return super unless $CHEFSPEC_MODE
|
70
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: 'resource', resource: self)
|
71
|
+
end
|
39
72
|
|
40
|
-
|
41
|
-
|
42
|
-
|
73
|
+
def shell_out_compacted!(*args)
|
74
|
+
return super unless $CHEFSPEC_MODE
|
75
|
+
shell_out_compacted(*args).tap {|c| c.error! }
|
76
|
+
end
|
77
|
+
else
|
78
|
+
def shell_out(*args)
|
79
|
+
return super unless $CHEFSPEC_MODE
|
80
|
+
raise ChefSpec::Error::ShellOutNotStubbed.new(args: args, type: 'resource', resource: self)
|
81
|
+
end
|
43
82
|
end
|
44
83
|
|
84
|
+
#
|
85
|
+
# tracking
|
86
|
+
#
|
87
|
+
|
45
88
|
def perform_action(action, options = {})
|
89
|
+
@performed_actions ||= {}
|
46
90
|
@performed_actions[action.to_sym] ||= {}
|
47
91
|
@performed_actions[action.to_sym].merge!(options)
|
48
92
|
end
|
49
93
|
|
50
94
|
def performed_action(action)
|
95
|
+
@performed_actions ||= {}
|
51
96
|
@performed_actions[action.to_sym]
|
52
97
|
end
|
53
98
|
|
@@ -60,6 +105,7 @@ module ChefSpec::Extensions::Chef::Resource
|
|
60
105
|
end
|
61
106
|
|
62
107
|
def performed_actions
|
108
|
+
@performed_actions ||= {}
|
63
109
|
@performed_actions.keys
|
64
110
|
end
|
65
111
|
|
@@ -120,6 +166,7 @@ module ChefSpec::Extensions::Chef::Resource
|
|
120
166
|
|
121
167
|
def inject_actions(*actions)
|
122
168
|
provides_names.each do |resource_name|
|
169
|
+
next unless resource_name
|
123
170
|
ChefSpec.define_matcher(resource_name)
|
124
171
|
actions.each do |action|
|
125
172
|
inject_method(:"#{action}_#{resource_name}", resource_name, action)
|
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'chef/resource/freebsd_package'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
false
|
16
|
-
end
|
17
|
-
end
|
3
|
+
Chef::Resource::FreebsdPackage.prepend(Module.new do
|
4
|
+
#
|
5
|
+
# Chef decided it was a good idea to just shellout inside of a resource.
|
6
|
+
# Not only is that a horrible fucking idea, but I got flak when I asked
|
7
|
+
# to change it. So we are just going to monkey patch the fucking thing so
|
8
|
+
# it does not shell out.
|
9
|
+
#
|
10
|
+
# @return [false]
|
11
|
+
#
|
12
|
+
def supports_pkgng?
|
13
|
+
return super unless $CHEFSPEC_MODE
|
14
|
+
true
|
18
15
|
end
|
19
|
-
end
|
16
|
+
end)
|