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
@@ -0,0 +1,50 @@
|
|
1
|
+
describe 'spec_step_into' do
|
2
|
+
platform 'ubuntu', '18.04'
|
3
|
+
|
4
|
+
context 'with no step_into' do
|
5
|
+
it { is_expected.to_not write_log('one') }
|
6
|
+
it { is_expected.to_not write_log('two') }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'with step_into one' do
|
10
|
+
step_into :spec_step_into_one
|
11
|
+
it { is_expected.to write_log('one') }
|
12
|
+
it { is_expected.to_not write_log('two') }
|
13
|
+
|
14
|
+
context 'with nested step_into one' do
|
15
|
+
step_into :spec_step_into_one
|
16
|
+
it { is_expected.to write_log('one') }
|
17
|
+
it { is_expected.to_not write_log('two') }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with nested step_into two' do
|
21
|
+
step_into :spec_step_into_two
|
22
|
+
it { is_expected.to write_log('one') }
|
23
|
+
it { is_expected.to write_log('two') }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with step_into two' do
|
28
|
+
step_into :spec_step_into_two
|
29
|
+
it { is_expected.to_not write_log('one') }
|
30
|
+
it { is_expected.to write_log('two') }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with step_into both' do
|
34
|
+
step_into :spec_step_into_one, :spec_step_into_two
|
35
|
+
it { is_expected.to write_log('one') }
|
36
|
+
it { is_expected.to write_log('two') }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with step_into as a string' do
|
40
|
+
step_into 'spec_step_into_one'
|
41
|
+
it { is_expected.to write_log('one') }
|
42
|
+
it { is_expected.to_not write_log('two') }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with step_into as an array' do
|
46
|
+
step_into [:spec_step_into_one]
|
47
|
+
it { is_expected.to write_log('one') }
|
48
|
+
it { is_expected.to_not write_log('two') }
|
49
|
+
end
|
50
|
+
end
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
3
3
|
ChefSpec.define_matcher(:state_attrs_lwrp)
|
4
4
|
|
5
5
|
describe 'state_attrs::default' do
|
6
|
-
let(:chef_run) { ChefSpec::
|
6
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
7
7
|
let(:lwrp) { chef_run.state_attrs_lwrp('name') }
|
8
8
|
|
9
9
|
it 'has the correct state attributes' do
|
@@ -2,7 +2,7 @@ require 'chefspec'
|
|
2
2
|
|
3
3
|
describe 'step_into::default' do
|
4
4
|
context 'without :step_into' do
|
5
|
-
let(:chef_run) { ChefSpec::
|
5
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
6
6
|
|
7
7
|
it 'does not execute the LWRPs action' do
|
8
8
|
expect(chef_run).to_not write_log('message')
|
@@ -15,7 +15,7 @@ describe 'step_into::default' do
|
|
15
15
|
|
16
16
|
context 'with :step_into' do
|
17
17
|
let(:chef_run) do
|
18
|
-
ChefSpec::
|
18
|
+
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04', step_into: %w(step_into_lwrp provides_this))
|
19
19
|
.converge(described_recipe)
|
20
20
|
end
|
21
21
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'stub_command::default' do
|
4
|
-
let(:chef_run) { ChefSpec::
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
|
6
6
|
context 'when the command is not stubbed' do
|
7
7
|
it 'raises an exception' do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'stub_data_bag::default' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
|
6
6
|
context 'when the data_bag is not stubbed' do
|
7
7
|
it 'raises an exception' do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'stub_data_bag_item::default' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
|
6
6
|
context 'when the data_bag_item is not stubbed' do
|
7
7
|
it 'raises an exception' do
|
@@ -2,7 +2,7 @@ require 'chefspec'
|
|
2
2
|
|
3
3
|
describe 'stub_node::default' do
|
4
4
|
let(:my_node) do
|
5
|
-
stub_node('example.com', platform: 'ubuntu', version: '
|
5
|
+
stub_node('example.com', platform: 'ubuntu', version: '18.04') do |node|
|
6
6
|
node.normal['foo']['bar'] = 'zip'
|
7
7
|
end
|
8
8
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'stub_search::block' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
|
6
6
|
context 'when the search is not stubbed' do
|
7
7
|
it 'raises an exception' do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'stub_search::default' do
|
4
|
-
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
|
6
6
|
context 'when the search is not stubbed' do
|
7
7
|
it 'raises an exception' do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
resource_name :stubs_for_test
|
2
|
+
|
3
|
+
property :cmd
|
4
|
+
property :value
|
5
|
+
property :run_resource, [true, false], default: false
|
6
|
+
property :run_load, [true, false], default: false
|
7
|
+
property :run_provider, [true, false], default: false
|
8
|
+
|
9
|
+
def foo
|
10
|
+
shell_out(cmd).stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
load_current_value do |new_resource|
|
14
|
+
value shell_out(new_resource.cmd).stdout if new_resource.run_load
|
15
|
+
end
|
16
|
+
|
17
|
+
action :run do
|
18
|
+
new_resource.foo if new_resource.run_resource
|
19
|
+
shell_out!(new_resource.cmd) if new_resource.run_provider
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
resource_name :stubs_for_old
|
2
|
+
|
3
|
+
property :cmd
|
4
|
+
property :value
|
5
|
+
property :run_resource, [true, false], default: false
|
6
|
+
property :run_load, [true, false], default: false
|
7
|
+
property :run_provider, [true, false], default: false
|
8
|
+
|
9
|
+
def foo
|
10
|
+
shell_out(cmd).stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
action_class do
|
14
|
+
def load_current_resource
|
15
|
+
@current_resource = new_resource.class.new(new_resource.name)
|
16
|
+
# current_resource.shell_out is weird but mostly doing it for completeness and parity checking with load_curent_value-style.
|
17
|
+
@current_resource.value @current_resource.shell_out(new_resource.cmd).stdout if new_resource.run_load
|
18
|
+
@current_resource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
action :run do
|
24
|
+
new_resource.foo if new_resource.run_resource
|
25
|
+
shell_out!(new_resource.cmd) if new_resource.run_provider
|
26
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
describe 'stubs_for' do
|
2
|
+
platform 'ubuntu'
|
3
|
+
step_into :stubs_for_test, :stubs_for_old
|
4
|
+
default_attributes['test'] = {run_load: false, run_resource: false, run_provider: false}
|
5
|
+
recipe do
|
6
|
+
stubs_for_test 'test' do
|
7
|
+
cmd 'this_is_not_a_cmd'
|
8
|
+
run_load node['test']['run_load']
|
9
|
+
run_resource node['test']['run_resource']
|
10
|
+
run_provider node['test']['run_provider']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with no stubs' do
|
15
|
+
context 'running nothing' do
|
16
|
+
it { expect { subject }.to_not raise_error }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'running load' do
|
20
|
+
default_attributes['test']['run_load'] = true
|
21
|
+
it { expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'running resource' do
|
25
|
+
default_attributes['test']['run_resource'] = true
|
26
|
+
it { expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'running provider' do
|
30
|
+
default_attributes['test']['run_provider'] = true
|
31
|
+
it { expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'running all three' do
|
35
|
+
default_attributes['test'] = {run_load: true, run_resource: true, run_provider: true}
|
36
|
+
it { expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with a single inline resource stub' do
|
41
|
+
context 'running load' do
|
42
|
+
default_attributes['test']['run_load'] = true
|
43
|
+
|
44
|
+
it do
|
45
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
46
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
47
|
+
end
|
48
|
+
subject
|
49
|
+
end
|
50
|
+
|
51
|
+
it do
|
52
|
+
stubs_for_current_resource('stubs_for_test[test]') do |res|
|
53
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
54
|
+
end
|
55
|
+
subject
|
56
|
+
end
|
57
|
+
|
58
|
+
it do
|
59
|
+
stubs_for_resource('stubs_for_test[test]', current_resource: false) do |res|
|
60
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
61
|
+
end
|
62
|
+
expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with old-style load_current_resource' do
|
66
|
+
recipe do
|
67
|
+
stubs_for_old 'test' do
|
68
|
+
cmd 'this_is_not_a_cmd'
|
69
|
+
run_load true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it do
|
74
|
+
stubs_for_current_resource('stubs_for_old[test]') do |res|
|
75
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
76
|
+
end
|
77
|
+
subject
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'running resource' do
|
83
|
+
default_attributes['test']['run_resource'] = true
|
84
|
+
|
85
|
+
it do
|
86
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
87
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
88
|
+
end
|
89
|
+
is_expected.to run_stubs_for_test('test').with(foo: 'asdf')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'running both' do
|
94
|
+
default_attributes['test']['run_load'] = true
|
95
|
+
default_attributes['test']['run_resource'] = true
|
96
|
+
|
97
|
+
it do
|
98
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
99
|
+
# Use expect instead of allow for this test.
|
100
|
+
expect(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf').at_least(:once)
|
101
|
+
end
|
102
|
+
is_expected.to run_stubs_for_test('test').with(foo: 'asdf')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'with a single inline provider stub' do
|
108
|
+
default_attributes['test']['run_provider'] = true
|
109
|
+
|
110
|
+
it do
|
111
|
+
stubs_for_provider('stubs_for_test[test]') do |prov|
|
112
|
+
allow(prov).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
113
|
+
end
|
114
|
+
subject
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'with a single group-level resource stub' do
|
119
|
+
context 'running load' do
|
120
|
+
default_attributes['test']['run_load'] = true
|
121
|
+
|
122
|
+
context 'with normal usage' do
|
123
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
124
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
125
|
+
end
|
126
|
+
|
127
|
+
it { subject }
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'with stubs_for_current_resource' do
|
131
|
+
stubs_for_current_resource('stubs_for_test[test]') do |res|
|
132
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
133
|
+
end
|
134
|
+
|
135
|
+
it { subject }
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'with current_resource: false' do
|
139
|
+
stubs_for_resource('stubs_for_test[test]', current_resource: false) do |res|
|
140
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
141
|
+
end
|
142
|
+
it { expect { subject }.to raise_error ChefSpec::Error::ShellOutNotStubbed }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'running resource' do
|
147
|
+
default_attributes['test']['run_resource'] = true
|
148
|
+
|
149
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
150
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf')
|
151
|
+
end
|
152
|
+
|
153
|
+
it { is_expected.to run_stubs_for_test('test').with(foo: 'asdf') }
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'running both' do
|
157
|
+
default_attributes['test']['run_load'] = true
|
158
|
+
default_attributes['test']['run_resource'] = true
|
159
|
+
|
160
|
+
stubs_for_resource('stubs_for_test[test]') do |res|
|
161
|
+
# Use expect instead of allow for this test.
|
162
|
+
expect(res).to receive_shell_out('this_is_not_a_cmd', stdout: 'asdf').at_least(:once)
|
163
|
+
end
|
164
|
+
|
165
|
+
it { is_expected.to run_stubs_for_test('test').with(foo: 'asdf') }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'with multiple nested stubs' do
|
170
|
+
recipe do
|
171
|
+
stubs_for_test 'test1' do
|
172
|
+
cmd 'this_is_not_a_cmd1'
|
173
|
+
run_resource true
|
174
|
+
end
|
175
|
+
stubs_for_test 'test2' do
|
176
|
+
cmd 'this_is_not_a_cmd2'
|
177
|
+
run_resource true
|
178
|
+
end
|
179
|
+
stubs_for_test 'test3' do
|
180
|
+
cmd 'this_is_not_a_cmd2'
|
181
|
+
run_resource true
|
182
|
+
end
|
183
|
+
stubs_for_old 'test4' do
|
184
|
+
cmd 'this_is_not_a_cmd3'
|
185
|
+
run_resource true
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
stubs_for_resource('stubs_for_test[test1]') do |res|
|
190
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd1', stdout: 'one')
|
191
|
+
end
|
192
|
+
stubs_for_resource('stubs_for_test') do |res|
|
193
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd2', stdout: 'two')
|
194
|
+
end
|
195
|
+
stubs_for_resource do |res|
|
196
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd3', stdout: 'three')
|
197
|
+
end
|
198
|
+
|
199
|
+
it { is_expected.to run_stubs_for_test('test1').with(foo: 'one') }
|
200
|
+
it { is_expected.to run_stubs_for_test('test2').with(foo: 'two') }
|
201
|
+
it { is_expected.to run_stubs_for_test('test3').with(foo: 'two') }
|
202
|
+
it { is_expected.to run_stubs_for_old('test4').with(foo: 'three') }
|
203
|
+
|
204
|
+
context 'nested a' do
|
205
|
+
stubs_for_resource('stubs_for_test[test1]') do |res|
|
206
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd1', stdout: 'four')
|
207
|
+
end
|
208
|
+
|
209
|
+
it { is_expected.to run_stubs_for_test('test1').with(foo: 'four') }
|
210
|
+
it { is_expected.to run_stubs_for_test('test2').with(foo: 'two') }
|
211
|
+
it { is_expected.to run_stubs_for_test('test3').with(foo: 'two') }
|
212
|
+
it { is_expected.to run_stubs_for_old('test4').with(foo: 'three') }
|
213
|
+
|
214
|
+
context 'nested b' do
|
215
|
+
stubs_for_resource do |res|
|
216
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd3', stdout: 'five')
|
217
|
+
end
|
218
|
+
|
219
|
+
it { is_expected.to run_stubs_for_test('test1').with(foo: 'four') }
|
220
|
+
it { is_expected.to run_stubs_for_test('test2').with(foo: 'two') }
|
221
|
+
it { is_expected.to run_stubs_for_test('test3').with(foo: 'two') }
|
222
|
+
it { is_expected.to run_stubs_for_old('test4').with(foo: 'five') }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'nested c' do
|
227
|
+
stubs_for_resource('stubs_for_test') do |res|
|
228
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd2', stdout: 'six')
|
229
|
+
end
|
230
|
+
stubs_for_resource do |res|
|
231
|
+
allow(res).to receive_shell_out('this_is_not_a_cmd3', stdout: 'seven')
|
232
|
+
end
|
233
|
+
|
234
|
+
it { is_expected.to run_stubs_for_test('test1').with(foo: 'one') }
|
235
|
+
it { is_expected.to run_stubs_for_test('test2').with(foo: 'six') }
|
236
|
+
it { is_expected.to run_stubs_for_test('test3').with(foo: 'six') }
|
237
|
+
it { is_expected.to run_stubs_for_old('test4').with(foo: 'seven') }
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
3
|
describe 'subscribes::before' do
|
4
|
-
let(:chef_run) { ChefSpec::
|
4
|
+
let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '18.04').converge(described_recipe) }
|
5
5
|
let(:service) { chef_run.service('receiving_resource') }
|
6
6
|
|
7
7
|
it 'subscribes to the template creation' do
|