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
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::install' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'installs a zypper_package with the default action' do
|
7
7
|
expect(chef_run).to install_zypper_package('default_action')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::lock' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'locks a zypper_package with an explicit action' do
|
7
7
|
expect(chef_run).to lock_zypper_package('explicit_action')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::purge' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'purges a zypper_package with an explicit action' do
|
7
7
|
expect(chef_run).to purge_zypper_package('explicit_action')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::remove' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'removes a zypper_package with an explicit action' do
|
7
7
|
expect(chef_run).to remove_zypper_package('explicit_action')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::unlock' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'unlocks a zypper_package with an explicit action' do
|
7
7
|
expect(chef_run).to unlock_zypper_package('explicit_action')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'zypper_package::upgrade' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.3').converge(described_recipe) }
|
5
5
|
|
6
6
|
it 'upgrades a zypper_package with an explicit action' do
|
7
7
|
expect(chef_run).to upgrade_zypper_package('explicit_action')
|
data/lib/chefspec.rb
CHANGED
@@ -63,12 +63,12 @@ require_relative 'chefspec/coverage'
|
|
63
63
|
require_relative 'chefspec/errors'
|
64
64
|
require_relative 'chefspec/expect_exception'
|
65
65
|
require_relative 'chefspec/formatter'
|
66
|
-
require_relative 'chefspec/macros'
|
67
66
|
require_relative 'chefspec/matchers'
|
68
67
|
require_relative 'chefspec/renderer'
|
69
68
|
require_relative 'chefspec/rspec'
|
70
69
|
require_relative 'chefspec/server_runner'
|
71
70
|
require_relative 'chefspec/solo_runner'
|
71
|
+
require_relative 'chefspec/runner'
|
72
72
|
require_relative 'chefspec/util'
|
73
73
|
require_relative 'chefspec/version'
|
74
74
|
|
data/lib/chefspec/api.rb
CHANGED
@@ -1,18 +1,37 @@
|
|
1
1
|
module ChefSpec
|
2
2
|
module API
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
autoload :Core, 'chefspec/api/core'
|
4
|
+
autoload :Described, 'chefspec/api/described'
|
5
|
+
autoload :DoNothing, 'chefspec/api/do_nothing'
|
6
|
+
autoload :IncludeRecipe, 'chefspec/api/include_recipe'
|
7
|
+
autoload :Link, 'chefspec/api/link'
|
8
|
+
autoload :Notifications, 'chefspec/api/notifications'
|
9
|
+
autoload :Reboot, 'chefspec/api/reboot'
|
10
|
+
autoload :RenderFile, 'chefspec/api/render_file'
|
11
|
+
autoload :StateAttrs, 'chefspec/api/state_attrs'
|
12
|
+
autoload :Stubs, 'chefspec/api/stubs'
|
13
|
+
autoload :StubsFor, 'chefspec/api/stubs_for'
|
14
|
+
autoload :Subscriptions, 'chefspec/api/subscriptions'
|
15
|
+
autoload :User, 'chefspec/api/user'
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
def self.included(klass)
|
18
|
+
# non-resources
|
19
|
+
klass.include(ChefSpec::API::Core)
|
20
|
+
klass.include(ChefSpec::API::Described)
|
21
|
+
klass.include(ChefSpec::API::DoNothing)
|
22
|
+
klass.include(ChefSpec::API::IncludeRecipe)
|
23
|
+
klass.include(ChefSpec::API::DoNothing)
|
24
|
+
klass.include(ChefSpec::API::RenderFile)
|
25
|
+
klass.include(ChefSpec::API::StateAttrs)
|
26
|
+
klass.include(ChefSpec::API::Notifications)
|
27
|
+
klass.include(ChefSpec::API::Stubs)
|
28
|
+
klass.include(ChefSpec::API::StubsFor)
|
29
|
+
klass.include(ChefSpec::API::Subscriptions)
|
14
30
|
|
15
|
-
# hacks and sugar for resources that don't follow the normal pattern
|
16
|
-
|
17
|
-
|
18
|
-
|
31
|
+
# hacks and sugar for resources that don't follow the normal pattern
|
32
|
+
klass.include(ChefSpec::API::User)
|
33
|
+
klass.include(ChefSpec::API::Link)
|
34
|
+
klass.include(ChefSpec::API::Reboot)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
module ChefSpec
|
2
|
+
module API
|
3
|
+
# Module containing the core RSpec API for ChefSpec.
|
4
|
+
module Core
|
5
|
+
# Pull in the needed machinery to use `around` and `let` in here.
|
6
|
+
extend RSpec::SharedContext
|
7
|
+
|
8
|
+
# Activate all of the various ChefSpec stubs for the duraction of this
|
9
|
+
# example block.
|
10
|
+
around do |ex|
|
11
|
+
old_chefspec_mode = $CHEFSPEC_MODE
|
12
|
+
$CHEFSPEC_MODE = true
|
13
|
+
begin
|
14
|
+
# Only run the preload if a platform is configured via the new system
|
15
|
+
# since otherwise it will spam warnings about the platform not being
|
16
|
+
# set.
|
17
|
+
chef_runner.preload! if chefspec_platform
|
18
|
+
ex.run
|
19
|
+
ensure
|
20
|
+
$CHEFSPEC_MODE = old_chefspec_mode
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Let variables to set the platform in a scoped way. Used below by
|
25
|
+
# {ClassMethods#platform}.
|
26
|
+
let(:chefspec_platform) { nil }
|
27
|
+
let(:chefspec_platform_version) { nil }
|
28
|
+
|
29
|
+
# Set up the runner object but don't actually run anything yet. This can
|
30
|
+
# be overridden if needed to set up very custom things.
|
31
|
+
let(:chef_runner) do
|
32
|
+
options = {
|
33
|
+
step_into: chefspec_ancestor_gather([], :step_into) {|memo, val| memo | val },
|
34
|
+
default_attributes: chefspec_attributes(:default_attributes),
|
35
|
+
normal_attributes: chefspec_attributes(:normal_attributes),
|
36
|
+
override_attributes: chefspec_attributes(:override_attributes),
|
37
|
+
automatic_attributes: chefspec_attributes(:automatic_attributes),
|
38
|
+
spec_declaration_locations: self.class.declaration_locations.last[0],
|
39
|
+
}
|
40
|
+
# Only specify these if set in the example so we don't override the
|
41
|
+
# global settings.
|
42
|
+
options[:platform] = chefspec_platform if chefspec_platform
|
43
|
+
options[:version] = chefspec_platform_version if chefspec_platform_version
|
44
|
+
# Merge in any final overrides.
|
45
|
+
options.update(chefspec_attributes(:chefspec_options).symbolize_keys)
|
46
|
+
# At some point this is probably going to need a flag for ServerRunner
|
47
|
+
# because someone will complain.
|
48
|
+
ChefSpec::SoloRunner.new(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
# By default, run the recipe in the base `describe` block.
|
52
|
+
let(:chef_run) do
|
53
|
+
chef_runner.converge(described_recipe)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Helper method for some of the nestable test value methods like
|
57
|
+
# {ClassMethods#default_attributes} and {ClassMethods#step_into}.
|
58
|
+
#
|
59
|
+
# @api private
|
60
|
+
# @param start [Object] Initial value for the reducer.
|
61
|
+
# @param method [Symbol] Name of the group-level method to call on each
|
62
|
+
# ancestor.
|
63
|
+
# @param block [Proc] Reducer callable.
|
64
|
+
# @return [Object]
|
65
|
+
def chefspec_ancestor_gather(start, method, &block)
|
66
|
+
candidate_ancestors = self.class.ancestors.select {|cls| cls.respond_to?(method) && cls != ChefSpec::API::Core }
|
67
|
+
candidate_ancestors.reverse.inject(start) do |memo, cls|
|
68
|
+
block.call(memo, cls.send(method))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Special case of {#chefspec_ancestor_gather} because we do it four times.
|
73
|
+
#
|
74
|
+
# @api private
|
75
|
+
# @param method [Symbol] Name of the group-level method to call on each
|
76
|
+
# ancestor.
|
77
|
+
# @return [Mash]
|
78
|
+
def chefspec_attributes(method)
|
79
|
+
chefspec_ancestor_gather(Mash.new, method) do |memo, val|
|
80
|
+
Chef::Mixin::DeepMerge.merge(memo, val)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Methods that will end up as group-level.
|
85
|
+
#
|
86
|
+
# @api private
|
87
|
+
module ClassMethods
|
88
|
+
# Set the Fauxhai platform to use for this example group.
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# describe 'myrecipe' do
|
92
|
+
# platform 'ubuntu', '18.04'
|
93
|
+
# @param name [String] Platform name to set.
|
94
|
+
# @param version [String, nil] Platform version to set.
|
95
|
+
# @return [void]
|
96
|
+
def platform(name, version=nil)
|
97
|
+
let(:chefspec_platform) { name }
|
98
|
+
let(:chefspec_platform_version) { version }
|
99
|
+
end
|
100
|
+
|
101
|
+
# Use an in-line block of recipe code for this example group rather
|
102
|
+
# than a recipe from a cookbook.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# describe 'my_resource' do
|
106
|
+
# recipe do
|
107
|
+
# my_resource 'helloworld'
|
108
|
+
# end
|
109
|
+
# @param block [Proc] A block of Chef recipe code.
|
110
|
+
# @return [void]
|
111
|
+
def recipe(&block)
|
112
|
+
let(:chef_run) do
|
113
|
+
chef_runner.converge_block(&block)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Set default-level node attributes to use for this example group.
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# describe 'myapp::install' do
|
121
|
+
# default_attributes['myapp']['version'] = '1.0'
|
122
|
+
# @return [Chef::Node::VividMash]
|
123
|
+
def default_attributes
|
124
|
+
@chefspec_default_attributes ||= Chef::Node::VividMash.new
|
125
|
+
end
|
126
|
+
|
127
|
+
# Set normal-level node attributes to use for this example group.
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
# describe 'myapp::install' do
|
131
|
+
# normal_attributes['myapp']['version'] = '1.0'
|
132
|
+
# @return [Chef::Node::VividMash]
|
133
|
+
def normal_attributes
|
134
|
+
@chefspec_normal_attributes ||= Chef::Node::VividMash.new
|
135
|
+
end
|
136
|
+
|
137
|
+
# Set override-level node attributes to use for this example group.
|
138
|
+
#
|
139
|
+
# @example
|
140
|
+
# describe 'myapp::install' do
|
141
|
+
# override_attributes['myapp']['version'] = '1.0'
|
142
|
+
# @return [Chef::Node::VividMash]
|
143
|
+
def override_attributes
|
144
|
+
@chefspec_override_attributes ||= Chef::Node::VividMash.new
|
145
|
+
end
|
146
|
+
|
147
|
+
# Set automatic-level node attributes to use for this example group.
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# describe 'myapp::install' do
|
151
|
+
# automatic_attributes['kernel']['machine'] = 'ppc64'
|
152
|
+
# @return [Chef::Node::VividMash]
|
153
|
+
def automatic_attributes
|
154
|
+
@chefspec_automatic_attributes ||= Chef::Node::VividMash.new
|
155
|
+
end
|
156
|
+
|
157
|
+
# Set additional ChefSpec runner options to use for this example group.
|
158
|
+
#
|
159
|
+
# @example
|
160
|
+
# describe 'myapp::install' do
|
161
|
+
# chefspec_options[:log_level] = :debug
|
162
|
+
# @return [Chef::Node::VividMash]
|
163
|
+
def chefspec_options
|
164
|
+
@chefspec_options ||= Chef::Node::VividMash.new
|
165
|
+
end
|
166
|
+
|
167
|
+
# Add resources to the step_into list for this example group.
|
168
|
+
#
|
169
|
+
# @example
|
170
|
+
# describe 'myapp::install' do
|
171
|
+
# step_into :my_resource
|
172
|
+
# @return [Array]
|
173
|
+
def step_into(*resources)
|
174
|
+
@chefspec_step_into ||= []
|
175
|
+
@chefspec_step_into |= resources.flatten.map(&:to_s)
|
176
|
+
end
|
177
|
+
|
178
|
+
# @api private
|
179
|
+
def included(klass)
|
180
|
+
super
|
181
|
+
# Inject classmethods into the group.
|
182
|
+
klass.extend(ClassMethods)
|
183
|
+
# If the describe block is aimed at string or resource/provider class
|
184
|
+
# then set the default subject to be the Chef run.
|
185
|
+
if klass.described_class.nil? || klass.described_class.is_a?(Class) && (klass.described_class < Chef::Resource || klass.described_class < Chef::Provider)
|
186
|
+
klass.subject { chef_run }
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
extend ClassMethods
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ChefSpec
|
2
|
+
module API
|
3
|
+
module Described
|
4
|
+
#
|
5
|
+
# The name of the currently running cookbook spec. Given the top-level
|
6
|
+
# +describe+ block is of the format:
|
7
|
+
#
|
8
|
+
# describe 'my_cookbook::my_recipe' do
|
9
|
+
# # ...
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# The value of +described_cookbook+ is "my_cookbook".
|
13
|
+
#
|
14
|
+
# @example Using +described_cookbook+ in a context block
|
15
|
+
# context "#{described_recipe} installs foo" do
|
16
|
+
# # ...
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
#
|
22
|
+
def described_cookbook
|
23
|
+
described_recipe.split('::').first
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# The name of the currently running recipe spec. Given the top-level
|
28
|
+
# +describe+ block is of the format:
|
29
|
+
#
|
30
|
+
# describe 'my_cookbook::my_recipe' do
|
31
|
+
# # ...
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# The value of +described_recipe+ is "my_cookbook::my_recipe".
|
35
|
+
#
|
36
|
+
# @example Using +described_recipe+ in the +ChefSpec::SoloRunner+
|
37
|
+
# let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) }
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
#
|
42
|
+
def described_recipe
|
43
|
+
scope = self.is_a?(Class) ? self : self.class
|
44
|
+
|
45
|
+
metahash = scope.metadata
|
46
|
+
while metahash.has_key?(:parent_example_group)
|
47
|
+
metahash = metahash[:parent_example_group]
|
48
|
+
end
|
49
|
+
|
50
|
+
metahash[:description].to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,21 +1,26 @@
|
|
1
|
-
module ChefSpec
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
module ChefSpec
|
2
|
+
module API
|
3
|
+
module DoNothing
|
4
|
+
#
|
5
|
+
# Assert that a resource in the Chef run does not perform any actions. Given
|
6
|
+
# a resource with +action :nothing+:
|
7
|
+
#
|
8
|
+
# package 'apache2' do
|
9
|
+
# action :nothing
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# The Examples section demonstrates the different ways to test that no
|
13
|
+
# actions were performed on a resource in a Chef run.
|
14
|
+
#
|
15
|
+
# @example Assert the +package+ does not perform any actions
|
16
|
+
# expect(chef_run.package('apache2')).to do_nothing
|
17
|
+
#
|
18
|
+
# @return [ChefSpec::Matchers::DoNothingMatcher]
|
19
|
+
#
|
20
|
+
def do_nothing
|
21
|
+
ChefSpec::Matchers::DoNothingMatcher.new
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|