summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-07-02 13:18:58 -0700
committerGitHub <noreply@github.com>2018-07-02 13:18:58 -0700
commit4ca23a0dd98c59e1cae29fd7ad6e485cbb12c2b3 (patch)
treec23401b04cc4184969ea7ab8d4ae5ad8760ee198
parent28f9fa7713cd2788f259efc7ec5405365d07419c (diff)
parent865b2aac61aea10db31bae7dcedd6146c9526f74 (diff)
downloadchef-4ca23a0dd98c59e1cae29fd7ad6e485cbb12c2b3.tar.gz
Merge pull request #7414 from chef/lcg/chefstyle2
Chefstyle fixes
-rwxr-xr-xbin/chef-service-manager12
-rw-r--r--chef-config/Rakefile2
-rw-r--r--chef-config/lib/chef-config/config.rb2
-rw-r--r--chef-config/lib/chef-config/package_task.rb86
-rw-r--r--chef-config/lib/chef-config/version.rb4
-rw-r--r--chef-config/spec/spec_helper.rb4
-rw-r--r--chef-config/spec/unit/workstation_config_loader_spec.rb76
-rw-r--r--ext/win32-eventlog/Rakefile14
-rw-r--r--lib/chef/api_client.rb20
-rw-r--r--lib/chef/api_client/registration.rb10
-rw-r--r--lib/chef/api_client_v1.rb28
-rw-r--r--lib/chef/application/apply.rb112
-rw-r--r--lib/chef/application/client.rb325
-rw-r--r--lib/chef/application/knife.rb154
-rw-r--r--lib/chef/application/solo.rb238
-rw-r--r--lib/chef/application/windows_service.rb38
-rw-r--r--lib/chef/application/windows_service_manager.rb70
-rw-r--r--lib/chef/audit/audit_event_proxy.rb12
-rw-r--r--lib/chef/audit/control_group_data.rb30
-rw-r--r--lib/chef/audit/runner.rb2
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb6
-rw-r--r--lib/chef/chef_fs/config.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb6
-rw-r--r--lib/chef/chef_fs/file_system/repository/directory.rb6
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb6
-rw-r--r--lib/chef/chef_fs/knife.rb12
-rw-r--r--lib/chef/chef_fs/parallelizer.rb2
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb84
-rw-r--r--lib/chef/cookbook/synchronizer.rb2
-rw-r--r--lib/chef/cookbook_manifest.rb10
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb8
-rw-r--r--lib/chef/cookbook_uploader.rb4
-rw-r--r--lib/chef/data_bag.rb4
-rw-r--r--lib/chef/data_bag_item.rb2
-rw-r--r--lib/chef/dsl/reboot_pending.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item/encryptor.rb2
-rw-r--r--lib/chef/environment.rb18
-rw-r--r--lib/chef/event_loggers/windows_eventlog.rb40
-rw-r--r--lib/chef/exceptions.rb6
-rw-r--r--lib/chef/file_cache.rb28
-rw-r--r--lib/chef/formatters/base.rb4
-rw-r--r--lib/chef/formatters/doc.rb12
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb100
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb20
-rw-r--r--lib/chef/formatters/error_inspectors/node_load_error_inspector.rb26
-rw-r--r--lib/chef/formatters/error_inspectors/registration_error_inspector.rb78
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb32
-rw-r--r--lib/chef/formatters/indentable_output_stream.rb8
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb4
-rw-r--r--lib/chef/handler/json_file.rb2
-rw-r--r--lib/chef/http/auth_credentials.rb4
-rw-r--r--lib/chef/http/authenticator.rb10
-rw-r--r--lib/chef/http/http_request.rb4
-rw-r--r--lib/chef/key.rb14
-rw-r--r--lib/chef/knife/bootstrap.rb232
-rw-r--r--lib/chef/knife/bootstrap/client_builder.rb2
-rw-r--r--lib/chef/knife/client_bulk_delete.rb6
-rw-r--r--lib/chef/knife/client_create.rb34
-rw-r--r--lib/chef/knife/client_delete.rb6
-rw-r--r--lib/chef/knife/client_list.rb6
-rw-r--r--lib/chef/knife/client_reregister.rb6
-rw-r--r--lib/chef/knife/configure.rb50
-rw-r--r--lib/chef/knife/cookbook_bulk_delete.rb2
-rw-r--r--lib/chef/knife/cookbook_delete.rb4
-rw-r--r--lib/chef/knife/cookbook_download.rb22
-rw-r--r--lib/chef/knife/cookbook_list.rb12
-rw-r--r--lib/chef/knife/cookbook_metadata.rb14
-rw-r--r--lib/chef/knife/cookbook_show.rb24
-rw-r--r--lib/chef/knife/cookbook_site_download.rb20
-rw-r--r--lib/chef/knife/cookbook_site_install.rb48
-rw-r--r--lib/chef/knife/cookbook_site_list.rb16
-rw-r--r--lib/chef/knife/cookbook_site_search.rb10
-rw-r--r--lib/chef/knife/cookbook_site_share.rb38
-rw-r--r--lib/chef/knife/cookbook_site_show.rb10
-rw-r--r--lib/chef/knife/cookbook_site_unshare.rb10
-rw-r--r--lib/chef/knife/cookbook_test.rb14
-rw-r--r--lib/chef/knife/cookbook_upload.rb60
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb8
-rw-r--r--lib/chef/knife/core/cookbook_scm_repo.rb2
-rw-r--r--lib/chef/knife/core/generic_presenter.rb14
-rw-r--r--lib/chef/knife/core/node_presenter.rb74
-rw-r--r--lib/chef/knife/core/status_presenter.rb22
-rw-r--r--lib/chef/knife/data_bag_from_file.rb8
-rw-r--r--lib/chef/knife/data_bag_list.rb6
-rw-r--r--lib/chef/knife/data_bag_secret_options.rb22
-rw-r--r--lib/chef/knife/delete.rb26
-rw-r--r--lib/chef/knife/deps.rb18
-rw-r--r--lib/chef/knife/diff.rb28
-rw-r--r--lib/chef/knife/download.rb46
-rw-r--r--lib/chef/knife/edit.rb6
-rw-r--r--lib/chef/knife/environment_compare.rb16
-rw-r--r--lib/chef/knife/environment_create.rb6
-rw-r--r--lib/chef/knife/environment_from_file.rb6
-rw-r--r--lib/chef/knife/environment_list.rb6
-rw-r--r--lib/chef/knife/exec.rb14
-rw-r--r--lib/chef/knife/key_create.rb8
-rw-r--r--lib/chef/knife/key_create_base.rb24
-rw-r--r--lib/chef/knife/key_edit.rb10
-rw-r--r--lib/chef/knife/key_edit_base.rb30
-rw-r--r--lib/chef/knife/key_list.rb6
-rw-r--r--lib/chef/knife/key_list_base.rb18
-rw-r--r--lib/chef/knife/list.rb38
-rw-r--r--lib/chef/knife/node_edit.rb8
-rw-r--r--lib/chef/knife/node_list.rb6
-rw-r--r--lib/chef/knife/node_run_list_add.rb12
-rw-r--r--lib/chef/knife/node_show.rb12
-rw-r--r--lib/chef/knife/osc_user_create.rb26
-rw-r--r--lib/chef/knife/osc_user_list.rb6
-rw-r--r--lib/chef/knife/osc_user_reregister.rb6
-rw-r--r--lib/chef/knife/raw.rb32
-rw-r--r--lib/chef/knife/role_create.rb6
-rw-r--r--lib/chef/knife/role_env_run_list_add.rb6
-rw-r--r--lib/chef/knife/role_env_run_list_remove.rb4
-rw-r--r--lib/chef/knife/role_list.rb6
-rw-r--r--lib/chef/knife/role_run_list_add.rb6
-rw-r--r--lib/chef/knife/role_run_list_remove.rb4
-rw-r--r--lib/chef/knife/search.rb46
-rw-r--r--lib/chef/knife/serve.rb12
-rw-r--r--lib/chef/knife/show.rb6
-rw-r--r--lib/chef/knife/ssh.rb132
-rw-r--r--lib/chef/knife/ssl_check.rb62
-rw-r--r--lib/chef/knife/ssl_fetch.rb10
-rw-r--r--lib/chef/knife/status.rb22
-rw-r--r--lib/chef/knife/upload.rb50
-rw-r--r--lib/chef/knife/user_create.rb56
-rw-r--r--lib/chef/knife/user_delete.rb18
-rw-r--r--lib/chef/knife/user_edit.rb18
-rw-r--r--lib/chef/knife/user_list.rb6
-rw-r--r--lib/chef/knife/user_reregister.rb24
-rw-r--r--lib/chef/knife/user_show.rb18
-rw-r--r--lib/chef/knife/xargs.rb72
-rw-r--r--lib/chef/log/winevt.rb40
-rw-r--r--lib/chef/mixin/api_version_request_handling.rb12
-rw-r--r--lib/chef/mixin/deprecation.rb2
-rw-r--r--lib/chef/mixin/securable.rb22
-rw-r--r--lib/chef/mixin/windows_env_helper.rb2
-rw-r--r--lib/chef/node.rb12
-rw-r--r--lib/chef/node_map.rb24
-rw-r--r--lib/chef/org.rb16
-rw-r--r--lib/chef/policy_builder/expand_node_object.rb2
-rw-r--r--lib/chef/provider/cron/unix.rb4
-rw-r--r--lib/chef/provider/dsc_resource.rb2
-rw-r--r--lib/chef/provider/dsc_script.rb16
-rw-r--r--lib/chef/provider/execute.rb2
-rw-r--r--lib/chef/provider/http_request.rb12
-rw-r--r--lib/chef/provider/mdadm.rb2
-rw-r--r--lib/chef/provider/mount/mount.rb2
-rw-r--r--lib/chef/provider/mount/windows.rb10
-rw-r--r--lib/chef/provider/package.rb2
-rw-r--r--lib/chef/provider/package/chocolatey.rb12
-rw-r--r--lib/chef/provider/powershell_script.rb146
-rw-r--r--lib/chef/provider/reboot.rb8
-rw-r--r--lib/chef/provider/remote_file/sftp.rb2
-rw-r--r--lib/chef/provider/resource_update.rb2
-rw-r--r--lib/chef/provider/service/openbsd.rb2
-rw-r--r--lib/chef/provider/service/redhat.rb2
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--lib/chef/provider/service/systemd.rb4
-rw-r--r--lib/chef/provider/service/windows.rb8
-rw-r--r--lib/chef/provider/subversion.rb6
-rw-r--r--lib/chef/provider/systemd_unit.rb4
-rw-r--r--lib/chef/provider/template/content.rb2
-rw-r--r--lib/chef/provider/user/dscl.rb2
-rw-r--r--lib/chef/provider/windows_env.rb12
-rw-r--r--lib/chef/provider/windows_task.rb24
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/cron.rb10
-rw-r--r--lib/chef/resource/dsc_script.rb10
-rw-r--r--lib/chef/resource/execute.rb2
-rw-r--r--lib/chef/resource/file/verification.rb2
-rw-r--r--lib/chef/resource/freebsd_package.rb2
-rw-r--r--lib/chef/resource/group.rb4
-rw-r--r--lib/chef/resource/hostname.rb2
-rw-r--r--lib/chef/resource/http_request.rb2
-rw-r--r--lib/chef/resource/powershell_script.rb4
-rw-r--r--lib/chef/resource/remote_directory.rb6
-rw-r--r--lib/chef/resource/remote_file.rb4
-rw-r--r--lib/chef/resource/resource_notification.rb32
-rw-r--r--lib/chef/resource/service.rb34
-rw-r--r--lib/chef/resource/template.rb2
-rw-r--r--lib/chef/resource/user.rb30
-rw-r--r--lib/chef/resource/windows_script.rb2
-rw-r--r--lib/chef/resource_definition.rb2
-rw-r--r--lib/chef/resource_reporter.rb6
-rw-r--r--lib/chef/role.rb12
-rw-r--r--lib/chef/run_context.rb12
-rw-r--r--lib/chef/run_list/run_list_expansion.rb10
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb4
-rw-r--r--lib/chef/run_status.rb20
-rw-r--r--lib/chef/shell.rb120
-rw-r--r--lib/chef/shell/ext.rb302
-rw-r--r--lib/chef/shell/shell_session.rb4
-rw-r--r--lib/chef/user.rb22
-rw-r--r--lib/chef/user_v1.rb50
-rw-r--r--lib/chef/util/backup.rb4
-rw-r--r--lib/chef/util/diff.rb2
-rw-r--r--lib/chef/util/dsc/configuration_generator.rb22
-rw-r--r--lib/chef/util/dsc/lcm_output_parser.rb2
-rw-r--r--lib/chef/util/file_edit.rb28
-rw-r--r--lib/chef/util/powershell/cmdlet.rb6
-rw-r--r--lib/chef/util/selinux.rb2
-rw-r--r--lib/chef/util/windows/net_group.rb2
-rw-r--r--lib/chef/util/windows/net_use.rb6
-rw-r--r--lib/chef/util/windows/net_user.rb22
-rw-r--r--lib/chef/util/windows/volume.rb4
-rw-r--r--lib/chef/version.rb4
-rw-r--r--lib/chef/win32/api.rb12
-rw-r--r--lib/chef/win32/api/error.rb4
-rw-r--r--lib/chef/win32/api/file.rb24
-rw-r--r--lib/chef/win32/api/net.rb116
-rw-r--r--lib/chef/win32/registry.rb16
-rw-r--r--lib/chef/win32/security/securable_object.rb20
-rw-r--r--lib/chef/win32/version.rb30
-rw-r--r--spec/functional/audit/rspec_formatter_spec.rb2
-rw-r--r--spec/functional/audit/runner_spec.rb2
-rw-r--r--spec/functional/dsl/reboot_pending_spec.rb6
-rw-r--r--spec/functional/dsl/registry_helper_spec.rb6
-rw-r--r--spec/functional/http/simple_spec.rb2
-rw-r--r--spec/functional/knife/exec_spec.rb2
-rw-r--r--spec/functional/knife/ssh_spec.rb4
-rw-r--r--spec/functional/mixin/shell_out_spec.rb8
-rw-r--r--spec/functional/rebooter_spec.rb12
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb4
-rw-r--r--spec/functional/resource/apt_package_spec.rb34
-rw-r--r--spec/functional/resource/bff_spec.rb2
-rw-r--r--spec/functional/resource/cron_spec.rb2
-rw-r--r--spec/functional/resource/dnf_package_spec.rb14
-rw-r--r--spec/functional/resource/dsc_script_spec.rb188
-rw-r--r--spec/functional/resource/execute_spec.rb8
-rw-r--r--spec/functional/resource/file_spec.rb2
-rw-r--r--spec/functional/resource/git_spec.rb38
-rw-r--r--spec/functional/resource/ifconfig_spec.rb10
-rw-r--r--spec/functional/resource/link_spec.rb2
-rw-r--r--spec/functional/resource/mount_spec.rb4
-rw-r--r--spec/functional/resource/powershell_script_spec.rb26
-rw-r--r--spec/functional/resource/reboot_spec.rb6
-rw-r--r--spec/functional/resource/registry_spec.rb164
-rw-r--r--spec/functional/resource/remote_file_spec.rb4
-rw-r--r--spec/functional/resource/rpm_spec.rb2
-rw-r--r--spec/functional/resource/template_spec.rb10
-rw-r--r--spec/functional/resource/user/dscl_spec.rb6
-rw-r--r--spec/functional/resource/windows_env_spec.rb2
-rw-r--r--spec/functional/resource/windows_service_spec.rb2
-rw-r--r--spec/functional/resource/windows_task_spec.rb76
-rw-r--r--spec/functional/resource/yum_package_spec.rb16
-rw-r--r--spec/functional/run_lock_spec.rb8
-rw-r--r--spec/functional/shell_spec.rb2
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb14
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/functional/win32/crypto_spec.rb18
-rw-r--r--spec/functional/win32/registry_spec.rb132
-rw-r--r--spec/integration/client/client_spec.rb438
-rw-r--r--spec/integration/client/exit_code_spec.rb38
-rw-r--r--spec/integration/client/ipv6_spec.rb72
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb260
-rw-r--r--spec/integration/knife/chef_repo_path_spec.rb836
-rw-r--r--spec/integration/knife/chef_repository_file_system_spec.rb70
-rw-r--r--spec/integration/knife/chefignore_spec.rb176
-rw-r--r--spec/integration/knife/client_bulk_delete_spec.rb98
-rw-r--r--spec/integration/knife/client_create_spec.rb10
-rw-r--r--spec/integration/knife/client_delete_spec.rb26
-rw-r--r--spec/integration/knife/client_key_delete_spec.rb4
-rw-r--r--spec/integration/knife/client_key_list_spec.rb8
-rw-r--r--spec/integration/knife/client_list_spec.rb16
-rw-r--r--spec/integration/knife/common_options_spec.rb60
-rw-r--r--spec/integration/knife/cookbook_api_ipv6_spec.rb76
-rw-r--r--spec/integration/knife/cookbook_bulk_delete_spec.rb28
-rw-r--r--spec/integration/knife/cookbook_download_spec.rb24
-rw-r--r--spec/integration/knife/cookbook_list_spec.rb16
-rw-r--r--spec/integration/knife/cookbook_show_spec.rb162
-rw-r--r--spec/integration/knife/cookbook_upload_spec.rb48
-rw-r--r--spec/integration/knife/data_bag_delete_spec.rb16
-rw-r--r--spec/integration/knife/data_bag_from_file_spec.rb94
-rw-r--r--spec/integration/knife/data_bag_list_spec.rb8
-rw-r--r--spec/integration/knife/data_bag_show_spec.rb14
-rw-r--r--spec/integration/knife/delete_spec.rb1186
-rw-r--r--spec/integration/knife/deps_spec.rb370
-rw-r--r--spec/integration/knife/diff_spec.rb232
-rw-r--r--spec/integration/knife/download_spec.rb1020
-rw-r--r--spec/integration/knife/environment_compare_spec.rb30
-rw-r--r--spec/integration/knife/environment_from_file_spec.rb118
-rw-r--r--spec/integration/knife/environment_list_spec.rb8
-rw-r--r--spec/integration/knife/environment_show_spec.rb50
-rw-r--r--spec/integration/knife/list_spec.rb1462
-rw-r--r--spec/integration/knife/node_bulk_delete_spec.rb16
-rw-r--r--spec/integration/knife/node_delete_spec.rb12
-rw-r--r--spec/integration/knife/node_environment_set_spec.rb6
-rw-r--r--spec/integration/knife/node_from_file_spec.rb32
-rw-r--r--spec/integration/knife/node_list_spec.rb10
-rw-r--r--spec/integration/knife/raw_spec.rb234
-rw-r--r--spec/integration/knife/role_bulk_delete_spec.rb16
-rw-r--r--spec/integration/knife/role_delete_spec.rb12
-rw-r--r--spec/integration/knife/role_from_file_spec.rb84
-rw-r--r--spec/integration/knife/role_list_spec.rb10
-rw-r--r--spec/integration/knife/role_show_spec.rb18
-rw-r--r--spec/integration/knife/show_spec.rb114
-rw-r--r--spec/integration/knife/upload_spec.rb792
-rw-r--r--spec/integration/recipes/accumulator_spec.rb4
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb16
-rw-r--r--spec/integration/recipes/lwrp_spec.rb24
-rw-r--r--spec/integration/recipes/notifies_spec.rb334
-rw-r--r--spec/integration/recipes/notifying_block_spec.rb4
-rw-r--r--spec/integration/recipes/remote_directory.rb2
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb198
-rw-r--r--spec/integration/recipes/resource_load_spec.rb16
-rw-r--r--spec/integration/solo/solo_spec.rb80
-rw-r--r--spec/scripts/ssl-serve.rb22
-rw-r--r--spec/spec_helper.rb146
-rw-r--r--spec/stress/win32/file_spec.rb4
-rw-r--r--spec/stress/win32/security_spec.rb4
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/support/shared/context/client.rb50
-rw-r--r--spec/support/shared/functional/securable_resource.rb26
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb10
-rw-r--r--spec/support/shared/functional/win32_service.rb10
-rw-r--r--spec/support/shared/functional/windows_script.rb6
-rw-r--r--spec/support/shared/integration/app_server_support.rb6
-rw-r--r--spec/support/shared/integration/integration_helper.rb4
-rw-r--r--spec/support/shared/integration/knife_support.rb4
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb12
-rw-r--r--spec/support/shared/unit/api_versioning.rb4
-rw-r--r--spec/support/shared/unit/execute_resource.rb4
-rw-r--r--spec/support/shared/unit/provider/file.rb24
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb46
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb6
-rw-r--r--spec/tiny_server.rb4
-rw-r--r--spec/unit/api_client/registration_spec.rb60
-rw-r--r--spec/unit/api_client_spec.rb12
-rw-r--r--spec/unit/api_client_v1_spec.rb12
-rw-r--r--spec/unit/application/apply_spec.rb8
-rw-r--r--spec/unit/application/client_spec.rb22
-rw-r--r--spec/unit/application/knife_spec.rb6
-rw-r--r--spec/unit/application/solo_spec.rb8
-rw-r--r--spec/unit/application_spec.rb22
-rw-r--r--spec/unit/audit/audit_event_proxy_spec.rb96
-rw-r--r--spec/unit/audit/audit_reporter_spec.rb98
-rw-r--r--spec/unit/audit/control_group_data_spec.rb40
-rw-r--r--spec/unit/audit/runner_spec.rb4
-rw-r--r--spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb2
-rw-r--r--spec/unit/chef_fs/data_handler/data_handler_base_spec.rb6
-rw-r--r--spec/unit/chef_fs/diff_spec.rb90
-rw-r--r--spec/unit/chef_fs/file_pattern_spec.rb4
-rw-r--r--spec/unit/chef_fs/file_system/repository/directory_spec.rb2
-rw-r--r--spec/unit/chef_fs/file_system_spec.rb16
-rw-r--r--spec/unit/chef_fs/parallelizer.rb24
-rw-r--r--spec/unit/client_spec.rb30
-rw-r--r--spec/unit/config_fetcher_spec.rb46
-rw-r--r--spec/unit/config_spec.rb4
-rw-r--r--spec/unit/cookbook/metadata_spec.rb158
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb342
-rw-r--r--spec/unit/cookbook_loader_spec.rb8
-rw-r--r--spec/unit/cookbook_site_streaming_uploader_spec.rb12
-rw-r--r--spec/unit/cookbook_uploader_spec.rb16
-rw-r--r--spec/unit/cookbook_version_file_specificity_spec.rb270
-rw-r--r--spec/unit/daemon_spec.rb8
-rw-r--r--spec/unit/data_bag_item_spec.rb4
-rw-r--r--spec/unit/data_bag_spec.rb2
-rw-r--r--spec/unit/data_collector/resource_report_spec.rb2
-rw-r--r--spec/unit/data_collector_spec.rb4
-rw-r--r--spec/unit/dsl/audit_spec.rb2
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb32
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb2
-rw-r--r--spec/unit/environment_spec.rb32
-rw-r--r--spec/unit/file_access_control_spec.rb16
-rw-r--r--spec/unit/file_content_management/deploy/mv_unix_spec.rb6
-rw-r--r--spec/unit/file_content_management/deploy/mv_windows_spec.rb52
-rw-r--r--spec/unit/formatters/error_description_spec.rb78
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb32
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb10
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb8
-rw-r--r--spec/unit/handler/json_file_spec.rb2
-rw-r--r--spec/unit/http/api_versions_spec.rb2
-rw-r--r--spec/unit/http/authenticator_spec.rb34
-rw-r--r--spec/unit/http/ssl_policies_spec.rb2
-rw-r--r--spec/unit/http/validate_content_length_spec.rb4
-rw-r--r--spec/unit/key_spec.rb24
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb6
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_reregister_spec.rb2
-rw-r--r--spec/unit/knife/configure_client_spec.rb8
-rw-r--r--spec/unit/knife/configure_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb42
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb14
-rw-r--r--spec/unit/knife/cookbook_show_spec.rb48
-rw-r--r--spec/unit/knife/cookbook_site_download_spec.rb46
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_site_share_spec.rb20
-rw-r--r--spec/unit/knife/cookbook_site_unshare_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb38
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb74
-rw-r--r--spec/unit/knife/core/cookbook_scm_repo_spec.rb40
-rw-r--r--spec/unit/knife/core/object_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/ui_spec.rb110
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_edit_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_secret_options_spec.rb10
-rw-r--r--spec/unit/knife/environment_from_file_spec.rb2
-rw-r--r--spec/unit/knife/key_create_spec.rb8
-rw-r--r--spec/unit/knife/key_delete_spec.rb6
-rw-r--r--spec/unit/knife/key_edit_spec.rb6
-rw-r--r--spec/unit/knife/key_list_spec.rb6
-rw-r--r--spec/unit/knife/key_show_spec.rb6
-rw-r--r--spec/unit/knife/node_delete_spec.rb2
-rw-r--r--spec/unit/knife/node_edit_spec.rb14
-rw-r--r--spec/unit/knife/node_from_file_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/osc_user_edit_spec.rb2
-rw-r--r--spec/unit/knife/osc_user_reregister_spec.rb2
-rw-r--r--spec/unit/knife/role_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_create_spec.rb2
-rw-r--r--spec/unit/knife/role_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb8
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_replace_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/role_from_file_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_add_spec.rb8
-rw-r--r--spec/unit/knife/role_run_list_clear_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_replace_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/ssh_spec.rb50
-rw-r--r--spec/unit/knife/ssl_check_spec.rb46
-rw-r--r--spec/unit/knife/ssl_fetch_spec.rb22
-rw-r--r--spec/unit/knife/user_delete_spec.rb2
-rw-r--r--spec/unit/knife/user_reregister_spec.rb2
-rw-r--r--spec/unit/knife_spec.rb52
-rw-r--r--spec/unit/log/syslog_spec.rb2
-rw-r--r--spec/unit/lwrp_spec.rb6
-rw-r--r--spec/unit/mash_spec.rb6
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb32
-rw-r--r--spec/unit/mixin/checksum_spec.rb2
-rw-r--r--spec/unit/mixin/enforce_ownership_and_permissions_spec.rb16
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb2
-rw-r--r--spec/unit/mixin/params_validate_spec.rb192
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb2
-rw-r--r--spec/unit/mixin/securable_spec.rb54
-rw-r--r--spec/unit/mixin/shell_out_spec.rb60
-rw-r--r--spec/unit/mixin/user_context_spec.rb2
-rw-r--r--spec/unit/mixin/xml_escape_spec.rb2
-rw-r--r--spec/unit/node/attribute_spec.rb6
-rw-r--r--spec/unit/node/vivid_mash_spec.rb6
-rw-r--r--spec/unit/node_map_spec.rb6
-rw-r--r--spec/unit/node_spec.rb30
-rw-r--r--spec/unit/org_spec.rb4
-rw-r--r--spec/unit/platform/query_helpers_spec.rb52
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb8
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb58
-rw-r--r--spec/unit/property_spec.rb10
-rw-r--r--spec/unit/provider/apt_repository_spec.rb38
-rw-r--r--spec/unit/provider/cookbook_file/content_spec.rb2
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb2
-rw-r--r--spec/unit/provider/cron/unix_spec.rb24
-rw-r--r--spec/unit/provider/cron_spec.rb558
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb12
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/file/content_spec.rb2
-rw-r--r--spec/unit/provider/file_spec.rb2
-rw-r--r--spec/unit/provider/git_spec.rb246
-rw-r--r--spec/unit/provider/group/dscl_spec.rb26
-rw-r--r--spec/unit/provider/group_spec.rb6
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb20
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb32
-rw-r--r--spec/unit/provider/ifconfig_spec.rb6
-rw-r--r--spec/unit/provider/launchd_spec.rb104
-rw-r--r--spec/unit/provider/link_spec.rb14
-rw-r--r--spec/unit/provider/mdadm_spec.rb6
-rw-r--r--spec/unit/provider/mount/aix_spec.rb78
-rw-r--r--spec/unit/provider/mount/mount_spec.rb52
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb4
-rw-r--r--spec/unit/provider/mount/windows_spec.rb8
-rw-r--r--spec/unit/provider/ohai_spec.rb18
-rw-r--r--spec/unit/provider/osx_profile_spec.rb2
-rw-r--r--spec/unit/provider/package/apt_spec.rb296
-rw-r--r--spec/unit/provider/package/bff_spec.rb24
-rw-r--r--spec/unit/provider/package/cab_spec.rb116
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb68
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb50
-rw-r--r--spec/unit/provider/package/freebsd/pkg_spec.rb44
-rw-r--r--spec/unit/provider/package/freebsd/pkgng_spec.rb38
-rw-r--r--spec/unit/provider/package/freebsd/port_spec.rb30
-rw-r--r--spec/unit/provider/package/homebrew_spec.rb8
-rw-r--r--spec/unit/provider/package/ips_spec.rb140
-rw-r--r--spec/unit/provider/package/macports_spec.rb14
-rw-r--r--spec/unit/provider/package/msu_spec.rb84
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb22
-rw-r--r--spec/unit/provider/package/pacman_spec.rb76
-rw-r--r--spec/unit/provider/package/paludis_spec.rb50
-rw-r--r--spec/unit/provider/package/portage_spec.rb18
-rw-r--r--spec/unit/provider/package/powershell_spec.rb176
-rw-r--r--spec/unit/provider/package/rpm_spec.rb12
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb104
-rw-r--r--spec/unit/provider/package/smartos_spec.rb32
-rw-r--r--spec/unit/provider/package/solaris_spec.rb36
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb2
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb2
-rw-r--r--spec/unit/provider/package/windows_spec.rb2
-rw-r--r--spec/unit/provider/package/zypper_spec.rb12
-rw-r--r--spec/unit/provider/powershell_script_spec.rb2
-rw-r--r--spec/unit/provider/registry_key_spec.rb44
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb8
-rw-r--r--spec/unit/provider/remote_file/fetcher_spec.rb10
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/local_file_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/network_file_spec.rb6
-rw-r--r--spec/unit/provider/remote_file/sftp_spec.rb4
-rw-r--r--spec/unit/provider/remote_file_spec.rb2
-rw-r--r--spec/unit/provider/script_spec.rb2
-rw-r--r--spec/unit/provider/service/aix_service_spec.rb16
-rw-r--r--spec/unit/provider/service/aixinit_service_spec.rb6
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb42
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb4
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb60
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb2
-rw-r--r--spec/unit/provider/service/init_service_spec.rb28
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb4
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb34
-rw-r--r--spec/unit/provider/service/macosx_spec.rb118
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb12
-rw-r--r--spec/unit/provider/service/redhat_spec.rb54
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb28
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb38
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb26
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb10
-rw-r--r--spec/unit/provider/service/windows_spec.rb76
-rw-r--r--spec/unit/provider/service_spec.rb6
-rw-r--r--spec/unit/provider/subversion_spec.rb26
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb20
-rw-r--r--spec/unit/provider/template/content_spec.rb88
-rw-r--r--spec/unit/provider/template_spec.rb4
-rw-r--r--spec/unit/provider/user/pw_spec.rb2
-rw-r--r--spec/unit/provider/windows_env_spec.rb4
-rw-r--r--spec/unit/provider/windows_task_spec.rb32
-rw-r--r--spec/unit/provider/zypper_repository_spec.rb14
-rw-r--r--spec/unit/provider_resolver_spec.rb4
-rw-r--r--spec/unit/recipe_spec.rb26
-rw-r--r--spec/unit/resource/conditional_spec.rb2
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb6
-rw-r--r--spec/unit/resource/dnf_package_spec.rb6
-rw-r--r--spec/unit/resource/execute_spec.rb4
-rw-r--r--spec/unit/resource/file/verification/systemd_unit_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb2
-rw-r--r--spec/unit/resource/file_spec.rb6
-rw-r--r--spec/unit/resource/freebsd_package_spec.rb8
-rw-r--r--spec/unit/resource/group_spec.rb8
-rw-r--r--spec/unit/resource/mount_spec.rb6
-rw-r--r--spec/unit/resource/package_spec.rb4
-rw-r--r--spec/unit/resource/powershell_package_source_spec.rb4
-rw-r--r--spec/unit/resource/powershell_package_spec.rb2
-rw-r--r--spec/unit/resource/powershell_script_spec.rb16
-rw-r--r--spec/unit/resource/registry_key_spec.rb38
-rw-r--r--spec/unit/resource/remote_file_spec.rb4
-rw-r--r--spec/unit/resource/resource_notification_spec.rb16
-rw-r--r--spec/unit/resource/service_spec.rb6
-rw-r--r--spec/unit/resource/template_spec.rb4
-rw-r--r--spec/unit/resource/user_spec.rb4
-rw-r--r--spec/unit/resource/yum_package_spec.rb6
-rw-r--r--spec/unit/resource_collection/resource_set_spec.rb12
-rw-r--r--spec/unit/resource_collection_spec.rb10
-rw-r--r--spec/unit/resource_definition_spec.rb4
-rw-r--r--spec/unit/resource_inspector_spec.rb6
-rw-r--r--spec/unit/resource_reporter_spec.rb48
-rw-r--r--spec/unit/resource_spec.rb60
-rw-r--r--spec/unit/role_spec.rb44
-rw-r--r--spec/unit/run_context_spec.rb2
-rw-r--r--spec/unit/run_list/run_list_item_spec.rb6
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb24
-rw-r--r--spec/unit/run_list_spec.rb12
-rw-r--r--spec/unit/runner_spec.rb8
-rw-r--r--spec/unit/scan_access_control_spec.rb6
-rw-r--r--spec/unit/shell/model_wrapper_spec.rb8
-rw-r--r--spec/unit/shell/shell_ext_spec.rb8
-rw-r--r--spec/unit/shell/shell_session_spec.rb56
-rw-r--r--spec/unit/user_spec.rb4
-rw-r--r--spec/unit/user_v1_spec.rb50
-rw-r--r--spec/unit/util/diff_spec.rb2
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb8
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb210
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb32
-rw-r--r--spec/unit/util/file_edit_spec.rb76
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb2
-rw-r--r--spec/unit/util/selinux_spec.rb12
-rw-r--r--spec/unit/win32/registry_spec.rb6
-rw-r--r--spec/unit/windows_service_spec.rb4
-rw-r--r--tasks/cbgb.rb2
-rw-r--r--tasks/dependencies.rb12
-rw-r--r--tasks/maintainers.rb4
-rw-r--r--tasks/rspec.rb4
606 files changed, 11513 insertions, 11514 deletions
diff --git a/bin/chef-service-manager b/bin/chef-service-manager
index c894b10f4f..bbdfe005df 100755
--- a/bin/chef-service-manager
+++ b/bin/chef-service-manager
@@ -25,12 +25,12 @@ require "chef/application/windows_service_manager"
if Chef::Platform.windows?
chef_client_service = {
- :service_name => "chef-client",
- :service_display_name => "Chef Client Service",
- :service_description => "Runs Chef Client on regular, configurable intervals.",
- :service_file_path => File.expand_path("../chef-windows-service", $PROGRAM_NAME),
- :delayed_start => true,
- :dependencies => ["Winmgmt"],
+ service_name: "chef-client",
+ service_display_name: "Chef Client Service",
+ service_description: "Runs Chef Client on regular, configurable intervals.",
+ service_file_path: File.expand_path("../chef-windows-service", $PROGRAM_NAME),
+ delayed_start: true,
+ dependencies: ["Winmgmt"],
}
Chef::Application::WindowsServiceManager.new(chef_client_service).run
else
diff --git a/chef-config/Rakefile b/chef-config/Rakefile
index fd6497a287..324dbbdcf4 100644
--- a/chef-config/Rakefile
+++ b/chef-config/Rakefile
@@ -4,7 +4,7 @@ ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "ChefConfig", "che
package.module_path = "chef-config"
end
-task :default => :spec
+task default: :spec
begin
require "rspec/core/rake_task"
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index ed8fab9ee4..07be3e9ef6 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -698,7 +698,7 @@ module ChefConfig
# Deprecated:
# Move this to the default value of syntax_cache_path when this is removed.
- default(:cache_options) { { :path => PathHelper.join(config_dir, "syntaxcache") } }
+ default(:cache_options) { { path: PathHelper.join(config_dir, "syntaxcache") } }
# Whether errors should be raised for deprecation warnings. When set to
# `false` (the default setting), a warning is emitted but code using
diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb
index 3ab273532d..ae5acef258 100644
--- a/chef-config/lib/chef-config/package_task.rb
+++ b/chef-config/lib/chef-config/package_task.rb
@@ -131,10 +131,10 @@ module ChefConfig
end
end
- task :package => :package_components
+ task package: :package_components
desc "Build and install component dependencies"
- task :install_components => :package_components do
+ task install_components: :package_components do
component_full_paths.each do |component_path|
Dir.chdir(component_path) do
sh "rake install"
@@ -142,7 +142,7 @@ module ChefConfig
end
end
- task :install => :install_components
+ task install: :install_components
desc "Clean up builds of component dependencies"
task :clobber_component_packages do
@@ -153,7 +153,7 @@ module ChefConfig
end
end
- task :clobber_package => :clobber_component_packages
+ task clobber_package: :clobber_component_packages
desc "Update the version number for component dependencies"
task :update_components_versions do
@@ -166,12 +166,12 @@ module ChefConfig
namespace :version do
desc "Regenerate lib/#{module_path}/version.rb from VERSION file"
- task :update => :update_components_versions do
+ task update: :update_components_versions do
update_version_rb
update_gemfile_lock
end
- task :bump => %w{version:bump_patch version:update}
+ task bump: %w{version:bump_patch version:update}
task :show do
puts version
@@ -201,41 +201,41 @@ module ChefConfig
def update_version_rb # rubocop:disable Lint/NestedMethodDefinition
puts "Updating #{version_rb_path} to include version #{version} ..."
- contents = <<-VERSION_RB
-# Copyright:: Copyright 2010-2016, Chef Software, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-# NOTE: This file is generated by running `rake version` in the top level of
-# this repo. Do not edit this manually. Edit the VERSION file and run the rake
-# task instead.
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-#{"\nrequire \"chef/version_string\"\n" if use_versionstring}
-#{class_or_module} #{module_name}
- #{module_name.upcase}_ROOT = File.expand_path("../..", __FILE__)
- VERSION = #{use_versionstring ? "Chef::VersionString.new(\"#{version}\")" : "\"#{version}\""}
-end
+ contents = <<~VERSION_RB
+ # Copyright:: Copyright 2010-2016, Chef Software, Inc.
+ # License:: Apache License, Version 2.0
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ # NOTE: This file is generated by running `rake version` in the top level of
+ # this repo. Do not edit this manually. Edit the VERSION file and run the rake
+ # task instead.
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ #{"\nrequire \"chef/version_string\"\n" if use_versionstring}
+ #{class_or_module} #{module_name}
+ #{module_name.upcase}_ROOT = File.expand_path("../..", __FILE__)
+ VERSION = #{use_versionstring ? "Chef::VersionString.new(\"#{version}\")" : "\"#{version}\""}
+ end
-#
-# NOTE: the Chef::Version class is defined in version_class.rb
-#
-# NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The
-# Chef::Version class is for _cookbooks_ only, and cannot handle
-# pre-release versions like "10.14.0.rc.2". Please use Rubygem's
-# Gem::Version class instead.
-#
+ #
+ # NOTE: the Chef::Version class is defined in version_class.rb
+ #
+ # NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The
+ # Chef::Version class is for _cookbooks_ only, and cannot handle
+ # pre-release versions like "10.14.0.rc.2". Please use Rubygem's
+ # Gem::Version class instead.
+ #
VERSION_RB
IO.write(version_rb_path, contents)
end
@@ -252,7 +252,7 @@ end
end
end
- task :version => "version:update"
+ task version: "version:update"
gemspec_platform_to_install = ""
Dir[File.expand_path("*.gemspec", root_path)].reverse_each do |gemspec_path|
@@ -264,7 +264,7 @@ end
end
desc "Build and install a #{module_path} gem"
- task :install => [:package] do
+ task install: [:package] do
with_clean_env do
full_module_path = File.join(full_package_dir, module_path)
sh %{gem install #{full_module_path}-#{version}#{gemspec_platform_to_install}.gem --no-rdoc --no-ri}
@@ -276,7 +276,7 @@ end
end
desc "Build it, tag it and ship it"
- task :ship => [:clobber_package, :gem] do
+ task ship: [:clobber_package, :gem] do
sh("git tag #{version}")
sh("git push #{git_remote} --tags")
Dir[File.expand_path("*.gem", full_package_dir)].reverse_each do |built_gem|
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 60e5372766..e7cf1f6274 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# NOTE: This file is generated by running `rake version` in the top level of
# this repo. Do not edit this manually. Edit the VERSION file and run the rake
# task instead.
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
diff --git a/chef-config/spec/spec_helper.rb b/chef-config/spec/spec_helper.rb
index 107becb9eb..6a324474e1 100644
--- a/chef-config/spec/spec_helper.rb
+++ b/chef-config/spec/spec_helper.rb
@@ -32,8 +32,8 @@ RSpec.configure do |config|
config.filter_run :focus
config.run_all_when_everything_filtered = true
- config.filter_run_excluding :windows_only => true unless ChefConfig.windows?
- config.filter_run_excluding :unix_only => true if ChefConfig.windows?
+ config.filter_run_excluding windows_only: true unless ChefConfig.windows?
+ config.filter_run_excluding unix_only: true if ChefConfig.windows?
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb
index f02b1c5016..6cebe1e09c 100644
--- a/chef-config/spec/unit/workstation_config_loader_spec.rb
+++ b/chef-config/spec/unit/workstation_config_loader_spec.rb
@@ -389,12 +389,12 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
context "and has a default profile" do
let(:content) do
- content = <<EOH
-[default]
-node_name = 'barney'
-client_key = "barney_rubble.pem"
-chef_server_url = "https://api.chef.io/organizations/bedrock"
-invalid_config_option1234 = "foobar"
+ content = <<~EOH
+ [default]
+ node_name = 'barney'
+ client_key = "barney_rubble.pem"
+ chef_server_url = "https://api.chef.io/organizations/bedrock"
+ invalid_config_option1234 = "foobar"
EOH
content
end
@@ -410,16 +410,16 @@ EOH
context "and has a default profile with knife settings" do
let(:content) do
- content = <<EOH
-[default]
-node_name = 'barney'
-client_key = "barney_rubble.pem"
-chef_server_url = "https://api.chef.io/organizations/bedrock"
-knife = {
- secret_file = "/home/barney/.chef/encrypted_data_bag_secret.pem"
-}
-[default.knife]
-ssh_user = "knife_ssh_user"
+ content = <<~EOH
+ [default]
+ node_name = 'barney'
+ client_key = "barney_rubble.pem"
+ chef_server_url = "https://api.chef.io/organizations/bedrock"
+ knife = {
+ secret_file = "/home/barney/.chef/encrypted_data_bag_secret.pem"
+ }
+ [default.knife]
+ ssh_user = "knife_ssh_user"
EOH
content
end
@@ -436,21 +436,21 @@ EOH
context "and has a profile containing a full key" do
let(:content) do
- content = <<EOH
-[default]
-client_key = """
------BEGIN RSA PRIVATE KEY-----
-foo
-"""
+ content = <<~EOH
+ [default]
+ client_key = """
+ -----BEGIN RSA PRIVATE KEY-----
+ foo
+ """
EOH
content
end
it "applies the expected config" do
expect { config_loader.load_credentials }.not_to raise_error
- expect(ChefConfig::Config.client_key_contents).to eq(<<EOH
------BEGIN RSA PRIVATE KEY-----
-foo
+ expect(ChefConfig::Config.client_key_contents).to eq(<<~EOH
+ -----BEGIN RSA PRIVATE KEY-----
+ foo
EOH
)
end
@@ -458,15 +458,15 @@ EOH
context "and has several profiles" do
let(:content) do
- content = <<EOH
-[default]
-client_name = "default"
-[environment]
-client_name = "environment"
-[explicit]
-client_name = "explicit"
-[context]
-client_name = "context"
+ content = <<~EOH
+ [default]
+ client_name = "default"
+ [environment]
+ client_name = "environment"
+ [explicit]
+ client_name = "explicit"
+ [context]
+ client_name = "context"
EOH
content
end
@@ -505,10 +505,10 @@ EOH
context "and contains both node_name and client_name" do
let(:content) do
- content = <<EOH
-[default]
-node_name = 'barney'
-client_name = 'barney'
+ content = <<~EOH
+ [default]
+ node_name = 'barney'
+ client_name = 'barney'
EOH
content
end
diff --git a/ext/win32-eventlog/Rakefile b/ext/win32-eventlog/Rakefile
index 5b1186cf13..3bdf7f91d8 100644
--- a/ext/win32-eventlog/Rakefile
+++ b/ext/win32-eventlog/Rakefile
@@ -22,8 +22,8 @@ CC = "gcc"
ensure_present [MC, RC, CC]
-task :build => [EVT_RESOURCE_OBJECT, EVT_SHARED_OBJECT]
-task :default => [:build, :register]
+task build: [EVT_RESOURCE_OBJECT, EVT_SHARED_OBJECT]
+task default: [:build, :register]
file EVT_RC_FILE => EVT_MC_FILE do
sh "#{MC} #{EVT_MC_FILE}"
@@ -37,15 +37,15 @@ file EVT_SHARED_OBJECT => EVT_RESOURCE_OBJECT do
sh "#{CC} -o #{EVT_SHARED_OBJECT} -shared #{EVT_RESOURCE_OBJECT}"
end
-task :register => EVT_SHARED_OBJECT do
+task register: EVT_SHARED_OBJECT do
require "win32/eventlog"
dll_file = File.expand_path(EVT_SHARED_OBJECT)
begin
Win32::EventLog.add_event_source(
- :source => "Application",
- :key_name => "Chef",
- :event_message_file => dll_file,
- :category_message_file => dll_file
+ source: "Application",
+ key_name: "Chef",
+ event_message_file: dll_file,
+ category_message_file: dll_file
)
rescue Errno::EIO => e
puts "Skipping event log registration due to missing privileges: #{e}"
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index 656a0e364f..3120b58cc0 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -53,7 +53,7 @@ class Chef
set_or_return(
:name,
arg,
- :regex => /^[\-[:alnum:]_\.]+$/
+ regex: /^[\-[:alnum:]_\.]+$/
)
end
@@ -65,7 +65,7 @@ class Chef
set_or_return(
:admin,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -77,7 +77,7 @@ class Chef
set_or_return(
:public_key,
arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -90,7 +90,7 @@ class Chef
set_or_return(
:validator,
arg,
- :kind_of => [TrueClass, FalseClass]
+ kind_of: [TrueClass, FalseClass]
)
end
@@ -102,7 +102,7 @@ class Chef
set_or_return(
:private_key,
arg,
- :kind_of => [String, FalseClass]
+ kind_of: [String, FalseClass]
)
end
@@ -145,7 +145,7 @@ class Chef
end
def self.http_api
- Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
+ Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" })
end
def self.reregister(name)
@@ -183,18 +183,18 @@ class Chef
# Save this client via the REST API, returns a hash including the private key
def save
- http_api.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator })
+ http_api.put("clients/#{name}", { name: name, admin: admin, validator: validator })
rescue Net::HTTPServerException => e
# If that fails, go ahead and try and update it
if e.response.code == "404"
- http_api.post("clients", { :name => name, :admin => admin, :validator => validator })
+ http_api.post("clients", { name: name, admin: admin, validator: validator })
else
raise e
end
end
def reregister
- reregistered_self = http_api.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator, :private_key => true })
+ reregistered_self = http_api.put("clients/#{name}", { name: name, admin: admin, validator: validator, private_key: true })
if reregistered_self.respond_to?(:[])
private_key(reregistered_self["private_key"])
else
@@ -219,7 +219,7 @@ class Chef
end
def http_api
- @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
+ @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" })
end
end
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb
index 27e1f18c17..6cbb071020 100644
--- a/lib/chef/api_client/registration.rb
+++ b/lib/chef/api_client/registration.rb
@@ -139,7 +139,7 @@ class Chef
end
def put_data
- base_put_data = { :name => name, :admin => false }
+ base_put_data = { name: name, admin: false }
if self_generate_keys?
base_put_data[:public_key] = generated_public_key
else
@@ -149,7 +149,7 @@ class Chef
end
def post_data
- post_data = { :name => name, :admin => false }
+ post_data = { name: name, admin: false }
post_data[:public_key] = generated_public_key if self_generate_keys?
post_data
end
@@ -157,9 +157,9 @@ class Chef
def http_api
@http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url],
{
- :api_version => "0",
- :client_name => Chef::Config[:validation_client_name],
- :signing_key_filename => Chef::Config[:validation_key],
+ api_version: "0",
+ client_name: Chef::Config[:validation_client_name],
+ signing_key_filename: Chef::Config[:validation_key],
}
)
end
diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb
index 7fbff6d6ba..645016c5b9 100644
--- a/lib/chef/api_client_v1.rb
+++ b/lib/chef/api_client_v1.rb
@@ -57,15 +57,15 @@ class Chef
end
def chef_rest_v0
- @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0", :inflate_json_class => false })
+ @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0", inflate_json_class: false })
end
def chef_rest_v1
- @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false })
+ @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false })
end
def self.http_api
- Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false })
+ Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false })
end
# Gets or sets the client name.
@@ -76,7 +76,7 @@ class Chef
set_or_return(
:name,
arg,
- :regex => /^[\-[:alnum:]_\.]+$/
+ regex: /^[\-[:alnum:]_\.]+$/
)
end
@@ -88,7 +88,7 @@ class Chef
set_or_return(
:admin,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -100,7 +100,7 @@ class Chef
set_or_return(
:public_key,
arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -113,7 +113,7 @@ class Chef
set_or_return(
:validator,
arg,
- :kind_of => [TrueClass, FalseClass]
+ kind_of: [TrueClass, FalseClass]
)
end
@@ -126,7 +126,7 @@ class Chef
set_or_return(
:private_key,
arg,
- :kind_of => [String, TrueClass, FalseClass]
+ kind_of: [String, TrueClass, FalseClass]
)
end
@@ -138,7 +138,7 @@ class Chef
set_or_return(
:create_key,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -226,7 +226,7 @@ class Chef
def reregister
# Try API V0 and if it fails due to V0 not being supported, raise the proper error message.
# reregister only supported in API V0 or lesser.
- reregistered_self = chef_rest_v0.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator, :private_key => true })
+ reregistered_self = chef_rest_v0.put("clients/#{name}", { name: name, admin: admin, validator: validator, private_key: true })
if reregistered_self.respond_to?(:[])
private_key(reregistered_self["private_key"])
else
@@ -254,7 +254,7 @@ class Chef
# it was never implemented, we will simply ignore that functionality
# as it is being deprecated.
# Delete this comment after V0 support is dropped.
- payload = { :name => name }
+ payload = { name: name }
payload[:validator] = validator unless validator.nil?
# DEPRECATION
@@ -277,11 +277,11 @@ class Chef
# Create the client via the REST API
def create
payload = {
- :name => name,
- :validator => validator,
+ name: name,
+ validator: validator,
# this field is ignored in API V1, but left for backwards-compat,
# can remove after OSC 11 support is finished?
- :admin => admin,
+ admin: admin,
}
begin
# try API V1
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index ec627ada2e..7325d89e1e 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -32,86 +32,86 @@ class Chef::Application::Apply < Chef::Application
banner "Usage: chef-apply [RECIPE_FILE | -e RECIPE_TEXT | -s] [OPTIONS]"
option :execute,
- :short => "-e RECIPE_TEXT",
- :long => "--execute RECIPE_TEXT",
- :description => "Execute resources supplied in a string",
- :proc => nil
+ short: "-e RECIPE_TEXT",
+ long: "--execute RECIPE_TEXT",
+ description: "Execute resources supplied in a string",
+ proc: nil
option :stdin,
- :short => "-s",
- :long => "--stdin",
- :description => "Execute resources read from STDIN",
- :boolean => true
+ short: "-s",
+ long: "--stdin",
+ description: "Execute resources read from STDIN",
+ boolean: true
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
attr_reader :json_attribs
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index ffb997f187..6e574e682f 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -38,172 +38,171 @@ class Chef::Application::Client < Chef::Application
SELF_PIPE = []
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :description => "The configuration file to use"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ description: "The configuration file to use"
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (auto, trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (auto, trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
- :proc => nil
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
+ proc: nil
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :user,
- :short => "-u USER",
- :long => "--user USER",
- :description => "User to set privilege to",
- :proc => nil
+ short: "-u USER",
+ long: "--user USER",
+ description: "User to set privilege to",
+ proc: nil
option :group,
- :short => "-g GROUP",
- :long => "--group GROUP",
- :description => "Group to set privilege to",
- :proc => nil
+ short: "-g GROUP",
+ long: "--group GROUP",
+ description: "Group to set privilege to",
+ proc: nil
unless Chef::Platform.windows?
option :daemonize,
- :short => "-d [WAIT]",
- :long => "--daemonize [WAIT]",
- :description =>
- "Daemonize the process. Accepts an optional integer which is the " \
+ short: "-d [WAIT]",
+ long: "--daemonize [WAIT]",
+ description: "Daemonize the process. Accepts an optional integer which is the " \
"number of seconds to wait before the first daemonized run.",
- :proc => lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
+ proc: lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
end
option :pid_file,
- :short => "-P PID_FILE",
- :long => "--pid PIDFILE",
- :description => "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid",
- :proc => nil
+ short: "-P PID_FILE",
+ long: "--pid PIDFILE",
+ description: "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid",
+ proc: nil
option :lockfile,
- :long => "--lockfile LOCKFILE",
- :description => "Set the lockfile location. Prevents multiple client processes from converging at the same time",
- :proc => nil
+ long: "--lockfile LOCKFILE",
+ description: "Set the lockfile location. Prevents multiple client processes from converging at the same time",
+ proc: nil
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Run chef-client periodically, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Run chef-client periodically, in seconds",
+ proc: lambda { |s| s.to_i }
option :once,
- :long => "--once",
- :description => "Cancel any interval or splay options, run chef once and exit",
- :boolean => true
+ long: "--once",
+ description: "Cancel any interval or splay options, run chef once and exit",
+ boolean: true
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :node_name,
- :short => "-N NODE_NAME",
- :long => "--node-name NODE_NAME",
- :description => "The node name for this client",
- :proc => nil
+ short: "-N NODE_NAME",
+ long: "--node-name NODE_NAME",
+ description: "The node name for this client",
+ proc: nil
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :chef_server_url,
- :short => "-S CHEFSERVERURL",
- :long => "--server CHEFSERVERURL",
- :description => "The chef server URL",
- :proc => nil
+ short: "-S CHEFSERVERURL",
+ long: "--server CHEFSERVERURL",
+ description: "The chef server URL",
+ proc: nil
option :validation_key,
- :short => "-K KEY_FILE",
- :long => "--validation_key KEY_FILE",
- :description => "Set the validation key file location, used for registering new clients",
- :proc => nil
+ short: "-K KEY_FILE",
+ long: "--validation_key KEY_FILE",
+ description: "Set the validation key file location, used for registering new clients",
+ proc: nil
option :client_key,
- :short => "-k KEY_FILE",
- :long => "--client_key KEY_FILE",
- :description => "Set the client key file location",
- :proc => nil
+ short: "-k KEY_FILE",
+ long: "--client_key KEY_FILE",
+ description: "Set the client key file location",
+ proc: nil
option :named_run_list,
- :short => "-n NAMED_RUN_LIST",
- :long => "--named-run-list NAMED_RUN_LIST",
- :description => "Use a policyfile's named run list instead of the default run list"
+ short: "-n NAMED_RUN_LIST",
+ long: "--named-run-list NAMED_RUN_LIST",
+ description: "Use a policyfile's named run list instead of the default run list"
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef Environment on the node"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef Environment on the node"
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :override_runlist,
- :short => "-o RunlistItem,RunlistItem...",
- :long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items for a single run",
- :proc => lambda { |items|
+ short: "-o RunlistItem,RunlistItem...",
+ long: "--override-runlist RunlistItem,RunlistItem...",
+ description: "Replace current run list with specified items for a single run",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
@@ -211,97 +210,97 @@ class Chef::Application::Client < Chef::Application
}
option :runlist,
- :short => "-r RunlistItem,RunlistItem...",
- :long => "--runlist RunlistItem,RunlistItem...",
- :description => "Permanently replace current run list with specified items",
- :proc => lambda { |items|
+ short: "-r RunlistItem,RunlistItem...",
+ long: "--runlist RunlistItem,RunlistItem...",
+ description: "Permanently replace current run list with specified items",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
end
}
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :client_fork,
- :short => "-f",
- :long => "--[no-]fork",
- :description => "Fork client"
+ short: "-f",
+ long: "--[no-]fork",
+ description: "Fork client"
option :recipe_url,
- :long => "--recipe-url=RECIPE_URL",
- :description => "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
+ long: "--recipe-url=RECIPE_URL",
+ description: "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
option :enable_reporting,
- :short => "-R",
- :long => "--enable-reporting",
- :description => "Enable reporting data collection for chef runs",
- :boolean => true
+ short: "-R",
+ long: "--enable-reporting",
+ description: "Enable reporting data collection for chef runs",
+ boolean: true
option :local_mode,
- :short => "-z",
- :long => "--local-mode",
- :description => "Point chef-client at local repository",
- :boolean => true
+ short: "-z",
+ long: "--local-mode",
+ description: "Point chef-client at local repository",
+ boolean: true
option :chef_zero_host,
- :long => "--chef-zero-host HOST",
- :description => "Host to start chef-zero on"
+ long: "--chef-zero-host HOST",
+ description: "Host to start chef-zero on"
option :chef_zero_port,
- :long => "--chef-zero-port PORT",
- :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
+ long: "--chef-zero-port PORT",
+ description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
option :disable_config,
- :long => "--disable-config",
- :description => "Refuse to load a config file and use defaults. This is for development and not a stable API",
- :boolean => true
+ long: "--disable-config",
+ description: "Refuse to load a config file and use defaults. This is for development and not a stable API",
+ boolean: true
option :run_lock_timeout,
- :long => "--run-lock-timeout SECONDS",
- :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
- :proc => lambda { |s| s.to_i }
+ long: "--run-lock-timeout SECONDS",
+ description: "Set maximum duration to wait for another client run to finish, default is indefinitely.",
+ proc: lambda { |s| s.to_i }
if Chef::Platform.windows?
option :fatal_windows_admin_check,
- :short => "-A",
- :long => "--fatal-windows-admin-check",
- :description => "Fail the run when chef-client doesn't have administrator privileges on Windows",
- :boolean => true
+ short: "-A",
+ long: "--fatal-windows-admin-check",
+ description: "Fail the run when chef-client doesn't have administrator privileges on Windows",
+ boolean: true
end
option :audit_mode,
- :long => "--audit-mode MODE",
- :description => "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`",
- :proc => lambda { |mo| mo.tr("-", "_").to_sym }
+ long: "--audit-mode MODE",
+ description: "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`",
+ proc: lambda { |mo| mo.tr("-", "_").to_sym }
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
option :listen,
- :long => "--[no-]listen",
- :description => "Whether a local mode (-z) server binds to a port",
- :boolean => false
+ long: "--[no-]listen",
+ description: "Whether a local mode (-z) server binds to a port",
+ boolean: false
option :fips,
- :long => "--[no-]fips",
- :description => "Enable fips mode",
- :boolean => true
+ long: "--[no-]fips",
+ description: "Enable fips mode",
+ boolean: true
option :delete_entire_chef_repo,
- :long => "--delete-entire-chef-repo",
- :description => "DANGEROUS: does what it says, only useful with --recipe-url",
- :boolean => true
+ long: "--delete-entire-chef-repo",
+ description: "DANGEROUS: does what it says, only useful with --recipe-url",
+ boolean: true
option :skip_cookbook_sync,
- :long => "--[no-]skip-cookbook-sync",
- :description => "Use cached cookbooks without overwriting local differences from the server",
- :boolean => false
+ long: "--[no-]skip-cookbook-sync",
+ description: "Use cached cookbooks without overwriting local differences from the server",
+ boolean: false
IMMEDIATE_RUN_SIGNAL = "1".freeze
RECONFIGURE_SIGNAL = "H".freeze
@@ -338,7 +337,7 @@ class Chef::Application::Client < Chef::Application
else
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
- FileUtils.rm_rf(recipes_path, :secure => true)
+ FileUtils.rm_rf(recipes_path, secure: true)
end
Chef::Log.trace "Creating path #{Chef::Config.chef_repo_path} to extract recipes into"
FileUtils.mkdir_p(Chef::Config.chef_repo_path)
@@ -518,7 +517,7 @@ class Chef::Application::Client < Chef::Application
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index c972e9313e..2c8d886b27 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -28,129 +28,129 @@ class Chef::Application::Knife < Chef::Application
banner "Usage: knife sub-command (options)"
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :description => "The configuration file to use",
- :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ description: "The configuration file to use",
+ proc: lambda { |path| File.expand_path(path, Dir.pwd) }
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
verbosity_level = 0
option :verbosity,
- :short => "-V",
- :long => "--verbose",
- :description => "More verbose output. Use twice for max verbosity",
- :proc => Proc.new { verbosity_level += 1 },
- :default => 0
+ short: "-V",
+ long: "--verbose",
+ description: "More verbose output. Use twice for max verbosity",
+ proc: Proc.new { verbosity_level += 1 },
+ default: 0
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
option :editor,
- :short => "-e EDITOR",
- :long => "--editor EDITOR",
- :description => "Set the editor to use for interactive commands",
- :default => ENV["EDITOR"]
+ short: "-e EDITOR",
+ long: "--editor EDITOR",
+ description: "Set the editor to use for interactive commands",
+ default: ENV["EDITOR"]
option :disable_editing,
- :short => "-d",
- :long => "--disable-editing",
- :description => "Do not open EDITOR, just accept the data as is",
- :boolean => true,
- :default => false
+ short: "-d",
+ long: "--disable-editing",
+ description: "Do not open EDITOR, just accept the data as is",
+ boolean: true,
+ default: false
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true
option :node_name,
- :short => "-u USER",
- :long => "--user USER",
- :description => "API Client Username"
+ short: "-u USER",
+ long: "--user USER",
+ description: "API Client Username"
option :client_key,
- :short => "-k KEY",
- :long => "--key KEY",
- :description => "API Client Key",
- :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
+ short: "-k KEY",
+ long: "--key KEY",
+ description: "API Client Key",
+ proc: lambda { |path| File.expand_path(path, Dir.pwd) }
option :chef_server_url,
- :short => "-s URL",
- :long => "--server-url URL",
- :description => "Chef Server URL"
+ short: "-s URL",
+ long: "--server-url URL",
+ description: "Chef Server URL"
option :yes,
- :short => "-y",
- :long => "--yes",
- :description => "Say yes to all prompts for confirmation"
+ short: "-y",
+ long: "--yes",
+ description: "Say yes to all prompts for confirmation"
option :defaults,
- :long => "--defaults",
- :description => "Accept default values for all questions"
+ long: "--defaults",
+ description: "Accept default values for all questions"
option :print_after,
- :long => "--print-after",
- :description => "Show the data after a destructive operation"
+ long: "--print-after",
+ description: "Show the data after a destructive operation"
option :format,
- :short => "-F FORMAT",
- :long => "--format FORMAT",
- :description => "Which format to use for output",
- :default => "summary"
+ short: "-F FORMAT",
+ long: "--format FORMAT",
+ description: "Which format to use for output",
+ default: "summary"
option :local_mode,
- :short => "-z",
- :long => "--local-mode",
- :description => "Point knife commands at local repository instead of server",
- :boolean => true
+ short: "-z",
+ long: "--local-mode",
+ description: "Point knife commands at local repository instead of server",
+ boolean: true
option :chef_zero_host,
- :long => "--chef-zero-host HOST",
- :description => "Host to start chef-zero on"
+ long: "--chef-zero-host HOST",
+ description: "Host to start chef-zero on"
option :chef_zero_port,
- :long => "--chef-zero-port PORT",
- :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
+ long: "--chef-zero-port PORT",
+ description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
option :listen,
- :long => "--[no-]listen",
- :description => "Whether a local mode (-z) server binds to a port",
- :boolean => false
+ long: "--[no-]listen",
+ description: "Whether a local mode (-z) server binds to a port",
+ boolean: false
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :fips,
- :long => "--[no-]fips",
- :description => "Enable fips mode",
- :boolean => true,
- :default => nil
+ long: "--[no-]fips",
+ description: "Enable fips mode",
+ boolean: true,
+ default: nil
option :profile,
- :long => "--profile PROFILE",
- :description => "The credentials profile to select"
+ long: "--profile PROFILE",
+ description: "The credentials profile to select"
# Run knife
def run
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 646d68182c..cd364dc6ae 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -35,137 +35,137 @@ class Chef::Application::Solo < Chef::Application
include ChefConfig::Mixin::DotD
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => Chef::Config.platform_specific_path("/etc/chef/solo.rb"),
- :description => "The configuration file to use"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: Chef::Config.platform_specific_path("/etc/chef/solo.rb"),
+ description: "The configuration file to use"
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => !Chef::Platform.windows?,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: !Chef::Platform.windows?,
+ description: "Use colored output, defaults to enabled"
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location, defaults to STDOUT",
- :proc => nil
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location, defaults to STDOUT",
+ proc: nil
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :user,
- :short => "-u USER",
- :long => "--user USER",
- :description => "User to set privilege to",
- :proc => nil
+ short: "-u USER",
+ long: "--user USER",
+ description: "User to set privilege to",
+ proc: nil
option :group,
- :short => "-g GROUP",
- :long => "--group GROUP",
- :description => "Group to set privilege to",
- :proc => nil
+ short: "-g GROUP",
+ long: "--group GROUP",
+ description: "Group to set privilege to",
+ proc: nil
unless Chef::Platform.windows?
option :daemonize,
- :short => "-d",
- :long => "--daemonize",
- :description => "Daemonize the process",
- :proc => lambda { |p| true }
+ short: "-d",
+ long: "--daemonize",
+ description: "Daemonize the process",
+ proc: lambda { |p| true }
end
option :lockfile,
- :long => "--lockfile LOCKFILE",
- :description => "Set the lockfile location. Prevents multiple processes from converging at the same time",
- :proc => nil
+ long: "--lockfile LOCKFILE",
+ description: "Set the lockfile location. Prevents multiple processes from converging at the same time",
+ proc: nil
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Run chef-client periodically, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Run chef-client periodically, in seconds",
+ proc: lambda { |s| s.to_i }
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :node_name,
- :short => "-N NODE_NAME",
- :long => "--node-name NODE_NAME",
- :description => "The node name for this client",
- :proc => nil
+ short: "-N NODE_NAME",
+ long: "--node-name NODE_NAME",
+ description: "The node name for this client",
+ proc: nil
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :recipe_url,
- :short => "-r RECIPE_URL",
- :long => "--recipe-url RECIPE_URL",
- :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache."
+ short: "-r RECIPE_URL",
+ long: "--recipe-url RECIPE_URL",
+ description: "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache."
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :override_runlist,
- :short => "-o RunlistItem,RunlistItem...",
- :long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items",
- :proc => lambda { |items|
+ short: "-o RunlistItem,RunlistItem...",
+ long: "--override-runlist RunlistItem,RunlistItem...",
+ description: "Replace current run list with specified items",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
@@ -173,45 +173,45 @@ class Chef::Application::Solo < Chef::Application
}
option :client_fork,
- :short => "-f",
- :long => "--[no-]fork",
- :description => "Fork client"
+ short: "-f",
+ long: "--[no-]fork",
+ description: "Fork client"
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :ez,
- :long => "--ez",
- :description => "A memorial for Ezra Zygmuntowicz",
- :boolean => true
+ long: "--ez",
+ description: "A memorial for Ezra Zygmuntowicz",
+ boolean: true
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef Environment on the node"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef Environment on the node"
option :run_lock_timeout,
- :long => "--run-lock-timeout SECONDS",
- :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
- :proc => lambda { |s| s.to_i }
+ long: "--run-lock-timeout SECONDS",
+ description: "Set maximum duration to wait for another client run to finish, default is indefinitely.",
+ proc: lambda { |s| s.to_i }
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
option :delete_entire_chef_repo,
- :long => "--delete-entire-chef-repo",
- :description => "DANGEROUS: does what it says, only useful with --recipe-url",
- :boolean => true
+ long: "--delete-entire-chef-repo",
+ description: "DANGEROUS: does what it says, only useful with --recipe-url",
+ boolean: true
option :solo_legacy_mode,
- :long => "--legacy-mode",
- :description => "Run chef-solo in legacy mode",
- :boolean => true
+ long: "--legacy-mode",
+ description: "Run chef-solo in legacy mode",
+ boolean: true
attr_reader :chef_client_json
@@ -273,7 +273,7 @@ class Chef::Application::Solo < Chef::Application
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{recipes_path} before extract recipes into it"
- FileUtils.rm_rf(recipes_path, :secure => true)
+ FileUtils.rm_rf(recipes_path, secure: true)
end
Chef::Log.trace "Creating path #{recipes_path} to extract recipes into"
FileUtils.mkdir_p(recipes_path)
@@ -315,12 +315,12 @@ class Chef::Application::Solo < Chef::Application
private
def for_ezra
- puts <<-EOH
-For Ezra Zygmuntowicz:
- The man who brought you Chef Solo
- Early contributor to Chef
- Kind hearted open source advocate
- Rest in peace, Ezra.
+ puts <<~EOH
+ For Ezra Zygmuntowicz:
+ The man who brought you Chef Solo
+ Early contributor to Chef
+ Kind hearted open source advocate
+ Rest in peace, Ezra.
EOH
end
@@ -370,7 +370,7 @@ EOH
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 41dcc55d70..5fe4dbb9b7 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -37,27 +37,27 @@ class Chef
include Chef::Mixin::ShellOut
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
- :description => ""
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
+ description: ""
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location"
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location"
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Set the number of seconds to wait between chef-client runs",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Set the number of seconds to wait between chef-client runs",
+ proc: lambda { |s| s.to_i }
DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log"
@@ -197,11 +197,11 @@ class Chef
result = shell_out(
"chef-client.bat #{config_params}",
- :timeout => Chef::Config[:windows_service][:watchdog_timeout],
- :logger => Chef::Log
+ timeout: Chef::Config[:windows_service][:watchdog_timeout],
+ logger: Chef::Log
)
- Chef::Log.trace "#{result.stdout}"
- Chef::Log.trace "#{result.stderr}"
+ Chef::Log.trace (result.stdout).to_s
+ Chef::Log.trace (result.stderr).to_s
rescue Mixlib::ShellOut::CommandTimeout => e
Chef::Log.error "chef-client timed out\n(#{e})"
Chef::Log.error(<<-EOF)
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 5c572bc260..bff4a7511a 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -37,38 +37,38 @@ class Chef
include Mixlib::CLI
option :action,
- :short => "-a ACTION",
- :long => "--action ACTION",
- :default => "status",
- :description => "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)"
+ short: "-a ACTION",
+ long: "--action ACTION",
+ default: "status",
+ description: "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)"
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
- :description => "The configuration file to use for chef runs"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
+ description: "The configuration file to use for chef runs"
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location for chef-service"
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location for chef-service"
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
def initialize(service_options)
# having to call super in initialize is the most annoying
@@ -114,22 +114,22 @@ class Chef
cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR)
::Win32::Service.new(
- :service_name => @service_name,
- :display_name => @service_display_name,
- :description => @service_description,
+ service_name: @service_name,
+ display_name: @service_display_name,
+ description: @service_description,
# Prior to 0.8.5, win32-service creates interactive services by default,
# and we don't want that, so we need to override the service type.
- :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
- :start_type => ::Win32::Service::SERVICE_AUTO_START,
- :binary_path_name => cmd,
- :service_start_name => @service_start_name,
- :password => @password,
- :dependencies => @dependencies
+ service_type: ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
+ start_type: ::Win32::Service::SERVICE_AUTO_START,
+ binary_path_name: cmd,
+ service_start_name: @service_start_name,
+ password: @password,
+ dependencies: @dependencies
)
unless @delayed_start.nil?
::Win32::Service.configure(
- :service_name => @service_name,
- :delayed_start => @delayed_start
+ service_name: @service_name,
+ delayed_start: @delayed_start
)
end
puts "Service '#{@service_name}' has successfully been installed."
diff --git a/lib/chef/audit/audit_event_proxy.rb b/lib/chef/audit/audit_event_proxy.rb
index e2e6ab1ede..1cb8545d28 100644
--- a/lib/chef/audit/audit_event_proxy.rb
+++ b/lib/chef/audit/audit_event_proxy.rb
@@ -79,12 +79,12 @@ class Chef
outermost_group_desc = describe_groups.shift
[outermost_group_desc, {
- :name => example.description,
- :desc => example.full_description,
- :resource_type => resource_type,
- :resource_name => resource_name,
- :context => describe_groups,
- :line_number => example.metadata[:line_number],
+ name: example.description,
+ desc: example.full_description,
+ resource_type: resource_type,
+ resource_name: resource_name,
+ context: describe_groups,
+ line_number: example.metadata[:line_number],
}]
end
diff --git a/lib/chef/audit/control_group_data.rb b/lib/chef/audit/control_group_data.rb
index 476ebe95e9..8825860023 100644
--- a/lib/chef/audit/control_group_data.rb
+++ b/lib/chef/audit/control_group_data.rb
@@ -37,11 +37,11 @@ class Chef
def to_hash
{
- :node_name => node_name,
- :run_id => run_id,
- :start_time => start_time,
- :end_time => end_time,
- :control_groups => control_groups.collect { |c| c.to_hash },
+ node_name: node_name,
+ run_id: run_id,
+ start_time: start_time,
+ end_time: end_time,
+ control_groups: control_groups.collect { |c| c.to_hash },
}
end
end
@@ -81,11 +81,11 @@ class Chef
# they appeared in the recipe
controls.sort! { |x, y| x.line_number <=> y.line_number }
h = {
- :name => name,
- :status => status,
- :number_succeeded => number_succeeded,
- :number_failed => number_failed,
- :controls => controls.collect { |c| c.to_hash },
+ name: name,
+ status: status,
+ number_succeeded: number_succeeded,
+ number_failed: number_failed,
+ controls: controls.collect { |c| c.to_hash },
}
# If there is a duplicate key, metadata will overwrite it
add_display_only_data(h).merge(metadata)
@@ -124,11 +124,11 @@ class Chef
def to_hash
h = {
- :name => name,
- :status => status,
- :details => details,
- :resource_type => resource_type,
- :resource_name => resource_name,
+ name: name,
+ status: status,
+ details: details,
+ resource_type: resource_type,
+ resource_name: resource_name,
}
h[:context] = context || []
h
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index f6fed3fc64..847d5efbd5 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -148,7 +148,7 @@ class Chef
def configure_specinfra
if Chef::Platform.windows?
Specinfra.configuration.backend = :cmd
- Specinfra.configuration.os = { :family => "windows" }
+ Specinfra.configuration.os = { family: "windows" }
else
Specinfra.configuration.backend = :exec
end
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 697c2db232..c42f08a462 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -537,9 +537,9 @@ class Chef
if chef_fs.versioned_cookbooks || path[0] == "cookbook_artifacts"
result = with_entry([ path[0] ]) do |entry|
# list /cookbooks/name = filter /cookbooks/name-version down to name
- entry.children.map { |child| split_name_version(child.name) }.
- select { |name, version| name == path[1] }.
- map { |name, version| version }
+ entry.children.map { |child| split_name_version(child.name) }
+ .select { |name, version| name == path[1] }
+ .map { |name, version| version }
end
if result.empty?
raise ChefZero::DataStore::DataNotFoundError.new(path)
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 0725426275..2a41fb5870 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -173,7 +173,7 @@ class Chef
def create_chef_fs
require "chef/chef_fs/file_system/chef_server/chef_server_root_dir"
- Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir.new("remote", @chef_config, :cookbook_version => @cookbook_version)
+ Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir.new("remote", @chef_config, cookbook_version: @cookbook_version)
end
def local_fs
diff --git a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
index 63ce71ef40..3447e3500a 100644
--- a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
@@ -99,7 +99,7 @@ class Chef
end
def rest
- Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key, :raw_output => true, :api_version => "0")
+ Chef::ServerAPI.new(chef_server_url, client_name: chef_username, signing_key_filename: chef_private_key, raw_output: true, api_version: "0")
end
def get_json(path)
@@ -107,7 +107,7 @@ class Chef
end
def chef_rest
- Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key, :api_version => "0")
+ Chef::ServerAPI.new(chef_server_url, client_name: chef_username, signing_key_filename: chef_private_key, api_version: "0")
end
def api_path
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
index 4e8e68e364..e0eca5f6de 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb
@@ -74,7 +74,7 @@ class Chef
def upload_cookbook(other, options)
cookbook_to_upload = other.chef_object
cookbook_to_upload.freeze_version if options[:freeze]
- uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => chef_rest)
+ uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: chef_rest)
with_actual_cookbooks_dir(other.parent.file_path) do
uploader.upload_cookbooks
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
index adaffb99a7..344a3deecc 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
@@ -40,7 +40,7 @@ class Chef
end
def write(contents)
- desired_invites = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false))
+ desired_invites = minimize_value(Chef::JSONCompat.parse(contents, create_additions: false))
actual_invites = _read_json.inject({}) { |h, val| h[val["username"]] = val["id"]; h }
invites = actual_invites.keys
(desired_invites - invites).each do |invite|
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
index 7e9c7141c4..a780ddd97b 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
@@ -40,7 +40,7 @@ class Chef
end
def write(contents)
- desired_members = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false))
+ desired_members = minimize_value(Chef::JSONCompat.parse(contents, create_additions: false))
members = minimize_value(_read_json)
(desired_members - members).each do |member|
begin
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
index c16c5ad4d7..876ad7282b 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
@@ -177,7 +177,7 @@ class Chef
if data_handler
object = data_handler.normalize_for_put(object, self)
data_handler.verify_integrity(object, self) do |error|
- raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, nil, "#{error}")
+ raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, nil, error.to_s)
end
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
index 8da3718136..94c1a5b695 100644
--- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
@@ -78,7 +78,7 @@ class Chef
cookbook_to_upload.freeze_version if options[:freeze]
# Instantiate a new uploader based on the proxy loader
- uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => chef_rest)
+ uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: chef_rest)
with_actual_cookbooks_dir(temp_cookbooks_path) do
uploader.upload_cookbooks
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
index b296901dd1..8e64e3ca06 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
@@ -64,7 +64,7 @@ class Chef
def write(cookbook_path, cookbook_version_json, from_fs)
# Use the copy/diff algorithm to copy it down so we don't destroy
# chefignored data. This is terribly un-thread-safe.
- Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, self, nil, { :purge => true })
+ Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, self, nil, { purge: true })
# Write out .uploaded-cookbook-version.json
# cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
index 90b8c88cff..c840fad126 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
@@ -52,9 +52,9 @@ class Chef
end
def children
- entries = Dir.entries(file_path).sort.
- map { |child_name| make_child_entry(child_name) }.
- select { |child| child && can_have_child?(child.name, child.dir?) }
+ entries = Dir.entries(file_path).sort
+ .map { |child_name| make_child_entry(child_name) }
+ .select { |child| child && can_have_child?(child.name, child.dir?) }
entries.select { |entry| !(entry.dir? && entry.children.size == 0 ) }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
diff --git a/lib/chef/chef_fs/file_system/repository/directory.rb b/lib/chef/chef_fs/file_system/repository/directory.rb
index 328cf92b03..d3f8d84324 100644
--- a/lib/chef/chef_fs/file_system/repository/directory.rb
+++ b/lib/chef/chef_fs/file_system/repository/directory.rb
@@ -71,9 +71,9 @@ class Chef
def children
return FileSystemCache.instance.children(file_path) if FileSystemCache.instance.exist?(file_path)
- children = dir_ls.sort.
- map { |child_name| make_child_entry(child_name) }.
- select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
+ children = dir_ls.sort
+ .map { |child_name| make_child_entry(child_name) }
+ .select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
FileSystemCache.instance.set_children(file_path, children)
rescue Errno::ENOENT => e
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
index 45ae002521..183fcda26d 100644
--- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
@@ -80,9 +80,9 @@ class Chef
def children
# Except cookbooks and data bag dirs, all things must be json files
- Dir.entries(file_path).sort.
- map { |child_name| make_child_entry(child_name) }.
- select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
+ Dir.entries(file_path).sort
+ .map { |child_name| make_child_entry(child_name) }
+ .select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb
index 1731e19ce1..36445e5680 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/lib/chef/chef_fs/knife.rb
@@ -45,16 +45,16 @@ class Chef
end
option :repo_mode,
- :long => "--repo-mode MODE",
- :description => "Specifies the local repository layout. Values: static, everything, hosted_everything. Default: everything/hosted_everything"
+ long: "--repo-mode MODE",
+ description: "Specifies the local repository layout. Values: static, everything, hosted_everything. Default: everything/hosted_everything"
option :chef_repo_path,
- :long => "--chef-repo-path PATH",
- :description => "Overrides the location of chef repo. Default is specified by chef_repo_path in the config"
+ long: "--chef-repo-path PATH",
+ description: "Overrides the location of chef repo. Default is specified by chef_repo_path in the config"
option :concurrency,
- :long => "--concurrency THREADS",
- :description => "Maximum number of simultaneous requests to send (default: 10)"
+ long: "--concurrency THREADS",
+ description: "Maximum number of simultaneous requests to send (default: 10)"
def configure_chef
super
diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb
index 32de61e048..eee555fc93 100644
--- a/lib/chef/chef_fs/parallelizer.rb
+++ b/lib/chef/chef_fs/parallelizer.rb
@@ -45,7 +45,7 @@ class Chef
end
def parallel_do(enumerable, options = {}, &block)
- ParallelEnumerable.new(@tasks, enumerable, options.merge(:ordered => false), &block).wait
+ ParallelEnumerable.new(@tasks, enumerable, options.merge(ordered: false), &block).wait
end
def stop(wait = true, timeout = nil)
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index b139a8d489..c864c30505 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -34,7 +34,7 @@ class Chef
@relative_path = /#{Regexp.escape(@cookbook_path)}\/(.+)$/
@metadata_loaded = false
@cookbook_settings = {
- :all_files => {},
+ all_files: {},
}
@metadata_filenames = []
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index c378cb75b6..03e2d7a090 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -61,10 +61,10 @@ class Chef
:source_url, :issues_url, :privacy, :chef_versions, :ohai_versions,
:gems ]
- VERSION_CONSTRAINTS = { :depends => DEPENDENCIES,
- :provides => PROVIDING,
- :chef_version => CHEF_VERSIONS,
- :ohai_version => OHAI_VERSIONS }
+ VERSION_CONSTRAINTS = { depends: DEPENDENCIES,
+ provides: PROVIDING,
+ chef_version: CHEF_VERSIONS,
+ ohai_version: OHAI_VERSIONS }
include Chef::Mixin::ParamsValidate
include Chef::Mixin::FromFile
@@ -161,7 +161,7 @@ class Chef
set_or_return(
:maintainer,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -176,7 +176,7 @@ class Chef
set_or_return(
:maintainer_email,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -191,7 +191,7 @@ class Chef
set_or_return(
:license,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -206,7 +206,7 @@ class Chef
set_or_return(
:description,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -221,7 +221,7 @@ class Chef
set_or_return(
:long_description,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -252,7 +252,7 @@ class Chef
set_or_return(
:name,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -409,17 +409,17 @@ class Chef
validate(
options,
{
- :display_name => { :kind_of => String },
- :description => { :kind_of => String },
- :choice => { :kind_of => [ Array ], :default => [] },
- :calculated => { :equal_to => [ true, false ], :default => false },
- :type => { :equal_to => %w{string array hash symbol boolean numeric}, :default => "string" },
- :required => { :equal_to => [ "required", "recommended", "optional", true, false ], :default => "optional" },
- :recipes => { :kind_of => [ Array ], :default => [] },
- :default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] },
- :source_url => { :kind_of => String },
- :issues_url => { :kind_of => String },
- :privacy => { :kind_of => [ TrueClass, FalseClass ] },
+ display_name: { kind_of: String },
+ description: { kind_of: String },
+ choice: { kind_of: [ Array ], default: [] },
+ calculated: { equal_to: [ true, false ], default: false },
+ type: { equal_to: %w{string array hash symbol boolean numeric}, default: "string" },
+ required: { equal_to: [ "required", "recommended", "optional", true, false ], default: "optional" },
+ recipes: { kind_of: [ Array ], default: [] },
+ default: { kind_of: [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] },
+ source_url: { kind_of: String },
+ issues_url: { kind_of: String },
+ privacy: { kind_of: [ TrueClass, FalseClass ] },
}
)
options[:required] = remap_required_attribute(options[:required]) unless options[:required].nil?
@@ -556,7 +556,7 @@ class Chef
set_or_return(
:source_url,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -571,7 +571,7 @@ class Chef
set_or_return(
:issues_url,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -588,7 +588,7 @@ class Chef
set_or_return(
:privacy,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -649,14 +649,14 @@ class Chef
elsif version_constraints.size == 1
version_constraints.first
else
- msg = <<-OBSOLETED
-The dependency specification syntax you are using is no longer valid. You may not
-specify more than one version constraint for a particular cookbook.
-Consult https://docs.chef.io/config_rb_metadata.html for the updated syntax.
-
-Called by: #{caller_name} '#{dep_name}', #{version_constraints.map { |vc| vc.inspect }.join(", ")}
-Called from:
-#{caller[0...5].map { |line| " " + line }.join("\n")}
+ msg = <<~OBSOLETED
+ The dependency specification syntax you are using is no longer valid. You may not
+ specify more than one version constraint for a particular cookbook.
+ Consult https://docs.chef.io/config_rb_metadata.html for the updated syntax.
+
+ Called by: #{caller_name} '#{dep_name}', #{version_constraints.map { |vc| vc.inspect }.join(", ")}
+ Called from:
+ #{caller[0...5].map { |line| " " + line }.join("\n")}
OBSOLETED
raise Exceptions::ObsoleteDependencySyntax, msg
end
@@ -667,15 +667,15 @@ OBSOLETED
rescue Chef::Exceptions::InvalidVersionConstraint => e
Log.debug(e)
- msg = <<-INVALID
-The version constraint syntax you are using is not valid. If you recently
-upgraded to Chef 0.10.0, be aware that you no may longer use "<<" and ">>" for
-'less than' and 'greater than'; use '<' and '>' instead.
-Consult https://docs.chef.io/config_rb_metadata.html for more information.
+ msg = <<~INVALID
+ The version constraint syntax you are using is not valid. If you recently
+ upgraded to Chef 0.10.0, be aware that you no may longer use "<<" and ">>" for
+ 'less than' and 'greater than'; use '<' and '>' instead.
+ Consult https://docs.chef.io/config_rb_metadata.html for more information.
-Called by: #{caller_name} '#{dep_name}', '#{constraint_str}'
-Called from:
-#{caller[0...5].map { |line| " " + line }.join("\n")}
+ Called by: #{caller_name} '#{dep_name}', '#{constraint_str}'
+ Called from:
+ #{caller[0...5].map { |line| " " + line }.join("\n")}
INVALID
raise Exceptions::InvalidVersionConstraint, msg
end
@@ -689,7 +689,7 @@ INVALID
def validate_string_array(arry)
if arry.kind_of?(Array)
arry.each do |choice|
- validate( { :choice => choice }, { :choice => { :kind_of => String } } )
+ validate( { choice: choice }, { choice: { kind_of: String } } )
end
end
end
@@ -717,7 +717,7 @@ INVALID
end
opts[:choice].each do |choice|
- validate( { :choice => choice }, { :choice => { :kind_of => validator } } )
+ validate( { choice: choice }, { choice: { kind_of: validator } } )
end
end
end
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index 6df39fece3..6955abd6d7 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -143,7 +143,7 @@ class Chef
end
# Synchronizes all the cookbooks from the chef-server.
- #)
+ # )
# === Returns
# true:: Always returns true
def sync_cookbooks
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index 9adcee6b78..c0c5b57a60 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -236,13 +236,13 @@ class Chef
csum = checksum_cookbook_file(file)
@checksums[csum] = file
rs = Mash.new({
- :name => name,
- :path => path,
- :checksum => csum,
- :specificity => specificity,
+ name: name,
+ path: path,
+ checksum: csum,
+ specificity: specificity,
# full_path is not a part of the normal manifest, but is very useful to keep around.
# uploaders should strip this out.
- :full_path => file,
+ full_path: file,
})
manifest[:all_files] << rs
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index e4b45532f0..8611357e1a 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -115,10 +115,10 @@ class Chef
content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
signing_options = {
- :http_method => http_verb,
- :path => url.path,
- :user_id => user_id,
- :timestamp => timestamp }
+ http_method: http_verb,
+ path: url.path,
+ user_id: user_id,
+ timestamp: timestamp }
(content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || ""))
headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key))
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index e79a7774eb..5780c61cc9 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -56,7 +56,7 @@ class Chef
end
checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil; memo }
- new_sandbox = rest.post("sandboxes", { :checksums => checksums })
+ new_sandbox = rest.post("sandboxes", { checksums: checksums })
Chef::Log.info("Uploading files")
@@ -83,7 +83,7 @@ class Chef
# in eventual consistency)
retries = 0
begin
- rest.put(sandbox_url, { :is_completed => true })
+ rest.put(sandbox_url, { is_completed: true })
rescue Net::HTTPServerException => e
if e.message =~ /^400/ && (retries += 1) <= 5
sleep 2
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index c5e2b38c94..9a71d89abb 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -54,7 +54,7 @@ class Chef
set_or_return(
:name,
arg,
- :regex => VALID_NAME
+ regex: VALID_NAME
)
end
@@ -157,7 +157,7 @@ class Chef
self
end
- #create a data bag via RESTful API
+ # create a data bag via RESTful API
def create
chef_server_rest.post("data", self)
self
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 388da78dad..01ec4cf77e 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -81,7 +81,7 @@ class Chef
set_or_return(
:data_bag,
arg,
- :regex => /^[\-[:alnum:]_]+$/
+ regex: /^[\-[:alnum:]_]+$/
)
end
diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb
index 2ebad7e039..1dc0a8d41b 100644
--- a/lib/chef/dsl/reboot_pending.rb
+++ b/lib/chef/dsl/reboot_pending.rb
@@ -37,7 +37,7 @@ class Chef
# due to a file being in use (usually a temporary file and a system file)
# \??\c:\temp\test.sys!\??\c:\winnt\system32\test.sys
# http://technet.microsoft.com/en-us/library/cc960241.aspx
- registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }) ||
+ registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }) ||
# RebootRequired key contains Update IDs with a value of 1 if they require a reboot.
# The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update
diff --git a/lib/chef/encrypted_data_bag_item/encryptor.rb b/lib/chef/encrypted_data_bag_item/encryptor.rb
index 8d34033db6..21783503f4 100644
--- a/lib/chef/encrypted_data_bag_item/encryptor.rb
+++ b/lib/chef/encrypted_data_bag_item/encryptor.rb
@@ -123,7 +123,7 @@ class Chef::EncryptedDataBagItem
# Strings) that do not produce valid JSON when serialized without the
# wrapper.
def serialized_data
- FFI_Yajl::Encoder.encode(:json_wrapper => plaintext_data)
+ FFI_Yajl::Encoder.encode(json_wrapper: plaintext_data)
end
def self.encryptor_keys
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index be05b58989..61777fb7b4 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -57,7 +57,7 @@ class Chef
set_or_return(
:name,
arg,
- { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String }
+ { regex: /^[\-[:alnum:]_]+$/, kind_of: String }
)
end
@@ -65,7 +65,7 @@ class Chef
set_or_return(
:description,
arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -73,7 +73,7 @@ class Chef
set_or_return(
:default_attributes,
arg,
- :kind_of => Hash
+ kind_of: Hash
)
end
@@ -85,7 +85,7 @@ class Chef
set_or_return(
:override_attributes,
arg,
- :kind_of => Hash
+ kind_of: Hash
)
end
@@ -98,8 +98,8 @@ class Chef
:cookbook_versions,
arg,
{
- :kind_of => Hash,
- :callbacks => {
+ kind_of: Hash,
+ callbacks: {
"should be a valid set of cookbook version requirements" => lambda { |cv| Chef::Environment.validate_cookbook_versions(cv) },
},
}
@@ -108,10 +108,10 @@ class Chef
def cookbook(cookbook, version)
validate({
- :version => version,
+ version: version,
}, {
- :version => {
- :callbacks => { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } },
+ version: {
+ callbacks: { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } },
},
})
@cookbook_versions[cookbook] = version
diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb
index 1ff87945e7..860d049314 100644
--- a/lib/chef/event_loggers/windows_eventlog.rb
+++ b/lib/chef/event_loggers/windows_eventlog.rb
@@ -47,36 +47,36 @@ class Chef
def run_start(version)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::INFO_TYPE,
- :source => SOURCE,
- :event_id => RUN_START_EVENT_ID,
- :data => [version]
+ event_type: ::Win32::EventLog::INFO_TYPE,
+ source: SOURCE,
+ event_id: RUN_START_EVENT_ID,
+ data: [version]
)
end
def run_started(run_status)
@run_status = run_status
@eventlog.report_event(
- :event_type => ::Win32::EventLog::INFO_TYPE,
- :source => SOURCE,
- :event_id => RUN_STARTED_EVENT_ID,
- :data => [run_status.run_id]
+ event_type: ::Win32::EventLog::INFO_TYPE,
+ source: SOURCE,
+ event_id: RUN_STARTED_EVENT_ID,
+ data: [run_status.run_id]
)
end
def run_completed(node)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::INFO_TYPE,
- :source => SOURCE,
- :event_id => RUN_COMPLETED_EVENT_ID,
- :data => [@run_status.run_id, @run_status.elapsed_time.to_s]
+ event_type: ::Win32::EventLog::INFO_TYPE,
+ source: SOURCE,
+ event_id: RUN_COMPLETED_EVENT_ID,
+ data: [@run_status.run_id, @run_status.elapsed_time.to_s]
)
end
- #Failed chef-client run %1 in %2 seconds.
- #Exception type: %3
- #Exception message: %4
- #Exception backtrace: %5
+ # Failed chef-client run %1 in %2 seconds.
+ # Exception type: %3
+ # Exception message: %4
+ # Exception backtrace: %5
def run_failed(e)
data =
if @run_status
@@ -87,10 +87,10 @@ class Chef
end
@eventlog.report_event(
- :event_type => ::Win32::EventLog::ERROR_TYPE,
- :source => SOURCE,
- :event_id => RUN_FAILED_EVENT_ID,
- :data => data + [e.class.name,
+ event_type: ::Win32::EventLog::ERROR_TYPE,
+ source: SOURCE,
+ event_id: RUN_FAILED_EVENT_ID,
+ data: data + [e.class.name,
e.message,
e.backtrace.join("\n")]
)
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 1ed71d2a55..ca388d33cd 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -398,9 +398,9 @@ class Chef
# length declared in the http response.
class ContentLengthMismatch < RuntimeError
def initialize(response_length, content_length)
- super <<-EOF
-Response body length #{response_length} does not match HTTP Content-Length header #{content_length}.
-This error is most often caused by network issues (proxies, etc) outside of chef-client.
+ super <<~EOF
+ Response body length #{response_length} does not match HTTP Content-Length header #{content_length}.
+ This error is most often caused by network issues (proxies, etc) outside of chef-client.
EOF
end
end
diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb
index 8e9bb1e3e4..f1c261ecd0 100644
--- a/lib/chef/file_cache.rb
+++ b/lib/chef/file_cache.rb
@@ -42,12 +42,12 @@ class Chef
def store(path, contents, perm = 0640)
validate(
{
- :path => path,
- :contents => contents,
+ path: path,
+ contents: contents,
},
{
- :path => { :kind_of => String },
- :contents => { :kind_of => String },
+ path: { kind_of: String },
+ contents: { kind_of: String },
}
)
@@ -68,12 +68,12 @@ class Chef
def move_to(file, path)
validate(
{
- :file => file,
- :path => path,
+ file: file,
+ path: path,
},
{
- :file => { :kind_of => String },
- :path => { :kind_of => String },
+ file: { kind_of: String },
+ path: { kind_of: String },
}
)
@@ -105,10 +105,10 @@ class Chef
def load(path, read = true)
validate(
{
- :path => path,
+ path: path,
},
{
- :path => { :kind_of => String },
+ path: { kind_of: String },
}
)
cache_path = create_cache_path(path, false)
@@ -131,10 +131,10 @@ class Chef
def delete(path)
validate(
{
- :path => path,
+ path: path,
},
{
- :path => { :kind_of => String },
+ path: { kind_of: String },
}
)
cache_path = create_cache_path(path, false)
@@ -178,10 +178,10 @@ class Chef
def has_key?(path)
validate(
{
- :path => path,
+ path: path,
},
{
- :path => { :kind_of => String },
+ path: { kind_of: String },
}
)
full_path = create_cache_path(path, false)
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 997577aa7b..fa309b67e7 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -96,7 +96,7 @@ class Chef
if @output.indent < 0
# This is left commented out for now. We need to uncomment it and fix at least one bug in
# the formatter, and then leave this line uncommented in the future.
- #Chef::Log.warn "Internal Formatter Error -- Attempt to indent by negative number of spaces"
+ # Chef::Log.warn "Internal Formatter Error -- Attempt to indent by negative number of spaces"
@output.indent = 0
end
@output.indent
@@ -110,7 +110,7 @@ class Chef
end
def registration_failed(node_name, exception, config)
- #A Formatters::ErrorDescription object
+ # A Formatters::ErrorDescription object
description = ErrorMapper.registration_failed(node_name, exception, config)
display_error(description)
end
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index d47ab73a30..19a6fafae6 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -254,7 +254,7 @@ class Chef
puts_line ""
puts_line "Audit phase exception:"
indent
- puts_line "#{error.message}"
+ puts_line (error.message).to_s
if error.backtrace
error.backtrace.each do |l|
puts_line l
@@ -285,7 +285,7 @@ class Chef
indent
end
# TODO: info about notifies
- start_line "* #{resource} action #{action}", :stream => resource
+ start_line "* #{resource} action #{action}", stream: resource
indent
end
@@ -318,7 +318,7 @@ class Chef
def resource_skipped(resource, action, conditional)
@skipped_resources += 1
# TODO: more info about conditional
- puts " (skipped due to #{conditional.short_description})", :stream => resource
+ puts " (skipped due to #{conditional.short_description})", stream: resource
unindent
end
@@ -329,12 +329,12 @@ class Chef
# Called when a resource has no converge actions, e.g., it was already correct.
def resource_up_to_date(resource, action)
@up_to_date_resources += 1
- puts " (up to date)", :stream => resource
+ puts " (up to date)", stream: resource
unindent
end
def resource_bypassed(resource, action, provider)
- puts " (Skipped: whyrun not supported by provider #{provider.class.name})", :stream => resource
+ puts " (Skipped: whyrun not supported by provider #{provider.class.name})", stream: resource
unindent
end
@@ -375,7 +375,7 @@ class Chef
end
def stream_output(stream, output, options = {})
- print(output, { :stream => stream }.merge(options))
+ print(output, { stream: stream }.merge(options))
end
# Called before handlers run
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index 53549ee77c..954eebafdb 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -26,79 +26,79 @@ class Chef
NETWORK_ERROR_CLASSES = [Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError]
def describe_network_errors(error_description)
- error_description.section("Networking Error:", <<-E)
-#{exception.message}
+ error_description.section("Networking Error:", <<~E)
+ #{exception.message}
-Your chef_server_url may be misconfigured, or the network could be down.
+ Your chef_server_url may be misconfigured, or the network could be down.
E
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
E
end
def describe_eof_error(error_description)
- error_description.section("Authentication Error:", <<-E)
-Received an EOF on transport socket. This almost always indicates a network
-error external to chef-client. Some causes include:
+ error_description.section("Authentication Error:", <<~E)
+ Received an EOF on transport socket. This almost always indicates a network
+ error external to chef-client. Some causes include:
- - Blocking ICMP Dest Unreachable (breaking Path MTU Discovery)
- - IPsec or VPN tunnelling / TCP Encapsulation MTU issues
- - Jumbo frames configured only on one side (breaking Path MTU)
- - Jumbo frames configured on a LAN that does not support them
- - Proxies or Load Balancers breaking large POSTs
- - Broken TCP offload in network drivers/hardware
+ - Blocking ICMP Dest Unreachable (breaking Path MTU Discovery)
+ - IPsec or VPN tunnelling / TCP Encapsulation MTU issues
+ - Jumbo frames configured only on one side (breaking Path MTU)
+ - Jumbo frames configured on a LAN that does not support them
+ - Proxies or Load Balancers breaking large POSTs
+ - Broken TCP offload in network drivers/hardware
-Try sending large pings to the destination:
+ Try sending large pings to the destination:
- windows: ping server.example.com -f -l 9999
- unix: ping server.example.com -s 9999
+ windows: ping server.example.com -f -l 9999
+ unix: ping server.example.com -s 9999
-Try sending large POSTs to the destination (any HTTP code returned is success):
+ Try sending large POSTs to the destination (any HTTP code returned is success):
- e.g.: curl http://server.example.com/`printf '%*s' 9999 '' | tr ' ' 'a'`
+ e.g.: curl http://server.example.com/`printf '%*s' 9999 '' | tr ' ' 'a'`
-Try disabling TCP Offload Engines (TOE) in your ethernet drivers.
+ Try disabling TCP Offload Engines (TOE) in your ethernet drivers.
- windows:
- Disable-NetAdapterChecksumOffload * -TcpIPv4 -UdpIPv4 -IpIPv4 -NoRestart
- Disable-NetAdapterLso * -IPv4 -NoRestart
- Set-NetAdapterAdvancedProperty * -DisplayName "Large Receive Offload (IPv4)" -DisplayValue Disabled –NoRestart
- Restart-NetAdapter *
- unix(bash):
- for i in rx tx sg tso ufo gso gro lro rxvlan txvlan rxhash; do /sbin/ethtool -K eth0 $i off; done
+ windows:
+ Disable-NetAdapterChecksumOffload * -TcpIPv4 -UdpIPv4 -IpIPv4 -NoRestart
+ Disable-NetAdapterLso * -IPv4 -NoRestart
+ Set-NetAdapterAdvancedProperty * -DisplayName "Large Receive Offload (IPv4)" -DisplayValue Disabled –NoRestart
+ Restart-NetAdapter *
+ unix(bash):
+ for i in rx tx sg tso ufo gso gro lro rxvlan txvlan rxhash; do /sbin/ethtool -K eth0 $i off; done
-In some cases the underlying virtualization layer (Xen, VMware, KVM, Hyper-V, etc) may have
-broken virtual networking code.
+ In some cases the underlying virtualization layer (Xen, VMware, KVM, Hyper-V, etc) may have
+ broken virtual networking code.
E
end
def describe_401_error(error_description)
if clock_skew?
- error_description.section("Authentication Error:", <<-E)
-Failed to authenticate to the chef server (http 401).
-The request failed because your clock has drifted by more than 15 minutes.
-Syncing your clock to an NTP Time source should resolve the issue.
+ error_description.section("Authentication Error:", <<~E)
+ Failed to authenticate to the chef server (http 401).
+ The request failed because your clock has drifted by more than 15 minutes.
+ Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:", <<-E)
-Failed to authenticate to the chef server (http 401).
+ error_description.section("Authentication Error:", <<~E)
+ Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
-node_name "#{username}"
-client_key "#{api_key}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
+ node_name "#{username}"
+ client_key "#{api_key}"
-If these settings are correct, your client_key may be invalid, or
-you may have a chef user with the same client name as this node.
+ If these settings are correct, your client_key may be invalid, or
+ you may have a chef user with the same client name as this node.
E
end
end
def describe_400_error(error_description)
- error_description.section("Invalid Request Data:", <<-E)
-The data in your request was invalid (HTTP 400).
+ error_description.section("Invalid Request Data:", <<~E)
+ The data in your request was invalid (HTTP 400).
E
error_description.section("Server Response:", format_rest_error)
end
@@ -110,11 +110,11 @@ E
min_server_version = version_header["min_version"]
max_server_version = version_header["max_version"]
- error_description.section("Incompatible server API version:", <<-E)
-This version of the API that this Chef request specified is not supported by the Chef server you sent this request to.
-The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
-Chef just made a request with an API version of #{client_api_version}.
-Please either update your Chef client or server to be a compatible set.
+ error_description.section("Incompatible server API version:", <<~E)
+ This version of the API that this Chef request specified is not supported by the Chef server you sent this request to.
+ The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
+ Chef just made a request with an API version of #{client_api_version}.
+ Please either update your Chef client or server to be a compatible set.
E
else
describe_http_error(error_description)
@@ -122,8 +122,8 @@ E
end
def describe_500_error(error_description)
- error_description.section("Unknown Server Error:", <<-E)
-The server had a fatal error attempting to load the node data.
+ error_description.section("Unknown Server Error:", <<~E)
+ The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
index eb1aa629ff..a046f1a277 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
@@ -56,12 +56,12 @@ class Chef
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error", <<-E)
-This client is not authorized to read some of the information required to
-access its cookbooks (HTTP 403).
+ error_description.section("Authorization Error", <<~E)
+ This client is not authorized to read some of the information required to
+ access its cookbooks (HTTP 403).
-To access its cookbooks, a client needs to be able to read its environment and
-all of the cookbooks in its expanded run list.
+ To access its cookbooks, a client needs to be able to read its environment and
+ all of the cookbooks in its expanded run list.
E
error_description.section("Expanded Run List:", expanded_run_list_ul)
error_description.section("Server Response:", format_rest_error)
@@ -115,11 +115,11 @@ E
explanation << "Error message: #{error_reasons["message"]}\n"
end
- explanation << <<EOM
-You might be able to resolve this issue with:
- 1-) Removing cookbook versions that depend on deleted cookbooks.
- 2-) Removing unused cookbook versions.
- 3-) Pinning exact cookbook versions using environments.
+ explanation << <<~EOM
+ You might be able to resolve this issue with:
+ 1-) Removing cookbook versions that depend on deleted cookbooks.
+ 2-) Removing unused cookbook versions.
+ 3-) Pinning exact cookbook versions using environments.
EOM
error_description.section("Cookbook dependency resolution error:", explanation)
end
diff --git a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
index c52dad4c09..a2f77c8287 100644
--- a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
@@ -43,12 +43,12 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:", <<-E)
-Your private key could not be loaded. If the key file exists, ensure that it is
-readable by chef-client.
+ error_description.section("Private Key Not Found:", <<~E)
+ Your private key could not be loaded. If the key file exists, ensure that it is
+ readable by chef-client.
E
- error_description.section("Relevant Config Settings:", <<-E)
-client_key "#{api_key}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ client_key "#{api_key}"
E
when EOFError
describe_eof_error(error_description)
@@ -69,13 +69,13 @@ E
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error", <<-E)
-Your client is not authorized to load the node data (HTTP 403).
+ error_description.section("Authorization Error", <<~E)
+ Your client is not authorized to load the node data (HTTP 403).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Possible Causes:", <<-E)
-* Your client (#{username}) may have misconfigured authorization permissions.
+ error_description.section("Possible Causes:", <<~E)
+ * Your client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
describe_400_error(error_description)
@@ -97,11 +97,11 @@ E
# one, e.g., PUT http://wrong.url/nodes/node-name becomes a GET after a
# redirect.
def describe_404_error(error_description)
- error_description.section("Resource Not Found:", <<-E)
-The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
+ error_description.section("Resource Not Found:", <<~E)
+ The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
E
end
diff --git a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
index c7c1454311..02e8b0d61a 100644
--- a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
@@ -26,26 +26,26 @@ class Chef
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Network Error:", <<-E)
-There was a network error connecting to the Chef Server:
-#{exception.message}
+ error_description.section("Network Error:", <<~E)
+ There was a network error connecting to the Chef Server:
+ #{exception.message}
E
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
-If your chef_server_url is correct, your network could be down.
+ If your chef_server_url is correct, your network could be down.
E
when Chef::Exceptions::PrivateKeyMissing
- error_description.section("Private Key Not Found:", <<-E)
-Your private key could not be loaded. If the key file exists, ensure that it is
-readable by chef-client.
+ error_description.section("Private Key Not Found:", <<~E)
+ Your private key could not be loaded. If the key file exists, ensure that it is
+ readable by chef-client.
E
- error_description.section("Relevant Config Settings:", <<-E)
-validation_key "#{api_key}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ validation_key "#{api_key}"
E
when Chef::Exceptions::InvalidRedirect
- error_description.section("Invalid Redirect:", <<-E)
-Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
+ error_description.section("Invalid Redirect:", <<~E)
+ Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
E
when EOFError
describe_eof_error(error_description)
@@ -59,50 +59,50 @@ E
case response
when Net::HTTPUnauthorized
if clock_skew?
- error_description.section("Authentication Error:", <<-E)
-Failed to authenticate to the chef server (http 401).
-The request failed because your clock has drifted by more than 15 minutes.
-Syncing your clock to an NTP Time source should resolve the issue.
+ error_description.section("Authentication Error:", <<~E)
+ Failed to authenticate to the chef server (http 401).
+ The request failed because your clock has drifted by more than 15 minutes.
+ Syncing your clock to an NTP Time source should resolve the issue.
E
else
- error_description.section("Authentication Error:", <<-E)
-Failed to authenticate to the chef server (http 401).
+ error_description.section("Authentication Error:", <<~E)
+ Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
-validation_client_name "#{username}"
-validation_key "#{api_key}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
+ validation_client_name "#{username}"
+ validation_key "#{api_key}"
-If these settings are correct, your validation_key may be invalid.
+ If these settings are correct, your validation_key may be invalid.
E
end
when Net::HTTPForbidden
- error_description.section("Authorization Error:", <<-E)
-Your validation client is not authorized to create the client for this node (HTTP 403).
+ error_description.section("Authorization Error:", <<~E)
+ Your validation client is not authorized to create the client for this node (HTTP 403).
E
- error_description.section("Possible Causes:", <<-E)
-* There may already be a client named "#{config[:node_name]}"
-* Your validation client (#{username}) may have misconfigured authorization permissions.
+ error_description.section("Possible Causes:", <<~E)
+ * There may already be a client named "#{config[:node_name]}"
+ * Your validation client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPBadRequest
- error_description.section("Invalid Request Data:", <<-E)
-The data in your request was invalid (HTTP 400).
+ error_description.section("Invalid Request Data:", <<~E)
+ The data in your request was invalid (HTTP 400).
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPNotFound
- error_description.section("Resource Not Found:", <<-E)
-The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
+ error_description.section("Resource Not Found:", <<~E)
+ The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
E
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
- error_description.section("Unknown Server Error:", <<-E)
-The server had a fatal error attempting to load the node data.
+ error_description.section("Unknown Server Error:", <<~E)
+ The server had a fatal error attempting to load the node data.
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
@@ -114,13 +114,13 @@ E
end
def username
- #config[:node_name]
+ # config[:node_name]
config[:validation_client_name]
end
def api_key
config[:validation_key]
- #config[:client_key]
+ # config[:client_key]
end
def server_url
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 94ecce88de..1cc147db7a 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -43,7 +43,7 @@ class Chef
error_description.section("Resource Declaration:", resource.sensitive ? "suppressed sensitive resource output" : recipe_snippet)
end
- error_description.section("Compiled Resource:", "#{resource.to_text}")
+ error_description.section("Compiled Resource:", (resource.to_text).to_s)
# Template errors get wrapped in an exception class that can show the relevant template code,
# so add them to the error output.
diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
index e94b347378..9d46465947 100644
--- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
@@ -36,10 +36,10 @@ class Chef
def add_explanation(error_description)
case exception
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
- error_description.section("Networking Error:", <<-E)
-#{exception.message}
+ error_description.section("Networking Error:", <<~E)
+ #{exception.message}
-Your chef_server_url may be misconfigured, or the network could be down.
+ Your chef_server_url may be misconfigured, or the network could be down.
E
when Net::HTTPServerException, Net::HTTPFatalError
humanize_http_exception(error_description)
@@ -76,35 +76,35 @@ E
response = exception.response
case response
when Net::HTTPUnauthorized
- error_description.section("Authentication Error:", <<-E)
-Failed to authenticate to the chef server (http 401).
+ error_description.section("Authentication Error:", <<~E)
+ Failed to authenticate to the chef server (http 401).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Relevant Config Settings:", <<-E)
-chef_server_url "#{server_url}"
-node_name "#{username}"
-client_key "#{api_key}"
+ error_description.section("Relevant Config Settings:", <<~E)
+ chef_server_url "#{server_url}"
+ node_name "#{username}"
+ client_key "#{api_key}"
-If these settings are correct, your client_key may be invalid.
+ If these settings are correct, your client_key may be invalid.
E
when Net::HTTPForbidden
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
- error_description.section("Authorization Error", <<-E)
-Your client is not authorized to load one or more of your roles (HTTP 403).
+ error_description.section("Authorization Error", <<~E)
+ Your client is not authorized to load one or more of your roles (HTTP 403).
E
error_description.section("Server Response:", format_rest_error)
- error_description.section("Possible Causes:", <<-E)
-* Your client (#{username}) may have misconfigured authorization permissions.
+ error_description.section("Possible Causes:", <<~E)
+ * Your client (#{username}) may have misconfigured authorization permissions.
E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
- error_description.section("Unknown Server Error:", <<-E)
-The server had a fatal error attempting to load a role.
+ error_description.section("Unknown Server Error:", <<~E)
+ The server had a fatal error attempting to load a role.
E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb
index e5e84e0f65..7882527327 100644
--- a/lib/chef/formatters/indentable_output_stream.rb
+++ b/lib/chef/formatters/indentable_output_stream.rb
@@ -35,19 +35,19 @@ class Chef
# cause indentation but will not move to the next line yet (future 'print'
# and 'puts' statements will stay on this line).
def start_line(string, *args)
- print(string, from_args(args, :start_line => true))
+ print(string, from_args(args, start_line: true))
end
# Print a line. This will continue from the last start_line or print,
# or start a new line and indent if necessary.
def puts(string, *args)
- print(string, from_args(args, :end_line => true))
+ print(string, from_args(args, end_line: true))
end
# Print an entire line from start to end. This will terminate any existing
# lines and cause indentation.
def puts_line(string, *args)
- print(string, from_args(args, :start_line => true, :end_line => true))
+ print(string, from_args(args, start_line: true, end_line: true))
end
# Print a raw chunk
@@ -103,7 +103,7 @@ class Chef
if colors.size == 1 && colors[0].kind_of?(Hash)
merge_options.merge(colors[0])
else
- merge_options.merge({ :colors => colors })
+ merge_options.merge({ colors: colors })
end
end
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index e245eab2c7..b1d497181b 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -42,9 +42,9 @@ class Chef
# We need to make sure we check for Script first because any resource
# that can get to here is an Execute resource.
if @resource.is_a? Chef::Resource::Script
- block_attributes = @command_opts.merge({ :code => @command })
+ block_attributes = @command_opts.merge({ code: @command })
else
- block_attributes = @command_opts.merge({ :command => @command })
+ block_attributes = @command_opts.merge({ command: @command })
end
# Handles cases like powershell_script where default
diff --git a/lib/chef/handler/json_file.rb b/lib/chef/handler/json_file.rb
index 7f29b91449..3dc7c51274 100644
--- a/lib/chef/handler/json_file.rb
+++ b/lib/chef/handler/json_file.rb
@@ -41,7 +41,7 @@ class Chef
savetime = Time.now.strftime("%Y%m%d%H%M%S")
File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
- #ensure start time and end time are output in the json properly in the event activesupport happens to be on the system
+ # ensure start time and end time are output in the json properly in the event activesupport happens to be on the system
run_data = data
run_data[:start_time] = run_data[:start_time].to_s
run_data[:end_time] = run_data[:end_time].to_s
diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb
index eeb9136607..547b5c8a83 100644
--- a/lib/chef/http/auth_credentials.rb
+++ b/lib/chef/http/auth_credentials.rb
@@ -50,8 +50,8 @@ class Chef
host = request_params.delete(:host) || "localhost"
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params)
- signed = sign_obj.sign(key, use_ssh_agent: @use_ssh_agent).merge({ :host => host })
- signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1]; memo }
+ signed = sign_obj.sign(key, use_ssh_agent: @use_ssh_agent).merge({ host: host })
+ signed.inject({}) { |memo, kv| memo[(kv[0].to_s.upcase).to_s] = kv[1]; memo }
end
end
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb
index 8e050832f0..bfb85785c8 100644
--- a/lib/chef/http/authenticator.rb
+++ b/lib/chef/http/authenticator.rb
@@ -104,11 +104,11 @@ class Chef
def authentication_headers(method, url, json_body = nil, headers = nil)
request_params = {
- :http_method => method,
- :path => url.path,
- :body => json_body,
- :host => "#{url.host}:#{url.port}",
- :headers => headers,
+ http_method: method,
+ path: url.path,
+ body: json_body,
+ host: "#{url.host}:#{url.port}",
+ headers: headers,
}
request_params[:body] ||= ""
auth_credentials.signature_headers(request_params)
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index de589e429e..774419a58c 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -27,7 +27,7 @@ require "net/http"
# However, in ohai before 0.6.0, the version is defined
# in ohai, not ohai/version
begin
- require "ohai/version" #used in user agent string.
+ require "ohai/version" # used in user agent string.
rescue LoadError
require "ohai"
end
@@ -152,7 +152,7 @@ class Chef
end
def configure_http_request(request_body = nil)
- req_path = "#{path}"
+ req_path = (path).to_s
req_path << "?#{query}" if query
@http_request = case method.to_s.downcase
diff --git a/lib/chef/key.rb b/lib/chef/key.rb
index bf8e533d62..1020d60ac6 100644
--- a/lib/chef/key.rb
+++ b/lib/chef/key.rb
@@ -77,23 +77,23 @@ class Chef
def actor(arg = nil)
set_or_return(:actor, arg,
- :regex => /^[a-z0-9\-_]+$/)
+ regex: /^[a-z0-9\-_]+$/)
end
def name(arg = nil)
set_or_return(:name, arg,
- :kind_of => String)
+ kind_of: String)
end
def public_key(arg = nil)
raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set the public_key if create_key is true" if !arg.nil? && @create_key
set_or_return(:public_key, arg,
- :kind_of => String)
+ kind_of: String)
end
def private_key(arg = nil)
set_or_return(:private_key, arg,
- :kind_of => String)
+ kind_of: String)
end
def delete_public_key
@@ -107,12 +107,12 @@ class Chef
def create_key(arg = nil)
raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set create_key to true if the public_key field exists" if arg == true && !@public_key.nil?
set_or_return(:create_key, arg,
- :kind_of => [TrueClass, FalseClass])
+ kind_of: [TrueClass, FalseClass])
end
def expiration_date(arg = nil)
set_or_return(:expiration_date, arg,
- :regex => /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|infinity)$/)
+ regex: /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|infinity)$/)
end
def to_hash
@@ -140,7 +140,7 @@ class Chef
# defaults the key name to the fingerprint of the key
if @name.nil?
# if they didn't pass a public_key,
- #then they must supply a name because we can't generate a fingerprint
+ # then they must supply a name because we can't generate a fingerprint
unless @public_key.nil?
@name = fingerprint
else
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 15d0f1be18..797080abe3 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -45,180 +45,180 @@ class Chef
banner "knife bootstrap [SSH_USER@]FQDN (options)"
option :ssh_user,
- :short => "-x USERNAME",
- :long => "--ssh-user USERNAME",
- :description => "The ssh username",
- :default => "root"
+ short: "-x USERNAME",
+ long: "--ssh-user USERNAME",
+ description: "The ssh username",
+ default: "root"
option :ssh_password,
- :short => "-P PASSWORD",
- :long => "--ssh-password PASSWORD",
- :description => "The ssh password"
+ short: "-P PASSWORD",
+ long: "--ssh-password PASSWORD",
+ description: "The ssh password"
option :ssh_port,
- :short => "-p PORT",
- :long => "--ssh-port PORT",
- :description => "The ssh port",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
+ short: "-p PORT",
+ long: "--ssh-port PORT",
+ description: "The ssh port",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
option :ssh_gateway,
- :short => "-G GATEWAY",
- :long => "--ssh-gateway GATEWAY",
- :description => "The ssh gateway",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
+ short: "-G GATEWAY",
+ long: "--ssh-gateway GATEWAY",
+ description: "The ssh gateway",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
option :ssh_gateway_identity,
- :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY",
- :description => "The SSH identity file used for gateway authentication",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway_identity] = key }
+ long: "--ssh-gateway-identity SSH_GATEWAY_IDENTITY",
+ description: "The SSH identity file used for gateway authentication",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway_identity] = key }
option :forward_agent,
- :short => "-A",
- :long => "--forward-agent",
- :description => "Enable SSH agent forwarding",
- :boolean => true
+ short: "-A",
+ long: "--forward-agent",
+ description: "Enable SSH agent forwarding",
+ boolean: true
option :identity_file,
- :long => "--identity-file IDENTITY_FILE",
- :description => "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead."
+ long: "--identity-file IDENTITY_FILE",
+ description: "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead."
option :ssh_identity_file,
- :short => "-i IDENTITY_FILE",
- :long => "--ssh-identity-file IDENTITY_FILE",
- :description => "The SSH identity file used for authentication"
+ short: "-i IDENTITY_FILE",
+ long: "--ssh-identity-file IDENTITY_FILE",
+ description: "The SSH identity file used for authentication"
option :chef_node_name,
- :short => "-N NAME",
- :long => "--node-name NAME",
- :description => "The Chef node name for your new node"
+ short: "-N NAME",
+ long: "--node-name NAME",
+ description: "The Chef node name for your new node"
option :prerelease,
- :long => "--prerelease",
- :description => "Install the pre-release chef gems"
+ long: "--prerelease",
+ description: "Install the pre-release chef gems"
option :bootstrap_version,
- :long => "--bootstrap-version VERSION",
- :description => "The version of Chef to install",
- :proc => lambda { |v| Chef::Config[:knife][:bootstrap_version] = v }
+ long: "--bootstrap-version VERSION",
+ description: "The version of Chef to install",
+ proc: lambda { |v| Chef::Config[:knife][:bootstrap_version] = v }
option :bootstrap_proxy,
- :long => "--bootstrap-proxy PROXY_URL",
- :description => "The proxy server for the node being bootstrapped",
- :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
+ long: "--bootstrap-proxy PROXY_URL",
+ description: "The proxy server for the node being bootstrapped",
+ proc: Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
option :bootstrap_proxy_user,
- :long => "--bootstrap-proxy-user PROXY_USER",
- :description => "The proxy authentication username for the node being bootstrapped"
+ long: "--bootstrap-proxy-user PROXY_USER",
+ description: "The proxy authentication username for the node being bootstrapped"
option :bootstrap_proxy_pass,
- :long => "--bootstrap-proxy-pass PROXY_PASS",
- :description => "The proxy authentication password for the node being bootstrapped"
+ long: "--bootstrap-proxy-pass PROXY_PASS",
+ description: "The proxy authentication password for the node being bootstrapped"
option :bootstrap_no_proxy,
- :long => "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
- :description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
- :proc => Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
+ long: "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
+ description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
+ proc: Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
option :bootstrap_template,
- :short => "-t TEMPLATE",
- :long => "--bootstrap-template TEMPLATE",
- :description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
+ short: "-t TEMPLATE",
+ long: "--bootstrap-template TEMPLATE",
+ description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
option :use_sudo,
- :long => "--sudo",
- :description => "Execute the bootstrap via sudo",
- :boolean => true
+ long: "--sudo",
+ description: "Execute the bootstrap via sudo",
+ boolean: true
option :preserve_home,
- :long => "--sudo-preserve-home",
- :description => "Preserve non-root user HOME environment variable with sudo",
- :boolean => true
+ long: "--sudo-preserve-home",
+ description: "Preserve non-root user HOME environment variable with sudo",
+ boolean: true
option :use_sudo_password,
- :long => "--use-sudo-password",
- :description => "Execute the bootstrap via sudo with password",
- :boolean => false
+ long: "--use-sudo-password",
+ description: "Execute the bootstrap via sudo with password",
+ boolean: false
option :run_list,
- :short => "-r RUN_LIST",
- :long => "--run-list RUN_LIST",
- :description => "Comma separated list of roles/recipes to apply",
- :proc => lambda { |o| o.split(/[\s,]+/) },
- :default => []
+ short: "-r RUN_LIST",
+ long: "--run-list RUN_LIST",
+ description: "Comma separated list of roles/recipes to apply",
+ proc: lambda { |o| o.split(/[\s,]+/) },
+ default: []
option :policy_name,
- :long => "--policy-name POLICY_NAME",
- :description => "Policyfile name to use (--policy-group must also be given)",
- :default => nil
+ long: "--policy-name POLICY_NAME",
+ description: "Policyfile name to use (--policy-group must also be given)",
+ default: nil
option :policy_group,
- :long => "--policy-group POLICY_GROUP",
- :description => "Policy group name to use (--policy-name must also be given)",
- :default => nil
+ long: "--policy-group POLICY_GROUP",
+ description: "Policy group name to use (--policy-name must also be given)",
+ default: nil
option :tags,
- :long => "--tags TAGS",
- :description => "Comma separated list of tags to apply to the node",
- :proc => lambda { |o| o.split(/[\s,]+/) },
- :default => []
+ long: "--tags TAGS",
+ description: "Comma separated list of tags to apply to the node",
+ proc: lambda { |o| o.split(/[\s,]+/) },
+ default: []
option :first_boot_attributes,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes",
- :description => "A JSON string to be added to the first run of chef-client",
- :proc => lambda { |o| Chef::JSONCompat.parse(o) },
- :default => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes",
+ description: "A JSON string to be added to the first run of chef-client",
+ proc: lambda { |o| Chef::JSONCompat.parse(o) },
+ default: nil
option :first_boot_attributes_from_file,
- :long => "--json-attribute-file FILE",
- :description => "A JSON file to be used to the first run of chef-client",
- :proc => lambda { |o| Chef::JSONCompat.parse(File.read(o)) },
- :default => nil
+ long: "--json-attribute-file FILE",
+ description: "A JSON file to be used to the first run of chef-client",
+ proc: lambda { |o| Chef::JSONCompat.parse(File.read(o)) },
+ default: nil
option :host_key_verify,
- :long => "--[no-]host-key-verify",
- :description => "Verify host key, enabled by default.",
- :boolean => true,
- :default => true
+ long: "--[no-]host-key-verify",
+ description: "Verify host key, enabled by default.",
+ boolean: true,
+ default: true
option :hint,
- :long => "--hint HINT_NAME[=HINT_FILE]",
- :description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
- :proc => Proc.new { |h|
+ long: "--hint HINT_NAME[=HINT_FILE]",
+ description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
+ proc: Proc.new { |h|
Chef::Config[:knife][:hints] ||= Hash.new
name, path = h.split("=")
Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new
}
option :bootstrap_url,
- :long => "--bootstrap-url URL",
- :description => "URL to a custom installation script",
- :proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
+ long: "--bootstrap-url URL",
+ description: "URL to a custom installation script",
+ proc: Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
option :bootstrap_install_command,
- :long => "--bootstrap-install-command COMMANDS",
- :description => "Custom command to install chef-client",
- :proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
+ long: "--bootstrap-install-command COMMANDS",
+ description: "Custom command to install chef-client",
+ proc: Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
option :bootstrap_preinstall_command,
- :long => "--bootstrap-preinstall-command COMMANDS",
- :description => "Custom commands to run before installing chef-client",
- :proc => Proc.new { |preic| Chef::Config[:knife][:bootstrap_preinstall_command] = preic }
+ long: "--bootstrap-preinstall-command COMMANDS",
+ description: "Custom commands to run before installing chef-client",
+ proc: Proc.new { |preic| Chef::Config[:knife][:bootstrap_preinstall_command] = preic }
option :bootstrap_wget_options,
- :long => "--bootstrap-wget-options OPTIONS",
- :description => "Add options to wget when installing chef-client",
- :proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
+ long: "--bootstrap-wget-options OPTIONS",
+ description: "Add options to wget when installing chef-client",
+ proc: Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
option :bootstrap_curl_options,
- :long => "--bootstrap-curl-options OPTIONS",
- :description => "Add options to curl when install chef-client",
- :proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
+ long: "--bootstrap-curl-options OPTIONS",
+ description: "Add options to curl when install chef-client",
+ proc: Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
option :node_ssl_verify_mode,
- :long => "--node-ssl-verify-mode [peer|none]",
- :description => "Whether or not to verify the SSL cert for all HTTPS requests.",
- :proc => Proc.new { |v|
+ long: "--node-ssl-verify-mode [peer|none]",
+ description: "Whether or not to verify the SSL cert for all HTTPS requests.",
+ proc: Proc.new { |v|
valid_values = %w{none peer}
unless valid_values.include?(v)
raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}"
@@ -227,22 +227,22 @@ class Chef
}
option :node_verify_api_cert,
- :long => "--[no-]node-verify-api-cert",
- :description => "Verify the SSL cert for HTTPS requests to the Chef server API.",
- :boolean => true
+ long: "--[no-]node-verify-api-cert",
+ description: "Verify the SSL cert for HTTPS requests to the Chef server API.",
+ boolean: true
option :bootstrap_vault_file,
- :long => "--bootstrap-vault-file VAULT_FILE",
- :description => "A JSON file with a list of vault(s) and item(s) to be updated"
+ long: "--bootstrap-vault-file VAULT_FILE",
+ description: "A JSON file with a list of vault(s) and item(s) to be updated"
option :bootstrap_vault_json,
- :long => "--bootstrap-vault-json VAULT_JSON",
- :description => "A JSON string with the vault(s) and item(s) to be updated"
+ long: "--bootstrap-vault-json VAULT_JSON",
+ description: "A JSON string with the vault(s) and item(s) to be updated"
option :bootstrap_vault_item,
- :long => "--bootstrap-vault-item VAULT_ITEM",
- :description => 'A single vault and item to update as "vault:item"',
- :proc => Proc.new { |i|
+ long: "--bootstrap-vault-item VAULT_ITEM",
+ description: 'A single vault and item to update as "vault:item"',
+ proc: Proc.new { |i|
(vault, item) = i.split(/:/)
Chef::Config[:knife][:bootstrap_vault_item] ||= {}
Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb
index cab33cd811..f5c49ab620 100644
--- a/lib/chef/knife/bootstrap/client_builder.rb
+++ b/lib/chef/knife/bootstrap/client_builder.rb
@@ -194,7 +194,7 @@ class Chef
# @return [Chef::ServerAPI] REST client using the client credentials
def client_rest
- @client_rest ||= Chef::ServerAPI.new(chef_server_url, :client_name => node_name, :signing_key_filename => client_path)
+ @client_rest ||= Chef::ServerAPI.new(chef_server_url, client_name: node_name, signing_key_filename: client_path)
end
# @return [Chef::ServerAPI] REST client using the cli user's knife credentials
diff --git a/lib/chef/knife/client_bulk_delete.rb b/lib/chef/knife/client_bulk_delete.rb
index a7fa7142c8..a5fe94681d 100644
--- a/lib/chef/knife/client_bulk_delete.rb
+++ b/lib/chef/knife/client_bulk_delete.rb
@@ -28,9 +28,9 @@ class Chef
end
option :delete_validators,
- :short => "-D",
- :long => "--delete-validators",
- :description => "Force deletion of clients if they're validators"
+ short: "-D",
+ long: "--delete-validators",
+ description: "Force deletion of clients if they're validators"
banner "knife client bulk delete REGEX (options)"
diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb
index e28378cd4a..b821a8a56b 100644
--- a/lib/chef/knife/client_create.rb
+++ b/lib/chef/knife/client_create.rb
@@ -28,31 +28,31 @@ class Chef
end
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file if the server generated one."
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file if the server generated one."
option :admin,
- :short => "-a",
- :long => "--admin",
- :description => "Open Source Chef Server 11 only. Create the client as an admin.",
- :boolean => true
+ short: "-a",
+ long: "--admin",
+ description: "Open Source Chef Server 11 only. Create the client as an admin.",
+ boolean: true
option :validator,
- :long => "--validator",
- :description => "Create the client as a validator.",
- :boolean => true
+ long: "--validator",
+ description: "Create the client as a validator.",
+ boolean: true
option :public_key,
- :short => "-p FILE",
- :long => "--public-key",
- :description => "Set the initial default key for the client from a file on disk (cannot pass with --prevent-keygen)."
+ short: "-p FILE",
+ long: "--public-key",
+ description: "Set the initial default key for the client from a file on disk (cannot pass with --prevent-keygen)."
option :prevent_keygen,
- :short => "-k",
- :long => "--prevent-keygen",
- :description => "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --public-key.",
- :boolean => true
+ short: "-k",
+ long: "--prevent-keygen",
+ description: "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --public-key.",
+ boolean: true
banner "knife client create CLIENTNAME (options)"
diff --git a/lib/chef/knife/client_delete.rb b/lib/chef/knife/client_delete.rb
index 82b521c7d1..a043b6f731 100644
--- a/lib/chef/knife/client_delete.rb
+++ b/lib/chef/knife/client_delete.rb
@@ -28,9 +28,9 @@ class Chef
end
option :delete_validators,
- :short => "-D",
- :long => "--delete-validators",
- :description => "Force deletion of client if it's a validator"
+ short: "-D",
+ long: "--delete-validators",
+ description: "Force deletion of client if it's a validator"
banner "knife client delete [CLIENT [CLIENT]] (options)"
diff --git a/lib/chef/knife/client_list.rb b/lib/chef/knife/client_list.rb
index b17de0f3ad..794d8c9411 100644
--- a/lib/chef/knife/client_list.rb
+++ b/lib/chef/knife/client_list.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife client list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::ApiClientV1.list))
diff --git a/lib/chef/knife/client_reregister.rb b/lib/chef/knife/client_reregister.rb
index cc2b218e87..ce34884803 100644
--- a/lib/chef/knife/client_reregister.rb
+++ b/lib/chef/knife/client_reregister.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife client reregister CLIENT (options)"
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the key to a file"
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the key to a file"
def run
@client_name = @name_args[0]
diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb
index df021826ae..4b33998eaa 100644
--- a/lib/chef/knife/configure.rb
+++ b/lib/chef/knife/configure.rb
@@ -34,31 +34,31 @@ class Chef
banner "knife configure (options)"
option :repository,
- :short => "-r REPO",
- :long => "--repository REPO",
- :description => "The path to the chef-repo"
+ short: "-r REPO",
+ long: "--repository REPO",
+ description: "The path to the chef-repo"
option :initial,
- :short => "-i",
- :long => "--initial",
- :boolean => true,
- :description => "Use to create a API client, typically an administrator client on a freshly-installed server"
+ short: "-i",
+ long: "--initial",
+ boolean: true,
+ description: "Use to create a API client, typically an administrator client on a freshly-installed server"
option :admin_client_name,
- :long => "--admin-client-name NAME",
- :description => "The name of the client, typically the name of the admin client"
+ long: "--admin-client-name NAME",
+ description: "The name of the client, typically the name of the admin client"
option :admin_client_key,
- :long => "--admin-client-key PATH",
- :description => "The path to the private key used by the client, typically a file named admin.pem"
+ long: "--admin-client-key PATH",
+ description: "The path to the private key used by the client, typically a file named admin.pem"
option :validation_client_name,
- :long => "--validation-client-name NAME",
- :description => "The name of the validation client, typically a client named chef-validator"
+ long: "--validation-client-name NAME",
+ description: "The name of the validation client, typically a client named chef-validator"
option :validation_key,
- :long => "--validation-key PATH",
- :description => "The path to the validation key used by the client, typically a file named validation.pem"
+ long: "--validation-key PATH",
+ description: "The path to the validation key used by the client, typically a file named validation.pem"
def configure_chef
# We are just faking out the system so that you can do this without a key specified
@@ -75,11 +75,11 @@ class Chef
confirm("Overwrite #{config_file_path}") if ::File.exist?(config_file_path)
::File.open(config_file_path, "w") do |f|
- f.puts <<-EOH
-[default]
-client_name = '#{new_client_name}'
-client_key = '#{new_client_key}'
-chef_server_url = '#{chef_server}'
+ f.puts <<~EOH
+ [default]
+ client_name = '#{new_client_name}'
+ client_key = '#{new_client_key}'
+ chef_server_url = '#{chef_server}'
EOH
end
@@ -112,14 +112,14 @@ EOH
def ask_user_for_config
server_name = guess_servername
- @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}/organizations/myorg")
+ @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", default: "https://#{server_name}/organizations/myorg")
if config[:initial]
- @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", :default => Etc.getlogin)
- @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => "admin")
- @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", :default => "/etc/chef-server/admin.pem")
+ @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", default: Etc.getlogin)
+ @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", default: "admin")
+ @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "/etc/chef-server/admin.pem")
@admin_client_key = File.expand_path(@admin_client_key)
else
- @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", :default => Etc.getlogin)
+ @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin)
end
@new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem")
diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/lib/chef/knife/cookbook_bulk_delete.rb
index cdd1584e36..a68e8f00f4 100644
--- a/lib/chef/knife/cookbook_bulk_delete.rb
+++ b/lib/chef/knife/cookbook_bulk_delete.rb
@@ -28,7 +28,7 @@ class Chef
require "chef/cookbook_version"
end
- option :purge, :short => "-p", :long => "--purge", :boolean => true, :description => "Permanently remove files from backing data store"
+ option :purge, short: "-p", long: "--purge", boolean: true, description: "Permanently remove files from backing data store"
banner "knife cookbook bulk delete REGEX (options)"
diff --git a/lib/chef/knife/cookbook_delete.rb b/lib/chef/knife/cookbook_delete.rb
index b1bb88b388..4f2ada53cb 100644
--- a/lib/chef/knife/cookbook_delete.rb
+++ b/lib/chef/knife/cookbook_delete.rb
@@ -28,9 +28,9 @@ class Chef
require "chef/cookbook_version"
end
- option :all, :short => "-a", :long => "--all", :boolean => true, :description => "delete all versions"
+ option :all, short: "-a", long: "--all", boolean: true, description: "delete all versions"
- option :purge, :short => "-p", :long => "--purge", :boolean => true, :description => "Permanently remove files from backing data store"
+ option :purge, short: "-p", long: "--purge", boolean: true, description: "Permanently remove files from backing data store"
banner "knife cookbook delete COOKBOOK VERSION (options)"
diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb
index 77e7aa0d09..a321d217db 100644
--- a/lib/chef/knife/cookbook_download.rb
+++ b/lib/chef/knife/cookbook_download.rb
@@ -33,21 +33,21 @@ class Chef
banner "knife cookbook download COOKBOOK [VERSION] (options)"
option :latest,
- :short => "-N",
- :long => "--latest",
- :description => "The version of the cookbook to download",
- :boolean => true
+ short: "-N",
+ long: "--latest",
+ description: "The version of the cookbook to download",
+ boolean: true
option :download_directory,
- :short => "-d DOWNLOAD_DIRECTORY",
- :long => "--dir DOWNLOAD_DIRECTORY",
- :description => "The directory to download the cookbook into",
- :default => Dir.pwd
+ short: "-d DOWNLOAD_DIRECTORY",
+ long: "--dir DOWNLOAD_DIRECTORY",
+ description: "The directory to download the cookbook into",
+ default: Dir.pwd
option :force,
- :short => "-f",
- :long => "--force",
- :description => "Force download over the download directory if it exists"
+ short: "-f",
+ long: "--force",
+ description: "Force download over the download directory if it exists"
# TODO: tim/cw: 5-23-2010: need to implement knife-side
# specificity for downloads - need to implement --platform and
diff --git a/lib/chef/knife/cookbook_list.rb b/lib/chef/knife/cookbook_list.rb
index ea81f5d286..deb36baef4 100644
--- a/lib/chef/knife/cookbook_list.rb
+++ b/lib/chef/knife/cookbook_list.rb
@@ -26,14 +26,14 @@ class Chef
banner "knife cookbook list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
option :all_versions,
- :short => "-a",
- :long => "--all",
- :description => "Show all available versions."
+ short: "-a",
+ long: "--all",
+ description: "Show all available versions."
def run
env = config[:environment]
diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb
index babb4ac4d1..8a9c57f1c3 100644
--- a/lib/chef/knife/cookbook_metadata.rb
+++ b/lib/chef/knife/cookbook_metadata.rb
@@ -30,15 +30,15 @@ class Chef
banner "knife cookbook metadata COOKBOOK (options)"
option :cookbook_path,
- :short => "-o PATH:PATH",
- :long => "--cookbook-path PATH:PATH",
- :description => "A colon-separated path to look for cookbooks in",
- :proc => lambda { |o| o.split(":") }
+ short: "-o PATH:PATH",
+ long: "--cookbook-path PATH:PATH",
+ description: "A colon-separated path to look for cookbooks in",
+ proc: lambda { |o| o.split(":") }
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Generate metadata for all cookbooks, rather than just a single cookbook"
+ short: "-a",
+ long: "--all",
+ description: "Generate metadata for all cookbooks, rather than just a single cookbook"
def run
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb
index 1d9983632d..78951d00c7 100644
--- a/lib/chef/knife/cookbook_show.rb
+++ b/lib/chef/knife/cookbook_show.rb
@@ -31,24 +31,24 @@ class Chef
banner "knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)"
option :fqdn,
- :short => "-f FQDN",
- :long => "--fqdn FQDN",
- :description => "The FQDN of the host to see the file for"
+ short: "-f FQDN",
+ long: "--fqdn FQDN",
+ description: "The FQDN of the host to see the file for"
option :platform,
- :short => "-p PLATFORM",
- :long => "--platform PLATFORM",
- :description => "The platform to see the file for"
+ short: "-p PLATFORM",
+ long: "--platform PLATFORM",
+ description: "The platform to see the file for"
option :platform_version,
- :short => "-V VERSION",
- :long => "--platform-version VERSION",
- :description => "The platform version to see the file for"
+ short: "-V VERSION",
+ long: "--platform-version VERSION",
+ description: "The platform version to see the file for"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
cookbook_name, cookbook_version, segment, filename = @name_args
diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb
index b957b0a362..ad4a2a83a2 100644
--- a/lib/chef/knife/cookbook_site_download.rb
+++ b/lib/chef/knife/cookbook_site_download.rb
@@ -30,20 +30,20 @@ class Chef
category "cookbook site"
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "The filename to write to"
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "The filename to write to"
option :force,
- :long => "--force",
- :description => "Force download deprecated version"
+ long: "--force",
+ description: "Force download deprecated version"
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
if current_cookbook_deprecated?
diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb
index f4d692e13c..18cddb19f4 100644
--- a/lib/chef/knife/cookbook_site_install.rb
+++ b/lib/chef/knife/cookbook_site_install.rb
@@ -35,37 +35,37 @@ class Chef
category "cookbook site"
option :no_deps,
- :short => "-D",
- :long => "--skip-dependencies",
- :boolean => true,
- :default => false,
- :description => "Skips automatic dependency installation."
+ short: "-D",
+ long: "--skip-dependencies",
+ boolean: true,
+ default: false,
+ description: "Skips automatic dependency installation."
option :cookbook_path,
- :short => "-o PATH:PATH",
- :long => "--cookbook-path PATH:PATH",
- :description => "A colon-separated path to look for cookbooks in",
- :proc => lambda { |o| o.split(":") }
+ short: "-o PATH:PATH",
+ long: "--cookbook-path PATH:PATH",
+ description: "A colon-separated path to look for cookbooks in",
+ proc: lambda { |o| o.split(":") }
option :default_branch,
- :short => "-B BRANCH",
- :long => "--branch BRANCH",
- :description => "Default branch to work with",
- :default => "master"
+ short: "-B BRANCH",
+ long: "--branch BRANCH",
+ description: "Default branch to work with",
+ default: "master"
option :use_current_branch,
- :short => "-b",
- :long => "--use-current-branch",
- :description => "Use the current branch",
- :boolean => true,
- :default => false
+ short: "-b",
+ long: "--use-current-branch",
+ description: "Use the current branch",
+ boolean: true,
+ default: false
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
attr_reader :cookbook_name
attr_reader :vendor_path
@@ -86,7 +86,7 @@ class Chef
ui.info "Installing #{@cookbook_name} to #{@install_path}"
@repo = CookbookSCMRepo.new(@install_path, ui, config)
- #cookbook_path = File.join(vendor_path, name_args[0])
+ # cookbook_path = File.join(vendor_path, name_args[0])
upstream_file = File.join(@install_path, "#{@cookbook_name}.tar.gz")
@repo.sanity_check
diff --git a/lib/chef/knife/cookbook_site_list.rb b/lib/chef/knife/cookbook_site_list.rb
index 3bdef8abe5..3b0b20a4df 100644
--- a/lib/chef/knife/cookbook_site_list.rb
+++ b/lib/chef/knife/cookbook_site_list.rb
@@ -26,16 +26,16 @@ class Chef
category "cookbook site"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
if config[:with_uri]
diff --git a/lib/chef/knife/cookbook_site_search.rb b/lib/chef/knife/cookbook_site_search.rb
index 0fee993f30..6a598bd22b 100644
--- a/lib/chef/knife/cookbook_site_search.rb
+++ b/lib/chef/knife/cookbook_site_search.rb
@@ -26,11 +26,11 @@ class Chef
category "cookbook site"
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
output(search_cookbook(name_args[0]))
diff --git a/lib/chef/knife/cookbook_site_share.rb b/lib/chef/knife/cookbook_site_share.rb
index 5d5b3ddcc4..dcfd224295 100644
--- a/lib/chef/knife/cookbook_site_share.rb
+++ b/lib/chef/knife/cookbook_site_share.rb
@@ -39,24 +39,24 @@ class Chef
category "cookbook site"
option :cookbook_path,
- :short => "-o PATH:PATH",
- :long => "--cookbook-path PATH:PATH",
- :description => "A colon-separated path to look for cookbooks in",
- :proc => lambda { |o| Chef::Config.cookbook_path = o.split(":") }
+ short: "-o PATH:PATH",
+ long: "--cookbook-path PATH:PATH",
+ description: "A colon-separated path to look for cookbooks in",
+ proc: lambda { |o| Chef::Config.cookbook_path = o.split(":") }
option :dry_run,
- :long => "--dry-run",
- :short => "-n",
- :boolean => true,
- :default => false,
- :description => "Don't take action, only print what files will be uploaded to Supermarket."
+ long: "--dry-run",
+ short: "-n",
+ boolean: true,
+ default: false,
+ description: "Don't take action, only print what files will be uploaded to Supermarket."
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
@@ -81,7 +81,7 @@ class Chef
begin
Chef::Log.trace("Temp cookbook directory is #{tmp_cookbook_dir.inspect}")
ui.info("Making tarball #{cookbook_name}.tgz")
- shell_out!("#{tar_cmd} -czf #{cookbook_name}.tgz #{cookbook_name}", :cwd => tmp_cookbook_dir)
+ shell_out!("#{tar_cmd} -czf #{cookbook_name}.tgz #{cookbook_name}", cwd: tmp_cookbook_dir)
rescue => e
ui.error("Error making tarball #{cookbook_name}.tgz: #{e.message}. Increase log verbosity (-VV) for more information.")
Chef::Log.trace("\n#{e.backtrace.join("\n")}")
@@ -90,7 +90,7 @@ class Chef
if config[:dry_run]
ui.info("Not uploading #{cookbook_name}.tgz due to --dry-run flag.")
- result = shell_out!("#{tar_cmd} -tzf #{cookbook_name}.tgz", :cwd => tmp_cookbook_dir)
+ result = shell_out!("#{tar_cmd} -tzf #{cookbook_name}.tgz", cwd: tmp_cookbook_dir)
ui.info(result.stdout)
FileUtils.rm_rf tmp_cookbook_dir
return
@@ -129,8 +129,8 @@ class Chef
category_string = Chef::JSONCompat.to_json({ "category" => cookbook_category })
http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
- :tarball => File.open(cookbook_filename),
- :cookbook => category_string,
+ tarball: File.open(cookbook_filename),
+ cookbook: category_string,
})
res = Chef::JSONCompat.from_json(http_resp.body)
@@ -140,7 +140,7 @@ class Chef
ui.error "The same version of this cookbook already exists on Supermarket."
exit(1)
else
- ui.error "#{res['error_messages'][0]}"
+ ui.error (res["error_messages"][0]).to_s
exit(1)
end
else
diff --git a/lib/chef/knife/cookbook_site_show.rb b/lib/chef/knife/cookbook_site_show.rb
index 397d0067ad..1ae242d051 100644
--- a/lib/chef/knife/cookbook_site_show.rb
+++ b/lib/chef/knife/cookbook_site_show.rb
@@ -26,11 +26,11 @@ class Chef
category "cookbook site"
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
output(format_for_display(get_cookbook_data))
diff --git a/lib/chef/knife/cookbook_site_unshare.rb b/lib/chef/knife/cookbook_site_unshare.rb
index bdabff0b94..5f24781f38 100644
--- a/lib/chef/knife/cookbook_site_unshare.rb
+++ b/lib/chef/knife/cookbook_site_unshare.rb
@@ -31,11 +31,11 @@ class Chef
category "cookbook site"
option :supermarket_site,
- :short => "-m SUPERMARKET_SITE",
- :long => "--supermarket-site SUPERMARKET_SITE",
- :description => "Supermarket Site",
- :default => "https://supermarket.chef.io",
- :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
+ short: "-m SUPERMARKET_SITE",
+ long: "--supermarket-site SUPERMARKET_SITE",
+ description: "Supermarket Site",
+ default: "https://supermarket.chef.io",
+ proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
def run
@cookbook_name = @name_args[0]
diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb
index b4adf6c84f..2f600bf964 100644
--- a/lib/chef/knife/cookbook_test.rb
+++ b/lib/chef/knife/cookbook_test.rb
@@ -32,15 +32,15 @@ class Chef
banner "knife cookbook test [COOKBOOKS...] (options)"
option :cookbook_path,
- :short => "-o PATH:PATH",
- :long => "--cookbook-path PATH:PATH",
- :description => "A colon-separated path to look for cookbooks in",
- :proc => lambda { |o| o.split(":") }
+ short: "-o PATH:PATH",
+ long: "--cookbook-path PATH:PATH",
+ description: "A colon-separated path to look for cookbooks in",
+ proc: lambda { |o| o.split(":") }
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Test all cookbooks, rather than just a single cookbook"
+ short: "-a",
+ long: "--all",
+ description: "Test all cookbooks, rather than just a single cookbook"
def run
ui.warn("DEPRECATED: Please use ChefSpec or Cookstyle to syntax-check cookbooks.")
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index f67a26dc9a..b19c352b79 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -37,42 +37,42 @@ class Chef
banner "knife cookbook upload [COOKBOOKS...] (options)"
option :cookbook_path,
- :short => "-o PATH:PATH",
- :long => "--cookbook-path PATH:PATH",
- :description => "A colon-separated path to look for cookbooks in",
- :proc => lambda { |o| o.split(":") }
+ short: "-o PATH:PATH",
+ long: "--cookbook-path PATH:PATH",
+ description: "A colon-separated path to look for cookbooks in",
+ proc: lambda { |o| o.split(":") }
option :freeze,
- :long => "--freeze",
- :description => "Freeze this version of the cookbook so that it cannot be overwritten",
- :boolean => true
+ long: "--freeze",
+ description: "Freeze this version of the cookbook so that it cannot be overwritten",
+ boolean: true
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Upload all cookbooks, rather than just a single cookbook"
+ short: "-a",
+ long: "--all",
+ description: "Upload all cookbooks, rather than just a single cookbook"
option :force,
- :long => "--force",
- :boolean => true,
- :description => "Update cookbook versions even if they have been frozen"
+ long: "--force",
+ boolean: true,
+ description: "Update cookbook versions even if they have been frozen"
option :concurrency,
- :long => "--concurrency NUMBER_OF_THREADS",
- :description => "How many concurrent threads will be used",
- :default => 10,
- :proc => lambda { |o| o.to_i }
+ long: "--concurrency NUMBER_OF_THREADS",
+ description: "How many concurrent threads will be used",
+ default: 10,
+ proc: lambda { |o| o.to_i }
option :environment,
- :short => "-E",
- :long => "--environment ENVIRONMENT",
- :description => "Set ENVIRONMENT's version dependency match the version you're uploading.",
- :default => nil
+ short: "-E",
+ long: "--environment ENVIRONMENT",
+ description: "Set ENVIRONMENT's version dependency match the version you're uploading.",
+ default: nil
option :depends,
- :short => "-d",
- :long => "--include-dependencies",
- :description => "Also upload cookbook dependencies"
+ short: "-d",
+ long: "--include-dependencies",
+ description: "Also upload cookbook dependencies"
def run
# Sanity check before we load anything from the server
@@ -209,12 +209,12 @@ class Chef
unless cookbook_repo.merged_cookbooks.empty?
ui.warn "* " * 40
- ui.warn(<<-WARNING)
-The cookbooks: #{cookbook_repo.merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path.
-A composite version of these cookbooks has been compiled for uploading.
+ ui.warn(<<~WARNING)
+ The cookbooks: #{cookbook_repo.merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path.
+ A composite version of these cookbooks has been compiled for uploading.
-#{ui.color('IMPORTANT:', :red, :bold)} In a future version of Chef, this behavior will be removed and you will no longer
-be able to have the same version of a cookbook in multiple places in your cookbook_path.
+ #{ui.color('IMPORTANT:', :red, :bold)} In a future version of Chef, this behavior will be removed and you will no longer
+ be able to have the same version of a cookbook in multiple places in your cookbook_path.
WARNING
ui.warn "The affected cookbooks are located:"
ui.output ui.format_for_display(cookbook_repo.merged_cookbook_paths)
@@ -242,7 +242,7 @@ WARNING
check_for_broken_links!(cb)
check_for_dependencies!(cb)
end
- Chef::CookbookUploader.new(cookbooks, :force => config[:force], :concurrency => config[:concurrency]).upload_cookbooks
+ Chef::CookbookUploader.new(cookbooks, force: config[:force], concurrency: config[:concurrency]).upload_cookbooks
rescue Chef::Exceptions::CookbookFrozen => e
ui.error e
raise
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index deb7f8a3b4..bb20780590 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -86,9 +86,9 @@ class Chef
end
def config_content
- client_rb = <<-CONFIG
-chef_server_url "#{@chef_config[:chef_server_url]}"
-validation_client_name "#{@chef_config[:validation_client_name]}"
+ client_rb = <<~CONFIG
+ chef_server_url "#{@chef_config[:chef_server_url]}"
+ validation_client_name "#{@chef_config[:validation_client_name]}"
CONFIG
if !(@chef_config[:config_log_level].nil? || @chef_config[:config_log_level].empty?)
@@ -228,7 +228,7 @@ validation_client_name "#{@chef_config[:validation_client_name]}"
end
attributes.delete(:run_list) if attributes[:policy_name] && !attributes[:policy_name].empty?
- attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty?
+ attributes.merge!(tags: @config[:tags]) if @config[:tags] && !@config[:tags].empty?
end
end
diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb
index 38f432e5bb..f583f0bd8e 100644
--- a/lib/chef/knife/core/cookbook_scm_repo.rb
+++ b/lib/chef/knife/core/cookbook_scm_repo.rb
@@ -151,7 +151,7 @@ class Chef
end
def git(command)
- shell_out!("git #{command}", :cwd => repo_path)
+ shell_out!("git #{command}", cwd: repo_path)
end
end
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 861bf1510d..7b3fee00b5 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -29,15 +29,15 @@ class Chef
def self.included(includer)
includer.class_eval do
option :field_separator,
- :short => "-S SEPARATOR",
- :long => "--field-separator SEPARATOR",
- :description => "Character separator used to delineate nesting in --attribute filters (default \".\")"
+ short: "-S SEPARATOR",
+ long: "--field-separator SEPARATOR",
+ description: "Character separator used to delineate nesting in --attribute filters (default \".\")"
option :attribute,
- :short => "-a ATTR1 [-a ATTR2]",
- :long => "--attribute ATTR1 [--attribute ATTR2] ",
- :description => "Show one or more attributes",
- :proc => Proc.new { |a|
+ short: "-a ATTR1 [-a ATTR2]",
+ long: "--attribute ATTR1 [--attribute ATTR2] ",
+ description: "Show one or more attributes",
+ proc: Proc.new { |a|
Chef::Config[:knife][:attribute] ||= []
Chef::Config[:knife][:attribute].push(a)
}
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index cdb664ec33..7cb0e4d6fe 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -32,18 +32,18 @@ class Chef
def self.included(includer)
includer.class_eval do
option :medium_output,
- :short => "-m",
- :long => "--medium",
- :boolean => true,
- :default => false,
- :description => "Include normal attributes in the output"
+ short: "-m",
+ long: "--medium",
+ boolean: true,
+ default: false,
+ description: "Include normal attributes in the output"
option :long_output,
- :short => "-l",
- :long => "--long",
- :boolean => true,
- :default => false,
- :description => "Include all attributes in the output"
+ short: "-l",
+ long: "--long",
+ boolean: true,
+ default: false,
+ description: "Include all attributes in the output"
end
end
end
@@ -98,49 +98,49 @@ class Chef
# special case ec2 with their split horizon whatsis.
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
- summarized = <<-SUMMARY
-#{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
+ summarized = <<~SUMMARY
+ #{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
SUMMARY
show_policy = !(node.policy_name.nil? && node.policy_group.nil?)
if show_policy
- summarized << <<-POLICY
-#{key('Policy Name:')} #{node.policy_name}
-#{key('Policy Group:')} #{node.policy_group}
+ summarized << <<~POLICY
+ #{key('Policy Name:')} #{node.policy_name}
+ #{key('Policy Group:')} #{node.policy_group}
POLICY
else
- summarized << <<-ENV
-#{key('Environment:')} #{node.chef_environment}
+ summarized << <<~ENV
+ #{key('Environment:')} #{node.chef_environment}
ENV
end
- summarized << <<-SUMMARY
-#{key('FQDN:')} #{node[:fqdn]}
-#{key('IP:')} #{ip}
-#{key('Run List:')} #{node.run_list}
+ summarized << <<~SUMMARY
+ #{key('FQDN:')} #{node[:fqdn]}
+ #{key('IP:')} #{ip}
+ #{key('Run List:')} #{node.run_list}
SUMMARY
unless show_policy
- summarized << <<-ROLES
-#{key('Roles:')} #{Array(node[:roles]).join(', ')}
+ summarized << <<~ROLES
+ #{key('Roles:')} #{Array(node[:roles]).join(', ')}
ROLES
end
- summarized << <<-SUMMARY
-#{key('Recipes:')} #{Array(node[:recipes]).join(', ')}
-#{key('Platform:')} #{node[:platform]} #{node[:platform_version]}
-#{key('Tags:')} #{node.tags.join(', ')}
+ summarized << <<~SUMMARY
+ #{key('Recipes:')} #{Array(node[:recipes]).join(', ')}
+ #{key('Platform:')} #{node[:platform]} #{node[:platform_version]}
+ #{key('Tags:')} #{node.tags.join(', ')}
SUMMARY
if config[:medium_output] || config[:long_output]
- summarized += <<-MORE
-#{key('Attributes:')}
-#{text_format(node.normal_attrs)}
+ summarized += <<~MORE
+ #{key('Attributes:')}
+ #{text_format(node.normal_attrs)}
MORE
end
if config[:long_output]
- summarized += <<-MOST
-#{key('Default Attributes:')}
-#{text_format(node.default_attrs)}
-#{key('Override Attributes:')}
-#{text_format(node.override_attrs)}
-#{key('Automatic Attributes (Ohai Data):')}
-#{text_format(node.automatic_attrs)}
+ summarized += <<~MOST
+ #{key('Default Attributes:')}
+ #{text_format(node.default_attrs)}
+ #{key('Override Attributes:')}
+ #{text_format(node.override_attrs)}
+ #{key('Automatic Attributes (Ohai Data):')}
+ #{text_format(node.automatic_attrs)}
MOST
end
summarized
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 1e2d9b41b6..5672124007 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -32,18 +32,18 @@ class Chef
def self.included(includer)
includer.class_eval do
option :medium_output,
- :short => "-m",
- :long => "--medium",
- :boolean => true,
- :default => false,
- :description => "Include normal attributes in the output"
+ short: "-m",
+ long: "--medium",
+ boolean: true,
+ default: false,
+ description: "Include normal attributes in the output"
option :long_output,
- :short => "-l",
- :long => "--long",
- :boolean => true,
- :default => false,
- :description => "Include all attributes in the output"
+ short: "-l",
+ long: "--long",
+ boolean: true,
+ default: false,
+ description: "Include all attributes in the output"
end
end
end
@@ -101,7 +101,7 @@ class Chef
fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
name = node["name"] || node.name
- run_list = "#{node['run_list']}" if config[:run_list]
+ run_list = (node["run_list"]).to_s if config[:run_list]
line_parts = Array.new
if node["ohai_time"]
diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb
index 30b9de3386..91adcb3129 100644
--- a/lib/chef/knife/data_bag_from_file.rb
+++ b/lib/chef/knife/data_bag_from_file.rb
@@ -38,9 +38,9 @@ class Chef
category "data bag"
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Upload all data bags or all items for specified data bags"
+ short: "-a",
+ long: "--all",
+ description: "Upload all data bags or all items for specified data bags"
def loader
@loader ||= Knife::Core::ObjectLoader.new(DataBagItem, ui)
@@ -84,7 +84,7 @@ class Chef
items ||= find_all_data_bag_items(data_bag)
item_paths = normalize_item_paths(items)
item_paths.each do |item_path|
- item = loader.load_from("#{data_bags_path}", data_bag, item_path)
+ item = loader.load_from((data_bags_path).to_s, data_bag, item_path)
item = if encryption_secret_provided?
Chef::EncryptedDataBagItem.encrypt_data_bag_item(item, read_secret)
else
diff --git a/lib/chef/knife/data_bag_list.rb b/lib/chef/knife/data_bag_list.rb
index d507925ec8..454b0a4908 100644
--- a/lib/chef/knife/data_bag_list.rb
+++ b/lib/chef/knife/data_bag_list.rb
@@ -30,9 +30,9 @@ class Chef
category "data bag"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::DataBag.list))
diff --git a/lib/chef/knife/data_bag_secret_options.rb b/lib/chef/knife/data_bag_secret_options.rb
index a612004e15..62a3e71ec5 100644
--- a/lib/chef/knife/data_bag_secret_options.rb
+++ b/lib/chef/knife/data_bag_secret_options.rb
@@ -35,23 +35,23 @@ class Chef
def self.included(base)
base.option :secret,
- :short => "-s SECRET",
- :long => "--secret ",
- :description => "The secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret'",
+ short: "-s SECRET",
+ long: "--secret ",
+ description: "The secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret'",
# Need to store value from command line in separate variable - knife#merge_configs populates same keys
# on config object from
- :proc => Proc.new { |s| set_cl_secret(s) }
+ proc: Proc.new { |s| set_cl_secret(s) }
base.option :secret_file,
- :long => "--secret-file SECRET_FILE",
- :description => "A file containing the secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret_file'",
- :proc => Proc.new { |sf| set_cl_secret_file(sf) }
+ long: "--secret-file SECRET_FILE",
+ description: "A file containing the secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret_file'",
+ proc: Proc.new { |sf| set_cl_secret_file(sf) }
base.option :encrypt,
- :long => "--encrypt",
- :description => "If 'secret' or 'secret_file' is present in your config, then encrypt data bags using it",
- :boolean => true,
- :default => false
+ long: "--encrypt",
+ description: "If 'secret' or 'secret_file' is present in your config, then encrypt data bags using it",
+ boolean: true,
+ default: false
end
def encryption_secret_provided?
diff --git a/lib/chef/knife/delete.rb b/lib/chef/knife/delete.rb
index 19f75df012..1c05fba3cf 100644
--- a/lib/chef/knife/delete.rb
+++ b/lib/chef/knife/delete.rb
@@ -28,21 +28,21 @@ class Chef
end
option :recurse,
- :short => "-r",
- :long => "--[no-]recurse",
- :boolean => true,
- :default => false,
- :description => "Delete directories recursively."
+ short: "-r",
+ long: "--[no-]recurse",
+ boolean: true,
+ default: false,
+ description: "Delete directories recursively."
option :both,
- :long => "--both",
- :boolean => true,
- :default => false,
- :description => "Delete both the local and remote copies."
+ long: "--both",
+ boolean: true,
+ default: false,
+ description: "Delete both the local and remote copies."
option :local,
- :long => "--local",
- :boolean => true,
- :default => false,
- :description => "Delete the local copy (leave the remote copy)."
+ long: "--local",
+ boolean: true,
+ default: false,
+ description: "Delete the local copy (leave the remote copy)."
def run
if name_args.length == 0
diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb
index fb2a8bb40f..4cb77eea46 100644
--- a/lib/chef/knife/deps.rb
+++ b/lib/chef/knife/deps.rb
@@ -29,17 +29,17 @@ class Chef
end
option :recurse,
- :long => "--[no-]recurse",
- :boolean => true,
- :description => "List dependencies recursively (default: true). Only works with --tree."
+ long: "--[no-]recurse",
+ boolean: true,
+ description: "List dependencies recursively (default: true). Only works with --tree."
option :tree,
- :long => "--tree",
- :boolean => true,
- :description => "Show dependencies in a visual tree. May show duplicates."
+ long: "--tree",
+ boolean: true,
+ description: "Show dependencies in a visual tree. May show duplicates."
option :remote,
- :long => "--remote",
- :boolean => true,
- :description => "List dependencies on the server instead of the local filesystem"
+ long: "--remote",
+ boolean: true,
+ description: "List dependencies on the server instead of the local filesystem"
attr_accessor :exit_code
diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb
index a14335c296..aac42ed5c5 100644
--- a/lib/chef/knife/diff.rb
+++ b/lib/chef/knife/diff.rb
@@ -28,29 +28,29 @@ class Chef
end
option :recurse,
- :long => "--[no-]recurse",
- :boolean => true,
- :default => true,
- :description => "List directories recursively."
+ long: "--[no-]recurse",
+ boolean: true,
+ default: true,
+ description: "List directories recursively."
option :name_only,
- :long => "--name-only",
- :boolean => true,
- :description => "Only show names of modified files."
+ long: "--name-only",
+ boolean: true,
+ description: "Only show names of modified files."
option :name_status,
- :long => "--name-status",
- :boolean => true,
- :description => "Only show names and statuses of modified files: Added, Deleted, Modified, and Type Changed."
+ long: "--name-status",
+ boolean: true,
+ description: "Only show names and statuses of modified files: Added, Deleted, Modified, and Type Changed."
option :diff_filter,
- :long => "--diff-filter=[(A|D|M|T)...[*]]",
- :description => "Select only files that are Added (A), Deleted (D), Modified (M), or have their type (i.e. regular file, directory) changed (T). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if
+ long: "--diff-filter=[(A|D|M|T)...[*]]",
+ description: "Select only files that are Added (A), Deleted (D), Modified (M), or have their type (i.e. regular file, directory) changed (T). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if
there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected."
option :cookbook_version,
- :long => "--cookbook-version VERSION",
- :description => "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)"
+ long: "--cookbook-version VERSION",
+ description: "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)"
def run
if config[:name_only]
diff --git a/lib/chef/knife/download.rb b/lib/chef/knife/download.rb
index 942d17d330..f1dfd13326 100644
--- a/lib/chef/knife/download.rb
+++ b/lib/chef/knife/download.rb
@@ -28,39 +28,39 @@ class Chef
end
option :recurse,
- :long => "--[no-]recurse",
- :boolean => true,
- :default => true,
- :description => "List directories recursively."
+ long: "--[no-]recurse",
+ boolean: true,
+ default: true,
+ description: "List directories recursively."
option :purge,
- :long => "--[no-]purge",
- :boolean => true,
- :default => false,
- :description => "Delete matching local files and directories that do not exist remotely."
+ long: "--[no-]purge",
+ boolean: true,
+ default: false,
+ description: "Delete matching local files and directories that do not exist remotely."
option :force,
- :long => "--[no-]force",
- :boolean => true,
- :default => false,
- :description => "Force upload of files even if they match (quicker and harmless, but doesn't print out what it changed)"
+ long: "--[no-]force",
+ boolean: true,
+ default: false,
+ description: "Force upload of files even if they match (quicker and harmless, but doesn't print out what it changed)"
option :dry_run,
- :long => "--dry-run",
- :short => "-n",
- :boolean => true,
- :default => false,
- :description => "Don't take action, only print what would happen"
+ long: "--dry-run",
+ short: "-n",
+ boolean: true,
+ default: false,
+ description: "Don't take action, only print what would happen"
option :diff,
- :long => "--[no-]diff",
- :boolean => true,
- :default => true,
- :description => "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff"
+ long: "--[no-]diff",
+ boolean: true,
+ default: true,
+ description: "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff"
option :cookbook_version,
- :long => "--cookbook-version VERSION",
- :description => "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)"
+ long: "--cookbook-version VERSION",
+ description: "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)"
def run
if name_args.length == 0
diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb
index 597b284356..e150babc31 100644
--- a/lib/chef/knife/edit.rb
+++ b/lib/chef/knife/edit.rb
@@ -29,9 +29,9 @@ class Chef
end
option :local,
- :long => "--local",
- :boolean => true,
- :description => "Show local files instead of remote"
+ long: "--local",
+ boolean: true,
+ description: "Show local files instead of remote"
def run
# Get the matches (recursively)
diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb
index 9131f06068..1395db3f34 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/lib/chef/knife/environment_compare.rb
@@ -29,16 +29,16 @@ class Chef
banner "knife environment compare [ENVIRONMENT..] (options)"
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Show all cookbooks",
- :boolean => true
+ short: "-a",
+ long: "--all",
+ description: "Show all cookbooks",
+ boolean: true
option :mismatch,
- :short => "-m",
- :long => "--mismatch",
- :description => "Only show mismatching versions",
- :boolean => true
+ short: "-m",
+ long: "--mismatch",
+ description: "Only show mismatching versions",
+ boolean: true
def run
# Get the commandline environments or all if none are provided.
diff --git a/lib/chef/knife/environment_create.rb b/lib/chef/knife/environment_create.rb
index cfc1bc268c..e533a70172 100644
--- a/lib/chef/knife/environment_create.rb
+++ b/lib/chef/knife/environment_create.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife environment create ENVIRONMENT (options)"
option :description,
- :short => "-d DESCRIPTION",
- :long => "--description DESCRIPTION",
- :description => "The environment description"
+ short: "-d DESCRIPTION",
+ long: "--description DESCRIPTION",
+ description: "The environment description"
def run
env_name = @name_args[0]
diff --git a/lib/chef/knife/environment_from_file.rb b/lib/chef/knife/environment_from_file.rb
index b16c3331bd..6e22e8b0f6 100644
--- a/lib/chef/knife/environment_from_file.rb
+++ b/lib/chef/knife/environment_from_file.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife environment from file FILE [FILE..] (options)"
option :all,
- :short => "-a",
- :long => "--all",
- :description => "Upload all environments"
+ short: "-a",
+ long: "--all",
+ description: "Upload all environments"
def loader
@loader ||= Knife::Core::ObjectLoader.new(Chef::Environment, ui)
diff --git a/lib/chef/knife/environment_list.rb b/lib/chef/knife/environment_list.rb
index f278046bf9..c3f2ef2e39 100644
--- a/lib/chef/knife/environment_list.rb
+++ b/lib/chef/knife/environment_list.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife environment list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::Environment.list))
diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb
index 7b27a51b85..ed7101c0cc 100644
--- a/lib/chef/knife/exec.rb
+++ b/lib/chef/knife/exec.rb
@@ -24,15 +24,15 @@ class Chef::Knife::Exec < Chef::Knife
banner "knife exec [SCRIPT] (options)"
option :exec,
- :short => "-E CODE",
- :long => "--exec CODE",
- :description => "a string of Chef code to execute"
+ short: "-E CODE",
+ long: "--exec CODE",
+ description: "a string of Chef code to execute"
option :script_path,
- :short => "-p PATH:PATH",
- :long => "--script-path PATH:PATH",
- :description => "A colon-separated path to look for scripts in",
- :proc => lambda { |o| o.split(":") }
+ short: "-p PATH:PATH",
+ long: "--script-path PATH:PATH",
+ description: "A colon-separated path to look for scripts in",
+ proc: lambda { |o| o.split(":") }
deps do
require "chef/shell/ext"
diff --git a/lib/chef/knife/key_create.rb b/lib/chef/knife/key_create.rb
index a9f9da97a7..395bbc4bfd 100644
--- a/lib/chef/knife/key_create.rb
+++ b/lib/chef/knife/key_create.rb
@@ -40,10 +40,10 @@ class Chef
end
def public_key_or_key_name_error_msg
- <<EOS
-You must pass either --public-key or --key-name, or both.
-If you only pass --public-key, a key name will be generated from the fingerprint of your key.
-If you only pass --key-name, a key pair will be generated by the server.
+ <<~EOS
+ You must pass either --public-key or --key-name, or both.
+ If you only pass --public-key, a key name will be generated from the fingerprint of your key.
+ If you only pass --key-name, a key pair will be generated by the server.
EOS
end
diff --git a/lib/chef/knife/key_create_base.rb b/lib/chef/knife/key_create_base.rb
index d02d5ee180..d69f442e71 100644
--- a/lib/chef/knife/key_create_base.rb
+++ b/lib/chef/knife/key_create_base.rb
@@ -25,24 +25,24 @@ class Chef
def self.included(includer)
includer.class_eval do
option :public_key,
- :short => "-p FILENAME",
- :long => "--public-key FILENAME",
- :description => "Public key for newly created key. If not passed, the server will create a key pair for you, but you must pass --key-name NAME in that case."
+ short: "-p FILENAME",
+ long: "--public-key FILENAME",
+ description: "Public key for newly created key. If not passed, the server will create a key pair for you, but you must pass --key-name NAME in that case."
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file, if you requested the server to create one."
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file, if you requested the server to create one."
option :key_name,
- :short => "-k NAME",
- :long => "--key-name NAME",
- :description => "The name for your key. If you do not pass a name, you must pass --public-key, and the name will default to the fingerprint of the public key passed."
+ short: "-k NAME",
+ long: "--key-name NAME",
+ description: "The name for your key. If you do not pass a name, you must pass --public-key, and the name will default to the fingerprint of the public key passed."
option :expiration_date,
- :short => "-e DATE",
- :long => "--expiration-date DATE",
- :description => "Optionally pass the expiration date for the key in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z. Defaults to infinity if not passed. UTC timezone assumed."
+ short: "-e DATE",
+ long: "--expiration-date DATE",
+ description: "Optionally pass the expiration date for the key in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z. Defaults to infinity if not passed. UTC timezone assumed."
end
end
end
diff --git a/lib/chef/knife/key_edit.rb b/lib/chef/knife/key_edit.rb
index 8490d10fa5..d05ee11d1c 100644
--- a/lib/chef/knife/key_edit.rb
+++ b/lib/chef/knife/key_edit.rb
@@ -41,11 +41,11 @@ class Chef
end
def public_key_and_create_key_error_msg
- <<EOS
-You passed both --public-key and --create-key. Only pass one, or the other, or neither.
-Do not pass either if you do not want to change the public_key field of your key.
-Pass --public-key if you want to update the public_key field of your key from a specific public key.
-Pass --create-key if you want the server to generate a new key and use that to update the public_key field of your key.
+ <<~EOS
+ You passed both --public-key and --create-key. Only pass one, or the other, or neither.
+ Do not pass either if you do not want to change the public_key field of your key.
+ Pass --public-key if you want to update the public_key field of your key from a specific public key.
+ Pass --create-key if you want the server to generate a new key and use that to update the public_key field of your key.
EOS
end
diff --git a/lib/chef/knife/key_edit_base.rb b/lib/chef/knife/key_edit_base.rb
index 1a613ef1bc..ecdb4b0038 100644
--- a/lib/chef/knife/key_edit_base.rb
+++ b/lib/chef/knife/key_edit_base.rb
@@ -25,29 +25,29 @@ class Chef
def self.included(includer)
includer.class_eval do
option :public_key,
- :short => "-p FILENAME",
- :long => "--public-key FILENAME",
- :description => "Replace the public_key field from a file on disk. If not passed, the public_key field will not change."
+ short: "-p FILENAME",
+ long: "--public-key FILENAME",
+ description: "Replace the public_key field from a file on disk. If not passed, the public_key field will not change."
option :create_key,
- :short => "-c",
- :long => "--create-key",
- :description => "Replace the public_key field with a key generated by the server. The private key will be returned."
+ short: "-c",
+ long: "--create-key",
+ description: "Replace the public_key field with a key generated by the server. The private key will be returned."
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file, if you requested the server to create one via --create-key."
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file, if you requested the server to create one via --create-key."
option :key_name,
- :short => "-k NAME",
- :long => "--key-name NAME",
- :description => "The new name for your key. Pass if you wish to update the name field of your key."
+ short: "-k NAME",
+ long: "--key-name NAME",
+ description: "The new name for your key. Pass if you wish to update the name field of your key."
option :expiration_date,
- :short => "-e DATE",
- :long => "--expiration-date DATE",
- :description => "Updates the expiration_date field of your key if passed. Pass in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z or infinity. UTC timezone assumed."
+ short: "-e DATE",
+ long: "--expiration-date DATE",
+ description: "Updates the expiration_date field of your key if passed. Pass in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z or infinity. UTC timezone assumed."
end
end
end
diff --git a/lib/chef/knife/key_list.rb b/lib/chef/knife/key_list.rb
index 9a820b7a50..9d3a2c0c26 100644
--- a/lib/chef/knife/key_list.rb
+++ b/lib/chef/knife/key_list.rb
@@ -40,9 +40,9 @@ class Chef
end
def expired_and_non_expired_msg
- <<EOS
-You cannot pass both --only-expired and --only-non-expired.
-Please pass one or none.
+ <<~EOS
+ You cannot pass both --only-expired and --only-non-expired.
+ Please pass one or none.
EOS
end
diff --git a/lib/chef/knife/key_list_base.rb b/lib/chef/knife/key_list_base.rb
index 95858e9ba1..6470bf78ad 100644
--- a/lib/chef/knife/key_list_base.rb
+++ b/lib/chef/knife/key_list_base.rb
@@ -25,19 +25,19 @@ class Chef
def self.included(includer)
includer.class_eval do
option :with_details,
- :short => "-w",
- :long => "--with-details",
- :description => "Show corresponding URIs and whether the key has expired or not."
+ short: "-w",
+ long: "--with-details",
+ description: "Show corresponding URIs and whether the key has expired or not."
option :only_expired,
- :short => "-e",
- :long => "--only-expired",
- :description => "Only show expired keys."
+ short: "-e",
+ long: "--only-expired",
+ description: "Only show expired keys."
option :only_non_expired,
- :short => "-n",
- :long => "--only-non-expired",
- :description => "Only show non-expired keys."
+ short: "-n",
+ long: "--only-non-expired",
+ description: "Only show non-expired keys."
end
end
end
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb
index 7dc91d7266..9452478ddb 100644
--- a/lib/chef/knife/list.rb
+++ b/lib/chef/knife/list.rb
@@ -29,30 +29,30 @@ class Chef
end
option :recursive,
- :short => "-R",
- :boolean => true,
- :description => "List directories recursively"
+ short: "-R",
+ boolean: true,
+ description: "List directories recursively"
option :bare_directories,
- :short => "-d",
- :boolean => true,
- :description => "When directories match the pattern, do not show the directories' children"
+ short: "-d",
+ boolean: true,
+ description: "When directories match the pattern, do not show the directories' children"
option :local,
- :long => "--local",
- :boolean => true,
- :description => "List local directory instead of remote"
+ long: "--local",
+ boolean: true,
+ description: "List local directory instead of remote"
option :flat,
- :short => "-f",
- :long => "--flat",
- :boolean => true,
- :description => "Show a list of filenames rather than the prettified ls-like output normally produced"
+ short: "-f",
+ long: "--flat",
+ boolean: true,
+ description: "Show a list of filenames rather than the prettified ls-like output normally produced"
option :one_column,
- :short => "-1",
- :boolean => true,
- :description => "Show only one column of results"
+ short: "-1",
+ boolean: true,
+ description: "Show only one column of results"
option :trailing_slashes,
- :short => "-p",
- :boolean => true,
- :description => "Show trailing slashes after directories"
+ short: "-p",
+ boolean: true,
+ description: "Show trailing slashes after directories"
attr_accessor :exit_code
diff --git a/lib/chef/knife/node_edit.rb b/lib/chef/knife/node_edit.rb
index 4632c0a5b4..7551a8a7da 100644
--- a/lib/chef/knife/node_edit.rb
+++ b/lib/chef/knife/node_edit.rb
@@ -32,10 +32,10 @@ class Chef
banner "knife node edit NODE (options)"
option :all_attributes,
- :short => "-a",
- :long => "--all",
- :boolean => true,
- :description => "Display all attributes when editing"
+ short: "-a",
+ long: "--all",
+ boolean: true,
+ description: "Display all attributes when editing"
def run
if node_name.nil?
diff --git a/lib/chef/knife/node_list.rb b/lib/chef/knife/node_list.rb
index 4885208136..4bc2c34508 100644
--- a/lib/chef/knife/node_list.rb
+++ b/lib/chef/knife/node_list.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife node list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
env = Chef::Config[:environment]
diff --git a/lib/chef/knife/node_run_list_add.rb b/lib/chef/knife/node_run_list_add.rb
index fb4ce3bc12..3fc28c041d 100644
--- a/lib/chef/knife/node_run_list_add.rb
+++ b/lib/chef/knife/node_run_list_add.rb
@@ -30,14 +30,14 @@ class Chef
banner "knife node run_list add [NODE] [ENTRY [ENTRY]] (options)"
option :after,
- :short => "-a ITEM",
- :long => "--after ITEM",
- :description => "Place the ENTRY in the run list after ITEM"
+ short: "-a ITEM",
+ long: "--after ITEM",
+ description: "Place the ENTRY in the run list after ITEM"
option :before,
- :short => "-b ITEM",
- :long => "--before ITEM",
- :description => "Place the ENTRY in the run list before ITEM"
+ short: "-b ITEM",
+ long: "--before ITEM",
+ description: "Place the ENTRY in the run list before ITEM"
def run
node = Chef::Node.load(@name_args[0])
diff --git a/lib/chef/knife/node_show.rb b/lib/chef/knife/node_show.rb
index 3092b3fc27..43e7e9dbee 100644
--- a/lib/chef/knife/node_show.rb
+++ b/lib/chef/knife/node_show.rb
@@ -34,14 +34,14 @@ class Chef
banner "knife node show NODE (options)"
option :run_list,
- :short => "-r",
- :long => "--run-list",
- :description => "Show only the run list"
+ short: "-r",
+ long: "--run-list",
+ description: "Show only the run list"
option :environment,
- :short => "-E",
- :long => "--environment",
- :description => "Show only the Chef environment"
+ short: "-E",
+ long: "--environment",
+ description: "Show only the Chef environment"
def run
ui.use_presenter Knife::Core::NodePresenter
diff --git a/lib/chef/knife/osc_user_create.rb b/lib/chef/knife/osc_user_create.rb
index 74b50a4ef4..9ebf268110 100644
--- a/lib/chef/knife/osc_user_create.rb
+++ b/lib/chef/knife/osc_user_create.rb
@@ -32,25 +32,25 @@ class Chef
end
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file"
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file"
option :admin,
- :short => "-a",
- :long => "--admin",
- :description => "Create the user as an admin",
- :boolean => true
+ short: "-a",
+ long: "--admin",
+ description: "Create the user as an admin",
+ boolean: true
option :user_password,
- :short => "-p PASSWORD",
- :long => "--password PASSWORD",
- :description => "Password for newly created user",
- :default => ""
+ short: "-p PASSWORD",
+ long: "--password PASSWORD",
+ description: "Password for newly created user",
+ default: ""
option :user_key,
- :long => "--user-key FILENAME",
- :description => "Public key for newly created user. By default a key will be created for you."
+ long: "--user-key FILENAME",
+ description: "Public key for newly created user. By default a key will be created for you."
banner "knife osc_user create USER (options)"
diff --git a/lib/chef/knife/osc_user_list.rb b/lib/chef/knife/osc_user_list.rb
index f1002c4f54..17a7a781d9 100644
--- a/lib/chef/knife/osc_user_list.rb
+++ b/lib/chef/knife/osc_user_list.rb
@@ -35,9 +35,9 @@ class Chef
banner "knife osc_user list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::User.list))
diff --git a/lib/chef/knife/osc_user_reregister.rb b/lib/chef/knife/osc_user_reregister.rb
index dee1cf41b1..5f5d3fb246 100644
--- a/lib/chef/knife/osc_user_reregister.rb
+++ b/lib/chef/knife/osc_user_reregister.rb
@@ -35,9 +35,9 @@ class Chef
banner "knife osc_user reregister USER (options)"
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file"
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file"
def run
@user_name = @name_args[0]
diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb
index dfbf423e92..2d49c457fc 100644
--- a/lib/chef/knife/raw.rb
+++ b/lib/chef/knife/raw.rb
@@ -33,27 +33,27 @@ class Chef
end
option :method,
- :long => "--method METHOD",
- :short => "-m METHOD",
- :default => "GET",
- :description => "Request method (GET, POST, PUT or DELETE). Default: GET"
+ long: "--method METHOD",
+ short: "-m METHOD",
+ default: "GET",
+ description: "Request method (GET, POST, PUT or DELETE). Default: GET"
option :pretty,
- :long => "--[no-]pretty",
- :boolean => true,
- :default => true,
- :description => "Pretty-print JSON output. Default: true"
+ long: "--[no-]pretty",
+ boolean: true,
+ default: true,
+ description: "Pretty-print JSON output. Default: true"
option :input,
- :long => "--input FILE",
- :short => "-i FILE",
- :description => "Name of file to use for PUT or POST"
+ long: "--input FILE",
+ short: "-i FILE",
+ description: "Name of file to use for PUT or POST"
option :proxy_auth,
- :long => "--proxy-auth",
- :boolean => true,
- :default => false,
- :description => "Use webui proxy authentication. Client key must be the webui key."
+ long: "--proxy-auth",
+ boolean: true,
+ default: false,
+ description: "Use webui proxy authentication. Client key must be the webui key."
# We need a custom HTTP client class here because we don't want to even
# try to decode the body, in case we get back corrupted JSON or whatnot.
@@ -105,7 +105,7 @@ class Chef
result = Chef::JSONCompat.to_json_pretty(result)
end
else
- chef_rest = RawInputServerAPI.new(:raw_output => true)
+ chef_rest = RawInputServerAPI.new(raw_output: true)
result = chef_rest.request(method, name_args[0], headers, data)
end
output result
diff --git a/lib/chef/knife/role_create.rb b/lib/chef/knife/role_create.rb
index a389d849f7..6b953f31c8 100644
--- a/lib/chef/knife/role_create.rb
+++ b/lib/chef/knife/role_create.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife role create ROLE (options)"
option :description,
- :short => "-d DESC",
- :long => "--description DESC",
- :description => "The role description"
+ short: "-d DESC",
+ long: "--description DESC",
+ description: "The role description"
def run
@role_name = @name_args[0]
diff --git a/lib/chef/knife/role_env_run_list_add.rb b/lib/chef/knife/role_env_run_list_add.rb
index c24ae3d331..0f4bee9dbf 100644
--- a/lib/chef/knife/role_env_run_list_add.rb
+++ b/lib/chef/knife/role_env_run_list_add.rb
@@ -31,9 +31,9 @@ class Chef
banner "knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY [ENTRY]] (options)"
option :after,
- :short => "-a ITEM",
- :long => "--after ITEM",
- :description => "Place the ENTRY in the run list after ITEM"
+ short: "-a ITEM",
+ long: "--after ITEM",
+ description: "Place the ENTRY in the run list after ITEM"
def add_to_env_run_list(role, environment, entries, after = nil)
if after
diff --git a/lib/chef/knife/role_env_run_list_remove.rb b/lib/chef/knife/role_env_run_list_remove.rb
index 576e32e2a9..f31f40b58a 100644
--- a/lib/chef/knife/role_env_run_list_remove.rb
+++ b/lib/chef/knife/role_env_run_list_remove.rb
@@ -33,9 +33,9 @@ class Chef
nlist = []
role.run_list_for(environment).each do |entry|
nlist << entry unless entry == item_to_remove
- #unless entry == @name_args[2]
+ # unless entry == @name_args[2]
# nlist << entry
- #end
+ # end
end
role.env_run_lists_add(environment => nlist)
end
diff --git a/lib/chef/knife/role_list.rb b/lib/chef/knife/role_list.rb
index 1247478ef5..3d6c3b4574 100644
--- a/lib/chef/knife/role_list.rb
+++ b/lib/chef/knife/role_list.rb
@@ -30,9 +30,9 @@ class Chef
banner "knife role list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::Role.list))
diff --git a/lib/chef/knife/role_run_list_add.rb b/lib/chef/knife/role_run_list_add.rb
index df06d91725..c6564f9d04 100644
--- a/lib/chef/knife/role_run_list_add.rb
+++ b/lib/chef/knife/role_run_list_add.rb
@@ -31,9 +31,9 @@ class Chef
banner "knife role run_list add [ROLE] [ENTRY [ENTRY]] (options)"
option :after,
- :short => "-a ITEM",
- :long => "--after ITEM",
- :description => "Place the ENTRY in the run list after ITEM"
+ short: "-a ITEM",
+ long: "--after ITEM",
+ description: "Place the ENTRY in the run list after ITEM"
def add_to_env_run_list(role, environment, entries, after = nil)
if after
diff --git a/lib/chef/knife/role_run_list_remove.rb b/lib/chef/knife/role_run_list_remove.rb
index 0dacfee051..6fd35c6aaa 100644
--- a/lib/chef/knife/role_run_list_remove.rb
+++ b/lib/chef/knife/role_run_list_remove.rb
@@ -33,9 +33,9 @@ class Chef
nlist = []
role.run_list_for(environment).each do |entry|
nlist << entry unless entry == item_to_remove
- #unless entry == @name_args[2]
+ # unless entry == @name_args[2]
# nlist << entry
- #end
+ # end
end
role.env_run_lists_add(environment => nlist)
end
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index 94c33aa594..1bc9ce9f7e 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -38,38 +38,38 @@ class Chef
banner "knife search INDEX QUERY (options)"
option :start,
- :short => "-b ROW",
- :long => "--start ROW",
- :description => "The row to start returning results at",
- :default => 0,
- :proc => lambda { |i| i.to_i }
+ short: "-b ROW",
+ long: "--start ROW",
+ description: "The row to start returning results at",
+ default: 0,
+ proc: lambda { |i| i.to_i }
option :rows,
- :short => "-R INT",
- :long => "--rows INT",
- :description => "The number of rows to return",
- :default => nil,
- :proc => lambda { |i| i.to_i }
+ short: "-R INT",
+ long: "--rows INT",
+ description: "The number of rows to return",
+ default: nil,
+ proc: lambda { |i| i.to_i }
option :run_list,
- :short => "-r",
- :long => "--run-list",
- :description => "Show only the run list"
+ short: "-r",
+ long: "--run-list",
+ description: "Show only the run list"
option :id_only,
- :short => "-i",
- :long => "--id-only",
- :description => "Show only the ID of matching objects"
+ short: "-i",
+ long: "--id-only",
+ description: "Show only the ID of matching objects"
option :query,
- :short => "-q QUERY",
- :long => "--query QUERY",
- :description => "The search query; useful to protect queries starting with -"
+ short: "-q QUERY",
+ long: "--query QUERY",
+ description: "The search query; useful to protect queries starting with -"
option :filter_result,
- :short => "-f FILTER",
- :long => "--filter-result FILTER",
- :description => "Only return specific attributes of the matching objects; for example: \"ServerName=name, Kernel=kernel.version\""
+ short: "-f FILTER",
+ long: "--filter-result FILTER",
+ description: "Only return specific attributes of the matching objects; for example: \"ServerName=name, Kernel=kernel.version\""
def run
read_cli_args
@@ -116,7 +116,7 @@ class Chef
end
if ui.interchange?
- output({ :results => result_count, :rows => result_items })
+ output({ results: result_count, rows: result_items })
else
ui.log "#{result_count} items found"
ui.log("\n")
diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb
index cac7fe8884..eb5c98963c 100644
--- a/lib/chef/knife/serve.rb
+++ b/lib/chef/knife/serve.rb
@@ -24,16 +24,16 @@ class Chef
banner "knife serve (options)"
option :repo_mode,
- :long => "--repo-mode MODE",
- :description => "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything"
+ long: "--repo-mode MODE",
+ description: "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything"
option :chef_repo_path,
- :long => "--chef-repo-path PATH",
- :description => "Overrides the location of chef repo. Default is specified by chef_repo_path in the config"
+ long: "--chef-repo-path PATH",
+ description: "Overrides the location of chef repo. Default is specified by chef_repo_path in the config"
option :chef_zero_host,
- :long => "--chef-zero-host IP",
- :description => "Overrides the host upon which chef-zero listens. Default is 127.0.0.1."
+ long: "--chef-zero-host IP",
+ description: "Overrides the host upon which chef-zero listens. Default is 127.0.0.1."
def configure_chef
super
diff --git a/lib/chef/knife/show.rb b/lib/chef/knife/show.rb
index 92b7ce1483..4511a86004 100644
--- a/lib/chef/knife/show.rb
+++ b/lib/chef/knife/show.rb
@@ -29,9 +29,9 @@ class Chef
end
option :local,
- :long => "--local",
- :boolean => true,
- :description => "Show local files instead of remote"
+ long: "--local",
+ boolean: true,
+ description: "Show local files instead of remote"
def run
# Get the matches (recursively)
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index c38dc43e74..74e457ac8e 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -40,105 +40,105 @@ class Chef
banner "knife ssh QUERY COMMAND (options)"
option :concurrency,
- :short => "-C NUM",
- :long => "--concurrency NUM",
- :description => "The number of concurrent connections",
- :default => nil,
- :proc => lambda { |o| o.to_i }
+ short: "-C NUM",
+ long: "--concurrency NUM",
+ description: "The number of concurrent connections",
+ default: nil,
+ proc: lambda { |o| o.to_i }
option :ssh_attribute,
- :short => "-a ATTR",
- :long => "--attribute ATTR",
- :description => "The attribute to use for opening the connection - default depends on the context"
+ short: "-a ATTR",
+ long: "--attribute ATTR",
+ description: "The attribute to use for opening the connection - default depends on the context"
option :manual,
- :short => "-m",
- :long => "--manual-list",
- :boolean => true,
- :description => "QUERY is a space separated list of servers",
- :default => false
+ short: "-m",
+ long: "--manual-list",
+ boolean: true,
+ description: "QUERY is a space separated list of servers",
+ default: false
option :prefix_attribute,
- :long => "--prefix-attribute ATTR",
- :description => "The attribute to use for prefixing the ouput - default depends on the context"
+ long: "--prefix-attribute ATTR",
+ description: "The attribute to use for prefixing the ouput - default depends on the context"
option :ssh_user,
- :short => "-x USERNAME",
- :long => "--ssh-user USERNAME",
- :description => "The ssh username"
+ short: "-x USERNAME",
+ long: "--ssh-user USERNAME",
+ description: "The ssh username"
option :ssh_password_ng,
- :short => "-P [PASSWORD]",
- :long => "--ssh-password [PASSWORD]",
- :description => "The ssh password - will prompt if flag is specified but no password is given",
+ short: "-P [PASSWORD]",
+ long: "--ssh-password [PASSWORD]",
+ description: "The ssh password - will prompt if flag is specified but no password is given",
# default to a value that can not be a password (boolean)
# so we can effectively test if this parameter was specified
# without a value
- :default => false
+ default: false
option :ssh_port,
- :short => "-p PORT",
- :long => "--ssh-port PORT",
- :description => "The ssh port",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip }
+ short: "-p PORT",
+ long: "--ssh-port PORT",
+ description: "The ssh port",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip }
option :ssh_timeout,
- :short => "-t SECONDS",
- :long => "--ssh-timeout SECONDS",
- :description => "The ssh connection timeout",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_timeout] = key.strip.to_i },
- :default => 120
+ short: "-t SECONDS",
+ long: "--ssh-timeout SECONDS",
+ description: "The ssh connection timeout",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_timeout] = key.strip.to_i },
+ default: 120
option :ssh_gateway,
- :short => "-G GATEWAY",
- :long => "--ssh-gateway GATEWAY",
- :description => "The ssh gateway",
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip }
+ short: "-G GATEWAY",
+ long: "--ssh-gateway GATEWAY",
+ description: "The ssh gateway",
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip }
option :ssh_gateway_identity,
- :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY",
- :description => "The SSH identity file used for gateway authentication"
+ long: "--ssh-gateway-identity SSH_GATEWAY_IDENTITY",
+ description: "The SSH identity file used for gateway authentication"
option :forward_agent,
- :short => "-A",
- :long => "--forward-agent",
- :description => "Enable SSH agent forwarding",
- :boolean => true
+ short: "-A",
+ long: "--forward-agent",
+ description: "Enable SSH agent forwarding",
+ boolean: true
option :ssh_identity_file,
- :short => "-i IDENTITY_FILE",
- :long => "--ssh-identity-file IDENTITY_FILE",
- :description => "The SSH identity file used for authentication"
+ short: "-i IDENTITY_FILE",
+ long: "--ssh-identity-file IDENTITY_FILE",
+ description: "The SSH identity file used for authentication"
option :host_key_verify,
- :long => "--[no-]host-key-verify",
- :description => "Verify host key, enabled by default.",
- :boolean => true,
- :default => true
+ long: "--[no-]host-key-verify",
+ description: "Verify host key, enabled by default.",
+ boolean: true,
+ default: true
option :on_error,
- :short => "-e",
- :long => "--exit-on-error",
- :description => "Immediately exit if an error is encountered",
- :boolean => true,
- :default => false
+ short: "-e",
+ long: "--exit-on-error",
+ description: "Immediately exit if an error is encountered",
+ boolean: true,
+ default: false
option :duplicated_fqdns,
- :long => "--duplicated-fqdns",
- :description => "Behavior if FQDNs are duplicated, ignored by default",
- :proc => Proc.new { |key| Chef::Config[:knife][:duplicated_fqdns] = key.strip.to_sym },
- :default => :ignore
+ long: "--duplicated-fqdns",
+ description: "Behavior if FQDNs are duplicated, ignored by default",
+ proc: Proc.new { |key| Chef::Config[:knife][:duplicated_fqdns] = key.strip.to_sym },
+ default: :ignore
option :tmux_split,
- :long => "--tmux-split",
- :description => "Split tmux window.",
- :boolean => true,
- :default => false
+ long: "--tmux-split",
+ description: "Split tmux window.",
+ boolean: true,
+ default: false
def session
ssh_error_handler = Proc.new do |server|
if config[:on_error]
- #Net::SSH::Multi magic to force exception to be re-raised.
+ # Net::SSH::Multi magic to force exception to be re-raised.
throw :go, :raise
else
ui.warn "Failed to connect to #{server.host} -- #{$!.class.name}: #{$!.message}"
@@ -146,7 +146,7 @@ class Chef
end
end
- @session ||= Net::SSH::Multi.start(:concurrent_connections => config[:concurrency], :on_error => ssh_error_handler)
+ @session ||= Net::SSH::Multi.start(concurrent_connections: config[:concurrency], on_error: ssh_error_handler)
end
def configure_gateway
@@ -505,18 +505,18 @@ class Chef
end
Appscript.app("/Applications/Utilities/Terminal.app").windows.first.activate
- Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using => :command_down)
+ Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", using: :command_down)
term = Appscript.app("Terminal")
window = term.windows.first.get
(session.servers_for.size - 1).times do |i|
window.activate
- Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down)
+ Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", using: :command_down)
end
session.servers_for.each_with_index do |server, tab_number|
cmd = "unset PROMPT_COMMAND; echo -e \"\\033]0;#{server.host}\\007\"; ssh #{server.user ? "#{server.user}@#{server.host}" : server.host}"
- Appscript.app("Terminal").do_script(cmd, :in => window.tabs[tab_number + 1].get)
+ Appscript.app("Terminal").do_script(cmd, in: window.tabs[tab_number + 1].get)
end
end
diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb
index c864ef52ec..858ab3cf89 100644
--- a/lib/chef/knife/ssl_check.rb
+++ b/lib/chef/knife/ssl_check.rb
@@ -151,25 +151,25 @@ class Chef
debug_ssl_settings
debug_chef_ssl_config
- ui.warn(<<-BAD_CERTS)
-There are invalid certificates in your trusted_certs_dir.
-OpenSSL will not use the following certificates when verifying SSL connections:
+ ui.warn(<<~BAD_CERTS)
+ There are invalid certificates in your trusted_certs_dir.
+ OpenSSL will not use the following certificates when verifying SSL connections:
-#{cert_debug_msg}
+ #{cert_debug_msg}
-#{ui.color("TO FIX THESE WARNINGS:", :bold)}
+ #{ui.color("TO FIX THESE WARNINGS:", :bold)}
-We are working on documentation for resolving common issues uncovered here.
+ We are working on documentation for resolving common issues uncovered here.
-* If the certificate is generated by the server, you may try redownloading the
-server's certificate. By default, the certificate is stored in the following
-location on the host where your chef-server runs:
+ * If the certificate is generated by the server, you may try redownloading the
+ server's certificate. By default, the certificate is stored in the following
+ location on the host where your chef-server runs:
- /var/opt/opscode/nginx/ca/SERVER_HOSTNAME.crt
+ /var/opt/opscode/nginx/ca/SERVER_HOSTNAME.crt
-Copy that file to your trusted_certs_dir (currently: #{configuration.trusted_certs_dir})
-using SSH/SCP or some other secure method, then re-run this command to confirm
-that the server's certificate is now trusted.
+ Copy that file to your trusted_certs_dir (currently: #{configuration.trusted_certs_dir})
+ using SSH/SCP or some other secure method, then re-run this command to confirm
+ that the server's certificate is now trusted.
BAD_CERTS
# @TODO: ^ needs URL once documentation is posted.
@@ -184,21 +184,21 @@ BAD_CERTS
debug_ssl_settings
debug_chef_ssl_config
- ui.err(<<-ADVICE)
+ ui.err(<<~ADVICE)
-#{ui.color("TO FIX THIS ERROR:", :bold)}
+ #{ui.color("TO FIX THIS ERROR:", :bold)}
-If the server you are connecting to uses a self-signed certificate, you must
-configure chef to trust that server's certificate.
+ If the server you are connecting to uses a self-signed certificate, you must
+ configure chef to trust that server's certificate.
-By default, the certificate is stored in the following location on the host
-where your chef-server runs:
+ By default, the certificate is stored in the following location on the host
+ where your chef-server runs:
- /var/opt/opscode/nginx/ca/SERVER_HOSTNAME.crt
+ /var/opt/opscode/nginx/ca/SERVER_HOSTNAME.crt
-Copy that file to your trusted_certs_dir (currently: #{configuration.trusted_certs_dir})
-using SSH/SCP or some other secure method, then re-run this command to confirm
-that the server's certificate is now trusted.
+ Copy that file to your trusted_certs_dir (currently: #{configuration.trusted_certs_dir})
+ using SSH/SCP or some other secure method, then re-run this command to confirm
+ that the server's certificate is now trusted.
ADVICE
end
@@ -211,17 +211,17 @@ ADVICE
ui.error("You are attempting to connect to: '#{host}'")
ui.error("The server's certificate belongs to '#{cn}'")
- ui.err(<<-ADVICE)
+ ui.err(<<~ADVICE)
-#{ui.color("TO FIX THIS ERROR:", :bold)}
+ #{ui.color("TO FIX THIS ERROR:", :bold)}
-The solution for this issue depends on your networking configuration. If you
-are able to connect to this server using the hostname #{cn}
-instead of #{host}, then you can resolve this issue by updating chef_server_url
-in your configuration file.
+ The solution for this issue depends on your networking configuration. If you
+ are able to connect to this server using the hostname #{cn}
+ instead of #{host}, then you can resolve this issue by updating chef_server_url
+ in your configuration file.
-If you are not able to connect to the server using the hostname #{cn}
-you will have to update the certificate on the server to use the correct hostname.
+ If you are not able to connect to the server using the hostname #{cn}
+ you will have to update the certificate on the server to use the correct hostname.
ADVICE
end
diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb
index 98c98d06ae..88eb95e97d 100644
--- a/lib/chef/knife/ssl_fetch.rb
+++ b/lib/chef/knife/ssl_fetch.rb
@@ -130,12 +130,12 @@ class Chef
def run
validate_uri
- ui.warn(<<-TRUST_TRUST)
-Certificates from #{host} will be fetched and placed in your trusted_cert
-directory (#{trusted_certs_dir}).
+ ui.warn(<<~TRUST_TRUST)
+ Certificates from #{host} will be fetched and placed in your trusted_cert
+ directory (#{trusted_certs_dir}).
-Knife has no means to verify these are the correct certificates. You should
-verify the authenticity of these certificates after downloading.
+ Knife has no means to verify these are the correct certificates. You should
+ verify the authenticity of these certificates after downloading.
TRUST_TRUST
remote_cert_chain.each do |cert|
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 0e3cd7e7d6..413bff4f66 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -32,23 +32,23 @@ class Chef
banner "knife status QUERY (options)"
option :run_list,
- :short => "-r",
- :long => "--run-list",
- :description => "Show the run list"
+ short: "-r",
+ long: "--run-list",
+ description: "Show the run list"
option :sort_reverse,
- :short => "-s",
- :long => "--sort-reverse",
- :description => "Sort the status list by last run time descending"
+ short: "-s",
+ long: "--sort-reverse",
+ description: "Sort the status list by last run time descending"
option :hide_healthy,
- :short => "-H",
- :long => "--hide-healthy",
- :description => "Hide nodes that have run chef in the last hour. [DEPRECATED] Use --hide-by-mins MINS instead"
+ short: "-H",
+ long: "--hide-healthy",
+ description: "Hide nodes that have run chef in the last hour. [DEPRECATED] Use --hide-by-mins MINS instead"
option :hide_by_mins,
- :long => "--hide-by-mins MINS",
- :description => "Hide nodes that have run chef in the last MINS minutes"
+ long: "--hide-by-mins MINS",
+ description: "Hide nodes that have run chef in the last MINS minutes"
def append_to_query(term)
@query << " AND " unless @query.empty?
diff --git a/lib/chef/knife/upload.rb b/lib/chef/knife/upload.rb
index 063ed26892..e4e0a74b28 100644
--- a/lib/chef/knife/upload.rb
+++ b/lib/chef/knife/upload.rb
@@ -28,41 +28,41 @@ class Chef
end
option :recurse,
- :long => "--[no-]recurse",
- :boolean => true,
- :default => true,
- :description => "List directories recursively."
+ long: "--[no-]recurse",
+ boolean: true,
+ default: true,
+ description: "List directories recursively."
option :purge,
- :long => "--[no-]purge",
- :boolean => true,
- :default => false,
- :description => "Delete matching local files and directories that do not exist remotely."
+ long: "--[no-]purge",
+ boolean: true,
+ default: false,
+ description: "Delete matching local files and directories that do not exist remotely."
option :force,
- :long => "--[no-]force",
- :boolean => true,
- :default => false,
- :description => "Force upload of files even if they match (quicker for many files). Will overwrite frozen cookbooks."
+ long: "--[no-]force",
+ boolean: true,
+ default: false,
+ description: "Force upload of files even if they match (quicker for many files). Will overwrite frozen cookbooks."
option :freeze,
- :long => "--[no-]freeze",
- :boolean => true,
- :default => false,
- :description => "Freeze cookbooks that get uploaded."
+ long: "--[no-]freeze",
+ boolean: true,
+ default: false,
+ description: "Freeze cookbooks that get uploaded."
option :dry_run,
- :long => "--dry-run",
- :short => "-n",
- :boolean => true,
- :default => false,
- :description => "Don't take action, only print what would happen"
+ long: "--dry-run",
+ short: "-n",
+ boolean: true,
+ default: false,
+ description: "Don't take action, only print what would happen"
option :diff,
- :long => "--[no-]diff",
- :boolean => true,
- :default => true,
- :description => "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff"
+ long: "--[no-]diff",
+ boolean: true,
+ default: true,
+ description: "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff"
def run
if name_args.length == 0
diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb
index c4a89f3707..a1761de979 100644
--- a/lib/chef/knife/user_create.rb
+++ b/lib/chef/knife/user_create.rb
@@ -32,31 +32,31 @@ class Chef
end
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file if the server generated one."
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file if the server generated one."
option :user_key,
- :long => "--user-key FILENAME",
- :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)."
+ long: "--user-key FILENAME",
+ description: "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)."
option :prevent_keygen,
- :short => "-k",
- :long => "--prevent-keygen",
- :description => "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.",
- :boolean => true
+ short: "-k",
+ long: "--prevent-keygen",
+ description: "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.",
+ boolean: true
option :admin,
- :short => "-a",
- :long => "--admin",
- :description => "DEPRECATED: Open Source Chef 11 only. Create the user as an admin.",
- :boolean => true
+ short: "-a",
+ long: "--admin",
+ description: "DEPRECATED: Open Source Chef 11 only. Create the user as an admin.",
+ boolean: true
option :user_password,
- :short => "-p PASSWORD",
- :long => "--password PASSWORD",
- :description => "DEPRECATED: Open Source Chef 11 only. Password for newly created user.",
- :default => ""
+ short: "-p PASSWORD",
+ long: "--password PASSWORD",
+ description: "DEPRECATED: Open Source Chef 11 only. Password for newly created user.",
+ default: ""
banner "knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)"
@@ -69,17 +69,17 @@ class Chef
end
def osc_11_warning
- <<-EOF
-IF YOU ARE USING CHEF SERVER 12+, PLEASE FOLLOW THE INSTRUCTIONS UNDER knife user create --help.
-You only passed a single argument to knife user create.
-For backwards compatibility, when only a single argument is passed,
-knife user create assumes you want Open Source 11 Server user creation.
-knife user create for Open Source 11 Server is being deprecated.
-Open Source 11 Server user commands now live under the knife osc_user namespace.
-For backwards compatibility, we will forward this request to knife osc_user create.
-If you are using an Open Source 11 Server, please use that command to avoid this warning.
-NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
-in Chef 15 which will be released April 2019.
+ <<~EOF
+ IF YOU ARE USING CHEF SERVER 12+, PLEASE FOLLOW THE INSTRUCTIONS UNDER knife user create --help.
+ You only passed a single argument to knife user create.
+ For backwards compatibility, when only a single argument is passed,
+ knife user create assumes you want Open Source 11 Server user creation.
+ knife user create for Open Source 11 Server is being deprecated.
+ Open Source 11 Server user commands now live under the knife osc_user namespace.
+ For backwards compatibility, we will forward this request to knife osc_user create.
+ If you are using an Open Source 11 Server, please use that command to avoid this warning.
+ NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
+ in Chef 15 which will be released April 2019.
EOF
end
diff --git a/lib/chef/knife/user_delete.rb b/lib/chef/knife/user_delete.rb
index abfb45253e..b0a2ece065 100644
--- a/lib/chef/knife/user_delete.rb
+++ b/lib/chef/knife/user_delete.rb
@@ -30,15 +30,15 @@ class Chef
banner "knife user delete USER (options)"
def osc_11_warning
- <<-EOF
-The Chef Server you are using does not support the username field.
-This means it is an Open Source 11 Server.
-knife user delete for Open Source 11 Server is being deprecated.
-Open Source 11 Server user commands now live under the knife osc_user namespace.
-For backwards compatibility, we will forward this request to knife osc_user delete.
-If you are using an Open Source 11 Server, please use that command to avoid this warning.
-NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
-in Chef 15 which will be released April 2019.
+ <<~EOF
+ The Chef Server you are using does not support the username field.
+ This means it is an Open Source 11 Server.
+ knife user delete for Open Source 11 Server is being deprecated.
+ Open Source 11 Server user commands now live under the knife osc_user namespace.
+ For backwards compatibility, we will forward this request to knife osc_user delete.
+ If you are using an Open Source 11 Server, please use that command to avoid this warning.
+ NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
+ in Chef 15 which will be released April 2019.
EOF
end
diff --git a/lib/chef/knife/user_edit.rb b/lib/chef/knife/user_edit.rb
index d184b85a6c..8b89b847a9 100644
--- a/lib/chef/knife/user_edit.rb
+++ b/lib/chef/knife/user_edit.rb
@@ -30,15 +30,15 @@ class Chef
banner "knife user edit USER (options)"
def osc_11_warning
- <<-EOF
-The Chef Server you are using does not support the username field.
-This means it is an Open Source 11 Server.
-knife user edit for Open Source 11 Server is being deprecated.
-Open Source 11 Server user commands now live under the knife oc_user namespace.
-For backwards compatibility, we will forward this request to knife osc_user edit.
-If you are using an Open Source 11 Server, please use that command to avoid this warning.
-NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
-in Chef 15 which will be released April 2019.
+ <<~EOF
+ The Chef Server you are using does not support the username field.
+ This means it is an Open Source 11 Server.
+ knife user edit for Open Source 11 Server is being deprecated.
+ Open Source 11 Server user commands now live under the knife oc_user namespace.
+ For backwards compatibility, we will forward this request to knife osc_user edit.
+ If you are using an Open Source 11 Server, please use that command to avoid this warning.
+ NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
+ in Chef 15 which will be released April 2019.
EOF
end
diff --git a/lib/chef/knife/user_list.rb b/lib/chef/knife/user_list.rb
index 88e834025d..eccb8d15a4 100644
--- a/lib/chef/knife/user_list.rb
+++ b/lib/chef/knife/user_list.rb
@@ -32,9 +32,9 @@ class Chef
banner "knife user list (options)"
option :with_uri,
- :short => "-w",
- :long => "--with-uri",
- :description => "Show corresponding URIs"
+ short: "-w",
+ long: "--with-uri",
+ description: "Show corresponding URIs"
def run
output(format_list_for_display(Chef::UserV1.list))
diff --git a/lib/chef/knife/user_reregister.rb b/lib/chef/knife/user_reregister.rb
index fec6792134..c79deb09a7 100644
--- a/lib/chef/knife/user_reregister.rb
+++ b/lib/chef/knife/user_reregister.rb
@@ -30,15 +30,15 @@ class Chef
banner "knife user reregister USER (options)"
def osc_11_warning
- <<-EOF
-The Chef Server you are using does not support the username field.
-This means it is an Open Source 11 Server.
-knife user reregister for Open Source 11 Server is being deprecated.
-Open Source 11 Server user commands now live under the knife osc_user namespace.
-For backwards compatibility, we will forward this request to knife osc_user reregister.
-If you are using an Open Source 11 Server, please use that command to avoid this warning.
-NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
-in Chef 15 which will be released April 2019.
+ <<~EOF
+ The Chef Server you are using does not support the username field.
+ This means it is an Open Source 11 Server.
+ knife user reregister for Open Source 11 Server is being deprecated.
+ Open Source 11 Server user commands now live under the knife osc_user namespace.
+ For backwards compatibility, we will forward this request to knife osc_user reregister.
+ If you are using an Open Source 11 Server, please use that command to avoid this warning.
+ NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
+ in Chef 15 which will be released April 2019.
EOF
end
@@ -50,9 +50,9 @@ EOF
end
option :file,
- :short => "-f FILE",
- :long => "--file FILE",
- :description => "Write the private key to a file"
+ short: "-f FILE",
+ long: "--file FILE",
+ description: "Write the private key to a file"
def run
@user_name = @name_args[0]
diff --git a/lib/chef/knife/user_show.rb b/lib/chef/knife/user_show.rb
index 6ba4ab5016..c2842aa576 100644
--- a/lib/chef/knife/user_show.rb
+++ b/lib/chef/knife/user_show.rb
@@ -32,15 +32,15 @@ class Chef
banner "knife user show USER (options)"
def osc_11_warning
- <<-EOF
-The Chef Server you are using does not support the username field.
-This means it is an Open Source 11 Server.
-knife user show for Open Source 11 Server is being deprecated.
-Open Source 11 Server user commands now live under the knife osc_user namespace.
-For backwards compatibility, we will forward this request to knife osc_user show.
-If you are using an Open Source 11 Server, please use that command to avoid this warning.
-NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
-in Chef 15 which will be released April 2019.
+ <<~EOF
+ The Chef Server you are using does not support the username field.
+ This means it is an Open Source 11 Server.
+ knife user show for Open Source 11 Server is being deprecated.
+ Open Source 11 Server user commands now live under the knife osc_user namespace.
+ For backwards compatibility, we will forward this request to knife osc_user show.
+ If you are using an Open Source 11 Server, please use that command to avoid this warning.
+ NOTE: Backwards compatibility for Open Source 11 Server in these commands will be removed
+ in Chef 15 which will be released April 2019.
EOF
end
diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb
index f663b480e8..bb3ce39717 100644
--- a/lib/chef/knife/xargs.rb
+++ b/lib/chef/knife/xargs.rb
@@ -30,61 +30,61 @@ class Chef
# TODO modify to remote-only / local-only pattern (more like delete)
option :local,
- :long => "--local",
- :boolean => true,
- :description => "Xargs local files instead of remote"
+ long: "--local",
+ boolean: true,
+ description: "Xargs local files instead of remote"
option :patterns,
- :long => "--pattern [PATTERN]",
- :short => "-p [PATTERN]",
- :description => "Pattern on command line (if these are not specified, a list of patterns is expected on standard input). Multiple patterns may be passed in this way.",
- :arg_arity => [1, -1]
+ long: "--pattern [PATTERN]",
+ short: "-p [PATTERN]",
+ description: "Pattern on command line (if these are not specified, a list of patterns is expected on standard input). Multiple patterns may be passed in this way.",
+ arg_arity: [1, -1]
option :diff,
- :long => "--[no-]diff",
- :default => true,
- :boolean => true,
- :description => "Whether to show a diff when files change (default: true)"
+ long: "--[no-]diff",
+ default: true,
+ boolean: true,
+ description: "Whether to show a diff when files change (default: true)"
option :dry_run,
- :long => "--dry-run",
- :boolean => true,
- :description => "Prevents changes from actually being uploaded to the server."
+ long: "--dry-run",
+ boolean: true,
+ description: "Prevents changes from actually being uploaded to the server."
option :force,
- :long => "--[no-]force",
- :boolean => true,
- :default => false,
- :description => "Force upload of files even if they are not changed (quicker and harmless, but doesn't print out what it changed)"
+ long: "--[no-]force",
+ boolean: true,
+ default: false,
+ description: "Force upload of files even if they are not changed (quicker and harmless, but doesn't print out what it changed)"
option :replace_first,
- :long => "--replace-first REPLACESTR",
- :short => "-J REPLACESTR",
- :description => "String to replace with filenames. -J will only replace the FIRST occurrence of the replacement string."
+ long: "--replace-first REPLACESTR",
+ short: "-J REPLACESTR",
+ description: "String to replace with filenames. -J will only replace the FIRST occurrence of the replacement string."
option :replace_all,
- :long => "--replace REPLACESTR",
- :short => "-I REPLACESTR",
- :description => "String to replace with filenames. -I will replace ALL occurrence of the replacement string."
+ long: "--replace REPLACESTR",
+ short: "-I REPLACESTR",
+ description: "String to replace with filenames. -I will replace ALL occurrence of the replacement string."
option :max_arguments_per_command,
- :long => "--max-args MAXARGS",
- :short => "-n MAXARGS",
- :description => "Maximum number of arguments per command line."
+ long: "--max-args MAXARGS",
+ short: "-n MAXARGS",
+ description: "Maximum number of arguments per command line."
option :max_command_line,
- :long => "--max-chars LENGTH",
- :short => "-s LENGTH",
- :description => "Maximum size of command line, in characters"
+ long: "--max-chars LENGTH",
+ short: "-s LENGTH",
+ description: "Maximum size of command line, in characters"
option :verbose_commands,
- :short => "-t",
- :description => "Print command to be run on the command line"
+ short: "-t",
+ description: "Print command to be run on the command line"
option :null_separator,
- :short => "-0",
- :boolean => true,
- :description => "Use the NULL character (\0) as a separator, instead of whitespace"
+ short: "-0",
+ boolean: true,
+ description: "Use the NULL character (\0) as a separator, instead of whitespace"
def run
error = false
@@ -175,7 +175,7 @@ class Chef
# Create the temporary files
files.each do |file|
tempfile = Tempfile.new(file.name)
- tempfiles[tempfile] = { :file => file }
+ tempfiles[tempfile] = { file: file }
end
rescue
destroy_tempfiles(files)
diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb
index 506d4c9a6c..a35f99c52c 100644
--- a/lib/chef/log/winevt.rb
+++ b/lib/chef/log/winevt.rb
@@ -51,46 +51,46 @@ class Chef
def info(msg)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::INFO_TYPE,
- :source => SOURCE,
- :event_id => INFO_EVENT_ID,
- :data => [msg]
+ event_type: ::Win32::EventLog::INFO_TYPE,
+ source: SOURCE,
+ event_id: INFO_EVENT_ID,
+ data: [msg]
)
end
def warn(msg)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::WARN_TYPE,
- :source => SOURCE,
- :event_id => WARN_EVENT_ID,
- :data => [msg]
+ event_type: ::Win32::EventLog::WARN_TYPE,
+ source: SOURCE,
+ event_id: WARN_EVENT_ID,
+ data: [msg]
)
end
def debug(msg)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::INFO_TYPE,
- :source => SOURCE,
- :event_id => DEBUG_EVENT_ID,
- :data => [msg]
+ event_type: ::Win32::EventLog::INFO_TYPE,
+ source: SOURCE,
+ event_id: DEBUG_EVENT_ID,
+ data: [msg]
)
end
def error(msg)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::ERROR_TYPE,
- :source => SOURCE,
- :event_id => ERROR_EVENT_ID,
- :data => [msg]
+ event_type: ::Win32::EventLog::ERROR_TYPE,
+ source: SOURCE,
+ event_id: ERROR_EVENT_ID,
+ data: [msg]
)
end
def fatal(msg)
@eventlog.report_event(
- :event_type => ::Win32::EventLog::ERROR_TYPE,
- :source => SOURCE,
- :event_id => FATAL_EVENT_ID,
- :data => [msg]
+ event_type: ::Win32::EventLog::ERROR_TYPE,
+ source: SOURCE,
+ event_id: FATAL_EVENT_ID,
+ data: [msg]
)
end
diff --git a/lib/chef/mixin/api_version_request_handling.rb b/lib/chef/mixin/api_version_request_handling.rb
index 5566addf1d..5b9a588cac 100644
--- a/lib/chef/mixin/api_version_request_handling.rb
+++ b/lib/chef/mixin/api_version_request_handling.rb
@@ -50,12 +50,12 @@ class Chef
end
def reregister_only_v0_supported_error_msg(max_version, min_version)
- <<-EOH
-The reregister command only supports server API version 0.
-The server that received the request supports a min version of #{min_version} and a max version of #{max_version}.
-User keys are now managed via the key rotation commmands.
-Please refer to the documentation on how to manage your keys via the key rotation commands:
-https://docs.chef.io/server_security.html#key-rotation
+ <<~EOH
+ The reregister command only supports server API version 0.
+ The server that received the request supports a min version of #{min_version} and a max version of #{max_version}.
+ User keys are now managed via the key rotation commmands.
+ Please refer to the documentation on how to manage your keys via the key rotation commands:
+ https://docs.chef.io/server_security.html#key-rotation
EOH
end
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb
index 6621555585..06726b5252 100644
--- a/lib/chef/mixin/deprecation.rb
+++ b/lib/chef/mixin/deprecation.rb
@@ -33,7 +33,7 @@ class Chef
# Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead.
# EOM
def self.deprecate_constant(name, replacement, message)
- deprecated_constants[name] = { :replacement => replacement, :message => message }
+ deprecated_constants[name] = { replacement: replacement, message: message }
end
# Const missing hook to look up deprecated constants defined with
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index 788b236d94..eb59f184d1 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -24,7 +24,7 @@ class Chef
set_or_return(
:owner,
arg,
- :regex => Chef::Config[:user_valid_regex]
+ regex: Chef::Config[:user_valid_regex]
)
end
@@ -34,7 +34,7 @@ class Chef
set_or_return(
:group,
arg,
- :regex => Chef::Config[:group_valid_regex]
+ regex: Chef::Config[:group_valid_regex]
)
end
@@ -42,7 +42,7 @@ class Chef
set_or_return(
:mode,
arg,
- :callbacks => {
+ callbacks: {
"not in valid numeric range" => lambda do |m|
if m.kind_of?(String)
m =~ /^0/ || m = "0#{m}"
@@ -110,16 +110,16 @@ class Chef
rights = instance_variable_get("@#{name}".to_sym)
unless permissions.nil?
input = {
- :permissions => permissions,
- :principals => principals,
+ permissions: permissions,
+ principals: principals,
}
input.merge!(args_hash) unless args_hash.nil?
- validations = { :permissions => { :required => true },
- :principals => { :required => true, :kind_of => [String, Array] },
- :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ] },
- :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] },
- :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] },
+ validations = { permissions: { required: true },
+ principals: { required: true, kind_of: [String, Array] },
+ applies_to_children: { equal_to: [ true, false, :containers_only, :objects_only ] },
+ applies_to_self: { kind_of: [ TrueClass, FalseClass ] },
+ one_level_deep: { kind_of: [ TrueClass, FalseClass ] },
}
validate(input, validations)
@@ -167,7 +167,7 @@ class Chef
set_or_return(
:inherits,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
end
diff --git a/lib/chef/mixin/windows_env_helper.rb b/lib/chef/mixin/windows_env_helper.rb
index 65b4b33cf0..610c0cd075 100644
--- a/lib/chef/mixin/windows_env_helper.rb
+++ b/lib/chef/mixin/windows_env_helper.rb
@@ -32,7 +32,7 @@ class Chef
include Chef::ReservedNames::Win32::API::System
end
- #see: http://msdn.microsoft.com/en-us/library/ms682653%28VS.85%29.aspx
+ # see: http://msdn.microsoft.com/en-us/library/ms682653%28VS.85%29.aspx
HWND_BROADCAST = 0xffff
WM_SETTINGCHANGE = 0x001A
SMTO_BLOCK = 0x0001
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index f03e0ca0b1..b9a005e419 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -115,10 +115,10 @@ class Chef
def name(arg = nil)
if !arg.nil?
validate(
- { :name => arg },
- { :name => { :kind_of => String,
- :cannot_be => :blank,
- :regex => /^[\-[:alnum:]_:.]+$/ },
+ { name: arg },
+ { name: { kind_of: String,
+ cannot_be: :blank,
+ regex: /^[\-[:alnum:]_:.]+$/ },
})
@name = arg
else
@@ -130,7 +130,7 @@ class Chef
set_or_return(
:chef_environment,
arg,
- { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String }
+ { regex: /^[\-[:alnum:]_]+$/, kind_of: String }
)
end
@@ -495,7 +495,7 @@ class Chef
"chef_type" => "node",
"default" => attributes.combined_default,
"override" => attributes.combined_override,
- #Render correctly for run_list items so malformed json does not result
+ # Render correctly for run_list items so malformed json does not result
"run_list" => @primary_runlist.run_list.map { |item| item.to_s },
}
# Chef Server rejects node JSON with extra keys; prior to 12.3,
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index c0066bfce5..6496d91de7 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -37,20 +37,20 @@
#
class Chef
class NodeMap
- COLLISION_WARNING_14 = <<-EOH.gsub(/\s+/, " ").strip
-%{type_caps} %{key} has been loaded from a cookbook. The %{type} %{key} is now
-included in Chef and will take precedence over the existing cookbook %{type} in the
-next major release of Chef (15.0, April 2019). You may be able to remove this cookbook dependency from
-your runlist if you do not use other recipes/resources/libraries from the cookbook.
-Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
+ COLLISION_WARNING_14 = <<~EOH.gsub(/\s+/, " ").strip
+ %{type_caps} %{key} has been loaded from a cookbook. The %{type} %{key} is now
+ included in Chef and will take precedence over the existing cookbook %{type} in the
+ next major release of Chef (15.0, April 2019). You may be able to remove this cookbook dependency from
+ your runlist if you do not use other recipes/resources/libraries from the cookbook.
+ Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
EOH
- COLLISION_WARNING_15 = <<-EOH.gsub(/\s+/, " ").strip
-%{type_caps} %{key} attempted to load from a cookbook. The %{type} %{key} is now
-included in Chef and takes precedence over the existing cookbook %{type}
-which will be ignored. You may be able to remove this cookbook dependency from
-your runlist if you do not use other recipes/resources/libraries from the cookbook.
-Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
+ COLLISION_WARNING_15 = <<~EOH.gsub(/\s+/, " ").strip
+ %{type_caps} %{key} attempted to load from a cookbook. The %{type} %{key} is now
+ included in Chef and takes precedence over the existing cookbook %{type}
+ which will be ignored. You may be able to remove this cookbook dependency from
+ your runlist if you do not use other recipes/resources/libraries from the cookbook.
+ Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
EOH
#
diff --git a/lib/chef/org.rb b/lib/chef/org.rb
index 73a129c7c1..ea1c411b67 100644
--- a/lib/chef/org.rb
+++ b/lib/chef/org.rb
@@ -40,22 +40,22 @@ class Chef
def name(arg = nil)
set_or_return(:name, arg,
- :regex => /^[a-z0-9\-_]+$/)
+ regex: /^[a-z0-9\-_]+$/)
end
def full_name(arg = nil)
set_or_return(:full_name,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def private_key(arg = nil)
set_or_return(:private_key,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def guid(arg = nil)
set_or_return(:guid,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def to_hash
@@ -73,13 +73,13 @@ class Chef
end
def create
- payload = { :name => name, :full_name => full_name }
+ payload = { name: name, full_name: full_name }
new_org = chef_rest.post("organizations", payload)
Chef::Org.from_hash(to_hash.merge(new_org))
end
def update
- payload = { :name => name, :full_name => full_name }
+ payload = { name: name, full_name: full_name }
new_org = chef_rest.put("organizations/#{name}", payload)
Chef::Org.from_hash(to_hash.merge(new_org))
end
@@ -99,10 +99,10 @@ class Chef
end
def associate_user(username)
- request_body = { :user => username }
+ request_body = { user: username }
response = chef_rest.post "organizations/#{@name}/association_requests", request_body
association_id = response["uri"].split("/").last
- chef_rest.put "users/#{username}/association_requests/#{association_id}", { :response => "accept" }
+ chef_rest.put "users/#{username}/association_requests/#{association_id}", { response: "accept" }
end
def dissociate_user(username)
diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb
index b390042ea7..c91c74b047 100644
--- a/lib/chef/policy_builder/expand_node_object.rb
+++ b/lib/chef/policy_builder/expand_node_object.rb
@@ -175,7 +175,7 @@ class Chef
begin
events.cookbook_resolution_start(@expanded_run_list_with_versions)
cookbook_hash = api_service.post("environments/#{node.chef_environment}/cookbook_versions",
- { :run_list => @expanded_run_list_with_versions })
+ { run_list: @expanded_run_list_with_versions })
cookbook_hash = cookbook_hash.inject({}) do |memo, (key, value)|
memo[key] = Chef::CookbookVersion.from_hash(value)
diff --git a/lib/chef/provider/cron/unix.rb b/lib/chef/provider/cron/unix.rb
index 15195dbb88..4edd5ba206 100644
--- a/lib/chef/provider/cron/unix.rb
+++ b/lib/chef/provider/cron/unix.rb
@@ -33,7 +33,7 @@ class Chef
private
def read_crontab
- crontab = shell_out("/usr/bin/crontab -l", :user => @new_resource.user)
+ crontab = shell_out("/usr/bin/crontab -l", user: @new_resource.user)
status = crontab.status.exitstatus
logger.trace crontab.format_for_exception if status > 0
@@ -53,7 +53,7 @@ class Chef
exit_status = 0
error_message = ""
begin
- crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", :user => @new_resource.user)
+ crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", user: @new_resource.user)
stderr = crontab_write.stderr
exit_status = crontab_write.status.exitstatus
# solaris9, 10 on some failures for example invalid 'mins' in crontab fails with exit code of zero :(
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index 9c147cb634..3a209a08a1 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -169,7 +169,7 @@ class Chef
"Invoke-DscResource #{switches}",
output_format
)
- cmdlet.run!({}, { :timeout => new_resource.timeout })
+ cmdlet.run!({}, { timeout: new_resource.timeout })
end
def return_dsc_resource_result(result, property_name)
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index 7a101fa68b..fd20f34786 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -32,10 +32,10 @@ class Chef
@dsc_resource = dsc_resource
@resource_converged = false
@operations = {
- :set => Proc.new do |config_manager, document, shellout_flags|
+ set: Proc.new do |config_manager, document, shellout_flags|
config_manager.set_configuration(document, shellout_flags)
end,
- :test => Proc.new do |config_manager, document, shellout_flags|
+ test: Proc.new do |config_manager, document, shellout_flags|
config_manager.test_configuration(document, shellout_flags)
end }
end
@@ -86,9 +86,9 @@ class Chef
config_manager = Chef::Util::DSC::LocalConfigurationManager.new(@run_context.node, config_directory)
shellout_flags = {
- :cwd => @dsc_resource.cwd,
- :environment => @dsc_resource.environment,
- :timeout => @dsc_resource.timeout,
+ cwd: @dsc_resource.cwd,
+ environment: @dsc_resource.environment,
+ timeout: @dsc_resource.timeout,
}
begin
@@ -113,9 +113,9 @@ class Chef
def generate_configuration_document(config_directory, configuration_flags)
shellout_flags = {
- :cwd => @dsc_resource.cwd,
- :environment => @dsc_resource.environment,
- :timeout => @dsc_resource.timeout,
+ cwd: @dsc_resource.cwd,
+ environment: @dsc_resource.environment,
+ timeout: @dsc_resource.timeout,
}
generator = Chef::Util::DSC::ConfigurationGenerator.new(@run_context.node, config_directory)
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index 3d3255260f..1b97dbf464 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -102,7 +102,7 @@ class Chef
opts[:log_tag] = new_resource.to_s
if (logger.info? || live_stream?) && !sensitive?
if run_context.events.formatter?
- opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute)
+ opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute)
elsif stream_to_stdout?
opts[:live_stream] = STDOUT
end
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 885d473a7a..e8aad1e896 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -37,7 +37,7 @@ class Chef
# CHEF-4762: we expect a nil return value from Chef::HTTP for a "200 Success" response
# and false for a "304 Not Modified" response
modified = @http.head(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
new_resource.headers
)
logger.info("#{new_resource} HEAD to #{new_resource.url} successful")
@@ -54,7 +54,7 @@ class Chef
message = check_message(new_resource.message)
body = @http.get(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
new_resource.headers
)
logger.info("#{new_resource} GET to #{new_resource.url} successful")
@@ -67,7 +67,7 @@ class Chef
converge_by("#{new_resource} PATCH to #{new_resource.url}") do
message = check_message(new_resource.message)
body = @http.patch(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
message,
new_resource.headers
)
@@ -81,7 +81,7 @@ class Chef
converge_by("#{new_resource} PUT to #{new_resource.url}") do
message = check_message(new_resource.message)
body = @http.put(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
message,
new_resource.headers
)
@@ -95,7 +95,7 @@ class Chef
converge_by("#{new_resource} POST to #{new_resource.url}") do
message = check_message(new_resource.message)
body = @http.post(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
message,
new_resource.headers
)
@@ -108,7 +108,7 @@ class Chef
def action_delete
converge_by("#{new_resource} DELETE to #{new_resource.url}") do
body = @http.delete(
- "#{new_resource.url}",
+ (new_resource.url).to_s,
new_resource.headers
)
new_resource.updated_by_last_action(true)
diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb
index c5f15a851a..9b023b1a65 100644
--- a/lib/chef/provider/mdadm.rb
+++ b/lib/chef/provider/mdadm.rb
@@ -31,7 +31,7 @@ class Chef
logger.trace("#{new_resource} checking for software raid device #{current_resource.raid_device}")
device_not_found = 4
- mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", :returns => [0, device_not_found])
+ mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", returns: [0, device_not_found])
exists = (mdadm.status == 0)
current_resource.exists(exists)
end
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index d0da30a30a..52d55f5404 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -232,7 +232,7 @@ class Chef
def device_logstring
case @new_resource.device_type
when :device
- "#{device_real}"
+ (device_real).to_s
when :label
"#{device_real} with label #{@new_resource.device}"
when :uuid
diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb
index 590b2bfa52..1650d1e43a 100644
--- a/lib/chef/provider/mount/windows.rb
+++ b/lib/chef/provider/mount/windows.rb
@@ -41,7 +41,7 @@ class Chef
def load_current_resource
if is_volume(@new_resource.device)
@mount = Chef::Util::Windows::Volume.new(@new_resource.mount_point)
- else #assume network drive
+ else # assume network drive
@mount = Chef::Util::Windows::NetUse.new(@new_resource.mount_point)
end
@@ -61,10 +61,10 @@ class Chef
def mount_fs
unless @current_resource.mounted
- @mount.add(:remote => @new_resource.device,
- :username => @new_resource.username,
- :domainname => @new_resource.domain,
- :password => @new_resource.password)
+ @mount.add(remote: @new_resource.device,
+ username: @new_resource.username,
+ domainname: @new_resource.domain,
+ password: @new_resource.password)
logger.trace("#{@new_resource} is mounted at #{@new_resource.mount_point}")
else
logger.trace("#{@new_resource} is already mounted at #{@new_resource.mount_point}")
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 0af4f87d7f..01d8829dd2 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -307,7 +307,7 @@ class Chef
# used by subclasses. deprecated. use #a_to_s instead.
def expand_options(options)
# its deprecated but still work to do to deprecate it fully
- #Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out instead")
+ # Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out instead")
if options
" #{options.is_a?(Array) ? Shellwords.join(options) : options}"
else
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index c60483d0dc..eb27b23408 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -31,12 +31,12 @@ class Chef
use_multipackage_api
PATHFINDING_POWERSHELL_COMMAND = "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')".freeze
- CHOCO_MISSING_MSG = <<-EOS.freeze
-Could not locate your Chocolatey install. To install chocolatey, we recommend
-the 'chocolatey' cookbook (https://github.com/chocolatey/chocolatey-cookbook).
-If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment
-variable is correctly set. You can verify this with the PowerShell command
-'#{PATHFINDING_POWERSHELL_COMMAND}'.
+ CHOCO_MISSING_MSG = <<~EOS.freeze
+ Could not locate your Chocolatey install. To install chocolatey, we recommend
+ the 'chocolatey' cookbook (https://github.com/chocolatey/chocolatey-cookbook).
+ If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment
+ variable is correctly set. You can verify this with the PowerShell command
+ '#{PATHFINDING_POWERSHELL_COMMAND}'.
EOS
# Responsible for building the current_resource.
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 5af73b8b69..31521c3675 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -85,10 +85,10 @@ class Chef
# in that block will still trigger a syntax error which is
# exactly what we want here -- verify the syntax without
# actually running the script.
- user_code_wrapped_in_powershell_script_block = <<-EOH
-{
- #{new_resource.code}
-}
+ user_code_wrapped_in_powershell_script_block = <<~EOH
+ {
+ #{new_resource.code}
+ }
EOH
user_script_file.puts user_code_wrapped_in_powershell_script_block
@@ -146,75 +146,75 @@ EOH
# executed, otherwise 0 or 1 based on whether $? is set to true
# (success, where we return 0) or false (where we return 1).
def wrapper_script
- <<-EOH
-# Chef Client wrapper for powershell_script resources
-
-# In rare cases, such as when PowerShell is executed
-# as an alternate user, the new-variable cmdlet is not
-# available, so import it just in case
-if ( get-module -ListAvailable Microsoft.PowerShell.Utility )
-{
- Import-Module Microsoft.PowerShell.Utility
-}
-
-# LASTEXITCODE can be uninitialized -- make it explictly 0
-# to avoid incorrect detection of failure (non-zero) codes
-$global:LASTEXITCODE = 0
-
-# Catch any exceptions -- without this, exceptions will result
-# In a zero return code instead of the desired non-zero code
-# that indicates a failure
-trap [Exception] {write-error ($_.Exception.Message);exit 1}
-
-# Variable state that should not be accessible to the user code
-new-variable -name interpolatedexitcode -visibility private -value $#{new_resource.convert_boolean_return}
-new-variable -name chefscriptresult -visibility private
-
-# Initialize a variable we use to capture $? inside a block
-$global:lastcmdlet = $null
-
-# Execute the user's code in a script block --
-$chefscriptresult =
-{
- #{new_resource.code}
-
- # This assignment doesn't affect the block's return value
- $global:lastcmdlet = $?
-}.invokereturnasis()
-
-# Assume failure status of 1 -- success cases
-# will have to override this
-$exitstatus = 1
-
-# If convert_boolean_return is enabled, the block's return value
-# gets precedence in determining our exit status
-if ($interpolatedexitcode -and $chefscriptresult -ne $null -and $chefscriptresult.gettype().name -eq 'boolean')
-{
- $exitstatus = [int32](!$chefscriptresult)
-}
-elseif ($lastcmdlet)
-{
- # Otherwise, a successful cmdlet execution defines the status
- $exitstatus = 0
-}
-elseif ( $LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0 )
-{
- # If the cmdlet status is failed, allow the Win32 status
- # in $LASTEXITCODE to define exit status. This handles the case
- # where no cmdlets, only Win32 processes have run since $?
- # will be set to $false whenever a Win32 process returns a non-zero
- # status.
- $exitstatus = $LASTEXITCODE
-}
-
-# Print STDOUT for the script execution
-Write-Output $chefscriptresult
-
-# If this script is launched with -File, the process exit
-# status of PowerShell.exe will be $exitstatus. If it was
-# launched with -Command, it will be 0 if $exitstatus was 0,
-# 1 (i.e. failed) otherwise.
-exit $exitstatus
+ <<~EOH
+ # Chef Client wrapper for powershell_script resources
+
+ # In rare cases, such as when PowerShell is executed
+ # as an alternate user, the new-variable cmdlet is not
+ # available, so import it just in case
+ if ( get-module -ListAvailable Microsoft.PowerShell.Utility )
+ {
+ Import-Module Microsoft.PowerShell.Utility
+ }
+
+ # LASTEXITCODE can be uninitialized -- make it explictly 0
+ # to avoid incorrect detection of failure (non-zero) codes
+ $global:LASTEXITCODE = 0
+
+ # Catch any exceptions -- without this, exceptions will result
+ # In a zero return code instead of the desired non-zero code
+ # that indicates a failure
+ trap [Exception] {write-error ($_.Exception.Message);exit 1}
+
+ # Variable state that should not be accessible to the user code
+ new-variable -name interpolatedexitcode -visibility private -value $#{new_resource.convert_boolean_return}
+ new-variable -name chefscriptresult -visibility private
+
+ # Initialize a variable we use to capture $? inside a block
+ $global:lastcmdlet = $null
+
+ # Execute the user's code in a script block --
+ $chefscriptresult =
+ {
+ #{new_resource.code}
+
+ # This assignment doesn't affect the block's return value
+ $global:lastcmdlet = $?
+ }.invokereturnasis()
+
+ # Assume failure status of 1 -- success cases
+ # will have to override this
+ $exitstatus = 1
+
+ # If convert_boolean_return is enabled, the block's return value
+ # gets precedence in determining our exit status
+ if ($interpolatedexitcode -and $chefscriptresult -ne $null -and $chefscriptresult.gettype().name -eq 'boolean')
+ {
+ $exitstatus = [int32](!$chefscriptresult)
+ }
+ elseif ($lastcmdlet)
+ {
+ # Otherwise, a successful cmdlet execution defines the status
+ $exitstatus = 0
+ }
+ elseif ( $LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0 )
+ {
+ # If the cmdlet status is failed, allow the Win32 status
+ # in $LASTEXITCODE to define exit status. This handles the case
+ # where no cmdlets, only Win32 processes have run since $?
+ # will be set to $false whenever a Win32 process returns a non-zero
+ # status.
+ $exitstatus = $LASTEXITCODE
+ }
+
+ # Print STDOUT for the script execution
+ Write-Output $chefscriptresult
+
+ # If this script is launched with -File, the process exit
+ # status of PowerShell.exe will be $exitstatus. If it was
+ # launched with -Command, it will be 0 if $exitstatus was 0,
+ # 1 (i.e. failed) otherwise.
+ exit $exitstatus
EOH
end
diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb
index f054af0567..dd07e7448d 100644
--- a/lib/chef/provider/reboot.rb
+++ b/lib/chef/provider/reboot.rb
@@ -45,10 +45,10 @@ class Chef
# @return [void]
def request_reboot
node.run_context.request_reboot(
- :delay_mins => new_resource.delay_mins,
- :reason => new_resource.reason,
- :timestamp => Time.now,
- :requested_by => new_resource.name
+ delay_mins: new_resource.delay_mins,
+ reason: new_resource.reason,
+ timestamp: Time.now,
+ requested_by: new_resource.name
)
end
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index 21c5c4ca04..66540fea8c 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -58,7 +58,7 @@ class Chef
def sftp
host = port ? "#{hostname}:#{port}" : hostname
- @sftp ||= Net::SFTP.start(host, user, :password => pass)
+ @sftp ||= Net::SFTP.start(host, user, password: pass)
end
def pass
diff --git a/lib/chef/provider/resource_update.rb b/lib/chef/provider/resource_update.rb
index e069a8201c..d3c674dd22 100644
--- a/lib/chef/provider/resource_update.rb
+++ b/lib/chef/provider/resource_update.rb
@@ -31,7 +31,7 @@ class Chef
attr_accessor :type
attr_accessor :name
- attr_accessor :duration #ms
+ attr_accessor :duration # ms
attr_accessor :status
attr_accessor :initial_state
attr_accessor :final_state
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 552173fbee..126a431742 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -116,7 +116,7 @@ class Chef
old_list = rc_conf_local.match(/^pkg_scripts="(.*)"/)
old_list = old_list ? old_list[1].split(" ") : []
new_list = old_list - [new_resource.service_name]
- update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = "#{new_list.join(' ')}")
+ update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = (new_list.join(" ")).to_s)
end
end
end
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 1da3d7c01a..18ef245083 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -81,7 +81,7 @@ class Chef
super
if ::File.exists?("/sbin/chkconfig")
- chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1])
+ chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1])
unless run_levels.nil? || run_levels.empty?
all_levels_match = true
chkconfig.stdout.split(/\s+/)[1..-1].each do |level|
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index f2b1ec4262..51105bd06f 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -80,7 +80,7 @@ class Chef
end
def service_status
- cmd = shell_out!(@status_command, "-l", @current_resource.service_name, :returns => [0, 1])
+ cmd = shell_out!(@status_command, "-l", @current_resource.service_name, returns: [0, 1])
# Example output
# $ svcs -l rsyslog
# fmri svc:/application/rsyslog:default
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index badd7695a5..6d5bc338c7 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -79,10 +79,10 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if new_resource.user
uid = Etc.getpwnam(new_resource.user).uid
options = {
- :environment => {
+ environment: {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
},
- :user => new_resource.user,
+ user: new_resource.user,
}
args = "--user"
else
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb
index 487940e84e..2482ce6a5c 100644
--- a/lib/chef/provider/service/windows.rb
+++ b/lib/chef/provider/service/windows.rb
@@ -33,12 +33,12 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
include Chef::ReservedNames::Win32::API::Error rescue LoadError
include Chef::Win32ServiceConstants
- #Win32::Service.get_start_type
+ # Win32::Service.get_start_type
AUTO_START = "auto start"
MANUAL = "demand start"
DISABLED = "disabled"
- #Win32::Service.get_current_state
+ # Win32::Service.get_current_state
RUNNING = "running"
STOPPED = "stopped"
CONTINUE_PENDING = "continue pending"
@@ -361,8 +361,8 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
logger.trace "#{@new_resource.name} setting start_type to #{type}"
Win32::Service.configure(
- :service_name => @new_resource.service_name,
- :start_type => startup_type
+ service_name: @new_resource.service_name,
+ start_type: startup_type
)
@new_resource.updated_by_last_action(true)
end
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index abcc260a78..dec9e06f87 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-#TODO subversion and git should both extend from a base SCM provider.
+# TODO subversion and git should both extend from a base SCM provider.
require "chef/log"
require "chef/provider"
@@ -126,7 +126,7 @@ class Chef
new_resource.revision
else
command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}")
- svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout
+ svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout
extract_revision_info(svn_info)
end
@@ -138,7 +138,7 @@ class Chef
def find_current_revision
return nil unless ::File.exist?(::File.join(new_resource.destination, ".svn"))
command = scm(:info)
- svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout
+ svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout
extract_revision_info(svn_info)
end
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index 0450516d58..44f34fb8d7 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -247,8 +247,8 @@ class Chef
if new_resource.user
uid = Etc.getpwnam(new_resource.user).uid
{
- :user => new_resource.user,
- :environment => {
+ user: new_resource.user,
+ environment: {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
},
}
diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb
index b40794564a..9ac5a89b3e 100644
--- a/lib/chef/provider/template/content.rb
+++ b/lib/chef/provider/template/content.rb
@@ -29,7 +29,7 @@ class Chef
def template_location
@template_file_cache_location ||= begin
- template_finder.find(new_resource.source, :local => new_resource.local, :cookbook => new_resource.cookbook)
+ template_finder.find(new_resource.source, local: new_resource.local, cookbook: new_resource.cookbook)
end
end
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index c22329d0d6..9584e20656 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -326,7 +326,7 @@ user password using shadow hash.")
end
def ditto_home
- shell_out!("/usr/sbin/createhomedir", "-c", "-u", "#{new_resource.username}")
+ shell_out!("/usr/sbin/createhomedir", "-c", "-u", (new_resource.username).to_s)
end
def move_home
diff --git a/lib/chef/provider/windows_env.rb b/lib/chef/provider/windows_env.rb
index 4e7fa34216..e5af49fa8f 100644
--- a/lib/chef/provider/windows_env.rb
+++ b/lib/chef/provider/windows_env.rb
@@ -63,7 +63,7 @@ class Chef
# <false>:: If a change is not required
def requires_modify_or_create?
if new_resource.delim
- #e.g. check for existing value within PATH
+ # e.g. check for existing value within PATH
new_values.inject(0) do |index, val|
next_index = current_values.find_index val
return true if next_index.nil? || next_index < index
@@ -91,18 +91,18 @@ class Chef
end
end
- #e.g. delete a PATH element
+ # e.g. delete a PATH element
#
# ==== Returns
# <true>:: If we handled the element case and caller should not delete the key
# <false>:: Caller should delete the key, either no :delim was specific or value was empty
# after we removed the element.
def delete_element
- return false unless new_resource.delim #no delim: delete the key
+ return false unless new_resource.delim # no delim: delete the key
needs_delete = new_values.any? { |v| current_values.include?(v) }
if !needs_delete
logger.trace("#{new_resource} element '#{new_resource.value}' does not exist")
- return true #do not delete the key
+ return true # do not delete the key
else
new_value =
current_values.select do |item|
@@ -110,13 +110,13 @@ class Chef
end.join(new_resource.delim)
if new_value.empty?
- return false #nothing left here, delete the key
+ return false # nothing left here, delete the key
else
old_value = new_resource.value(new_value)
create_env
logger.trace("#{new_resource} deleted #{old_value} element")
new_resource.updated_by_last_action(true)
- return true #we removed the element and updated; do not delete the key
+ return true # we removed the element and updated; do not delete the key
end
end
end
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 1676ec3f6b..f8df5dc9a8 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -46,7 +46,7 @@ class Chef
SEP: TaskScheduler::SEPTEMBER,
OCT: TaskScheduler::OCTOBER,
NOV: TaskScheduler::NOVEMBER,
- DEC: TaskScheduler::DECEMBER
+ DEC: TaskScheduler::DECEMBER,
}
DAYS_OF_WEEK = { MON: TaskScheduler::MONDAY,
@@ -61,7 +61,7 @@ class Chef
FIRST: TaskScheduler::FIRST_WEEK,
SECOND: TaskScheduler::SECOND_WEEK,
THIRD: TaskScheduler::THIRD_WEEK,
- FOURTH: TaskScheduler::FOURTH_WEEK
+ FOURTH: TaskScheduler::FOURTH_WEEK,
}
DAYS_OF_MONTH = {
@@ -95,7 +95,7 @@ class Chef
28 => TaskScheduler::TASK_TWENTY_EIGHTH,
29 => TaskScheduler::TASK_TWENTY_NINTH,
30 => TaskScheduler::TASK_THIRTYETH,
- 31 => TaskScheduler::TASK_THIRTY_FIRST
+ 31 => TaskScheduler::TASK_THIRTY_FIRST,
}
def load_current_resource
@@ -195,7 +195,7 @@ class Chef
logger.trace "#{new_resource} task exists"
if current_resource.task.status == "not scheduled"
converge_by("#{new_resource} task enabled") do
- #TODO wind32-taskscheduler currently not having any method to handle this so using schtasks.exe here
+ # TODO wind32-taskscheduler currently not having any method to handle this so using schtasks.exe here
run_schtasks "CHANGE", "ENABLE" => ""
end
else
@@ -212,7 +212,7 @@ class Chef
logger.info "#{new_resource} task exists"
if %w{ready running}.include?(current_resource.task.status)
converge_by("#{new_resource} task disabled") do
- #TODO: in win32-taskscheduler there is no method whcih disbales the task so currently calling disable with schtasks.exe
+ # TODO: in win32-taskscheduler there is no method whcih disbales the task so currently calling disable with schtasks.exe
run_schtasks "CHANGE", "DISABLE" => ""
end
else
@@ -256,7 +256,7 @@ class Chef
def trigger
start_month, start_day, start_year = new_resource.start_day.to_s.split("/")
start_hour, start_minute = new_resource.start_time.to_s.split(":")
- #TODO currently end_month, end_year and end_year needs to be set to 0. If not set win32-taskscheduler throwing nil into integer error.
+ # TODO currently end_month, end_year and end_year needs to be set to 0. If not set win32-taskscheduler throwing nil into integer error.
trigger_hash = {
start_year: start_year.to_i,
start_month: start_month.to_i,
@@ -268,7 +268,7 @@ class Chef
end_year: 0,
trigger_type: trigger_type,
type: type,
- random_minutes_interval: new_resource.random_delay
+ random_minutes_interval: new_resource.random_delay,
}
if new_resource.frequency == :minute
@@ -318,7 +318,7 @@ class Chef
hours.to_i * 60 if hours
end
- #TODO : Try to optimize this method
+ # TODO : Try to optimize this method
# known issue : Since start_day and time is not mandatory while updating weekly frequency for which start_day is not mentioned by user idempotency
# is not gettting maintained as new_resource.start_day is nil and we fetch the day of week from start_day to set and its currently coming as nil and don't match with current_task
def task_needs_update?(task)
@@ -452,7 +452,7 @@ class Chef
def days_of_week
if new_resource.day
- #this line of code is just to support backward compatibility of wild card *
+ # this line of code is just to support backward compatibility of wild card *
new_resource.day = "mon, tue, wed, thu, fri, sat, sun" if new_resource.day == "*" && new_resource.frequency == :weekly
days = new_resource.day.split(",")
days.map! { |day| day.to_s.strip.upcase }
@@ -475,7 +475,7 @@ class Chef
end
if new_resource.months
- #this line of code is just to support backward compatibility of wild card *
+ # this line of code is just to support backward compatibility of wild card *
new_resource.months = "jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec" if new_resource.months == "*" && new_resource.frequency == :monthly
months = new_resource.months.split(",")
months.map! { |month| month.to_s.strip.upcase }
@@ -539,11 +539,11 @@ class Chef
end
end
- #TODO: while creating the configuration settings win32-taskscheduler it accepts execution time limit values in ISO8601 formata
+ # TODO: while creating the configuration settings win32-taskscheduler it accepts execution time limit values in ISO8601 formata
def config_settings
settings = {
execution_time_limit: new_resource.execution_time_limit,
- enabled: true
+ enabled: true,
}
settings[:idle_duration] = new_resource.idle_time if new_resource.idle_time
settings[:run_only_if_idle] = true if new_resource.idle_time
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 478637ff4e..a30504bc91 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -469,7 +469,7 @@ class Chef
if arg.nil?
@guard_interpreter || @default_guard_interpreter
else
- set_or_return(:guard_interpreter, arg, :kind_of => Symbol)
+ set_or_return(:guard_interpreter, arg, kind_of: Symbol)
end
end
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb
index ea6d692709..57cc483c8a 100644
--- a/lib/chef/resource/cron.rb
+++ b/lib/chef/resource/cron.rb
@@ -55,7 +55,7 @@ class Chef
set_or_return(
:minute,
converted_arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -72,7 +72,7 @@ class Chef
set_or_return(
:hour,
converted_arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -89,7 +89,7 @@ class Chef
set_or_return(
:day,
converted_arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -106,7 +106,7 @@ class Chef
set_or_return(
:month,
converted_arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -130,7 +130,7 @@ class Chef
set_or_return(
:weekday,
converted_arg,
- :kind_of => [String, Symbol]
+ kind_of: [String, Symbol]
)
end
diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb
index f3fa5d0314..7d1e11b659 100644
--- a/lib/chef/resource/dsc_script.rb
+++ b/lib/chef/resource/dsc_script.rb
@@ -54,7 +54,7 @@ class Chef
set_or_return(
:code,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -65,7 +65,7 @@ class Chef
set_or_return(
:configuration_name,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -76,7 +76,7 @@ class Chef
set_or_return(
:command,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -87,7 +87,7 @@ class Chef
set_or_return(
:configuration_data,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -98,7 +98,7 @@ class Chef
set_or_return(
:configuration_data_script,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 7003b546fe..dfccfeb138 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -52,7 +52,7 @@ class Chef
set_or_return(
:command,
arg,
- :kind_of => [ String, Array ]
+ kind_of: [ String, Array ]
)
end
property :umask, [ String, Integer ]
diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb
index 578e6066a2..ae4f9043b2 100644
--- a/lib/chef/resource/file/verification.rb
+++ b/lib/chef/resource/file/verification.rb
@@ -113,7 +113,7 @@ class Chef
if @command.include?("%{file}")
raise ArgumentError, "The %{file} expansion for verify commands has been removed. Please use %{path} instead."
end
- command = @command % { :path => path }
+ command = @command % { path: path }
interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts)
interpreter.evaluate
end
diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb
index e85a75e906..f5e4010ee7 100644
--- a/lib/chef/resource/freebsd_package.rb
+++ b/lib/chef/resource/freebsd_package.rb
@@ -46,7 +46,7 @@ class Chef
#
# @return [Boolean] do we support pkgng
def supports_pkgng?
- ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", :env => nil).stdout.match(/yes/i)
+ ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", env: nil).stdout.match(/yes/i)
end
private
diff --git a/lib/chef/resource/group.rb b/lib/chef/resource/group.rb
index 9298fbc150..b67bfe188e 100644
--- a/lib/chef/resource/group.rb
+++ b/lib/chef/resource/group.rb
@@ -41,7 +41,7 @@ class Chef
set_or_return(
:members,
converted_members,
- :kind_of => [ Array ]
+ kind_of: [ Array ]
)
end
@@ -52,7 +52,7 @@ class Chef
set_or_return(
:excluded_members,
converted_members,
- :kind_of => [ Array ]
+ kind_of: [ Array ]
)
end
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb
index 02996f4464..f213ae47ad 100644
--- a/lib/chef/resource/hostname.rb
+++ b/lib/chef/resource/hostname.rb
@@ -132,7 +132,7 @@ class Chef
# this must come before other methods like /etc/hostname and /etc/sysconfig/network
declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do
notifies :reload, "ohai[reload hostname]"
- not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
+ not_if { shell_out!("hostnamectl status", { returns: [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
end
when ::File.exist?("/etc/hostname")
# debian family uses /etc/hostname
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
index 3493cec9db..6e92fb821c 100644
--- a/lib/chef/resource/http_request.rb
+++ b/lib/chef/resource/http_request.rb
@@ -48,7 +48,7 @@ class Chef
set_or_return(
:message,
args,
- :kind_of => Object
+ kind_of: Object
)
end
diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb
index 99821bcefd..95efadd4e6 100644
--- a/lib/chef/resource/powershell_script.rb
+++ b/lib/chef/resource/powershell_script.rb
@@ -40,7 +40,7 @@ class Chef
set_or_return(
:convert_boolean_return,
arg,
- :kind_of => [ FalseClass, TrueClass ]
+ kind_of: [ FalseClass, TrueClass ]
)
end
@@ -52,7 +52,7 @@ class Chef
# guard context and recipe resource context will have the
# same behavior.
def self.get_default_attributes(opts)
- { :convert_boolean_return => true }
+ { convert_boolean_return: true }
end
end
end
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
index daeb7b35bb..f03b13ef02 100644
--- a/lib/chef/resource/remote_directory.rb
+++ b/lib/chef/resource/remote_directory.rb
@@ -63,7 +63,7 @@ class Chef
set_or_return(
:files_group,
arg,
- :regex => Chef::Config[:group_valid_regex]
+ regex: Chef::Config[:group_valid_regex]
)
end
@@ -71,7 +71,7 @@ class Chef
set_or_return(
:files_mode,
arg,
- :regex => /^\d{3,4}$/
+ regex: /^\d{3,4}$/
)
end
@@ -79,7 +79,7 @@ class Chef
set_or_return(
:files_owner,
arg,
- :regex => Chef::Config[:user_valid_regex]
+ regex: Chef::Config[:user_valid_regex]
)
end
end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 832fd3568e..3607a3cbc5 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -48,8 +48,8 @@ class Chef
arg = parse_source_args(args)
ret = set_or_return(:source,
arg,
- { :callbacks => {
- :validate_source => method(:validate_source),
+ { callbacks: {
+ validate_source: method(:validate_source),
} })
if ret.is_a? String
Array(ret)
diff --git a/lib/chef/resource/resource_notification.rb b/lib/chef/resource/resource_notification.rb
index 24f8821b6b..a3475e3301 100644
--- a/lib/chef/resource/resource_notification.rb
+++ b/lib/chef/resource/resource_notification.rb
@@ -79,18 +79,18 @@ class Chef
self.resource = matching_resource
rescue Chef::Exceptions::ResourceNotFound => e
- err = Chef::Exceptions::ResourceNotFound.new(<<-FAIL)
-resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
-but #{resource} cannot be found in the resource collection. #{notifying_resource} is defined in \
-#{notifying_resource.source_line}
+ err = Chef::Exceptions::ResourceNotFound.new(<<~FAIL)
+ resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
+ but #{resource} cannot be found in the resource collection. #{notifying_resource} is defined in \
+ #{notifying_resource.source_line}
FAIL
err.set_backtrace(e.backtrace)
raise err
rescue Chef::Exceptions::InvalidResourceSpecification => e
- err = Chef::Exceptions::InvalidResourceSpecification.new(<<-F)
-Resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
-but #{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
-is defined near #{notifying_resource.source_line}
+ err = Chef::Exceptions::InvalidResourceSpecification.new(<<~F)
+ Resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
+ but #{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
+ is defined near #{notifying_resource.source_line}
F
err.set_backtrace(e.backtrace)
raise err
@@ -112,18 +112,18 @@ is defined near #{notifying_resource.source_line}
self.notifying_resource = matching_notifier
rescue Chef::Exceptions::ResourceNotFound => e
- err = Chef::Exceptions::ResourceNotFound.new(<<-FAIL)
-Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
-but #{notifying_resource} cannot be found in the resource collection. #{resource} is defined in \
-#{resource.source_line}
+ err = Chef::Exceptions::ResourceNotFound.new(<<~FAIL)
+ Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
+ but #{notifying_resource} cannot be found in the resource collection. #{resource} is defined in \
+ #{resource.source_line}
FAIL
err.set_backtrace(e.backtrace)
raise err
rescue Chef::Exceptions::InvalidResourceSpecification => e
- err = Chef::Exceptions::InvalidResourceSpecification.new(<<-F)
-Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
-but #{notifying_resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
-is defined near #{resource.source_line}
+ err = Chef::Exceptions::InvalidResourceSpecification.new(<<~F)
+ Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
+ but #{notifying_resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
+ is defined near #{resource.source_line}
F
err.set_backtrace(e.backtrace)
raise err
diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb
index 07473c9709..fe13c433cb 100644
--- a/lib/chef/resource/service.rb
+++ b/lib/chef/resource/service.rb
@@ -62,7 +62,7 @@ class Chef
set_or_return(
:service_name,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -71,7 +71,7 @@ class Chef
set_or_return(
:pattern,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -80,7 +80,7 @@ class Chef
set_or_return(
:start_command,
arg,
- :kind_of => [ String, NilClass, FalseClass ]
+ kind_of: [ String, NilClass, FalseClass ]
)
end
@@ -89,7 +89,7 @@ class Chef
set_or_return(
:stop_command,
arg,
- :kind_of => [ String, NilClass, FalseClass ]
+ kind_of: [ String, NilClass, FalseClass ]
)
end
@@ -98,7 +98,7 @@ class Chef
set_or_return(
:status_command,
arg,
- :kind_of => [ String, NilClass, FalseClass ]
+ kind_of: [ String, NilClass, FalseClass ]
)
end
@@ -107,7 +107,7 @@ class Chef
set_or_return(
:restart_command,
arg,
- :kind_of => [ String, NilClass, FalseClass ]
+ kind_of: [ String, NilClass, FalseClass ]
)
end
@@ -115,7 +115,7 @@ class Chef
set_or_return(
:reload_command,
arg,
- :kind_of => [ String, NilClass, FalseClass ]
+ kind_of: [ String, NilClass, FalseClass ]
)
end
@@ -128,7 +128,7 @@ class Chef
set_or_return(
:init_command,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -137,7 +137,7 @@ class Chef
set_or_return(
:enabled,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -146,7 +146,7 @@ class Chef
set_or_return(
:running,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -155,7 +155,7 @@ class Chef
set_or_return(
:masked,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -163,7 +163,7 @@ class Chef
set_or_return(
:options,
arg.respond_to?(:split) ? arg.shellsplit : arg,
- :kind_of => [ Array, String ]
+ kind_of: [ Array, String ]
)
end
@@ -181,7 +181,7 @@ class Chef
set_or_return(
:priority,
arg,
- :kind_of => [ Integer, String, Hash ]
+ kind_of: [ Integer, String, Hash ]
)
end
@@ -190,7 +190,7 @@ class Chef
set_or_return(
:timeout,
arg,
- :kind_of => Integer
+ kind_of: Integer
)
end
@@ -198,7 +198,7 @@ class Chef
set_or_return(
:parameters,
arg,
- :kind_of => [ Hash ]
+ kind_of: [ Hash ]
)
end
@@ -206,14 +206,14 @@ class Chef
set_or_return(
:run_levels,
arg,
- :kind_of => [ Array ] )
+ kind_of: [ Array ] )
end
def user(arg = nil)
set_or_return(
:user,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
end
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
index 5fc29ec1c6..45879db8e6 100644
--- a/lib/chef/resource/template.rb
+++ b/lib/chef/resource/template.rb
@@ -53,7 +53,7 @@ class Chef
set_or_return(
:source,
file,
- :kind_of => [ String, Array ]
+ kind_of: [ String, Array ]
)
end
diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb
index 39d8159d4f..df52ebb083 100644
--- a/lib/chef/resource/user.rb
+++ b/lib/chef/resource/user.rb
@@ -51,7 +51,7 @@ class Chef
set_or_return(
:username,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -59,7 +59,7 @@ class Chef
set_or_return(
:comment,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -67,8 +67,8 @@ class Chef
set_or_return(
:uid,
arg,
- :kind_of => [ String, Integer, NilClass ],
- :coerce => proc { |x| x || nil }
+ kind_of: [ String, Integer, NilClass ],
+ coerce: proc { |x| x || nil }
)
end
@@ -76,8 +76,8 @@ class Chef
set_or_return(
:gid,
arg,
- :kind_of => [ String, Integer, NilClass ],
- :coerce => proc { |x| x || nil }
+ kind_of: [ String, Integer, NilClass ],
+ coerce: proc { |x| x || nil }
)
end
@@ -87,7 +87,7 @@ class Chef
set_or_return(
:home,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -95,7 +95,7 @@ class Chef
set_or_return(
:shell,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -103,7 +103,7 @@ class Chef
set_or_return(
:password,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -111,7 +111,7 @@ class Chef
set_or_return(
:salt,
arg,
- :kind_of => [ String ]
+ kind_of: [ String ]
)
end
@@ -119,7 +119,7 @@ class Chef
set_or_return(
:iterations,
arg,
- :kind_of => [ Integer ]
+ kind_of: [ Integer ]
)
end
@@ -127,7 +127,7 @@ class Chef
set_or_return(
:system,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -135,7 +135,7 @@ class Chef
set_or_return(
:manage_home,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -143,7 +143,7 @@ class Chef
set_or_return(
:force,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
@@ -151,7 +151,7 @@ class Chef
set_or_return(
:non_unique,
arg,
- :kind_of => [ TrueClass, FalseClass ]
+ kind_of: [ TrueClass, FalseClass ]
)
end
end
diff --git a/lib/chef/resource/windows_script.rb b/lib/chef/resource/windows_script.rb
index 7c39d9fba0..fe3e37989d 100644
--- a/lib/chef/resource/windows_script.rb
+++ b/lib/chef/resource/windows_script.rb
@@ -45,7 +45,7 @@ class Chef
result = set_or_return(
:architecture,
arg,
- :kind_of => Symbol
+ kind_of: Symbol
)
end
diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb
index aa114af46c..af22a5389e 100644
--- a/lib/chef/resource_definition.rb
+++ b/lib/chef/resource_definition.rb
@@ -62,7 +62,7 @@ class Chef
end
def to_s
- "#{name}"
+ (name).to_s
end
end
end
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index c76ac0a4a3..1ec25fc79a 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -72,7 +72,7 @@ class Chef
as_hash["result"] = action.to_s
if success?
else
- #as_hash["result"] = "failed"
+ # as_hash["result"] = "failed"
end
if new_resource.cookbook_name
as_hash["cookbook_name"] = new_resource.cookbook_name
@@ -120,8 +120,8 @@ class Chef
if reporting_enabled?
begin
resource_history_url = "reports/nodes/#{node_name}/runs"
- server_response = @rest_client.post(resource_history_url, { :action => :start, :run_id => run_id,
- :start_time => start_time.to_s }, headers)
+ server_response = @rest_client.post(resource_history_url, { action: :start, run_id: run_id,
+ start_time: start_time.to_s }, headers)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
handle_error_starting_run(e, resource_history_url)
end
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index ad01e9fa26..f0c4cdd542 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -55,7 +55,7 @@ class Chef
set_or_return(
:name,
arg,
- :regex => /^[\-[:alnum:]_]+$/
+ regex: /^[\-[:alnum:]_]+$/
)
end
@@ -63,7 +63,7 @@ class Chef
set_or_return(
:description,
arg,
- :kind_of => String
+ kind_of: String
)
end
@@ -118,7 +118,7 @@ class Chef
set_or_return(
:default_attributes,
arg,
- :kind_of => Hash
+ kind_of: Hash
)
end
@@ -126,7 +126,7 @@ class Chef
set_or_return(
:override_attributes,
arg,
- :kind_of => Hash
+ kind_of: Hash
)
end
@@ -141,8 +141,8 @@ class Chef
"override_attributes" => @override_attributes,
"chef_type" => "role",
- #Render to_json correctly for run_list items (both run_list and evn_run_lists)
- #so malformed json does not result
+ # Render to_json correctly for run_list items (both run_list and evn_run_lists)
+ # so malformed json does not result
"run_list" => run_list.run_list.map { |item| item.to_s },
"env_run_lists" => env_run_lists_without_default.inject({}) do |accumulator, (k, v)|
accumulator[k] = v.map { |x| x.to_s }
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 2b8c7cda30..a11cc676eb 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -331,12 +331,12 @@ class Chef
cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name, current_cookbook: current_cookbook)
if unreachable_cookbook?(cookbook_name) # CHEF-4367
- logger.warn(<<-ERROR_MESSAGE)
-MissingCookbookDependency:
-Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
-is not a dependency of any cookbook in the run_list. To load this recipe,
-first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
-including it from in that cookbook's metadata.
+ logger.warn(<<~ERROR_MESSAGE)
+ MissingCookbookDependency:
+ Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
+ is not a dependency of any cookbook in the run_list. To load this recipe,
+ first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
+ including it from in that cookbook's metadata.
ERROR_MESSAGE
end
diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb
index b895b53523..085dd9f6be 100644
--- a/lib/chef/run_list/run_list_expansion.rb
+++ b/lib/chef/run_list/run_list_expansion.rb
@@ -148,8 +148,8 @@ class Chef
end
def to_hash
- seen_items = { :recipe => {}, :role => {} }
- { :id => @environment, :run_list => convert_run_list_trace("top level", seen_items) }
+ seen_items = { recipe: {}, role: {} }
+ { id: @environment, run_list: convert_run_list_trace("top level", seen_items) }
end
private
@@ -185,12 +185,12 @@ class Chef
seen_items[item.type][item.name] = true
case item.type
when :recipe
- { :type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped }
+ { type: "recipe", name: item.name, version: item.version, skipped: !!skipped }
when :role
error = @role_errors[item.name]
missing = @all_missing_roles[item.name]
- { :type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items),
- :missing => missing, :error => error, :skipped => skipped }
+ { type: :role, name: item.name, children: (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items),
+ missing: missing, error: error, skipped: skipped }
end
end
end
diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb
index ad769ee952..d9b3c17db3 100644
--- a/lib/chef/run_list/versioned_recipe_list.rb
+++ b/lib/chef/run_list/versioned_recipe_list.rb
@@ -40,7 +40,7 @@ class Chef
end
def with_versions
- map { |recipe_name| { :name => recipe_name, :version => @versions[recipe_name] } }
+ map { |recipe_name| { name: recipe_name, version: @versions[recipe_name] } }
end
# Return an Array of Hashes, each of the form:
@@ -48,7 +48,7 @@ class Chef
def with_version_constraints
map do |recipe_name|
constraint = Chef::VersionConstraint.new(@versions[recipe_name])
- { :name => recipe_name, :version_constraint => constraint }
+ { name: recipe_name, version_constraint: constraint }
end
end
diff --git a/lib/chef/run_status.rb b/lib/chef/run_status.rb
index c3b7945bc9..9a52f846c7 100644
--- a/lib/chef/run_status.rb
+++ b/lib/chef/run_status.rb
@@ -104,16 +104,16 @@ class Chef::RunStatus
# * :backtrace
def to_hash
# use a flat hash here so we can't errors from intermediate values being nil
- { :node => node,
- :success => success?,
- :start_time => start_time,
- :end_time => end_time,
- :elapsed_time => elapsed_time,
- :all_resources => all_resources,
- :updated_resources => updated_resources,
- :exception => formatted_exception,
- :backtrace => backtrace,
- :run_id => run_id }
+ { node: node,
+ success: success?,
+ start_time: start_time,
+ end_time: end_time,
+ elapsed_time: elapsed_time,
+ all_resources: all_resources,
+ updated_resources: updated_resources,
+ exception: formatted_exception,
+ backtrace: backtrace,
+ run_id: run_id }
end
# Returns a string of the format "ExceptionClass: message" or +nil+ if no
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index 88d26e78fc..6c5f70edcc 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -207,91 +207,91 @@ module Shell
banner("chef-shell #{Chef::VERSION}\n\nUsage: chef-shell [NAMED_CONF] (OPTIONS)")
- footer(<<-FOOTER)
-When no CONFIG is specified, chef-shell attempts to load a default configuration file:
-* If a NAMED_CONF is given, chef-shell will load ~/.chef/NAMED_CONF/chef_shell.rb
-* If no NAMED_CONF is given chef-shell will load ~/.chef/chef_shell.rb if it exists
-* If no chef_shell.rb can be found, chef-shell falls back to load:
- /etc/chef/client.rb if -z option is given.
- /etc/chef/solo.rb if --solo-legacy-mode option is given.
- .chef/knife.rb if -s option is given.
+ footer(<<~FOOTER)
+ When no CONFIG is specified, chef-shell attempts to load a default configuration file:
+ * If a NAMED_CONF is given, chef-shell will load ~/.chef/NAMED_CONF/chef_shell.rb
+ * If no NAMED_CONF is given chef-shell will load ~/.chef/chef_shell.rb if it exists
+ * If no chef_shell.rb can be found, chef-shell falls back to load:
+ /etc/chef/client.rb if -z option is given.
+ /etc/chef/solo.rb if --solo-legacy-mode option is given.
+ .chef/knife.rb if -s option is given.
FOOTER
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :description => "The configuration file to use"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ description: "The configuration file to use"
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :proc => proc { print_help }
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ proc: proc { print_help }
option :log_level,
- :short => "-l LOG_LEVEL",
- :long => "--log-level LOG_LEVEL",
- :description => "Set the logging level",
- :proc => proc { |level| Chef::Config.log_level = level.to_sym; Shell.setup_logger }
+ short: "-l LOG_LEVEL",
+ long: "--log-level LOG_LEVEL",
+ description: "Set the logging level",
+ proc: proc { |level| Chef::Config.log_level = level.to_sym; Shell.setup_logger }
option :standalone,
- :short => "-a",
- :long => "--standalone",
- :description => "standalone session",
- :default => true,
- :boolean => true
+ short: "-a",
+ long: "--standalone",
+ description: "standalone session",
+ default: true,
+ boolean: true
option :solo_shell,
- :short => "-s",
- :long => "--solo",
- :description => "chef-solo session",
- :boolean => true,
- :proc => proc { Chef::Config[:solo] = true }
+ short: "-s",
+ long: "--solo",
+ description: "chef-solo session",
+ boolean: true,
+ proc: proc { Chef::Config[:solo] = true }
option :client,
- :short => "-z",
- :long => "--client",
- :description => "chef-client session",
- :boolean => true
+ short: "-z",
+ long: "--client",
+ description: "chef-client session",
+ boolean: true
option :solo_legacy_shell,
- :long => "--solo-legacy-mode",
- :description => "chef-solo legacy session",
- :boolean => true,
- :proc => proc { Chef::Config[:solo_legacy_mode] = true }
+ long: "--solo-legacy-mode",
+ description: "chef-solo legacy session",
+ boolean: true,
+ proc: proc { Chef::Config[:solo_legacy_mode] = true }
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :chef_server_url,
- :short => "-S CHEFSERVERURL",
- :long => "--server CHEFSERVERURL",
- :description => "The chef server URL",
- :proc => nil
+ short: "-S CHEFSERVERURL",
+ long: "--server CHEFSERVERURL",
+ description: "The chef server URL",
+ proc: nil
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :override_runlist,
- :short => "-o RunlistItem,RunlistItem...",
- :long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items",
- :proc => lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } }
+ short: "-o RunlistItem,RunlistItem...",
+ long: "--override-runlist RunlistItem,RunlistItem...",
+ description: "Replace current run list with specified items",
+ proc: lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } }
option :skip_cookbook_sync,
- :long => "--[no-]skip-cookbook-sync",
- :description => "Use cached cookbooks without overwriting local differences from the server",
- :boolean => false
+ long: "--[no-]skip-cookbook-sync",
+ description: "Use cached cookbooks without overwriting local differences from the server",
+ boolean: false
def self.print_help
instance = new
diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb
index fb0733e96e..cb1fb9041b 100644
--- a/lib/chef/shell/ext.rb
+++ b/lib/chef/shell/ext.rb
@@ -190,12 +190,12 @@ module Shell
extend Shell::Extensions::ObjectCoreExtensions
desc "prints this help message"
- explain(<<-E)
-## SUMMARY ##
- When called with no argument, +help+ prints a table of all
- chef-shell commands. When called with an argument COMMAND, +help+
- prints a detailed explanation of the command if available, or the
- description if no explanation is available.
+ explain(<<~E)
+ ## SUMMARY ##
+ When called with no argument, +help+ prints a table of all
+ chef-shell commands. When called with an argument COMMAND, +help+
+ prints a detailed explanation of the command if available, or the
+ description if no explanation is available.
E
def help(commmand = nil)
if commmand
@@ -239,10 +239,10 @@ module Shell
end
desc "returns an object to control a paused chef run"
- subcommands :resume => "resume the chef run",
- :step => "run only the next resource",
- :skip_back => "move back in the run list",
- :skip_forward => "move forward in the run list"
+ subcommands resume: "resume the chef run",
+ step: "run only the next resource",
+ skip_back: "move back in the run list",
+ skip_forward: "move forward in the run list"
def chef_run
Shell.session.resource_collection.iterator
end
@@ -302,18 +302,18 @@ module Shell
RESTApiExtensions = Proc.new do
desc "edit an object in your EDITOR"
- explain(<<-E)
-## SUMMARY ##
- +edit(object)+ allows you to edit any object that can be converted to JSON.
- When finished editing, this method will return the edited object:
-
- new_node = edit(existing_node)
-
-## EDITOR SELECTION ##
- chef-shell looks for an editor using the following logic
- 1. Looks for an EDITOR set by Shell.editor = "EDITOR"
- 2. Looks for an EDITOR configured in your chef-shell config file
- 3. Uses the value of the EDITOR environment variable
+ explain(<<~E)
+ ## SUMMARY ##
+ +edit(object)+ allows you to edit any object that can be converted to JSON.
+ When finished editing, this method will return the edited object:
+
+ new_node = edit(existing_node)
+
+ ## EDITOR SELECTION ##
+ chef-shell looks for an editor using the following logic
+ 1. Looks for an EDITOR set by Shell.editor = "EDITOR"
+ 2. Looks for an EDITOR configured in your chef-shell config file
+ 3. Uses the value of the EDITOR environment variable
E
def edit(object)
unless Shell.editor
@@ -340,196 +340,196 @@ module Shell
end
desc "Find and edit API clients"
- explain(<<-E)
-## SUMMARY ##
- +clients+ allows you to query you chef server for information about your api
- clients.
+ explain(<<~E)
+ ## SUMMARY ##
+ +clients+ allows you to query you chef server for information about your api
+ clients.
-## LIST ALL CLIENTS ##
- To see all clients on the system, use
+ ## LIST ALL CLIENTS ##
+ To see all clients on the system, use
- clients.all #=> [<Chef::ApiClient...>, ...]
+ clients.all #=> [<Chef::ApiClient...>, ...]
- If the output from all is too verbose, or you're only interested in a specific
- value from each of the objects, you can give a code block to +all+:
+ If the output from all is too verbose, or you're only interested in a specific
+ value from each of the objects, you can give a code block to +all+:
- clients.all { |client| client.name } #=> [CLIENT1_NAME, CLIENT2_NAME, ...]
+ clients.all { |client| client.name } #=> [CLIENT1_NAME, CLIENT2_NAME, ...]
-## SHOW ONE CLIENT ##
- To see a specific client, use
+ ## SHOW ONE CLIENT ##
+ To see a specific client, use
- clients.show(CLIENT_NAME)
+ clients.show(CLIENT_NAME)
-## SEARCH FOR CLIENTS ##
- You can also search for clients using +find+ or +search+. You can use the
- familiar string search syntax:
+ ## SEARCH FOR CLIENTS ##
+ You can also search for clients using +find+ or +search+. You can use the
+ familiar string search syntax:
- clients.search("KEY:VALUE")
+ clients.search("KEY:VALUE")
- Just as the +all+ subcommand, the +search+ subcommand can use a code block to
- filter or transform the information returned from the search:
+ Just as the +all+ subcommand, the +search+ subcommand can use a code block to
+ filter or transform the information returned from the search:
- clients.search("KEY:VALUE") { |c| c.name }
+ clients.search("KEY:VALUE") { |c| c.name }
- You can also use a Hash based syntax, multiple search conditions will be
- joined with AND.
+ You can also use a Hash based syntax, multiple search conditions will be
+ joined with AND.
- clients.find :KEY => :VALUE, :KEY2 => :VALUE2, ...
+ clients.find :KEY => :VALUE, :KEY2 => :VALUE2, ...
-## BULK-EDIT CLIENTS ##
- **BE CAREFUL, THIS IS DESTRUCTIVE**
- You can bulk edit API Clients using the +transform+ subcommand, which requires
- a code block. Each client will be saved after the code block is run. If the
- code block returns +nil+ or +false+, that client will be skipped:
+ ## BULK-EDIT CLIENTS ##
+ **BE CAREFUL, THIS IS DESTRUCTIVE**
+ You can bulk edit API Clients using the +transform+ subcommand, which requires
+ a code block. Each client will be saved after the code block is run. If the
+ code block returns +nil+ or +false+, that client will be skipped:
- clients.transform("*:*") do |client|
- if client.name =~ /borat/i
- client.admin(false)
- true
- else
- nil
- end
- end
+ clients.transform("*:*") do |client|
+ if client.name =~ /borat/i
+ client.admin(false)
+ true
+ else
+ nil
+ end
+ end
- This will strip the admin privileges from any client named after borat.
+ This will strip the admin privileges from any client named after borat.
E
- subcommands :all => "list all api clients",
- :show => "load an api client by name",
- :search => "search for API clients",
- :transform => "edit all api clients via a code block and save them"
+ subcommands all: "list all api clients",
+ show: "load an api client by name",
+ search: "search for API clients",
+ transform: "edit all api clients via a code block and save them"
def clients
@clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client)
end
desc "Find and edit cookbooks"
- subcommands :all => "list all cookbooks",
- :show => "load a cookbook by name",
- :transform => "edit all cookbooks via a code block and save them"
+ subcommands all: "list all cookbooks",
+ show: "load a cookbook by name",
+ transform: "edit all cookbooks via a code block and save them"
def cookbooks
@cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion)
end
desc "Find and edit nodes via the API"
- explain(<<-E)
-## SUMMARY ##
- +nodes+ Allows you to query your chef server for information about your nodes.
+ explain(<<~E)
+ ## SUMMARY ##
+ +nodes+ Allows you to query your chef server for information about your nodes.
-## LIST ALL NODES ##
- You can list all nodes using +all+ or +list+
+ ## LIST ALL NODES ##
+ You can list all nodes using +all+ or +list+
- nodes.all #=> [<Chef::Node...>, <Chef::Node...>, ...]
+ nodes.all #=> [<Chef::Node...>, <Chef::Node...>, ...]
- To limit the information returned for each node, pass a code block to the +all+
- subcommand:
+ To limit the information returned for each node, pass a code block to the +all+
+ subcommand:
- nodes.all { |node| node.name } #=> [NODE1_NAME, NODE2_NAME, ...]
+ nodes.all { |node| node.name } #=> [NODE1_NAME, NODE2_NAME, ...]
-## SHOW ONE NODE ##
- You can show the data for a single node using the +show+ subcommand:
+ ## SHOW ONE NODE ##
+ You can show the data for a single node using the +show+ subcommand:
- nodes.show("NODE_NAME") => <Chef::Node @name="NODE_NAME" ...>
+ nodes.show("NODE_NAME") => <Chef::Node @name="NODE_NAME" ...>
-## SEARCH FOR NODES ##
- You can search for nodes using the +search+ or +find+ subcommands:
+ ## SEARCH FOR NODES ##
+ You can search for nodes using the +search+ or +find+ subcommands:
- nodes.find(:name => "app*") #=> [<Chef::Node @name="app1.example.com" ...>, ...]
+ nodes.find(:name => "app*") #=> [<Chef::Node @name="app1.example.com" ...>, ...]
- Similarly to +all+, you can pass a code block to limit or transform the
- information returned:
+ Similarly to +all+, you can pass a code block to limit or transform the
+ information returned:
- nodes.find(:name => "app#") { |node| node.ec2 }
+ nodes.find(:name => "app#") { |node| node.ec2 }
-## BULK EDIT NODES ##
- **BE CAREFUL, THIS OPERATION IS DESTRUCTIVE**
+ ## BULK EDIT NODES ##
+ **BE CAREFUL, THIS OPERATION IS DESTRUCTIVE**
- Bulk edit nodes by passing a code block to the +transform+ or +bulk_edit+
- subcommand. The block will be applied to each matching node, and then the node
- will be saved. If the block returns +nil+ or +false+, that node will be
- skipped.
+ Bulk edit nodes by passing a code block to the +transform+ or +bulk_edit+
+ subcommand. The block will be applied to each matching node, and then the node
+ will be saved. If the block returns +nil+ or +false+, that node will be
+ skipped.
- nodes.transform do |node|
- if node.fqdn =~ /.*\\.preprod\\.example\\.com/
- node.set[:environment] = "preprod"
- end
- end
+ nodes.transform do |node|
+ if node.fqdn =~ /.*\\.preprod\\.example\\.com/
+ node.set[:environment] = "preprod"
+ end
+ end
- This will assign the attribute to every node with a FQDN matching the regex.
+ This will assign the attribute to every node with a FQDN matching the regex.
E
- subcommands :all => "list all nodes",
- :show => "load a node by name",
- :search => "search for nodes",
- :transform => "edit all nodes via a code block and save them"
+ subcommands all: "list all nodes",
+ show: "load a node by name",
+ search: "search for nodes",
+ transform: "edit all nodes via a code block and save them"
def nodes
@nodes ||= Shell::ModelWrapper.new(Chef::Node)
end
desc "Find and edit roles via the API"
- explain(<<-E)
-## SUMMARY ##
- +roles+ allows you to query and edit roles on your Chef server.
-
-## SUBCOMMANDS ##
- * all (list)
- * show (load)
- * search (find)
- * transform (bulk_edit)
-
-## SEE ALSO ##
- See the help for +nodes+ for more information about the subcommands.
+ explain(<<~E)
+ ## SUMMARY ##
+ +roles+ allows you to query and edit roles on your Chef server.
+
+ ## SUBCOMMANDS ##
+ * all (list)
+ * show (load)
+ * search (find)
+ * transform (bulk_edit)
+
+ ## SEE ALSO ##
+ See the help for +nodes+ for more information about the subcommands.
E
- subcommands :all => "list all roles",
- :show => "load a role by name",
- :search => "search for roles",
- :transform => "edit all roles via a code block and save them"
+ subcommands all: "list all roles",
+ show: "load a role by name",
+ search: "search for roles",
+ transform: "edit all roles via a code block and save them"
def roles
@roles ||= Shell::ModelWrapper.new(Chef::Role)
end
desc "Find and edit +databag_name+ via the api"
- explain(<<-E)
-## SUMMARY ##
- +databags(DATABAG_NAME)+ allows you to query and edit data bag items on your
- Chef server. Unlike other commands for working with data on the server,
- +databags+ requires the databag name as an argument, for example:
- databags(:users).all
-
-## SUBCOMMANDS ##
- * all (list)
- * show (load)
- * search (find)
- * transform (bulk_edit)
-
-## SEE ALSO ##
- See the help for +nodes+ for more information about the subcommands.
+ explain(<<~E)
+ ## SUMMARY ##
+ +databags(DATABAG_NAME)+ allows you to query and edit data bag items on your
+ Chef server. Unlike other commands for working with data on the server,
+ +databags+ requires the databag name as an argument, for example:
+ databags(:users).all
+
+ ## SUBCOMMANDS ##
+ * all (list)
+ * show (load)
+ * search (find)
+ * transform (bulk_edit)
+
+ ## SEE ALSO ##
+ See the help for +nodes+ for more information about the subcommands.
E
- subcommands :all => "list all items in the data bag",
- :show => "load a data bag item by id",
- :search => "search for items in the data bag",
- :transform => "edit all items via a code block and save them"
+ subcommands all: "list all items in the data bag",
+ show: "load a data bag item by id",
+ search: "search for items in the data bag",
+ transform: "edit all items via a code block and save them"
def databags(databag_name)
@named_databags_wrappers ||= {}
@named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name)
end
desc "Find and edit environments via the API"
- explain(<<-E)
-## SUMMARY ##
- +environments+ allows you to query and edit environments on your Chef server.
-
-## SUBCOMMANDS ##
- * all (list)
- * show (load)
- * search (find)
- * transform (bulk_edit)
-
-## SEE ALSO ##
- See the help for +nodes+ for more information about the subcommands.
+ explain(<<~E)
+ ## SUMMARY ##
+ +environments+ allows you to query and edit environments on your Chef server.
+
+ ## SUBCOMMANDS ##
+ * all (list)
+ * show (load)
+ * search (find)
+ * transform (bulk_edit)
+
+ ## SEE ALSO ##
+ See the help for +nodes+ for more information about the subcommands.
E
- subcommands :all => "list all environments",
- :show => "load an environment by name",
- :search => "search for environments",
- :transform => "edit all environments via a code block and save them"
+ subcommands all: "list all environments",
+ show: "load an environment by name",
+ search: "search for environments",
+ transform: "edit all environments via a code block and save them"
def environments
@environments ||= Shell::ModelWrapper.new(Chef::Environment)
end
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index aec2152063..789a022b56 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -264,8 +264,8 @@ module Shell
end
def register
- @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], :client_name => Chef::Config[:node_name],
- :signing_key_filename => Chef::Config[:client_key])
+ @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], client_name: Chef::Config[:node_name],
+ signing_key_filename: Chef::Config[:client_key])
end
end
diff --git a/lib/chef/user.rb b/lib/chef/user.rb
index f52d0e2555..eba55c4186 100644
--- a/lib/chef/user.rb
+++ b/lib/chef/user.rb
@@ -49,32 +49,32 @@ class Chef
end
def chef_rest_v0
- @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" })
+ @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" })
end
def name(arg = nil)
set_or_return(:name, arg,
- :regex => /^[a-z0-9\-_]+$/)
+ regex: /^[a-z0-9\-_]+$/)
end
def admin(arg = nil)
set_or_return(:admin,
- arg, :kind_of => [TrueClass, FalseClass])
+ arg, kind_of: [TrueClass, FalseClass])
end
def public_key(arg = nil)
set_or_return(:public_key,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def private_key(arg = nil)
set_or_return(:private_key,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def password(arg = nil)
set_or_return(:password,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def to_hash
@@ -97,14 +97,14 @@ class Chef
end
def create
- payload = { :name => name, :admin => admin, :password => password }
+ payload = { name: name, admin: admin, password: password }
payload[:public_key] = public_key if public_key
new_user = chef_rest_v0.post("users", payload)
Chef::User.from_hash(to_hash.merge(new_user))
end
def update(new_key = false)
- payload = { :name => name, :admin => admin }
+ payload = { name: name, admin: admin }
payload[:private_key] = new_key if new_key
payload[:password] = password if password
updated_user = chef_rest_v0.put("users/#{name}", payload)
@@ -122,7 +122,7 @@ class Chef
end
def reregister
- reregistered_self = chef_rest_v0.put("users/#{name}", { :name => name, :admin => admin, :private_key => true })
+ reregistered_self = chef_rest_v0.put("users/#{name}", { name: name, admin: admin, private_key: true })
private_key(reregistered_self["private_key"])
self
end
@@ -153,7 +153,7 @@ class Chef
end
def self.list(inflate = false)
- response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users")
+ response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }).get("users")
users = if response.is_a?(Array)
transform_ohc_list_response(response) # OHC/OPC
else
@@ -170,7 +170,7 @@ class Chef
end
def self.load(name)
- response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users/#{name}")
+ response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }).get("users/#{name}")
Chef::User.from_hash(response)
end
diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb
index 0ca17c6ed6..8bd92dfab8 100644
--- a/lib/chef/user_v1.rb
+++ b/lib/chef/user_v1.rb
@@ -55,61 +55,61 @@ class Chef
end
def chef_root_rest_v0
- @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "0" })
+ @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "0" })
end
def chef_root_rest_v1
- @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "1" })
+ @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "1" })
end
def username(arg = nil)
set_or_return(:username, arg,
- :regex => /^[a-z0-9\-_]+$/)
+ regex: /^[a-z0-9\-_]+$/)
end
def display_name(arg = nil)
set_or_return(:display_name,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def first_name(arg = nil)
set_or_return(:first_name,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def middle_name(arg = nil)
set_or_return(:middle_name,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def last_name(arg = nil)
set_or_return(:last_name,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def email(arg = nil)
set_or_return(:email,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def create_key(arg = nil)
set_or_return(:create_key, arg,
- :kind_of => [TrueClass, FalseClass])
+ kind_of: [TrueClass, FalseClass])
end
def public_key(arg = nil)
set_or_return(:public_key,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def private_key(arg = nil)
set_or_return(:private_key,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def password(arg = nil)
set_or_return(:password,
- arg, :kind_of => String)
+ arg, kind_of: String)
end
def to_hash
@@ -141,12 +141,12 @@ class Chef
# try v1, fail back to v0 if v1 not supported
begin
payload = {
- :username => @username,
- :display_name => @display_name,
- :first_name => @first_name,
- :last_name => @last_name,
- :email => @email,
- :password => @password,
+ username: @username,
+ display_name: @display_name,
+ first_name: @first_name,
+ last_name: @last_name,
+ email: @email,
+ password: @password,
}
payload[:public_key] = @public_key unless @public_key.nil?
payload[:create_key] = @create_key unless @create_key.nil?
@@ -167,12 +167,12 @@ class Chef
supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS)
raise e unless supported_versions && supported_versions.include?(0)
payload = {
- :username => @username,
- :display_name => @display_name,
- :first_name => @first_name,
- :last_name => @last_name,
- :email => @email,
- :password => @password,
+ username: @username,
+ display_name: @display_name,
+ first_name: @first_name,
+ last_name: @last_name,
+ email: @email,
+ password: @password,
}
payload[:middle_name] = @middle_name unless @middle_name.nil?
payload[:public_key] = @public_key unless @public_key.nil?
@@ -185,7 +185,7 @@ class Chef
def update(new_key = false)
begin
- payload = { :username => username }
+ payload = { username: username }
payload[:display_name] = display_name unless display_name.nil?
payload[:first_name] = first_name unless first_name.nil?
payload[:middle_name] = middle_name unless middle_name.nil?
diff --git a/lib/chef/util/backup.rb b/lib/chef/util/backup.rb
index 8bf2b3f25b..5b6bf0b9b8 100644
--- a/lib/chef/util/backup.rb
+++ b/lib/chef/util/backup.rb
@@ -52,7 +52,7 @@ class Chef
nanoseconds = sprintf("%6f", time.to_f).split(".")[1]
savetime = time.strftime("%Y%m%d%H%M%S.#{nanoseconds}")
backup_filename = "#{path}.chef-#{savetime}"
- backup_filename = backup_filename.sub(/^([A-Za-z]:)/, "") #strip drive letter on Windows
+ backup_filename = backup_filename.sub(/^([A-Za-z]:)/, "") # strip drive letter on Windows
end
end
@@ -69,7 +69,7 @@ class Chef
def do_backup
FileUtils.mkdir_p(::File.dirname(backup_path)) if Chef::Config[:file_backup_path]
- FileUtils.cp(path, backup_path, :preserve => true)
+ FileUtils.cp(path, backup_path, preserve: true)
Chef::Log.info("#{@new_resource} backed up to #{backup_path}")
end
diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb
index b5c85df56d..decff35d85 100644
--- a/lib/chef/util/diff.rb
+++ b/lib/chef/util/diff.rb
@@ -176,7 +176,7 @@ class Chef
end
def encode_diff_for_json(diff_str)
- diff_str.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?")
+ diff_str.encode!("UTF-8", invalid: :replace, undef: :replace, replace: "?")
end
end
diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb
index 3e9475bac2..409730ce20 100644
--- a/lib/chef/util/dsc/configuration_generator.rb
+++ b/lib/chef/util/dsc/configuration_generator.rb
@@ -68,7 +68,7 @@ class Chef::Util::DSC
end
def get_merged_configuration_flags!(configuration_flags, configuration_name)
- merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) }
+ merged_configuration_flags = { outputpath: configuration_document_directory(configuration_name) }
if configuration_flags
configuration_flags.map do |switch, value|
if merged_configuration_flags.key?(switch.to_s.downcase.to_sym)
@@ -81,16 +81,16 @@ class Chef::Util::DSC
end
def configuration_code(code, configuration_name, imports)
- <<-EOF
-$ProgressPreference = 'SilentlyContinue';
-Configuration '#{configuration_name}'
-{
- #{generate_import_resource_statements(imports).join(" \n")}
- node 'localhost'
- {
- #{code}
- }
-}
+ <<~EOF
+ $ProgressPreference = 'SilentlyContinue';
+ Configuration '#{configuration_name}'
+ {
+ #{generate_import_resource_statements(imports).join(" \n")}
+ node 'localhost'
+ {
+ #{code}
+ }
+ }
EOF
end
diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb
index 658d5c7d8f..b164db6b19 100644
--- a/lib/chef/util/dsc/lcm_output_parser.rb
+++ b/lib/chef/util/dsc/lcm_output_parser.rb
@@ -128,7 +128,7 @@ class Chef
if current_resource[:name]
resources.push(current_resource)
end
- current_resource = { :name => info }
+ current_resource = { name: info }
else
Chef::Log.trace("Ignoring op_action #{op_action}: Read line #{line}")
end
diff --git a/lib/chef/util/file_edit.rb b/lib/chef/util/file_edit.rb
index 5aa33fd169..5a01e72e70 100644
--- a/lib/chef/util/file_edit.rb
+++ b/lib/chef/util/file_edit.rb
@@ -40,38 +40,38 @@ class Chef
@file_edited
end
- #search the file line by line and match each line with the given regex
- #if matched, replace the whole line with newline.
+ # search the file line by line and match each line with the given regex
+ # if matched, replace the whole line with newline.
def search_file_replace_line(regex, newline)
@changes = (editor.replace_lines(regex, newline) > 0) || @changes
end
- #search the file line by line and match each line with the given regex
- #if matched, replace the match (all occurrences) with the replace parameter
+ # search the file line by line and match each line with the given regex
+ # if matched, replace the match (all occurrences) with the replace parameter
def search_file_replace(regex, replace)
@changes = (editor.replace(regex, replace) > 0) || @changes
end
- #search the file line by line and match each line with the given regex
- #if matched, delete the line
+ # search the file line by line and match each line with the given regex
+ # if matched, delete the line
def search_file_delete_line(regex)
@changes = (editor.remove_lines(regex) > 0) || @changes
end
- #search the file line by line and match each line with the given regex
- #if matched, delete the match (all occurrences) from the line
+ # search the file line by line and match each line with the given regex
+ # if matched, delete the match (all occurrences) from the line
def search_file_delete(regex)
search_file_replace(regex, "")
end
- #search the file line by line and match each line with the given regex
- #if matched, insert newline after each matching line
+ # search the file line by line and match each line with the given regex
+ # if matched, insert newline after each matching line
def insert_line_after_match(regex, newline)
@changes = (editor.append_line_after(regex, newline) > 0) || @changes
end
- #search the file line by line and match each line with the given regex
- #if not matched, insert newline at the end of the file
+ # search the file line by line and match each line with the given regex
+ # if not matched, insert newline at the end of the file
def insert_line_if_no_match(regex, newline)
@changes = (editor.append_line_if_missing(regex, newline) > 0) || @changes
end
@@ -80,11 +80,11 @@ class Chef
!!@changes
end
- #Make a copy of old_file and write new file out (only if file changed)
+ # Make a copy of old_file and write new file out (only if file changed)
def write_file
if @changes
backup_pathname = original_pathname + ".old"
- FileUtils.cp(original_pathname, backup_pathname, :preserve => true)
+ FileUtils.cp(original_pathname, backup_pathname, preserve: true)
File.open(original_pathname, "w") do |newfile|
editor.lines.each do |line|
newfile.puts(line)
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index e300266b1e..edd3e92da1 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -48,8 +48,8 @@ class Chef
attr_reader :output_format
def run(switches = {}, execution_options = {}, *arguments)
- streams = { :json => CmdletStream.new("json"),
- :verbose => CmdletStream.new("verbose"),
+ streams = { json: CmdletStream.new("json"),
+ verbose: CmdletStream.new("verbose"),
}
arguments_string = arguments.join(" ")
@@ -74,7 +74,7 @@ class Chef
"#{arguments_string} #{redirections}"\
"#{json_command}\";if ( ! $? ) { exit 1 }"
- augmented_options = { :returns => [0], :live_stream => false }.merge(execution_options)
+ augmented_options = { returns: [0], live_stream: false }.merge(execution_options)
command = Mixlib::ShellOut.new(command_string, augmented_options)
status = nil
diff --git a/lib/chef/util/selinux.rb b/lib/chef/util/selinux.rb
index fb0c98cff5..a46e486f96 100644
--- a/lib/chef/util/selinux.rb
+++ b/lib/chef/util/selinux.rb
@@ -72,7 +72,7 @@ class Chef
def check_selinux_enabled?
if selinuxenabled_path
- cmd = shell_out!(selinuxenabled_path, :returns => [0, 1])
+ cmd = shell_out!(selinuxenabled_path, returns: [0, 1])
case cmd.exitstatus
when 1
return false
diff --git a/lib/chef/util/windows/net_group.rb b/lib/chef/util/windows/net_group.rb
index 214881df56..efe2561bf2 100644
--- a/lib/chef/util/windows/net_group.rb
+++ b/lib/chef/util/windows/net_group.rb
@@ -19,7 +19,7 @@
require "chef/util/windows"
require "chef/win32/net"
-#wrapper around a subset of the NetGroup* APIs.
+# wrapper around a subset of the NetGroup* APIs.
class Chef::Util::Windows::NetGroup
private
diff --git a/lib/chef/util/windows/net_use.rb b/lib/chef/util/windows/net_use.rb
index 196ce42215..99626371a0 100644
--- a/lib/chef/util/windows/net_use.rb
+++ b/lib/chef/util/windows/net_use.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-#the Win32 Volume APIs do not support mapping network drives. not supported by WMI either.
-#see also: WNetAddConnection2 and WNetAddConnection3
-#see also cmd.exe: net use /?
+# the Win32 Volume APIs do not support mapping network drives. not supported by WMI either.
+# see also: WNetAddConnection2 and WNetAddConnection3
+# see also cmd.exe: net use /?
require "chef/util/windows"
require "chef/win32/net"
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb
index cf8bf3615a..d282ba9046 100644
--- a/lib/chef/util/windows/net_user.rb
+++ b/lib/chef/util/windows/net_user.rb
@@ -21,8 +21,8 @@ require "chef/exceptions"
require "chef/win32/net"
require "chef/win32/security"
-#wrapper around a subset of the NetUser* APIs.
-#nothing Chef specific, but not complete enough to be its own gem, so util for now.
+# wrapper around a subset of the NetUser* APIs.
+# nothing Chef specific, but not complete enough to be its own gem, so util for now.
class Chef::Util::Windows::NetUser < Chef::Util::Windows
private
@@ -91,7 +91,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
LOGON32_PROVIDER_DEFAULT = Security::LOGON32_PROVIDER_DEFAULT
LOGON32_LOGON_NETWORK = Security::LOGON32_LOGON_NETWORK
- #XXX for an extra painful alternative, see: http://support.microsoft.com/kb/180548
+ # XXX for an extra painful alternative, see: http://support.microsoft.com/kb/180548
def validate_credentials(passwd)
token = Security.logon_user(@username, nil, passwd,
LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT)
@@ -118,8 +118,8 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
# FIXME: yard with @yield
def user_modify
user = get_info
- user[:last_logon] = user[:units_per_week] = 0 #ignored as per USER_INFO_3 doc
- user[:logon_hours] = nil #PBYTE field; \0 == no changes
+ user[:last_logon] = user[:units_per_week] = 0 # ignored as per USER_INFO_3 doc
+ user[:logon_hours] = nil # PBYTE field; \0 == no changes
yield(user)
set_info(user)
end
@@ -141,9 +141,9 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def disable_account
user_modify do |user|
user[:flags] |= NetUser::UF_ACCOUNTDISABLE
- #This does not set the password to nil. It (for some reason) means to ignore updating the field.
- #See similar behavior for the logon_hours field documented at
- #http://msdn.microsoft.com/en-us/library/windows/desktop/aa371338%28v=vs.85%29.aspx
+ # This does not set the password to nil. It (for some reason) means to ignore updating the field.
+ # See similar behavior for the logon_hours field documented at
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa371338%28v=vs.85%29.aspx
user[:password] = nil
end
end
@@ -151,9 +151,9 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def enable_account
user_modify do |user|
user[:flags] &= ~NetUser::UF_ACCOUNTDISABLE
- #This does not set the password to nil. It (for some reason) means to ignore updating the field.
- #See similar behavior for the logon_hours field documented at
- #http://msdn.microsoft.com/en-us/library/windows/desktop/aa371338%28v=vs.85%29.aspx
+ # This does not set the password to nil. It (for some reason) means to ignore updating the field.
+ # See similar behavior for the logon_hours field documented at
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa371338%28v=vs.85%29.aspx
user[:password] = nil
end
end
diff --git a/lib/chef/util/windows/volume.rb b/lib/chef/util/windows/volume.rb
index 358a3f4bb8..ff5f46163f 100644
--- a/lib/chef/util/windows/volume.rb
+++ b/lib/chef/util/windows/volume.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-#simple wrapper around Volume APIs. might be possible with WMI, but possibly more complex.
+# simple wrapper around Volume APIs. might be possible with WMI, but possibly more complex.
require "chef/win32/api/file"
require "chef/util/windows"
@@ -25,7 +25,7 @@ class Chef::Util::Windows::Volume < Chef::Util::Windows
attr_reader :mount_point
def initialize(name)
- name += "\\" unless name =~ /\\$/ #trailing slash required
+ name += "\\" unless name =~ /\\$/ # trailing slash required
@mount_point = name
end
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 3b76eecae6..4d98c99969 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# NOTE: This file is generated by running `rake version` in the top level of
# this repo. Do not edit this manually. Edit the VERSION file and run the rake
# task instead.
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
require "chef/version_string"
diff --git a/lib/chef/win32/api.rb b/lib/chef/win32/api.rb
index 503920a0ed..fccedd1d54 100644
--- a/lib/chef/win32/api.rb
+++ b/lib/chef/win32/api.rb
@@ -51,7 +51,7 @@ class Chef
host.typedef :bool, :BOOL
host.typedef :bool, :BOOLEAN
host.typedef :uchar, :BYTE # Byte (8 bits). Declared as unsigned char
- #CALLBACK: K, # Win32.API gem-specific ?? MSDN: #define CALLBACK __stdcall
+ # CALLBACK: K, # Win32.API gem-specific ?? MSDN: #define CALLBACK __stdcall
host.typedef :char, :CHAR # 8-bit Windows (ANSI) character. See http://msdn.microsoft.com/en-us/library/dd183415%28VS.85%29.aspx
host.typedef :uint32, :COLORREF # Red, green, blue (RGB) color value (32 bits). See COLORREF for more info.
host.typedef :uint32, :DWORD # 32-bit unsigned integer. The range is 0 through 4,294,967,295 decimal.
@@ -78,7 +78,7 @@ class Chef
host.typedef :ulong, :HDESK # (L) Handle to a desktop. http://msdn.microsoft.com/en-us/library/ms682573%28VS.85%29.aspx
host.typedef :ulong, :HDROP # (L) Handle to an internal drop structure.
host.typedef :ulong, :HDWP # (L) Handle to a deferred window position structure.
- host.typedef :ulong, :HENHMETAFILE #(L) Handle to an enhanced metafile. http://msdn.microsoft.com/en-us/library/dd145051%28VS.85%29.aspx
+ host.typedef :ulong, :HENHMETAFILE # (L) Handle to an enhanced metafile. http://msdn.microsoft.com/en-us/library/dd145051%28VS.85%29.aspx
host.typedef :uint, :HFILE # (I) Special file handle to a file opened by OpenFile, not CreateFile.
# WinDef.h: #host.typedef int HFILE;
host.typedef :ulong, :HFONT # (L) Handle to a font. http://msdn.microsoft.com/en-us/library/dd162470%28VS.85%29.aspx
@@ -107,7 +107,7 @@ class Chef
host.typedef :int, :INT # 32-bit signed integer. The range is -2147483648 through 2147483647 decimal.
host.typedef :int, :INT_PTR # Signed integer type for pointer precision. Use when casting a pointer to an integer
# to perform pointer arithmetic. BaseTsd.h:
- #if defined(_WIN64) host.typedef __int64 INT_PTR; #else host.typedef int INT_PTR;
+ # if defined(_WIN64) host.typedef __int64 INT_PTR; #else host.typedef int INT_PTR;
host.typedef :int32, :INT32 # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
host.typedef :int64, :INT64 # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
host.typedef :ushort, :LANGID # Language identifier. For more information, see Locales. WinNT.h: #host.typedef WORD LANGID;
@@ -122,7 +122,7 @@ class Chef
host.typedef :int64, :LONGLONG # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
host.typedef :long, :LONG_PTR # Signed long type for pointer precision. Use when casting a pointer to a long to
# perform pointer arithmetic. BaseTsd.h:
- #if defined(_WIN64) host.typedef __int64 LONG_PTR; #else host.typedef long LONG_PTR;
+ # if defined(_WIN64) host.typedef __int64 LONG_PTR; #else host.typedef long LONG_PTR;
host.typedef :long, :LPARAM # Message parameter. WinDef.h as follows: #host.typedef LONG_PTR LPARAM;
host.typedef :pointer, :LPBOOL # Pointer to a BOOL. WinDef.h as follows: #host.typedef BOOL far *LPBOOL;
host.typedef :pointer, :LPBYTE # Pointer to a BYTE. WinDef.h as follows: #host.typedef BYTE far *LPBYTE;
@@ -160,7 +160,7 @@ class Chef
host.typedef :pointer, :PDWORD32 # Pointer to a DWORD32.
host.typedef :pointer, :PDWORD64 # Pointer to a DWORD64.
host.typedef :pointer, :PFLOAT # Pointer to a FLOAT.
- host.typedef :pointer, :PGENERICMAPPING #Pointer to GENERIC_MAPPING
+ host.typedef :pointer, :PGENERICMAPPING # Pointer to GENERIC_MAPPING
host.typedef :pointer, :PHALF_PTR # Pointer to a HALF_PTR.
host.typedef :pointer, :PHANDLE # Pointer to a HANDLE.
host.typedef :pointer, :PHKEY # Pointer to an HKEY.
@@ -235,7 +235,7 @@ class Chef
host.typedef :ulong_long, :USN # Update sequence number (USN).
host.typedef :ushort, :WCHAR # 16-bit Unicode character. For more information, see Character Sets Used By Fonts.
# In WinNT.h: host.typedef wchar_t WCHAR;
- #WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
+ # WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
host.typedef :ushort, :WORD # 16-bit unsigned integer. The range is 0 through 65535 decimal.
host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
end
diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb
index 758eb98874..e37468c609 100644
--- a/lib/chef/win32/api/error.rb
+++ b/lib/chef/win32/api/error.rb
@@ -211,9 +211,9 @@ class Chef
ERROR_META_EXPANSION_TOO_LONG = 208 # if "*a" > 8.3
ERROR_INVALID_SIGNAL_NUMBER = 209
ERROR_THREAD_1_INACTIVE = 210
- ERROR_INFO_NOT_AVAIL = 211 #@@ PTM 5550
+ ERROR_INFO_NOT_AVAIL = 211 # @@ PTM 5550
ERROR_LOCKED = 212
- ERROR_BAD_DYNALINK = 213 #@@ PTM 5760
+ ERROR_BAD_DYNALINK = 213 # @@ PTM 5760
ERROR_TOO_MANY_MODULES = 214
ERROR_NESTING_NOT_ALLOWED = 215
ERROR_EXE_MACHINE_TYPE_MISMATCH = 216
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index 6aa2927e1f..a239671557 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -461,22 +461,22 @@ BOOL WINAPI DeviceIoControl(
=end
safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
-#BOOL WINAPI DeleteVolumeMountPoint(
- #_In_ LPCTSTR lpszVolumeMountPoint
-#);
+# BOOL WINAPI DeleteVolumeMountPoint(
+ # _In_ LPCTSTR lpszVolumeMountPoint
+# );
safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL
-#BOOL WINAPI SetVolumeMountPoint(
- #_In_ LPCTSTR lpszVolumeMountPoint,
- #_In_ LPCTSTR lpszVolumeName
-#);
+# BOOL WINAPI SetVolumeMountPoint(
+ # _In_ LPCTSTR lpszVolumeMountPoint,
+ # _In_ LPCTSTR lpszVolumeName
+# );
safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL
-#BOOL WINAPI GetVolumeNameForVolumeMountPoint(
- #_In_ LPCTSTR lpszVolumeMountPoint,
- #_Out_ LPTSTR lpszVolumeName,
- #_In_ DWORD cchBufferLength
-#);
+# BOOL WINAPI GetVolumeNameForVolumeMountPoint(
+ # _In_ LPCTSTR lpszVolumeMountPoint,
+ # _Out_ LPTSTR lpszVolumeName,
+ # _In_ DWORD cchBufferLength
+# );
safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL
=begin
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index 169c68bbdf..e7c191dd9c 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -43,7 +43,7 @@ class Chef
USE_NOFORCE = 0
USE_FORCE = 1
- USE_LOTS_OF_FORCE = 2 #every windows API should support this flag
+ USE_LOTS_OF_FORCE = 2 # every windows API should support this flag
NERR_Success = 0 # rubocop:disable Naming/ConstantName
ERROR_MORE_DATA = 234
@@ -158,32 +158,32 @@ class Chef
:ui2_domainname, :LMSTR
end
- #NET_API_STATUS NetLocalGroupAdd(
- #_In_ LPCWSTR servername,
- #_In_ DWORD level,
- #_In_ LPBYTE buf,
- #_Out_ LPDWORD parm_err
- #);
+ # NET_API_STATUS NetLocalGroupAdd(
+ # _In_ LPCWSTR servername,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _Out_ LPDWORD parm_err
+ # );
safe_attach_function :NetLocalGroupAdd, [
:LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
- #NET_API_STATUS NetLocalGroupDel(
- #_In_ LPCWSTR servername,
- #_In_ LPCWSTR groupname
- #);
+ # NET_API_STATUS NetLocalGroupDel(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR groupname
+ # );
safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD
- #NET_API_STATUS NetLocalGroupGetMembers(
- #_In_ LPCWSTR servername,
- #_In_ LPCWSTR localgroupname,
- #_In_ DWORD level,
- #_Out_ LPBYTE *bufptr,
- #_In_ DWORD prefmaxlen,
- #_Out_ LPDWORD entriesread,
- #_Out_ LPDWORD totalentries,
- #_Inout_ PDWORD_PTR resumehandle
- #);
+ # NET_API_STATUS NetLocalGroupGetMembers(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR localgroupname,
+ # _In_ DWORD level,
+ # _Out_ LPBYTE *bufptr,
+ # _In_ DWORD prefmaxlen,
+ # _Out_ LPDWORD entriesread,
+ # _Out_ LPDWORD totalentries,
+ # _Inout_ PDWORD_PTR resumehandle
+ # );
safe_attach_function :NetLocalGroupGetMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD,
:LPDWORD, :LPDWORD, :PDWORD_PTR
@@ -209,102 +209,102 @@ class Chef
# );
safe_attach_function :NetApiBufferFree, [:LPVOID], :DWORD
- #NET_API_STATUS NetUserAdd(
- #_In_ LMSTR servername,
- #_In_ DWORD level,
- #_In_ LPBYTE buf,
- #_Out_ LPDWORD parm_err
- #);
+ # NET_API_STATUS NetUserAdd(
+ # _In_ LMSTR servername,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _Out_ LPDWORD parm_err
+ # );
safe_attach_function :NetUserAdd, [
:LMSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
- #NET_API_STATUS NetLocalGroupAddMembers(
+ # NET_API_STATUS NetLocalGroupAddMembers(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR groupname,
# _In_ DWORD level,
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
- #);
+ # );
safe_attach_function :NetLocalGroupAddMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
- #NET_API_STATUS NetLocalGroupSetMembers(
+ # NET_API_STATUS NetLocalGroupSetMembers(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR groupname,
# _In_ DWORD level,
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
- #);
+ # );
safe_attach_function :NetLocalGroupSetMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
- #NET_API_STATUS NetLocalGroupDelMembers(
+ # NET_API_STATUS NetLocalGroupDelMembers(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR groupname,
# _In_ DWORD level,
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
- #);
+ # );
safe_attach_function :NetLocalGroupDelMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
- #NET_API_STATUS NetUserGetInfo(
+ # NET_API_STATUS NetUserGetInfo(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR username,
# _In_ DWORD level,
# _Out_ LPBYTE *bufptr
- #);
+ # );
safe_attach_function :NetUserGetInfo, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE
], :DWORD
- #NET_API_STATUS NetApiBufferFree(
+ # NET_API_STATUS NetApiBufferFree(
# _In_ LPVOID Buffer
- #);
+ # );
safe_attach_function :NetApiBufferFree, [:LPVOID], :DWORD
- #NET_API_STATUS NetUserSetInfo(
+ # NET_API_STATUS NetUserSetInfo(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR username,
# _In_ DWORD level,
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
- #);
+ # );
safe_attach_function :NetUserSetInfo, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
- #NET_API_STATUS NetUserDel(
+ # NET_API_STATUS NetUserDel(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR username
- #);
+ # );
safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD
- #NET_API_STATUS NetUseDel(
- #_In_ LMSTR UncServerName,
- #_In_ LMSTR UseName,
- #_In_ DWORD ForceCond
- #);
+ # NET_API_STATUS NetUseDel(
+ # _In_ LMSTR UncServerName,
+ # _In_ LMSTR UseName,
+ # _In_ DWORD ForceCond
+ # );
safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD
- #NET_API_STATUS NetUseGetInfo(
- #_In_ LMSTR UncServerName,
- #_In_ LMSTR UseName,
- #_In_ DWORD Level,
- #_Out_ LPBYTE *BufPtr
- #);
+ # NET_API_STATUS NetUseGetInfo(
+ # _In_ LMSTR UncServerName,
+ # _In_ LMSTR UseName,
+ # _In_ DWORD Level,
+ # _Out_ LPBYTE *BufPtr
+ # );
safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD
- #NET_API_STATUS NetUseAdd(
- #_In_ LMSTR UncServerName,
- #_In_ DWORD Level,
- #_In_ LPBYTE Buf,
- #_Out_ LPDWORD ParmError
- #);
+ # NET_API_STATUS NetUseAdd(
+ # _In_ LMSTR UncServerName,
+ # _In_ DWORD Level,
+ # _In_ LPBYTE Buf,
+ # _Out_ LPDWORD ParmError
+ # );
safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD
end
end
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 1193911b00..b1365fd61b 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -56,7 +56,7 @@ class Chef
hive, key = get_hive_and_key(key_path)
key_exists!(key_path)
values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.map { |name, type, data| { :name => name, :type => get_name_from_type(type), :data => data } }
+ reg.map { |name, type, data| { name: name, type: get_name_from_type(type), data: data } }
end
end
@@ -321,13 +321,13 @@ class Chef
def _type_name_map
{
- :binary => ::Win32::Registry::REG_BINARY,
- :string => ::Win32::Registry::REG_SZ,
- :multi_string => ::Win32::Registry::REG_MULTI_SZ,
- :expand_string => ::Win32::Registry::REG_EXPAND_SZ,
- :dword => ::Win32::Registry::REG_DWORD,
- :dword_big_endian => ::Win32::Registry::REG_DWORD_BIG_ENDIAN,
- :qword => ::Win32::Registry::REG_QWORD,
+ binary: ::Win32::Registry::REG_BINARY,
+ string: ::Win32::Registry::REG_SZ,
+ multi_string: ::Win32::Registry::REG_MULTI_SZ,
+ expand_string: ::Win32::Registry::REG_EXPAND_SZ,
+ dword: ::Win32::Registry::REG_DWORD,
+ dword_big_endian: ::Win32::Registry::REG_DWORD_BIG_ENDIAN,
+ qword: ::Win32::Registry::REG_QWORD,
}
end
diff --git a/lib/chef/win32/security/securable_object.rb b/lib/chef/win32/security/securable_object.rb
index aef1a72c8c..f0bbfc7354 100644
--- a/lib/chef/win32/security/securable_object.rb
+++ b/lib/chef/win32/security/securable_object.rb
@@ -42,10 +42,10 @@ class Chef
# compare an existing ACE with one you want to create.
def predict_rights_mask(generic_mask)
mask = generic_mask
- #mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_READ if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_READ) != 0
- #mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_WRITE if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE) != 0
- #mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_EXECUTE if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE) != 0
- #mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_ALL if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_ALL) != 0
+ # mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_READ if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_READ) != 0
+ # mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_WRITE if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE) != 0
+ # mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_EXECUTE if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE) != 0
+ # mask |= Chef::ReservedNames::Win32::API::Security::STANDARD_RIGHTS_ALL if (mask | Chef::ReservedNames::Win32::API::Security::GENERIC_ALL) != 0
if type == :SE_FILE_OBJECT
mask |= Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ if (mask & Chef::ReservedNames::Win32::API::Security::GENERIC_READ) != 0
mask |= Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE if (mask & Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE) != 0
@@ -71,36 +71,36 @@ class Chef
end
def dacl=(val)
- Security.set_named_security_info(path, type, :dacl => val)
+ Security.set_named_security_info(path, type, dacl: val)
end
# You don't set dacl_inherits without also setting dacl,
# because Windows gets angry and denies you access. So
# if you want to do that, you may as well do both at once.
def set_dacl(dacl, dacl_inherits)
- Security.set_named_security_info(path, type, :dacl => dacl, :dacl_inherits => dacl_inherits)
+ Security.set_named_security_info(path, type, dacl: dacl, dacl_inherits: dacl_inherits)
end
def group=(val)
- Security.set_named_security_info(path, type, :group => val)
+ Security.set_named_security_info(path, type, group: val)
end
def owner=(val)
# TODO to fix serious permissions problems, we may need to enable SeBackupPrivilege. But we might need it (almost) everywhere else, too.
Security.with_privileges("SeTakeOwnershipPrivilege", "SeRestorePrivilege") do
- Security.set_named_security_info(path, type, :owner => val)
+ Security.set_named_security_info(path, type, owner: val)
end
end
def sacl=(val)
Security.with_privileges("SeSecurityPrivilege") do
- Security.set_named_security_info(path, type, :sacl => val)
+ Security.set_named_security_info(path, type, sacl: val)
end
end
def set_sacl(sacl, sacl_inherits)
Security.with_privileges("SeSecurityPrivilege") do
- Security.set_named_security_info(path, type, :sacl => sacl, :sacl_inherits => sacl_inherits)
+ Security.set_named_security_info(path, type, sacl: sacl, sacl_inherits: sacl_inherits)
end
end
end
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index 944cb207f5..f96fd18316 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -50,21 +50,21 @@ class Chef
private_class_method :method_name_from_marketing_name
WIN_VERSIONS = {
- "Windows 10" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
- "Windows Server 2016" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
- "Windows 8.1" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
- "Windows Server 2012 R2" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
- "Windows 8" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
- "Windows Server 2012" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
- "Windows 7" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
- "Windows Server 2008 R2" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
- "Windows Server 2008" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
- "Windows Vista" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
- "Windows Server 2003 R2" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } },
- "Windows Home Server" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
- "Windows Server 2003" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } },
- "Windows XP" => { :major => 5, :minor => 1 },
- "Windows 2000" => { :major => 5, :minor => 0 },
+ "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2016" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8.1" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012 R2" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 7" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2008 R2" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Server 2008" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Vista" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2003 R2" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } },
+ "Windows Home Server" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
+ "Windows Server 2003" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } },
+ "Windows XP" => { major: 5, minor: 1 },
+ "Windows 2000" => { major: 5, minor: 0 },
}
def initialize
diff --git a/spec/functional/audit/rspec_formatter_spec.rb b/spec/functional/audit/rspec_formatter_spec.rb
index 209694ae70..f30f7bbd8a 100644
--- a/spec/functional/audit/rspec_formatter_spec.rb
+++ b/spec/functional/audit/rspec_formatter_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Audit::RspecFormatter do
let(:events) { double("events").as_null_object }
let(:audits) { {} }
- let(:run_context) { instance_double(Chef::RunContext, :events => events, :audits => audits) }
+ let(:run_context) { instance_double(Chef::RunContext, events: events, audits: audits) }
let(:runner) { Chef::Audit::Runner.new(run_context) }
let(:output) { double("output") }
diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb
index 54f014e28f..f80256fa5c 100644
--- a/spec/functional/audit/runner_spec.rb
+++ b/spec/functional/audit/runner_spec.rb
@@ -49,7 +49,7 @@ describe Chef::Audit::Runner do
describe "#run" do
let(:audits) { {} }
- let(:run_context) { instance_double(Chef::RunContext, :events => events, :audits => audits) }
+ let(:run_context) { instance_double(Chef::RunContext, events: events, audits: audits) }
let(:control_group_name) { "control_group_name" }
# Set cookbook path to include our parent, so that it will recognize this
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb
index c7a93c6822..ff7fd574b1 100644
--- a/spec/functional/dsl/reboot_pending_spec.rb
+++ b/spec/functional/dsl/reboot_pending_spec.rb
@@ -42,19 +42,19 @@ describe Chef::DSL::RebootPending, :windows_only do
describe 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations' do
let(:reg_key) { 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager' }
- let(:original_set) { registry.value_exists?(reg_key, { :name => "PendingFileRenameOperations" }) }
+ let(:original_set) { registry.value_exists?(reg_key, { name: "PendingFileRenameOperations" }) }
it "returns true if the registry value exists" do
skip "found existing registry key" if original_set
registry.set_value(reg_key,
- { :name => "PendingFileRenameOperations", :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] })
+ { name: "PendingFileRenameOperations", type: :multi_string, data: ['\??\C:\foo.txt|\??\C:\bar.txt'] })
expect(recipe.reboot_pending?).to be_truthy
end
after do
unless original_set
- registry.delete_value(reg_key, { :name => "PendingFileRenameOperations" })
+ registry.delete_value(reg_key, { name: "PendingFileRenameOperations" })
end
end
end
diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb
index d90d5090e4..7a56ee11cf 100644
--- a/spec/functional/dsl/registry_helper_spec.rb
+++ b/spec/functional/dsl/registry_helper_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
end
it "returns true if registry has specified value" do
values = @resource.registry_get_values("HKCU\\Software\\Root")
- expect(values.include?({ :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
+ expect(values.include?({ name: "RootType1", type: :string, data: "fibrous" })).to eq(true)
end
it "returns true if specified registry_has_subkey" do
expect(@resource.registry_has_subkeys?("HKCU\\Software\\Root")).to eq(true)
@@ -52,10 +52,10 @@ describe Chef::Resource::RegistryKey, :windows_only do
expect(subkeys.include?("Branch")).to eq(true)
end
it "returns true if registry_value_exists" do
- expect(@resource.registry_value_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
+ expect(@resource.registry_value_exists?("HKCU\\Software\\Root", { name: "RootType1", type: :string, data: "fibrous" })).to eq(true)
end
it "returns true if data_value_exists" do
- expect(@resource.registry_data_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
+ expect(@resource.registry_data_exists?("HKCU\\Software\\Root", { name: "RootType1", type: :string, data: "fibrous" })).to eq(true)
end
end
end
diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb
index fcabd3f308..562c037bb0 100644
--- a/spec/functional/http/simple_spec.rb
+++ b/spec/functional/http/simple_spec.rb
@@ -24,7 +24,7 @@ describe Chef::HTTP::Simple do
include ChefHTTPShared
let(:http_client) { described_class.new(source) }
- let(:http_client_disable_gzip) { described_class.new(source, { :disable_gzip => true } ) }
+ let(:http_client_disable_gzip) { described_class.new(source, { disable_gzip: true } ) }
before(:all) do
start_tiny_server(RequestTimeout: 1)
diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb
index ac8f617a90..7cdf1c93eb 100644
--- a/spec/functional/knife/exec_spec.rb
+++ b/spec/functional/knife/exec_spec.rb
@@ -21,7 +21,7 @@ require "tiny_server"
describe Chef::Knife::Exec do
before(:each) do
- @server = TinyServer::Manager.new #(:debug => true)
+ @server = TinyServer::Manager.new # (:debug => true)
@server.start
end
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index 3defbe781f..95e7b6454c 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway_identity file" do
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true })
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
@knife.run
expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
end
@@ -315,7 +315,7 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway_identity file" do
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true })
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
@knife.run
expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
end
diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb
index 48a34762c6..b3e9bf796d 100644
--- a/spec/functional/mixin/shell_out_spec.rb
+++ b/spec/functional/mixin/shell_out_spec.rb
@@ -40,9 +40,9 @@ describe Chef::Mixin::ShellOut do
describe "when environment['LC_ALL'] is set" do
it "should use the option's setting" do
cmd = if windows?
- shell_out_with_systems_locale("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" })
+ shell_out_with_systems_locale("echo %LC_ALL%", environment: { "LC_ALL" => "POSIX" })
else
- shell_out_with_systems_locale("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" })
+ shell_out_with_systems_locale("echo $LC_ALL", environment: { "LC_ALL" => "POSIX" })
end
expect(cmd.stdout.chomp).to eq "POSIX"
@@ -66,9 +66,9 @@ describe Chef::Mixin::ShellOut do
describe "when environment['LC_ALL'] is set" do
it "should use the option's setting" do
cmd = if windows?
- shell_out("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
+ shell_out("echo %LC_ALL%", environment: { "LC_ALL" => "POSIX" }, default_env: false)
else
- shell_out("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
+ shell_out("echo $LC_ALL", environment: { "LC_ALL" => "POSIX" }, default_env: false)
end
expect(cmd.stdout.chomp).to eq "POSIX"
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 36961593b0..8e5b23f86b 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -22,9 +22,9 @@ describe Chef::Platform::Rebooter do
let(:reboot_info) do
{
- :delay_mins => 5,
- :requested_by => "reboot resource functional test",
- :reason => "rebooter spec test",
+ delay_mins: 5,
+ requested_by: "reboot resource functional test",
+ reason: "rebooter spec test",
}
end
@@ -44,9 +44,9 @@ describe Chef::Platform::Rebooter do
let(:expected) do
{
- :windows => "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"",
- :linux => 'shutdown -r +5 "rebooter spec test" &',
- :solaris => 'shutdown -i6 -g5 -y "rebooter spec test" &',
+ windows: "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"",
+ linux: 'shutdown -r +5 "rebooter spec test" &',
+ solaris: 'shutdown -i6 -g5 -y "rebooter spec test" &',
}
end
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index bf50046b03..68ea5ab8b2 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -59,7 +59,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
let(:new_resource) do
new_resource = Chef::Resource::Service.new("chefinittest", run_context)
new_resource.provider Chef::Provider::Service::AixInit
- new_resource.supports({ :status => true, :restart => true, :reload => true })
+ new_resource.supports({ status: true, restart: true, reload: true })
new_resource
end
@@ -70,7 +70,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
before(:all) do
File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
- FileUtils.cp("#{File.join(File.dirname(__FILE__), "/../assets/chefinittest")}", "/etc/rc.d/init.d/chefinittest")
+ FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/chefinittest")).to_s, "/etc/rc.d/init.d/chefinittest")
end
after(:all) do
diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb
index c032bafc92..c1ac51c4b1 100644
--- a/spec/functional/resource/apt_package_spec.rb
+++ b/spec/functional/resource/apt_package_spec.rb
@@ -50,11 +50,11 @@ module AptServer
def apt_server
@apt_server ||= WEBrick::HTTPServer.new(
- :Port => 9000,
- :DocumentRoot => apt_data_dir + "/var/www/apt",
+ Port: 9000,
+ DocumentRoot: apt_data_dir + "/var/www/apt",
# Make WEBrick quiet, comment out for debug.
- :Logger => Logger.new(StringIO.new),
- :AccessLog => [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ]
+ Logger: Logger.new(StringIO.new),
+ AccessLog: [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ]
)
end
@@ -86,10 +86,10 @@ module AptServer
end
end
-metadata = { :unix_only => true,
- :requires_root => true,
- :provider => { :package => Chef::Provider::Package::Apt },
- :arch => "x86_64" # test packages are 64bit
+metadata = { unix_only: true,
+ requires_root: true,
+ provider: { package: Chef::Provider::Package::Apt },
+ arch: "x86_64" # test packages are 64bit
}
describe Chef::Resource::AptPackage, metadata do
@@ -169,13 +169,13 @@ describe Chef::Resource::AptPackage, metadata do
it "does nothing for action :remove" do
package_resource.run_action(:remove)
- shell_out!("dpkg -l chef-integration-test", :returns => [1])
+ shell_out!("dpkg -l chef-integration-test", returns: [1])
expect(package_resource).not_to be_updated_by_last_action
end
it "does nothing for action :purge" do
package_resource.run_action(:purge)
- shell_out!("dpkg -l chef-integration-test", :returns => [1])
+ shell_out!("dpkg -l chef-integration-test", returns: [1])
expect(package_resource).not_to be_updated_by_last_action
end
@@ -275,7 +275,7 @@ describe Chef::Resource::AptPackage, metadata do
r = base_resource
r.cookbook_name = "preseed"
r.response_file("preseed-template-variables.seed")
- r.response_file_variables({ :template_variable => "SUPPORTS VARIABLES" })
+ r.response_file_variables({ template_variable: "SUPPORTS VARIABLES" })
r
end
@@ -300,13 +300,13 @@ describe Chef::Resource::AptPackage, metadata do
it "does nothing for action :install" do
package_resource.run_action(:install)
- shell_out!("dpkg -l chef-integration-test", :returns => [0])
+ shell_out!("dpkg -l chef-integration-test", returns: [0])
expect(package_resource).not_to be_updated_by_last_action
end
it "does nothing for action :upgrade" do
package_resource.run_action(:upgrade)
- shell_out!("dpkg -l chef-integration-test", :returns => [0])
+ shell_out!("dpkg -l chef-integration-test", returns: [0])
expect(package_resource).not_to be_updated_by_last_action
end
@@ -324,7 +324,7 @@ describe Chef::Resource::AptPackage, metadata do
# un chef-integration-test <none> (no description available)
def pkg_should_be_removed
# will raise if exit code != 0,1
- pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0, 1])
+ pkg_check = shell_out!("dpkg -l chef-integration-test", returns: [0, 1])
if pkg_check.exitstatus == 0
expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/)
@@ -353,13 +353,13 @@ describe Chef::Resource::AptPackage, metadata do
it "does nothing for action :install" do
package_resource.run_action(:install)
- shell_out!("dpkg -l chef-integration-test", :returns => [0])
+ shell_out!("dpkg -l chef-integration-test", returns: [0])
expect(package_resource).not_to be_updated_by_last_action
end
it "upgrades the package for action :upgrade" do
package_resource.run_action(:upgrade)
- dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0])
+ dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
expect(package_resource).to be_updated_by_last_action
end
@@ -373,7 +373,7 @@ describe Chef::Resource::AptPackage, metadata do
it "upgrades the package for action :install" do
package_resource.run_action(:install)
- dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0])
+ dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
expect(package_resource).to be_updated_by_last_action
end
diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb
index 0b45e097af..9943e821e9 100644
--- a/spec/functional/resource/bff_spec.rb
+++ b/spec/functional/resource/bff_spec.rb
@@ -20,7 +20,7 @@ require "functional/resource/base"
require "chef/mixin/shell_out"
# Run the test only for AIX platform.
-describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform] != "aix" do
+describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] != "aix" do
include Chef::Mixin::ShellOut
let(:new_resource) do
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb
index 1bff8bf874..84fe304585 100644
--- a/spec/functional/resource/cron_spec.rb
+++ b/spec/functional/resource/cron_spec.rb
@@ -105,7 +105,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
end
exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform])
- describe "create action with various attributes", :external => exclude_solaris do
+ describe "create action with various attributes", external: exclude_solaris do
def create_and_validate_with_attribute(resource, attribute, value)
if ohai[:platform] == "aix"
expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index 01611ef996..f05d297004 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -21,7 +21,7 @@ require "chef/mixin/shell_out"
# run this test only for following platforms.
exclude_test = !(%w{rhel fedora}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
-describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do
+describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
include Chef::Mixin::ShellOut
def flush_cache
@@ -39,12 +39,12 @@ describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test d
before(:each) do
File.open("/etc/yum.repos.d/chef-dnf-localtesting.repo", "w+") do |f|
- f.write <<-EOF
-[chef-dnf-localtesting]
-name=Chef DNF spec testing repo
-baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
-enable=1
-gpgcheck=0
+ f.write <<~EOF
+ [chef-dnf-localtesting]
+ name=Chef DNF spec testing repo
+ baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
+ enable=1
+ gpgcheck=0
EOF
end
shell_out!("rpm -qa | grep chef_rpm | xargs -r rpm -e")
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index ce92c468f0..1caa07d105 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -147,38 +147,38 @@ EOH
let(:dsc_user_suffix_code) { dsc_user_suffix }
let(:dsc_script_environment_attribute) { nil }
let(:dsc_user_resources_code) do
- <<-EOH
- #{config_param_section}
-node localhost
-{
-$testuser = #{dsc_user_code}
-$testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force
-$testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword
-
-User dsctestusercreate
-{
- UserName = $testuser
- Password = $testcred
- Description = "DSC test user"
- Ensure = "Present"
- Disabled = $false
- PasswordNeverExpires = $true
- PasswordChangeRequired = $false
-}
-}
+ <<~EOH
+ #{config_param_section}
+ node localhost
+ {
+ $testuser = #{dsc_user_code}
+ $testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force
+ $testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword
+
+ User dsctestusercreate
+ {
+ UserName = $testuser
+ Password = $testcred
+ Description = "DSC test user"
+ Ensure = "Present"
+ Disabled = $false
+ PasswordNeverExpires = $true
+ PasswordChangeRequired = $false
+ }
+ }
EOH
end
let(:dsc_user_config_data) do
- <<-EOH
-@{
- AllNodes = @(
- @{
- NodeName = "localhost";
- PSDscAllowPlainTextPassword = $true
- }
- )
-}
+ <<~EOH
+ @{
+ AllNodes = @(
+ @{
+ NodeName = "localhost";
+ PSDscAllowPlainTextPassword = $true
+ }
+ )
+ }
EOH
end
@@ -188,17 +188,17 @@ EOH
let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
let(:exception_message_signature) { "LL927-LL928" }
let(:dsc_environment_config) do
- <<-EOH
-if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}')))
-{
- throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}'
-}
-environment "whatsmydir"
-{
- Name = '#{dsc_environment_env_var_name}'
- Value = $pwd.path
- Ensure = 'Present'
-}
+ <<~EOH
+ if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}')))
+ {
+ throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}'
+ }
+ environment "whatsmydir"
+ {
+ Name = '#{dsc_environment_env_var_name}'
+ Value = $pwd.path
+ Ensure = 'Present'
+ }
EOH
end
@@ -234,7 +234,7 @@ EOH
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true)
end
it_should_behave_like "a dsc_script resource with configuration affected by cwd"
@@ -243,12 +243,12 @@ EOH
shared_examples_for "a dsc_script resource with configuration affected by cwd" do
after(:each) do
removal_resource = Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
- removal_resource.code <<-EOH
-environment 'removethis'
-{
- Name = '#{dsc_environment_env_var_name}'
- Ensure = 'Absent'
-}
+ removal_resource.code <<~EOH
+ environment 'removethis'
+ {
+ Name = '#{dsc_environment_env_var_name}'
+ Ensure = 'Absent'
+ }
EOH
removal_resource.run_action(:run)
end
@@ -314,7 +314,7 @@ EOH
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true)
end
end
end
@@ -347,7 +347,7 @@ EOH
shared_examples_for "a dsc_script with configuration data that takes parameters" do
let(:dsc_user_code) { dsc_user_param_code }
let(:config_param_section) { config_params }
- let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}" } }
+ let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => (dsc_user_prefix).to_s, :"#{dsc_user_suffix_param_name}" => (dsc_user_suffix).to_s } }
it "does not directly contain the user name" do
configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
file.read
@@ -409,45 +409,45 @@ EOH
end
let(:dsc_configuration_script) do
- <<-MYCODE
-cd c:\\
-configuration LCM
-{
- param ($thumbprint)
- localconfigurationmanager
- {
- RebootNodeIfNeeded = $false
- ConfigurationMode = 'ApplyOnly'
- CertificateID = $thumbprint
- }
-}
-$cert = ls Cert:\\LocalMachine\\My\\ |
- Where-Object {$_.Subject -match "ChefTest"} |
- Select -first 1
-
-if($cert -eq $null) {
- $pfxpath = '#{self_signed_cert_path}'
- $password = ''
- $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath, $password, ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeyset))
- $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "My", ([System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine)
- $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
- $store.Add($cert)
- $store.Close()
-}
-
-lcm -thumbprint $cert.thumbprint
-set-dsclocalconfigurationmanager -path ./LCM
-$ConfigurationData = @"
-@{
-AllNodes = @(
- @{
- NodeName = "localhost";
- CertificateID = '$($cert.thumbprint)';
- };
-);
-}
-"@
-$ConfigurationData | out-file '#{configuration_data_path}' -force
+ <<~MYCODE
+ cd c:\\
+ configuration LCM
+ {
+ param ($thumbprint)
+ localconfigurationmanager
+ {
+ RebootNodeIfNeeded = $false
+ ConfigurationMode = 'ApplyOnly'
+ CertificateID = $thumbprint
+ }
+ }
+ $cert = ls Cert:\\LocalMachine\\My\\ |
+ Where-Object {$_.Subject -match "ChefTest"} |
+ Select -first 1
+
+ if($cert -eq $null) {
+ $pfxpath = '#{self_signed_cert_path}'
+ $password = ''
+ $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath, $password, ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeyset))
+ $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "My", ([System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine)
+ $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
+ $store.Add($cert)
+ $store.Close()
+ }
+
+ lcm -thumbprint $cert.thumbprint
+ set-dsclocalconfigurationmanager -path ./LCM
+ $ConfigurationData = @"
+ @{
+ AllNodes = @(
+ @{
+ NodeName = "localhost";
+ CertificateID = '$($cert.thumbprint)';
+ };
+ );
+ }
+ "@
+ $ConfigurationData | out-file '#{configuration_data_path}' -force
MYCODE
end
@@ -460,13 +460,13 @@ $ConfigurationData | out-file '#{configuration_data_path}' -force
let(:dsc_script_resource) do
dsc_test_resource_base.tap do |r|
- r.code <<-EOF
-User dsctestusercreate
-{
- UserName = '#{dsc_user}'
- Password = #{r.ps_credential('jf9a8m49jrajf4#')}
- Ensure = "Present"
-}
+ r.code <<~EOF
+ User dsctestusercreate
+ {
+ UserName = '#{dsc_user}'
+ Password = #{r.ps_credential('jf9a8m49jrajf4#')}
+ Ensure = "Present"
+ }
EOF
r.configuration_data_script(configuration_data_path)
end
diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb
index 4dd3110629..3ad8762169 100644
--- a/spec/functional/resource/execute_spec.rb
+++ b/spec/functional/resource/execute_spec.rb
@@ -106,7 +106,7 @@ describe Chef::Resource::Execute do
it "guard adds additional values in its :environment and runs" do
resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] != "regularsecret"'}, {
- :environment => { "SGCE_SECRET" => "regularsecret" },
+ environment: { "SGCE_SECRET" => "regularsecret" },
}
resource.run_action(:run)
expect(resource).to be_updated_by_last_action
@@ -114,7 +114,7 @@ describe Chef::Resource::Execute do
it "guard adds additional values in its :environment and does not run" do
resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] == "regularsecret"'}, {
- :environment => { "SGCE_SECRET" => "regularsecret" },
+ environment: { "SGCE_SECRET" => "regularsecret" },
}
resource.run_action(:run)
expect(resource).not_to be_updated_by_last_action
@@ -122,7 +122,7 @@ describe Chef::Resource::Execute do
it "guard overwrites value with its :environment and runs" do
resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] != "regularsecret"'}, {
- :environment => { "SAWS_SECRET" => "regularsecret" },
+ environment: { "SAWS_SECRET" => "regularsecret" },
}
resource.run_action(:run)
expect(resource).to be_updated_by_last_action
@@ -130,7 +130,7 @@ describe Chef::Resource::Execute do
it "guard overwrites value with its :environment and does not runs" do
resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] == "regularsecret"'}, {
- :environment => { "SAWS_SECRET" => "regularsecret" },
+ environment: { "SAWS_SECRET" => "regularsecret" },
}
resource.run_action(:run)
expect(resource).not_to be_updated_by_last_action
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index 0fa1317032..291311f3e2 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -51,7 +51,7 @@ describe Chef::Resource::File do
end
let(:resource_with_relative_path) do
- create_resource(:use_relative_path => true)
+ create_resource(use_relative_path: true)
end
let(:unmanaged_content) do
diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb
index 6808898c29..16cde6351a 100644
--- a/spec/functional/resource/git_spec.rb
+++ b/spec/functional/resource/git_spec.rb
@@ -22,7 +22,7 @@ require "tmpdir"
require "shellwords"
# Deploy relies heavily on symlinks, so it doesn't work on windows.
-describe Chef::Resource::Git, :requires_git => true do
+describe Chef::Resource::Git, requires_git: true do
include Chef::Mixin::ShellOut
let(:file_cache_path) { Dir.mktmpdir }
# Some versions of git complains when the deploy directory is
@@ -65,17 +65,17 @@ describe Chef::Resource::Git, :requires_git => true do
let(:rev_head) { "d294fbfd05aa7709ad9a9b8ef6343b17d355bf5f" }
let(:git_user_config) do
- <<-E
-[user]
- name = frodoTbaggins
- email = frodo@shire.org
+ <<~E
+ [user]
+ name = frodoTbaggins
+ email = frodo@shire.org
E
end
before(:each) do
Chef::Log.level = :warn # silence git command live streams
@old_file_cache_path = Chef::Config[:file_cache_path]
- shell_out!("git clone \"#{git_bundle_repo}\" example", :cwd => origin_repo_dir)
+ shell_out!("git clone \"#{git_bundle_repo}\" example", cwd: origin_repo_dir)
File.open("#{origin_repo}/.git/config", "a+") { |f| f.print(git_user_config) }
Chef::Config[:file_cache_path] = file_cache_path
end
@@ -127,10 +127,10 @@ E
it "checks out the revision pointed to by the tag commit, not the tag commit itself" do
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(v1_commit)
# also verify the tag commit itself is what we expect as an extra sanity check
- rev = shell_out!("git rev-parse v1.0.0", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ rev = shell_out!("git rev-parse v1.0.0", cwd: deploy_directory, returns: [0]).stdout.strip
expect(rev).to eq(v1_tag)
end
@@ -138,7 +138,7 @@ E
# this used to fail because we didn't resolve the annotated tag
# properly to the pointed to commit.
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(v1_commit)
copy_git_resource.run_action(:sync)
@@ -164,14 +164,14 @@ E
it "checks out the expected revision ed18" do
basic_git_resource.revision rev_foo
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(rev_foo)
end
it "doesn't update if up-to-date" do
basic_git_resource.revision rev_foo
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(rev_foo)
copy_git_resource.revision rev_foo
@@ -182,7 +182,7 @@ E
it "checks out the expected revision 972d" do
basic_git_resource.revision rev_testing
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(rev_testing)
end
end
@@ -197,7 +197,7 @@ E
it "checks out the expected revision" do
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(rev_head)
end
end
@@ -212,7 +212,7 @@ E
it "checks out HEAD as the default revision" do
basic_git_resource.run_action(:sync)
- head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip
+ head_rev = shell_out!("git rev-parse HEAD", cwd: deploy_directory, returns: [0]).stdout.strip
expect(head_rev).to eq(rev_head)
end
end
@@ -220,7 +220,7 @@ E
context "when dealing with a repo with a degenerate tag named 'HEAD'" do
before do
shell_out!("git tag -m\"degenerate tag\" HEAD ed181b3419b6f489bedab282348162a110d6d3a1",
- :cwd => origin_repo)
+ cwd: origin_repo)
end
let(:basic_git_resource) do
@@ -240,16 +240,16 @@ E
it "checks out the (master) HEAD revision and ignores the tag" do
basic_git_resource.run_action(:sync)
head_rev = shell_out!("git rev-parse HEAD",
- :cwd => deploy_directory,
- :returns => [0]).stdout.strip
+ cwd: deploy_directory,
+ returns: [0]).stdout.strip
expect(head_rev).to eq(rev_head)
end
it "checks out the (master) HEAD revision when no revision is specified (ignores tag)" do
git_resource_default_rev.run_action(:sync)
head_rev = shell_out!("git rev-parse HEAD",
- :cwd => deploy_directory,
- :returns => [0]).stdout.strip
+ cwd: deploy_directory,
+ returns: [0]).stdout.strip
expect(head_rev).to eq(rev_head)
end
diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb
index f32ed069b5..c52a4c0694 100644
--- a/spec/functional/resource/ifconfig_spec.rb
+++ b/spec/functional/resource/ifconfig_spec.rb
@@ -23,7 +23,7 @@ require "chef/mixin/shell_out"
# run this test only for following platforms.
include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7))
-describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do
+describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, external: include_flag do
# This test does not work in travis because there is no eth0
include Chef::Mixin::ShellOut
@@ -122,7 +122,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in
end
exclude_test = ohai[:platform] != "ubuntu"
- describe "#action_add", :external => exclude_test do
+ describe "#action_add", external: exclude_test do
after do
new_resource.run_action(:delete)
end
@@ -134,7 +134,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in
end
end
- describe "#action_enable", :external => exclude_test do
+ describe "#action_enable", external: exclude_test do
after do
new_resource.run_action(:disable)
end
@@ -145,7 +145,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in
end
end
- describe "#action_disable", :external => exclude_test do
+ describe "#action_disable", external: exclude_test do
before do
setup_enable_interface(new_resource)
new_resource.run_action(:enable)
@@ -157,7 +157,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in
end
end
- describe "#action_delete", :external => exclude_test do
+ describe "#action_delete", external: exclude_test do
before do
setup_add_interface(new_resource)
new_resource.run_action(:add)
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index 2b8b509730..4464b6ed69 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
if windows?
- require "chef/win32/file" #probably need this in spec_helper
+ require "chef/win32/file" # probably need this in spec_helper
require "chef/win32/security"
end
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index c98d6cec25..f4e528c755 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -24,7 +24,7 @@ require "tmpdir"
# run this test only for following platforms.
include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family]))
-describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do
+describe Chef::Resource::Mount, :requires_root, :skip_travis, external: include_flag do
# Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not
# exist even after loading the kernel module
@@ -161,7 +161,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu
# don't run the remount tests on solaris2 (tmpfs does not support remount)
# Need to make sure the platforms we've already excluded are considered:
skip_remount = include_flag || (ohai[:platform] == "solaris2")
- describe "when the filesystem should be remounted and the resource supports remounting", :external => skip_remount do
+ describe "when the filesystem should be remounted and the resource supports remounting", external: skip_remount do
it "should remount the filesystem if it is mounted" do
new_resource.run_action(:mount)
mount_should_exist(new_resource.mount_point, new_resource.device)
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index bbd304fd06..cc1bd8fd1c 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -255,16 +255,16 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
context "when dsc is supported", :windows_powershell_dsc_only do
it "can execute LCM configuration code" do
- resource.code <<-EOF
-configuration LCM
-{
- param ($thumbprint)
- localconfigurationmanager
- {
- RebootNodeIfNeeded = $false
- ConfigurationMode = 'ApplyOnly'
- }
-}
+ resource.code <<~EOF
+ configuration LCM
+ {
+ param ($thumbprint)
+ localconfigurationmanager
+ {
+ RebootNodeIfNeeded = $false
+ ConfigurationMode = 'ApplyOnly'
+ }
+ }
EOF
expect { resource.run_action(:run) }.not_to raise_error
end
@@ -474,13 +474,13 @@ configuration LCM
it "evaluates a not_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd
expect(resource.should_skip?(:run)).to be_falsey
end
@@ -581,7 +581,7 @@ configuration LCM
end
it "raises an error when a 32-bit guard is used on Windows Nano Server", :windows_nano_only do
- resource.only_if "$true", :architecture => :i386
+ resource.only_if "$true", architecture: :i386
expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb
index c264b122a7..3b8e3efe8a 100644
--- a/spec/functional/resource/reboot_spec.rb
+++ b/spec/functional/resource/reboot_spec.rb
@@ -22,9 +22,9 @@ describe Chef::Resource::Reboot do
let(:expected) do
{
- :delay_mins => 5,
- :requested_by => "reboot resource functional test",
- :reason => "reboot resource spec test",
+ delay_mins: 5,
+ requested_by: "reboot resource functional test",
+ reason: "reboot resource spec test",
}
end
diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb
index 7318086034..8de6577759 100644
--- a/spec/functional/resource/registry_spec.rb
+++ b/spec/functional/resource/registry_spec.rb
@@ -34,13 +34,13 @@ describe Chef::Resource::RegistryKey, :unix_only do
context "when load_current_resource is run on a non-windows node" do
it "throws an exception because you don't have a windows registry (derp)" do
@resource.key("HKCU\\Software\\Opscode")
- @resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ @resource.values([{ name: "Color", type: :string, data: "Orange" }])
expect { @resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32NotWindows)
end
end
end
-describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
+describe Chef::Resource::RegistryKey, :windows_only, broken: true do
# parent and key must be single keys, not paths
let(:parent) { "Opscode" }
@@ -107,7 +107,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
reset_registry
end
- #Reporting setup
+ # Reporting setup
before do
@node.name("windowsbox")
@@ -123,7 +123,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@run_id = @resource_reporter.run_id
@new_resource.cookbook_name = "monkey"
- @cookbook_version = double("Cookbook::Version", :version => "1.2.3")
+ @cookbook_version = double("Cookbook::Version", version: "1.2.3")
@new_resource.cookbook_version(@cookbook_version)
end
@@ -137,110 +137,110 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ @new_resource.values([{ name: "Color", type: :string, data: "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ @new_resource.values([{ name: "Color", type: :string, data: "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value and type but datatype of data differs" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "number", :type => :dword, :data => "12345" }])
+ @new_resource.values([{ name: "number", type: :dword, data: "12345" }])
@new_resource.run_action(:create)
expect(@new_resource).not_to be_updated_by_last_action
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, { :name => "number", :type => :dword, :data => 12344 })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "number", type: :dword, data: 12344 })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
+ @new_resource.values([{ name: "Mango", type: :string, data: "Yellow" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Mango", type: :string, data: "Yellow" })).to eq(true)
end
it "modifies the data if the key and value exist and type matches" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" }])
+ @new_resource.values([{ name: "Color", type: :string, data: "Not just Orange - OpscodeOrange!" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Not just Orange - OpscodeOrange!" })).to eq(true)
end
it "modifys the type if the key and value exist and the type does not match" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] }])
+ @new_resource.values([{ name: "Color", type: :multi_string, data: ["Not just Orange - OpscodeOrange!"] }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :multi_string, data: ["Not just Orange - OpscodeOrange!"] })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\OpscodeTest')
- @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} }])
+ @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\OpscodeTest', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\OpscodeTest', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
end
it "raises an error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
@new_resource.recursive(false)
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "raises an error if action create and type key missing in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :data => "my_data" }])
+ @new_resource.values([{ name: "OC", data: "my_data" }])
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
end
it "raises an error if action create and data key missing in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :type => :string }])
+ @new_resource.values([{ name: "OC", type: :string }])
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing)
end
it "raises an error if action create and only name key present in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC" }])
+ @new_resource.values([{ name: "OC" }])
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
end
it "does not raise an error if action create and all keys are present in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "my_data" }])
expect { @new_resource.run_action(:create) }.to_not raise_error
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Missing1\Missing2')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { name: "OC", type: :string, data: "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
+ @new_resource.values([{ name: "one", type: :string, data: "1" }, { name: "two", type: :string, data: "2" }, { name: "three", type: :string, data: "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@@ -259,12 +259,12 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates a key in a 32-bit registry that is not viewable in 64-bit" do
@new_resource.key(reg_child + '\Atraxi' )
- @new_resource.values([{ :name => "OC", :type => :string, :data => "Data" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "Data" }])
@new_resource.recursive(true)
@new_resource.architecture(:i386)
@new_resource.run_action(:create)
@registry.architecture = :i386
- expect(@registry.data_exists?(reg_child + '\Atraxi', { :name => "OC", :type => :string, :data => "Data" })).to eq(true)
+ expect(@registry.data_exists?(reg_child + '\Atraxi', { name: "OC", type: :string, data: "Data" })).to eq(true)
@registry.architecture = :x86_64
expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false)
end
@@ -272,7 +272,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for action :create" do
@new_resource.key(reg_child + '\Ood')
- @new_resource.values([{ :name => "ReportingVal1", :type => :string, :data => "report1" }, { :name => "ReportingVal2", :type => :string, :data => "report2" }])
+ @new_resource.values([{ name: "ReportingVal1", type: :string, data: "report1" }, { name: "ReportingVal2", type: :string, data: "report2" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@report = @resource_reporter.prepare_run_data
@@ -281,8 +281,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood')
- expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal1", :type => :string, :data => "report1" },
- { :name => "ReportingVal2", :type => :string, :data => "report2" }])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal1", type: :string, data: "report1" },
+ { name: "ReportingVal2", type: :string, data: "report2" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create")
expect(@report["status"]).to eq("success")
@@ -296,7 +296,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not raise an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -305,7 +305,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not create key if the action is create" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -313,28 +313,28 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not raise an exception if the action create and type key missing in values hash" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{ :name => "BriskWalk", :data => "my_data" }])
+ @new_resource.values([{ name: "BriskWalk", data: "my_data" }])
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
end
it "does not raise an exception if the action create and data key missing in values hash" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{ :name => "BriskWalk", :type => :string }])
+ @new_resource.values([{ name: "BriskWalk", type: :string }])
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
end
it "does not raise an exception if the action create and only name key present in values hash" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{ :name => "BriskWalk" }])
+ @new_resource.values([{ name: "BriskWalk" }])
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
end
it "does not raise an exception if the action create and all keys are present in values hash" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }])
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
end
@@ -348,85 +348,85 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ @new_resource.values([{ name: "Color", type: :string, data: "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_parent)).to eq(true)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ @new_resource.values([{ name: "Color", type: :string, data: "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Color", type: :string, data: "Orange" })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
+ @new_resource.values([{ name: "Mango", type: :string, data: "Yellow" }])
@new_resource.run_action(:create_if_missing)
- expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
+ expect(@registry.data_exists?(reg_child, { name: "Mango", type: :string, data: "Yellow" })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\Pyrovile')
- @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} }])
+ @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Pyrovile', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Pyrovile', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
end
it "raises an error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
@new_resource.recursive(false)
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "raises an error if action create_if_missing and type key missing in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :data => "my_data" }])
+ @new_resource.values([{ name: "OC", data: "my_data" }])
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
end
it "raises an error if action create_if_missing and data key missing in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :type => :string }])
+ @new_resource.values([{ name: "OC", type: :string }])
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing)
end
it "raises an error if action create_if_missing and only name key present in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC" }])
+ @new_resource.values([{ name: "OC" }])
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
end
it "does not raise an error if action create_if_missing and all keys are present in values hash" do
@new_resource.key(reg_child)
- @new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "my_data" }])
expect { @new_resource.run_action(:create_if_missing) }.to_not raise_error
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
+ @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { name: "OC", type: :string, data: "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child + '\Adipose')
- @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
+ @new_resource.values([{ name: "one", type: :string, data: "1" }, { name: "two", type: :string, data: "2" }, { name: "three", type: :string, data: "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@@ -437,7 +437,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for :create_if_missing" do
@new_resource.key(reg_child + '\Judoon')
- @new_resource.values([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
+ @new_resource.values([{ name: "ReportingVal3", type: :string, data: "report3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@report = @resource_reporter.prepare_run_data
@@ -446,7 +446,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon')
- expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal3", type: :string, data: "report3" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create_if_missing")
expect(@report["status"]).to eq("success")
@@ -460,7 +460,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not raise an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Zygons\Zygor')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -469,7 +469,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does nothing if the action is create_if_missing" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -477,28 +477,28 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not raise an exception if the action create_if_missing and type key missing in values hash" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{ :name => "BriskWalk", :data => "my_data" }])
+ @new_resource.values([{ name: "BriskWalk", data: "my_data" }])
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
end
it "does not raise an exception if the action create_if_missing and data key missing in values hash" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{ :name => "BriskWalk", :type => :string }])
+ @new_resource.values([{ name: "BriskWalk", type: :string }])
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
end
it "does not raise an exception if the action create_if_missing and only name key present in values hash" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{ :name => "BriskWalk" }])
+ @new_resource.values([{ name: "BriskWalk" }])
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
end
it "does not raise an exception if the action create_if_missing and all keys are present in values hash" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }])
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
end
@@ -522,54 +522,54 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "takes no action if the key exists but the value does not" do
- expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{ :name => "LooksLike", :type => :multi_string, :data => %w{SeattleGrey OCOrange} }])
+ @new_resource.values([{ name: "LooksLike", type: :multi_string, data: %w{SeattleGrey OCOrange} }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
end
it "deletes only specified values under a key path" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{ :name => "Opscode", :type => :multi_string, :data => %w{Seattle Washington} }, { :name => "AKA", :type => :string, :data => "OC" }])
+ @new_resource.values([{ name: "Opscode", type: :multi_string, data: %w{Seattle Washington} }, { name: "AKA", type: :string, data: "OC" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
- expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "AKA", :type => :string, :data => "OC" })).to eq(false)
- expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Opscode", :type => :multi_string, :data => %w{Seattle Washington} })).to eq(false)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "AKA", type: :string, data: "OC" })).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Opscode", type: :multi_string, data: %w{Seattle Washington} })).to eq(false)
end
it "it deletes the values with the same name irrespective of it type and data" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{ :name => "Color", :type => :multi_string, :data => %w{Black Orange} }])
+ @new_resource.values([{ name: "Color", type: :multi_string, data: %w{Black Orange} }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(false)
end
it "prepares the reporting data for action :delete" do
@new_resource.key(reg_parent + '\ReportKey')
- @new_resource.values([{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])
+ @new_resource.values([{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])
@new_resource.recursive(true)
@new_resource.run_action(:delete)
@report = @resource_reporter.prepare_run_data
- expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])).to eq(false)
expect(@report["action"]).to eq("end")
expect(@report["resources"].count).to eq(1)
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
- expect(@report["resources"][0]["before"][:values]).to eq([{ :name => "ReportVal4", :type => :string, :data => "report4" },
- { :name => "ReportVal5", :type => :string, :data => "report5" }])
- #Not testing for after values to match since after -> new_resource values.
+ expect(@report["resources"][0]["before"][:values]).to eq([{ name: "ReportVal4", type: :string, data: "report4" },
+ { name: "ReportVal5", type: :string, data: "report5" }])
+ # Not testing for after values to match since after -> new_resource values.
expect(@report["resources"][0]["result"]).to eq("delete")
expect(@report["status"]).to eq("success")
expect(@report["total_res_count"]).to eq("1")
@@ -581,7 +581,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does nothing if the action is delete" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
@@ -622,7 +622,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "ignores the values under a key" do
@new_resource.key(reg_parent + '\OpscodeIgnoredValues')
- #@new_resource.values([{:name=>"DontExist", :type=>:string, :data=>"These will be ignored anyways"}])
+ # @new_resource.values([{:name=>"DontExist", :type=>:string, :data=>"These will be ignored anyways"}])
@new_resource.recursive(true)
@new_resource.run_action(:delete_key)
end
@@ -645,9 +645,9 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
- #Not testing for before or after values to match since
- #after -> new_resource.values and
- #before -> current_resource.values
+ # Not testing for before or after values to match since
+ # after -> new_resource.values and
+ # before -> current_resource.values
expect(@report["resources"][0]["result"]).to eq("delete_key")
expect(@report["status"]).to eq("success")
expect(@report["total_res_count"]).to eq("1")
@@ -659,13 +659,13 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the key has subkeys but recursive is set to false" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
end
it "does nothing if the action is delete_key" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
+ @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 8e484b2968..a121cbb1f3 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -360,7 +360,7 @@ describe Chef::Resource::RemoteFile do
it "should raise ContentLengthMismatch" do
expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- #File.should_not exist(path) # XXX: CHEF-5081
+ # File.should_not exist(path) # XXX: CHEF-5081
end
end
@@ -373,7 +373,7 @@ describe Chef::Resource::RemoteFile do
it "should raise ContentLengthMismatch" do
expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- #File.should_not exist(path) # XXX: CHEF-5081
+ # File.should_not exist(path) # XXX: CHEF-5081
end
end
diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb
index 17d0bf9e3c..fcaf8817eb 100644
--- a/spec/functional/resource/rpm_spec.rb
+++ b/spec/functional/resource/rpm_spec.rb
@@ -22,7 +22,7 @@ require "chef/mixin/shell_out"
# run this test only for following platforms.
exclude_test = !%w{aix rhel fedora suse}.include?(ohai[:platform_family])
-describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do
+describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
include Chef::Mixin::ShellOut
let(:new_resource) do
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index b9a39255f4..679ffe661a 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -68,7 +68,7 @@ describe Chef::Resource::Template do
context "when the target file does not exist" do
it "creates the template with the rendered content using the variable attribute when the :create action is run" do
resource.source("openldap_variable_stuff.conf.erb")
- resource.variables(:secret => "nutella")
+ resource.variables(secret: "nutella")
resource.run_action(:create)
expect(IO.read(path)).to eq("super secret is nutella")
end
@@ -112,7 +112,7 @@ describe Chef::Resource::Template do
context "using single helper syntax referencing @node" do
before do
node.normal[:helper_test_attr] = "value from helper method"
- resource.helper(:helper_method) { "#{@node[:helper_test_attr]}" }
+ resource.helper(:helper_method) { (@node[:helper_test_attr]).to_s }
end
it_behaves_like "a template with helpers"
@@ -213,21 +213,21 @@ describe Chef::Resource::Template do
describe "when template variables contain lazy{} calls" do
it "resolves the DelayedEvaluator" do
resource.source("openldap_variable_stuff.conf.erb")
- resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" })
+ resource.variables(secret: Chef::DelayedEvaluator.new { "nutella" })
resource.run_action(:create)
expect(IO.read(path)).to eq("super secret is nutella")
end
it "does not mutate the resource variables" do
resource.source("openldap_variable_stuff.conf.erb")
- resource.variables(:secret => Chef::DelayedEvaluator.new { "nutella" })
+ resource.variables(secret: Chef::DelayedEvaluator.new { "nutella" })
resource.run_action(:create)
expect(resource.variables[:secret]).to be_a Chef::DelayedEvaluator
end
it "resolves the DelayedEvaluator when deeply nested" do
resource.source("openldap_nested_variable_stuff.erb")
- resource.variables(:secret => [{ "key" => Chef::DelayedEvaluator.new { "nutella" } }])
+ resource.variables(secret: [{ "key" => Chef::DelayedEvaluator.new { "nutella" } }])
resource.run_action(:create)
expect(IO.read(path)).to eq("super secret is nutella")
end
diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb
index ed96e31bac..78d7f2336e 100644
--- a/spec/functional/resource/user/dscl_spec.rb
+++ b/spec/functional/resource/user/dscl_spec.rb
@@ -19,9 +19,9 @@ require "spec_helper"
require "chef/mixin/shell_out"
metadata = {
- :mac_osx_only => true,
- :requires_root => true,
- :not_supported_on_mac_osx_106 => true,
+ mac_osx_only: true,
+ requires_root: true,
+ not_supported_on_mac_osx_106: true,
}
describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metadata do
diff --git a/spec/functional/resource/windows_env_spec.rb b/spec/functional/resource/windows_env_spec.rb
index a6c6b39970..e5f2032795 100644
--- a/spec/functional/resource/windows_env_spec.rb
+++ b/spec/functional/resource/windows_env_spec.rb
@@ -188,7 +188,7 @@ describe Chef::Resource::WindowsEnv, :windows_only do
test_resource.value("#{path_before};#{env_val}")
test_resource.run_action(:create)
expect(ENV["PATH"]).not_to include(env_val)
- expect(ENV["PATH"]).to include("#{random_name}")
+ expect(ENV["PATH"]).to include((random_name).to_s)
end
after(:each) do
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index 531f9e9250..f422ac21d6 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_gem_only, :appveyor_only, :broken => true do
+describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_gem_only, :appveyor_only, broken: true do
# Marking as broken. This test is causing appveyor tests to exit with 116.
include_context "using Win32::Service"
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 46fbfe2e82..05f46d20ce 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates scheduled task and sets command arguments" do
subject.command "chef-client -W"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq("chef-client")
@@ -64,7 +64,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates scheduled task and sets command arguments" do
subject.command "chef-client -W -L 'C:\\chef\\chef-ad-join.log'"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq("chef-client")
@@ -82,7 +82,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates scheduled task and sets command arguments" do
subject.command '"C:\\Program Files\\example\program.exe" -arg1 --arg2'
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq("C:\\Program Files\\example\\program.exe")
@@ -100,7 +100,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates scheduled task and sets command arguments" do
subject.command "ping http://www.google.com"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq("ping")
@@ -129,7 +129,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run every 1 hr starting on 09/20/2017" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq(task_name)
@@ -161,7 +161,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task that runs after every 15 minutes" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -209,7 +209,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task that runs after every 3 hrs" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -254,7 +254,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run daily" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -289,7 +289,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "if day property is not set creates a scheduled task to run monthly on first day of the month" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -309,7 +309,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run monthly on first, second and third day of the month" do
subject.day "1, 2, 3"
call_for_create_action
- #loading current resource again to check new task is created and it matches task parameters
+ # loading current resource again to check new task is created and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -330,15 +330,15 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run monthly on 1, 2, 3, 4, 8, 20, 21, 15, 28, 31 day of the month" do
subject.day "1, 2, 3, 4, 8, 20, 21, 15, 28, 31"
call_for_create_action
- #loading current resource again to check new task is created and it matches task parameters
+ # loading current resource again to check new task is created and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
expect(current_resource.task.application_name).to eq(task_name)
expect(trigger_details[:trigger_type]).to eq(4)
expect(current_resource.task.principals[:run_level]).to eq(1)
- expect(trigger_details[:type][:days]).to eq(1209548943) #TODO:: windows_task_provider.send(:days_of_month)
- expect(trigger_details[:type][:months]).to eq(4095) #windows_task_provider.send(:months_of_year)
+ expect(trigger_details[:type][:days]).to eq(1209548943) # TODO:: windows_task_provider.send(:days_of_month)
+ expect(trigger_details[:type][:months]).to eq(4095) # windows_task_provider.send(:months_of_year)
end
it "does not converge the resource if it is already converged" do
@@ -352,15 +352,15 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.day "1, 2, 3, 4, 8, 20, 21, 30"
subject.months "Jan, Feb, May, Sep, Dec"
call_for_create_action
- #loading current resource again to check new task is created and it matches task parameters
+ # loading current resource again to check new task is created and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
expect(current_resource.task.application_name).to eq(task_name)
expect(trigger_details[:trigger_type]).to eq(4)
expect(current_resource.task.principals[:run_level]).to eq(1)
- expect(trigger_details[:type][:days]).to eq(538443919) #TODO:windows_task_provider.send(:days_of_month)
- expect(trigger_details[:type][:months]).to eq(2323) #windows_task_provider.send(:months_of_year)
+ expect(trigger_details[:type][:days]).to eq(538443919) # TODO:windows_task_provider.send(:days_of_month)
+ expect(trigger_details[:type][:months]).to eq(2323) # windows_task_provider.send(:months_of_year)
end
it "does not converge the resource if it is already converged" do
@@ -375,7 +375,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.frequency_modifier "First"
subject.day "Mon, Fri, Sun"
call_for_create_action
- #loading current resource again to check new task is created and it matches task parameters
+ # loading current resource again to check new task is created and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -384,7 +384,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
expect(current_resource.task.principals[:run_level]).to eq(1)
expect(trigger_details[:type][:days_of_week]).to eq(35)
expect(trigger_details[:type][:weeks_of_month]).to eq(1)
- expect(trigger_details[:type][:months]).to eq(4095) #windows_task_provider.send(:months_of_year)
+ expect(trigger_details[:type][:months]).to eq(4095) # windows_task_provider.send(:months_of_year)
end
it "does not converge the resource if it is already converged" do
@@ -606,7 +606,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.day "2"
subject.start_day "03/07/2018"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -628,7 +628,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run monthly on first, second and third day of the month" do
subject.day "1,2,3"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -649,7 +649,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates a scheduled task to run monthly on each wednesday of the month" do
subject.frequency_modifier "1"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -657,7 +657,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
expect(trigger_details[:trigger_type]).to eq(4)
expect(current_resource.task.principals[:run_level]).to eq(1)
expect(trigger_details[:type][:days]).to eq(1)
- expect(trigger_details[:type][:months]).to eq(4095) #windows_task_provider.send(:months_of_year)
+ expect(trigger_details[:type][:months]).to eq(4095) # windows_task_provider.send(:months_of_year)
end
it "does not converge the resource if it is already converged" do
@@ -671,16 +671,16 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.frequency_modifier "2"
subject.months = nil
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
- #loading current resource
+ # loading current resource
expect(current_resource.task.application_name).to eq(task_name)
expect(trigger_details[:trigger_type]).to eq(4)
expect(current_resource.task.principals[:run_level]).to eq(1)
expect(trigger_details[:type][:days]).to eq(1)
- expect(trigger_details[:type][:months]).to eq(2730) #windows_task_provider.send(:months_of_year)
+ expect(trigger_details[:type][:months]).to eq(2730) # windows_task_provider.send(:months_of_year)
end
it "does not converge the resource if it is already converged" do
@@ -714,7 +714,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to run once at 5pm" do
subject.start_time "17:00"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -745,7 +745,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to run weekly" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -765,7 +765,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates hte scheduled task for all days of week" do
subject.day "*"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -789,7 +789,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.day "Mon, Fri"
subject.frequency_modifier 2
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -894,7 +894,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to run at system start up" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -914,7 +914,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.start_day "09/10/2018"
subject.start_time "15:00"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -941,7 +941,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to on logon" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -961,7 +961,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.start_day "09/10/2018"
subject.start_time "15:00"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -996,7 +996,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to run when system is idle" do
subject.idle_time 20
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -1021,7 +1021,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.start_day "09/10/2018"
subject.start_time "15:00"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -1049,7 +1049,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.frequency :minute
subject.random_delay "20"
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
trigger_details = current_resource.task.trigger(0)
@@ -1092,7 +1092,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "creates the scheduled task to run on demand only" do
call_for_create_action
- #loading current resource again to check new task is creted and it matches task parameters
+ # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
@@ -1514,7 +1514,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
subject.run_action(:run)
subject.run_action(:end)
current_resource = call_for_load_current_resource
- expect(current_resource.task.status).to eq("queued").or eq("ready") #queued or can be ready
+ expect(current_resource.task.status).to eq("queued").or eq("ready") # queued or can be ready
end
end
diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb
index 7c45a64ae5..5075c24ea0 100644
--- a/spec/functional/resource/yum_package_spec.rb
+++ b/spec/functional/resource/yum_package_spec.rb
@@ -21,7 +21,7 @@ require "chef/mixin/shell_out"
# run this test only for following platforms.
exclude_test = !(%w{rhel fedora}.include?(ohai[:platform_family]) && !File.exist?("/usr/bin/dnf"))
-describe Chef::Resource::YumPackage, :requires_root, :external => exclude_test do
+describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
include Chef::Mixin::ShellOut
# NOTE: every single test here either needs to explicitly call flush_cache or needs to explicitly
@@ -45,12 +45,12 @@ describe Chef::Resource::YumPackage, :requires_root, :external => exclude_test d
before(:each) do
File.open("/etc/yum.repos.d/chef-yum-localtesting.repo", "w+") do |f|
- f.write <<-EOF
-[chef-yum-localtesting]
-name=Chef DNF spec testing repo
-baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
-enable=1
-gpgcheck=0
+ f.write <<~EOF
+ [chef-yum-localtesting]
+ name=Chef DNF spec testing repo
+ baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
+ enable=1
+ gpgcheck=0
EOF
end
shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
@@ -289,7 +289,7 @@ gpgcheck=0
it "installs with 64-bit arch in the property" do
flush_cache
yum_package.package_name("chef_rpm")
- yum_package.arch("#{pkg_arch}")
+ yum_package.arch((pkg_arch).to_s)
yum_package.run_action(:install)
expect(yum_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index d270803698..49972360ef 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -21,7 +21,7 @@ require "chef/client"
describe Chef::RunLock do
# This behavior works on windows, but the tests use fork :(
- describe "when locking the chef-client run", :unix_only => true do
+ describe "when locking the chef-client run", unix_only: true do
##
# Lockfile location and helpers
@@ -150,7 +150,7 @@ describe Chef::RunLock do
end
end
- it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do
+ it "sets FD_CLOEXEC on the lockfile", supports_cloexec: true do
run_lock = File.open(lockfile)
expect(run_lock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).to eq(Fcntl::FD_CLOEXEC)
end
@@ -197,7 +197,7 @@ describe Chef::RunLock do
end
end
- it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do
+ it "sets FD_CLOEXEC on the lockfile", supports_cloexec: true do
run_lock = File.open(lockfile)
expect(run_lock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).to eq(Fcntl::FD_CLOEXEC)
end
@@ -461,7 +461,7 @@ describe Chef::RunLock do
buffer << fd.read_nonblock(1) while buffer[-1] != "\n"
buffer
- #rescue IO::EAGAINUnreadable
+ # rescue IO::EAGAINUnreadable
rescue IO::WaitReadable
unless buffer == ""
sleep 0.1
diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb
index 08c791f2d2..3990f1afe0 100644
--- a/spec/functional/shell_spec.rb
+++ b/spec/functional/shell_spec.rb
@@ -26,7 +26,7 @@ describe Shell do
# chef-shell's unit tests are by necessity very mock-heavy, and frequently do
# not catch cases where chef-shell fails to boot because of changes in
# chef/client.rb
- describe "smoke tests", :unix_only => true do
+ describe "smoke tests", unix_only: true do
TIMEOUT = 300
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 19f5e58a49..4be021a60b 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -25,10 +25,10 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
@node.consume_external_attrs(OHAI_SYSTEM.data, {})
end
let(:cmd_output_format) { :text }
- let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { :depth => 2 }) }
+ let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { depth: 2 }) }
let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) }
- let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { :depth => 2 }) }
- let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { :depth => 2 }) }
+ let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { depth: 2 }) }
+ let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { depth: 2 }) }
let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") }
@@ -58,7 +58,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "passes command line switches to the command" do
- result = cmdlet_alias_requires_switch_or_argument.run({ :name => "ls" })
+ result = cmdlet_alias_requires_switch_or_argument.run({ name: "ls" })
expect(result.succeeded?).to eq(true)
end
@@ -68,7 +68,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "passes command line arguments and switches to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({ :path => etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders")
+ result = cmdlet_get_item_requires_switch_or_argument.run({ path: etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders")
expect(result.succeeded?).to eq(true)
returned_directory = result.return_value
returned_directory.strip!
@@ -76,7 +76,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "passes execution options to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({}, { :cwd => etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders")
+ result = cmdlet_get_item_requires_switch_or_argument.run({}, { cwd: etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders")
expect(result.succeeded?).to eq(true)
returned_directory = result.return_value
returned_directory.strip!
@@ -95,7 +95,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
context "when returning Ruby objects" do
let(:cmd_output_format) { :object }
it "returns object format data" do
- result = simple_cmdlet.run({}, { :cwd => etc_directory }, "hosts")
+ result = simple_cmdlet.run({}, { cwd: etc_directory }, "hosts")
expect(result.succeeded?).to eq(true)
data = result.return_value
expect(data["Name"]).to eq("hosts")
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index a45c25ff8c..dc323e9d3a 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -28,7 +28,7 @@ describe "Chef Versions" do
binaries.each do |binary|
it "#{binary} version should be sane" do
- expect(shell_out!("ruby #{File.join("bin", binary)} -v", :cwd => chef_dir).stdout.chomp).to include("Chef: #{Chef::VERSION}")
+ expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to include("Chef: #{Chef::VERSION}")
end
end
diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb
index 145c9881b9..5fcbca02b6 100644
--- a/spec/functional/win32/crypto_spec.rb
+++ b/spec/functional/win32/crypto_spec.rb
@@ -37,15 +37,15 @@ describe "Chef::ReservedNames::Win32::Crypto", :windows_only do
it "can be decrypted by powershell" do
encrypted = Chef::ReservedNames::Win32::Crypto.encrypt(plaintext)
resource = Chef::Resource::WindowsScript::PowershellScript.new("Powershell resource functional test", @run_context)
- resource.code <<-EOF
-$encrypted = '#{encrypted}' | ConvertTo-SecureString
-$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($encrypted)
-$plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
-if ($plaintext -ne '#{plaintext}') {
- Write-Error 'Got: ' $plaintext
- exit 1
-}
-exit 0
+ resource.code <<~EOF
+ $encrypted = '#{encrypted}' | ConvertTo-SecureString
+ $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($encrypted)
+ $plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
+ if ($plaintext -ne '#{plaintext}') {
+ Write-Error 'Got: ' $plaintext
+ exit 1
+ }
+ exit 0
EOF
resource.returns(0)
resource.run_action(:run)
diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb
index bcfa0ffd48..923b952161 100644
--- a/spec/functional/win32/registry_spec.rb
+++ b/spec/functional/win32/registry_spec.rb
@@ -23,7 +23,7 @@ require "chef/win32/registry"
describe "Chef::Win32::Registry", :windows_only do
before(:all) do
- #Create a registry item
+ # Create a registry item
::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root"
::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch"
::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\B®anch"
@@ -39,17 +39,17 @@ describe "Chef::Win32::Registry", :windows_only do
reg["Petals", Win32::Registry::REG_MULTI_SZ] = %w{Pink Delicate}
end
- #Create the node with ohai data
+ # Create the node with ohai data
events = Chef::EventDispatch::Dispatcher.new
@node = Chef::Node.new
@node.consume_external_attrs(OHAI_SYSTEM.data, {})
@run_context = Chef::RunContext.new(@node, {}, events)
- #Create a registry object that has access ot the node previously created
+ # Create a registry object that has access ot the node previously created
@registry = Chef::Win32::Registry.new(@run_context)
end
- #Delete what is left of the registry key-values previously created
+ # Delete what is left of the registry key-values previously created
after(:all) do
::Win32::Registry::HKEY_CURRENT_USER.open("Software") do |reg|
reg.delete_key("Root", true)
@@ -102,85 +102,85 @@ describe "Chef::Win32::Registry", :windows_only do
describe "value_exists?" do
it "throws an exception if the hive does not exist" do
- expect { @registry.value_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.value_exists?("JKLM\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect { @registry.value_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists?("HKCU\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals" })).to eq(true)
end
it "returns true if the value exists with a case mismatch on the value name" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals" })).to eq(true)
end
it "returns false if the value does not exist" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" })).to eq(false)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "FOOBAR" })).to eq(false)
end
end
describe "value_exists!" do
it "throws an exception if the hive does not exist" do
- expect { @registry.value_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.value_exists!("JKLM\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect { @registry.value_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists!("HKCU\\Software\\Branch\\Flower", { name: "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true)
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals" })).to eq(true)
end
it "returns true if the value exists with a case mismatch on the value name" do
- expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true)
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals" })).to eq(true)
end
it "throws an exception if the value does not exist" do
- expect { @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" }) }.to raise_error(Chef::Exceptions::Win32RegValueMissing)
+ expect { @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "FOOBAR" }) }.to raise_error(Chef::Exceptions::Win32RegValueMissing)
end
end
describe "data_exists?" do
it "throws an exception if the hive does not exist" do
- expect { @registry.data_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.data_exists?("JKLM\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect { @registry.data_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists?("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true)
end
it "returns true if all the data matches with a case mismatch on the data name" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true)
end
it "returns false if the name does not exist" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "slateP", type: :multi_string, data: %w{Pink Delicate} })).to eq(false)
end
it "returns false if the types do not match" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" })).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Pink" })).to eq(false)
end
it "returns false if the data does not match" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Mauve Delicate} })).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Mauve Delicate} })).to eq(false)
end
end
describe "data_exists!" do
it "throws an exception if the hive does not exist" do
- expect { @registry.data_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.data_exists!("JKLM\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect { @registry.data_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true)
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true)
end
it "returns true if all the data matches with a case mismatch on the data name" do
- expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => %w{Pink Delicate} })).to eq(true)
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "petals", type: :multi_string, data: %w{Pink Delicate} })).to eq(true)
end
it "throws an exception if the name does not exist" do
- expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "slateP", type: :multi_string, data: %w{Pink Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the types do not match" do
- expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Pink" }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the data does not match" do
- expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => %w{Mauve Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: %w{Mauve Delicate} }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
end
@@ -188,8 +188,8 @@ describe "Chef::Win32::Registry", :windows_only do
it "returns all values for a key if it exists" do
values = @registry.get_values("HKCU\\Software\\Root")
expect(values).to be_an_instance_of Array
- expect(values).to eq([{ :name => "RootType1", :type => :string, :data => "fibrous" },
- { :name => "Roots", :type => :multi_string, :data => ["strong roots", "healthy tree"] }])
+ expect(values).to eq([{ name: "RootType1", type: :string, data: "fibrous" },
+ { name: "Roots", type: :multi_string, data: ["strong roots", "healthy tree"] }])
end
it "throws an exception if the key does not exist" do
@@ -203,70 +203,70 @@ describe "Chef::Win32::Registry", :windows_only do
describe "set_value" do
it "updates a value if the key, value exist and type matches and value different" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true)
end
it "updates a value if the type does match and the values are different" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Yellow" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :string, data: "Yellow" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(false)
end
it "creates a value if key exists and value does not" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true)
end
it "does nothing if data,type and name parameters for the value are same" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "Stamen", type: :multi_string, data: ["Yellow", "Changed Color"] })).to eq(true)
end
it "throws an exception if the key does not exist" do
- expect { @registry.set_value("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.set_value("HKCU\\Software\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect { @registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", { name: "Petals", type: :multi_string, data: ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
# we are validating that the data gets .to_i called on it when type is a :dword
it "casts an integer string given as a dword into an integer" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => "32767" })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => 32767 })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe32767", type: :dword, data: "32767" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe32767", type: :dword, data: 32767 })).to eq(true)
end
it "casts a nonsense string given as a dword into zero" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => "whatdoesthisdo" })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => 0 })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeZero", type: :dword, data: "whatdoesthisdo" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeZero", type: :dword, data: 0 })).to eq(true)
end
it "throws an exception when trying to cast an array to an int for a dword" do
- expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :dword, :data => %w{one two} }) }.to raise_error NoMethodError
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldThrow", type: :dword, data: %w{one two} }) }.to raise_error NoMethodError
end
# we are validating that the data gets .to_s called on it when type is a :string
it "stores the string representation of an array into a string if you pass it an array" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => %w{one two} })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => '["one", "two"]' })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBePainful", type: :string, data: %w{one two} })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBePainful", type: :string, data: '["one", "two"]' })).to eq(true)
end
it "stores the string representation of a number into a string if you pass it an number" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => 65535 })).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => "65535" })).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe65535", type: :string, data: 65535 })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBe65535", type: :string, data: "65535" })).to eq(true)
end
# we are validating that the data gets .to_a called on it when type is a :multi_string
it "throws an exception when a multi-string is passed a number" do
- expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :multi_string, :data => 65535 }) }.to raise_error NoMethodError
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldThrow", type: :multi_string, data: 65535 }) }.to raise_error NoMethodError
end
it "throws an exception when a multi-string is passed a string" do
- expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeWat", :type => :multi_string, :data => "foo" }) }.to raise_error NoMethodError
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { name: "ShouldBeWat", type: :multi_string, data: "foo" }) }.to raise_error NoMethodError
end
end
@@ -309,21 +309,21 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "deletes values if the value exists" do
- expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true)
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false)
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(false)
end
it "does nothing if value does not exist" do
- expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true)
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false)
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" })).to eq(false)
end
it "throws an exception if the key does not exist?" do
- expect { @registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect { @registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", { name: "Peter", type: :string, data: "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -566,38 +566,38 @@ describe "Chef::Win32::Registry", :windows_only do
describe "value_exists?" do
it "does not find 64-bit values in the 32-bit registry" do
@registry.architecture = :i386
- expect { @registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit values in the 32-bit registry" do
@registry.architecture = :i386
- expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" })).to eq(true)
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status" })).to eq(true)
end
it "does not find 32-bit values in the 64-bit registry" do
@registry.architecture = :x86_64
- expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" })).to eq(true)
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert" })).to eq(true)
end
it "finds 64-bit values in the 64-bit registry" do
@registry.architecture = :x86_64
- expect { @registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
describe "data_exists?" do
it "does not find 64-bit keys in the 32-bit registry" do
@registry.architecture = :i386
- expect { @registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert", type: :string, data: "Universal" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit keys in the 32-bit registry" do
@registry.architecture = :i386
- expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" })).to eq(true)
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status", type: :string, data: "Lost" })).to eq(true)
end
it "does not find 32-bit keys in the 64-bit registry" do
@registry.architecture = :x86_64
- expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" })).to eq(true)
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", { name: "Alert", type: :string, data: "Universal" })).to eq(true)
end
it "finds 64-bit keys in the 64-bit registry" do
@registry.architecture = :x86_64
- expect { @registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists?("HKLM\\Software\\Root\\Poosh", { name: "Status", type: :string, data: "Lost" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 8f2364d99a..4408c00b23 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -54,22 +54,22 @@ describe "chef-client" do
before { file "cookbooks/x/recipes/default.rb", "" }
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
end
- it "should complete successfully with no other environment variables", :skip => (Chef::Platform.windows?) do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ it "should complete successfully with no other environment variables", skip: (Chef::Platform.windows?) do
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
begin
- result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
result.error!
rescue
Chef::Log.info "Bare invocation will have the following load-path."
@@ -79,34 +79,34 @@ EOM
end
it "should complete successfully with --no-listen" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
it "should be able to node.save with bad utf8 characters in the node data" do
file "cookbooks/x/attributes/default.rb", 'default["badutf8"] = "Elan Ruusam\xE4e"'
- result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", :cwd => path_to(""))
+ result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", cwd: path_to(""))
result.error!
end
context "and no config file" do
it "should complete with success when cwd is just above cookbooks and paths are not specified" do
- result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to(""))
+ result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: path_to(""))
result.error!
end
it "should complete with success when cwd is below cookbooks and paths are not specified" do
- result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to("cookbooks/x"))
+ result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: path_to("cookbooks/x"))
result.error!
end
it "should fail when cwd is below high above and paths are not specified" do
- result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => File.expand_path("..", path_to("")))
+ result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", cwd: File.expand_path("..", path_to("")))
expect(result.exitstatus).to eq(1)
end
end
@@ -115,7 +115,7 @@ EOM
before { file ".chef/knife.rb", "xxx.xxx" }
it "should load .chef/knife.rb when -z is specified" do
- result = shell_out("#{chef_client} -z -o 'x::default'", :cwd => path_to(""))
+ result = shell_out("#{chef_client} -z -o 'x::default'", cwd: path_to(""))
# FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass
expect(result.stdout).to include("xxx")
end
@@ -123,79 +123,79 @@ EOM
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
context "and a private key" do
before do
- file "mykey.pem", <<EOM
------BEGIN RSA PRIVATE KEY-----
-MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
-0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
-NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
-0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
-AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
-HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
-8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
-zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
-k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
-i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
-G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
-ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
-awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
-7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
-g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
-Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
-HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
-V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
-fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
-lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
-c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
-fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
-YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
-syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
-+vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
------END RSA PRIVATE KEY-----
+ file "mykey.pem", <<~EOM
+ -----BEGIN RSA PRIVATE KEY-----
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
+ -----END RSA PRIVATE KEY-----
EOM
end
it "should complete with success even with a client key" do
- file "config/client.rb", <<EOM
-local_mode true
-client_key #{path_to('mykey.pem').inspect}
-cookbook_path #{path_to('cookbooks').inspect}
+ file "config/client.rb", <<~EOM
+ local_mode true
+ client_key #{path_to('mykey.pem').inspect}
+ cookbook_path #{path_to('cookbooks').inspect}
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
it "should run recipes specified directly on the command line" do
- file "config/client.rb", <<EOM
-local_mode true
-client_key #{path_to('mykey.pem').inspect}
-cookbook_path #{path_to('cookbooks').inspect}
+ file "config/client.rb", <<~EOM
+ local_mode true
+ client_key #{path_to('mykey.pem').inspect}
+ cookbook_path #{path_to('cookbooks').inspect}
EOM
- file "arbitrary.rb", <<EOM
-file #{path_to('tempfile.txt').inspect} do
- content '1'
-end
+ file "arbitrary.rb", <<~EOM
+ file #{path_to('tempfile.txt').inspect} do
+ content '1'
+ end
EOM
- file "arbitrary2.rb", <<EOM
-file #{path_to('tempfile2.txt').inspect} do
- content '2'
-end
+ file "arbitrary2.rb", <<~EOM
+ file #{path_to('tempfile2.txt').inspect} do
+ content '2'
+ end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -203,43 +203,43 @@ EOM
end
it "should run recipes specified as relative paths directly on the command line" do
- file "config/client.rb", <<EOM
-local_mode true
-client_key #{path_to('mykey.pem').inspect}
-cookbook_path #{path_to('cookbooks').inspect}
+ file "config/client.rb", <<~EOM
+ local_mode true
+ client_key #{path_to('mykey.pem').inspect}
+ cookbook_path #{path_to('cookbooks').inspect}
EOM
- file "arbitrary.rb", <<EOM
-file #{path_to('tempfile.txt').inspect} do
- content '1'
-end
+ file "arbitrary.rb", <<~EOM
+ file #{path_to('tempfile.txt').inspect} do
+ content '1'
+ end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
end
it "should run recipes specified directly on the command line AFTER recipes in the run list" do
- file "config/client.rb", <<EOM
-local_mode true
-client_key #{path_to('mykey.pem').inspect}
-cookbook_path #{path_to('cookbooks').inspect}
+ file "config/client.rb", <<~EOM
+ local_mode true
+ client_key #{path_to('mykey.pem').inspect}
+ cookbook_path #{path_to('cookbooks').inspect}
EOM
- file "cookbooks/x/recipes/constant_definition.rb", <<EOM
-class ::Blah
- THECONSTANT = '1'
-end
+ file "cookbooks/x/recipes/constant_definition.rb", <<~EOM
+ class ::Blah
+ THECONSTANT = '1'
+ end
EOM
- file "arbitrary.rb", <<EOM
-file #{path_to('tempfile.txt').inspect} do
- content ::Blah::THECONSTANT
-end
+ file "arbitrary.rb", <<~EOM
+ file #{path_to('tempfile.txt').inspect} do
+ content ::Blah::THECONSTANT
+ end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -248,74 +248,74 @@ EOM
end
it "should complete with success when passed the -z flag" do
- file "config/client.rb", <<EOM
-chef_server_url 'http://omg.com/blah'
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ chef_server_url 'http://omg.com/blah'
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
end
it "should complete with success when passed the --local-mode flag" do
- file "config/client.rb", <<EOM
-chef_server_url 'http://omg.com/blah'
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ chef_server_url 'http://omg.com/blah'
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir)
result.error!
end
it "should not print SSL warnings when running in local-mode" do
- file "config/client.rb", <<EOM
-chef_server_url 'http://omg.com/blah'
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ chef_server_url 'http://omg.com/blah'
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir)
expect(result.stdout).not_to include("SSL validation of HTTPS requests is disabled.")
result.error!
end
it "should complete with success when passed -z and --chef-zero-port" do
- file "config/client.rb", <<EOM
-chef_server_url 'http://omg.com/blah'
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ chef_server_url 'http://omg.com/blah'
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
end
it "should complete with success when setting the run list with -r" do
- file "config/client.rb", <<EOM
-chef_server_url 'http://omg.com/blah'
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ chef_server_url 'http://omg.com/blah'
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", cwd: chef_dir)
expect(result.stdout).not_to include("Overridden Run List")
expect(result.stdout).to include("Run List is [recipe[x::default]]")
result.error!
end
it "should complete with success when using --profile-ruby and output a profile file", :not_supported_on_aix do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", :cwd => chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir)
result.error!
expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true
end
it "doesn't produce a profile when --profile-ruby is not present" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false
end
@@ -324,18 +324,18 @@ EOM
when_the_repository "has a cookbook that should fail chef_version checks" do
before do
file "cookbooks/x/recipes/default.rb", ""
- file "cookbooks/x/metadata.rb", <<EOM
-name 'x'
-version '0.0.1'
-chef_version '~> 999.99'
+ file "cookbooks/x/metadata.rb", <<~EOM
+ name 'x'
+ version '0.0.1'
+ chef_version '~> 999.99'
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
it "should fail the chef client run" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
expect(command.exitstatus).to eql(1)
expect(command.stdout).to match(/Chef::Exceptions::CookbookChefVersionMismatch/)
end
@@ -361,7 +361,7 @@ EOM
end
it "the cheffish DSL is loaded lazily" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
expect(command.exitstatus).to eql(0)
end
end
@@ -380,7 +380,7 @@ EOM
it "the cheffish DSL tries to load but fails (because chef-provisioning is not there)" do
# we'd need to have a custom bundle to fix this that omitted chef-provisioning, but that would dig our crazy even deeper, so lets not
skip "but if chef-provisioning is in our bundle or in our gemset then this test, very annoyingly, always fails"
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
expect(command.exitstatus).to eql(1)
expect(command.stdout).to match(/cannot load such file -- chef\/provisioning/)
end
@@ -405,17 +405,17 @@ EOM
end
it "should output each deprecation warning only once, at the end of the run" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-# Mimick what happens when you are on the console
-formatters << :doc
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ # Mimick what happens when you are on the console
+ formatters << :doc
+ log_level :warn
EOM
ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
expect(result.error?).to be_falsey
# Search to the end of the client run in the output
@@ -430,37 +430,37 @@ EOM
when_the_repository "has a cookbook with only an audit recipe" do
before do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-audit_mode :enabled
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ audit_mode :enabled
EOM
end
it "should exit with a zero code when there is not an audit failure" do
- file "cookbooks/audit_test/recipes/succeed.rb", <<-RECIPE
-control_group "control group without top level control" do
- it "should succeed" do
- expect(2 - 2).to eq(0)
- end
-end
+ file "cookbooks/audit_test/recipes/succeed.rb", <<~RECIPE
+ control_group "control group without top level control" do
+ it "should succeed" do
+ expect(2 - 2).to eq(0)
+ end
+ end
RECIPE
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", cwd: chef_dir)
expect(result.error?).to be_falsey
expect(result.stdout).to include("Successfully executed all `control_group` blocks and contained examples")
end
it "should exit with a non-zero code when there is an audit failure" do
- file "cookbooks/audit_test/recipes/fail.rb", <<-RECIPE
-control_group "control group without top level control" do
- it "should fail" do
- expect(2 - 2).to eq(1)
- end
-end
+ file "cookbooks/audit_test/recipes/fail.rb", <<~RECIPE
+ control_group "control group without top level control" do
+ it "should fail" do
+ expect(2 - 2).to eq(1)
+ end
+ end
RECIPE
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", cwd: chef_dir)
expect(result.error?).to be_truthy
expect(result.stdout).to include("Failure/Error: expect(2 - 2).to eq(1)")
end
@@ -468,26 +468,26 @@ end
when_the_repository "has a cookbook that deploys a file" do
before do
- file "cookbooks/x/recipes/default.rb", <<-RECIPE
-cookbook_file #{path_to('tempfile.txt').inspect} do
- source "my_file"
-end
+ file "cookbooks/x/recipes/default.rb", <<~RECIPE
+ cookbook_file #{path_to('tempfile.txt').inspect} do
+ source "my_file"
+ end
RECIPE
- file "cookbooks/x/files/my_file", <<-FILE
-this is my file
+ file "cookbooks/x/files/my_file", <<~FILE
+ this is my file
FILE
end
[true, false].each do |lazy|
context "with no_lazy_load set to #{lazy}" do
it "should create the file" do
- file "config/client.rb", <<EOM
-no_lazy_load #{lazy}
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ no_lazy_load #{lazy}
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
- result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt")).strip).to eq("this is my file")
@@ -498,10 +498,10 @@ EOM
when_the_repository "has a cookbook with an ohai plugin" do
before do
- file "cookbooks/x/recipes/default.rb", <<-RECIPE
-file #{path_to('tempfile.txt').inspect} do
- content node["english"]["version"]
-end
+ file "cookbooks/x/recipes/default.rb", <<~RECIPE
+ file #{path_to('tempfile.txt').inspect} do
+ content node["english"]["version"]
+ end
RECIPE
file "cookbooks/x/ohai/english.rb", <<-OHAI
@@ -515,14 +515,14 @@ end
end
OHAI
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
it "should run the ohai plugin" do
- result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("2014")
@@ -542,21 +542,21 @@ EOM
let(:tmp_dir) { Dir.mktmpdir("recipe-url") }
it "should complete with success when passed -z and --recipe-url" do
- file "config/client.rb", <<EOM
-chef_repo_path "#{tmp_dir}"
+ file "config/client.rb", <<~EOM
+ chef_repo_path "#{tmp_dir}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => tmp_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir)
result.error!
end
it "should fail when passed --recipe-url and not passed -z" do
- result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => tmp_dir)
+ result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", cwd: tmp_dir)
expect(result.exitstatus).not_to eq(0)
end
it "should fail when passed --recipe-url with a file that doesn't exist" do
broken_path = File.join(CHEF_SPEC_DATA, "recipes_dont_exist.tgz")
- result = shell_out("#{chef_client} --recipe-url=#{broken_path}", :cwd => tmp_dir)
+ result = shell_out("#{chef_client} --recipe-url=#{broken_path}", cwd: tmp_dir)
expect(result.exitstatus).not_to eq(0)
end
end
@@ -564,31 +564,31 @@ EOM
when_the_repository "has a cookbook with broken metadata.rb, but has metadata.json" do
before do
file "cookbooks/x/recipes/default.rb", ""
- file "cookbooks/x/metadata.rb", <<EOM
-name 'x'
-version '0.0.1'
-raise "TEH SADNESS"
+ file "cookbooks/x/metadata.rb", <<~EOM
+ name 'x'
+ version '0.0.1'
+ raise "TEH SADNESS"
EOM
- file "cookbooks/x/metadata.json", <<EOM
-{
- "name": "x",
- "version": "0.0.1"
-}
+ file "cookbooks/x/metadata.json", <<~EOM
+ {
+ "name": "x",
+ "version": "0.0.1"
+ }
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
it "the chef client run should succeed" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
end
it "a chef-solo run should succeed" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
end
end
@@ -600,32 +600,32 @@ EOM
level :info
end
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
it "a chef client run should not log to info by default" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef client run to a pipe should not log to info by default" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef solo run should not log to info by default" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef solo run to a pipe should not log to info by default" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
@@ -636,44 +636,44 @@ EOM
file "cookbooks/x/recipes/default.rb", <<~EOM
puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
it "chef-client runs by default with no supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo runs by default with no supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-client --no-fork does not fork" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo --no-fork does not fork" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-client with --fork uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
it "chef-solo with --fork uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
@@ -684,21 +684,21 @@ EOM
file "cookbooks/x/recipes/default.rb", <<~EOM
puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-client_fork true
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ client_fork true
EOM
end
it "chef-client uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
it "chef-solo uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
@@ -709,21 +709,21 @@ EOM
file "cookbooks/x/recipes/default.rb", <<~EOM
puts Chef::Config[:client_fork] ? "WITHFORK" : "NOFORK"
EOM
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-client_fork false
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ client_fork false
EOM
end
it "chef-client uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb
index 4397426723..7352863dbf 100644
--- a/spec/integration/client/exit_code_spec.rb
+++ b/spec/integration/client/exit_code_spec.rb
@@ -28,24 +28,24 @@ describe "chef-client" do
when_the_repository "uses RFC 062 defined exit codes" do
def setup_client_rb
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
EOM
end
def setup_client_rb_with_audit_mode
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-audit_mode :audit_only
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ audit_mode :audit_only
EOM
end
def run_chef_client_and_expect_exit_code(exit_code)
shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'",
- :cwd => chef_dir,
- :returns => [exit_code])
+ cwd: chef_dir,
+ returns: [exit_code])
end
context "has a cookbook" do
@@ -66,12 +66,12 @@ EOM
context "with an audit recipe" do
context "which fails" do
before do
- file "cookbooks/x/recipes/default.rb", <<-RECIPE
-control_group "control group without top level control" do
- it "should fail" do
- expect(4 - 4).to eq(1)
- end
-end
+ file "cookbooks/x/recipes/default.rb", <<~RECIPE
+ control_group "control group without top level control" do
+ it "should fail" do
+ expect(4 - 4).to eq(1)
+ end
+ end
RECIPE
end
@@ -112,8 +112,8 @@ RECIPE
context "when a reboot exception is raised (like from the reboot resource)" do
before do
- file "cookbooks/x/recipes/default.rb", <<EOM
-raise Chef::Exceptions::Reboot.new
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ raise Chef::Exceptions::Reboot.new
EOM
end
@@ -125,8 +125,8 @@ EOM
context "when an attempt to reboot fails (like from the reboot resource)" do
before do
- file "cookbooks/x/recipes/default.rb", <<EOM
-raise Chef::Exceptions::RebootFailed.new
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ raise Chef::Exceptions::RebootFailed.new
EOM
end
diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb
index 6452db1e39..c3cb73e4fa 100644
--- a/spec/integration/client/ipv6_spec.rb
+++ b/spec/integration/client/ipv6_spec.rb
@@ -22,37 +22,37 @@ describe "chef-client" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_zero_opts) { { :host => "::1" } }
+ let(:chef_zero_opts) { { host: "::1" } }
let(:validation_pem) do
- <<-END_VALIDATION_PEM
------BEGIN RSA PRIVATE KEY-----
-MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
-0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
-NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
-0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
-AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
-HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
-8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
-zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
-k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
-i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
-G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
-ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
-awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
-7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
-g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
-Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
-HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
-V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
-fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
-lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
-c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
-fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
-YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
-syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
-+vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
------END RSA PRIVATE KEY-----
+ <<~END_VALIDATION_PEM
+ -----BEGIN RSA PRIVATE KEY-----
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
+ -----END RSA PRIVATE KEY-----
END_VALIDATION_PEM
end
@@ -61,11 +61,11 @@ END_VALIDATION_PEM
end
let(:basic_config_file) do
- <<-END_CLIENT_RB
-chef_server_url "http://[::1]:8900"
-validation_key '#{path_to('config/validator.pem')}'
-cache_path '#{cache_path}'
-client_key '#{cache_path}/client.pem'
+ <<~END_CLIENT_RB
+ chef_server_url "http://[::1]:8900"
+ validation_key '#{path_to('config/validator.pem')}'
+ cache_path '#{cache_path}'
+ client_key '#{cache_path}/client.pem'
END_CLIENT_RB
end
@@ -93,7 +93,7 @@ END_CLIENT_RB
end
it "should complete with success" do
- result = shell_out("#{chef_client_cmd} -o 'noop::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client_cmd} -o 'noop::default'", cwd: chef_dir)
result.error!
end
@@ -125,7 +125,7 @@ END_CLIENT_RB
end
it "should complete with success" do
- result = shell_out("#{chef_client_cmd} -o 'api-smoke-test::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client_cmd} -o 'api-smoke-test::default'", cwd: chef_dir)
result.error!
end
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index 02508b799d..79b0307e0d 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -54,59 +54,59 @@ describe "ChefFSDataStore tests", :workstation do
context "GET /TYPE" do
it "knife list -z -R returns everything" do
- knife("list -z -Rfp /").should_succeed <<EOM
-/acls/
-/acls/clients/
-/acls/clients/x.json
-/acls/containers/
-/acls/containers/x.json
-/acls/cookbook_artifacts/
-/acls/cookbook_artifacts/x.json
-/acls/cookbooks/
-/acls/cookbooks/x.json
-/acls/data_bags/
-/acls/data_bags/x.json
-/acls/environments/
-/acls/environments/x.json
-/acls/groups/
-/acls/groups/x.json
-/acls/nodes/
-/acls/nodes/x.json
-/acls/organization.json
-/acls/policies/
-/acls/policies/x.json
-/acls/policy_groups/
-/acls/policy_groups/x.json
-/acls/roles/
-/acls/roles/x.json
-/clients/
-/clients/x.json
-/containers/
-/containers/x.json
-/cookbook_artifacts/
-/cookbook_artifacts/x-111/
-/cookbook_artifacts/x-111/metadata.rb
-/cookbooks/
-/cookbooks/x/
-/cookbooks/x/metadata.rb
-/data_bags/
-/data_bags/x/
-/data_bags/x/y.json
-/environments/
-/environments/x.json
-/groups/
-/groups/x.json
-/invitations.json
-/members.json
-/nodes/
-/nodes/x.json
-/org.json
-/policies/
-/policies/x-111.json
-/policy_groups/
-/policy_groups/x.json
-/roles/
-/roles/x.json
+ knife("list -z -Rfp /").should_succeed <<~EOM
+ /acls/
+ /acls/clients/
+ /acls/clients/x.json
+ /acls/containers/
+ /acls/containers/x.json
+ /acls/cookbook_artifacts/
+ /acls/cookbook_artifacts/x.json
+ /acls/cookbooks/
+ /acls/cookbooks/x.json
+ /acls/data_bags/
+ /acls/data_bags/x.json
+ /acls/environments/
+ /acls/environments/x.json
+ /acls/groups/
+ /acls/groups/x.json
+ /acls/nodes/
+ /acls/nodes/x.json
+ /acls/organization.json
+ /acls/policies/
+ /acls/policies/x.json
+ /acls/policy_groups/
+ /acls/policy_groups/x.json
+ /acls/roles/
+ /acls/roles/x.json
+ /clients/
+ /clients/x.json
+ /containers/
+ /containers/x.json
+ /cookbook_artifacts/
+ /cookbook_artifacts/x-111/
+ /cookbook_artifacts/x-111/metadata.rb
+ /cookbooks/
+ /cookbooks/x/
+ /cookbooks/x/metadata.rb
+ /data_bags/
+ /data_bags/x/
+ /data_bags/x/y.json
+ /environments/
+ /environments/x.json
+ /groups/
+ /groups/x.json
+ /invitations.json
+ /members.json
+ /nodes/
+ /nodes/x.json
+ /org.json
+ /policies/
+ /policies/x-111.json
+ /policy_groups/
+ /policy_groups/x.json
+ /roles/
+ /roles/x.json
EOM
end
end
@@ -190,9 +190,9 @@ EOM
end
it "knife cookbook upload works" do
- knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed :stderr => <<EOM
-Uploading x [1.0.0]
-Uploaded 1 cookbook.
+ knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploaded 1 cookbook.
EOM
knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n"
end
@@ -218,13 +218,13 @@ EOM
knife("list --local /roles").should_succeed "/roles/x.json\n"
end
- it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do
+ it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do
knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ )
- expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip
-{
- "name": "x",
- "description": "hi there"
-}
+ expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
+ {
+ "name": "x",
+ "description": "hi there"
+ }
EOM
end
end
@@ -247,9 +247,9 @@ EOM
end
it "knife cookbook upload works" do
- knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed :stderr => <<EOM
-Uploading z [1.0.0]
-Uploaded 1 cookbook.
+ knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed stderr: <<~EOM
+ Uploading z [1.0.0]
+ Uploaded 1 cookbook.
EOM
knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n"
end
@@ -281,46 +281,46 @@ EOM
knife("list --local /roles").should_succeed "/roles/z.json\n"
end
- it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", :skip => (RUBY_VERSION < "1.9") do
+ it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", skip: (RUBY_VERSION < "1.9") do
knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ )
- expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip
-{
- "name": "x",
- "description": "hi there"
-}
+ expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
+ {
+ "name": "x",
+ "description": "hi there"
+ }
EOM
end
end
it "knife list -z -R returns nothing" do
- knife("list -z -Rfp /").should_succeed <<EOM
-/acls/
-/acls/clients/
-/acls/containers/
-/acls/cookbook_artifacts/
-/acls/cookbooks/
-/acls/data_bags/
-/acls/environments/
-/acls/groups/
-/acls/nodes/
-/acls/organization.json
-/acls/policies/
-/acls/policy_groups/
-/acls/roles/
-/clients/
-/containers/
-/cookbook_artifacts/
-/cookbooks/
-/data_bags/
-/environments/
-/groups/
-/invitations.json
-/members.json
-/nodes/
-/org.json
-/policies/
-/policy_groups/
-/roles/
+ knife("list -z -Rfp /").should_succeed <<~EOM
+ /acls/
+ /acls/clients/
+ /acls/containers/
+ /acls/cookbook_artifacts/
+ /acls/cookbooks/
+ /acls/data_bags/
+ /acls/environments/
+ /acls/groups/
+ /acls/nodes/
+ /acls/organization.json
+ /acls/policies/
+ /acls/policy_groups/
+ /acls/roles/
+ /clients/
+ /containers/
+ /cookbook_artifacts/
+ /cookbooks/
+ /data_bags/
+ /environments/
+ /groups/
+ /invitations.json
+ /members.json
+ /nodes/
+ /org.json
+ /policies/
+ /policy_groups/
+ /roles/
EOM
end
@@ -442,23 +442,23 @@ EOM
context "GET /TYPE" do
it "knife list -z -R returns everything" do
- knife("list -z -Rfp /").should_succeed <<EOM
-/clients/
-/clients/x.json
-/cookbooks/
-/cookbooks/x/
-/cookbooks/x/metadata.rb
-/data_bags/
-/data_bags/x/
-/data_bags/x/y.json
-/environments/
-/environments/x.json
-/nodes/
-/nodes/x.json
-/roles/
-/roles/x.json
-/users/
-/users/x.json
+ knife("list -z -Rfp /").should_succeed <<~EOM
+ /clients/
+ /clients/x.json
+ /cookbooks/
+ /cookbooks/x/
+ /cookbooks/x/metadata.rb
+ /data_bags/
+ /data_bags/x/
+ /data_bags/x/y.json
+ /environments/
+ /environments/x.json
+ /nodes/
+ /nodes/x.json
+ /roles/
+ /roles/x.json
+ /users/
+ /users/x.json
EOM
end
end
@@ -489,13 +489,13 @@ EOM
knife("list --local /users").should_succeed "/users/x.json\n"
end
- it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do
+ it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", skip: (RUBY_VERSION < "1.9") do
knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ )
- expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip
-{
- "name": "x",
- "description": "hi there"
-}
+ expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
+ {
+ "name": "x",
+ "description": "hi there"
+ }
EOM
end
end
@@ -519,14 +519,14 @@ EOM
end
it "knife list -z -R returns nothing" do
- knife("list -z -Rfp /").should_succeed <<EOM
-/clients/
-/cookbooks/
-/data_bags/
-/environments/
-/nodes/
-/roles/
-/users/
+ knife("list -z -Rfp /").should_succeed <<~EOM
+ /clients/
+ /cookbooks/
+ /data_bags/
+ /environments/
+ /nodes/
+ /roles/
+ /users/
EOM
end
diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb
index e609fa60b3..9df0b9def9 100644
--- a/spec/integration/knife/chef_repo_path_spec.rb
+++ b/spec/integration/knife/chef_repo_path_spec.rb
@@ -59,92 +59,92 @@ describe "chef_repo_path tests", :workstation do
it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do
Chef::Config.delete(:chef_repo_path)
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM
-/clients/
-/clients/client3.json
-/cookbooks/
-/cookbooks/cookbook3/
-/cookbooks/cookbook3/metadata.rb
-/data_bags/
-/data_bags/bag3/
-/data_bags/bag3/item3.json
-/environments/
-/environments/env3.json
-/nodes/
-/nodes/node3.json
-/roles/
-/roles/role3.json
-/users/
-/users/user3.json
+ knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM
+ /clients/
+ /clients/client3.json
+ /cookbooks/
+ /cookbooks/cookbook3/
+ /cookbooks/cookbook3/metadata.rb
+ /data_bags/
+ /data_bags/bag3/
+ /data_bags/bag3/item3.json
+ /environments/
+ /environments/env3.json
+ /nodes/
+ /nodes/node3.json
+ /roles/
+ /roles/role3.json
+ /users/
+ /users/user3.json
EOM
end
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only do
Chef::Config.delete(:chef_repo_path)
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<EOM
-/clients/
-/clients/client3.json
-/cookbooks/
-/cookbooks/cookbook3/
-/cookbooks/cookbook3/metadata.rb
-/data_bags/
-/data_bags/bag3/
-/data_bags/bag3/item3.json
-/environments/
-/environments/env3.json
-/nodes/
-/nodes/node3.json
-/roles/
-/roles/role3.json
-/users/
-/users/user3.json
+ knife("list --local -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM
+ /clients/
+ /clients/client3.json
+ /cookbooks/
+ /cookbooks/cookbook3/
+ /cookbooks/cookbook3/metadata.rb
+ /data_bags/
+ /data_bags/bag3/
+ /data_bags/bag3/item3.json
+ /environments/
+ /environments/env3.json
+ /nodes/
+ /nodes/node3.json
+ /roles/
+ /roles/role3.json
+ /users/
+ /users/user3.json
EOM
end
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only do
Chef::Config.delete(:chef_repo_path)
- knife("list -z -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<EOM
-/acls/
-/acls/clients/
-/acls/clients/client3.json
-/acls/containers/
-/acls/cookbook_artifacts/
-/acls/cookbooks/
-/acls/cookbooks/cookbook3.json
-/acls/data_bags/
-/acls/data_bags/bag3.json
-/acls/environments/
-/acls/environments/env3.json
-/acls/groups/
-/acls/nodes/
-/acls/nodes/node3.json
-/acls/organization.json
-/acls/policies/
-/acls/policy_groups/
-/acls/roles/
-/acls/roles/role3.json
-/clients/
-/clients/client3.json
-/containers/
-/cookbook_artifacts/
-/cookbooks/
-/cookbooks/cookbook3/
-/cookbooks/cookbook3/metadata.rb
-/data_bags/
-/data_bags/bag3/
-/data_bags/bag3/item3.json
-/environments/
-/environments/env3.json
-/groups/
-/invitations.json
-/members.json
-/nodes/
-/nodes/node3.json
-/org.json
-/policies/
-/policy_groups/
-/roles/
-/roles/role3.json
+ knife("list -z -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM
+ /acls/
+ /acls/clients/
+ /acls/clients/client3.json
+ /acls/containers/
+ /acls/cookbook_artifacts/
+ /acls/cookbooks/
+ /acls/cookbooks/cookbook3.json
+ /acls/data_bags/
+ /acls/data_bags/bag3.json
+ /acls/environments/
+ /acls/environments/env3.json
+ /acls/groups/
+ /acls/nodes/
+ /acls/nodes/node3.json
+ /acls/organization.json
+ /acls/policies/
+ /acls/policy_groups/
+ /acls/roles/
+ /acls/roles/role3.json
+ /clients/
+ /clients/client3.json
+ /containers/
+ /cookbook_artifacts/
+ /cookbooks/
+ /cookbooks/cookbook3/
+ /cookbooks/cookbook3/metadata.rb
+ /data_bags/
+ /data_bags/bag3/
+ /data_bags/bag3/item3.json
+ /environments/
+ /environments/env3.json
+ /groups/
+ /invitations.json
+ /members.json
+ /nodes/
+ /nodes/node3.json
+ /org.json
+ /policies/
+ /policy_groups/
+ /roles/
+ /roles/role3.json
EOM
end
@@ -157,23 +157,23 @@ EOM
end
it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM
-/clients/
-/clients/client3.json
-/cookbooks/
-/cookbooks/cookbook3/
-/cookbooks/cookbook3/metadata.rb
-/data_bags/
-/data_bags/bag3/
-/data_bags/bag3/item3.json
-/environments/
-/environments/env3.json
-/nodes/
-/nodes/node3.json
-/roles/
-/roles/role3.json
-/users/
-/users/user3.json
+ knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM
+ /clients/
+ /clients/client3.json
+ /cookbooks/
+ /cookbooks/cookbook3/
+ /cookbooks/cookbook3/metadata.rb
+ /data_bags/
+ /data_bags/bag3/
+ /data_bags/bag3/item3.json
+ /environments/
+ /environments/env3.json
+ /nodes/
+ /nodes/node3.json
+ /roles/
+ /roles/role3.json
+ /users/
+ /users/user3.json
EOM
end
@@ -194,23 +194,23 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client2.json
-cookbooks/
-cookbooks/cookbook2/
-cookbooks/cookbook2/metadata.rb
-data_bags/
-data_bags/bag2/
-data_bags/bag2/item2.json
-environments/
-environments/env2.json
-nodes/
-nodes/node2.json
-roles/
-roles/role2.json
-users/
-users/user2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client2.json
+ cookbooks/
+ cookbooks/cookbook2/
+ cookbooks/cookbook2/metadata.rb
+ data_bags/
+ data_bags/bag2/
+ data_bags/bag2/item2.json
+ environments/
+ environments/env2.json
+ nodes/
+ nodes/node2.json
+ roles/
+ roles/role2.json
+ users/
+ users/user2.json
EOM
end
end
@@ -218,9 +218,9 @@ EOM
context "when cwd is inside data_bags2" do
before { cwd "data_bags2" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag2/
-bag2/item2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag2/
+ bag2/item2.json
EOM
end
it "knife list --local -Rfp ../roles lists roles" do
@@ -239,23 +239,23 @@ EOM
context "when cwd is at the top level" do
before { cwd "." }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client2.json
-cookbooks/
-cookbooks/cookbook2/
-cookbooks/cookbook2/metadata.rb
-data_bags/
-data_bags/bag2/
-data_bags/bag2/item2.json
-environments/
-environments/env2.json
-nodes/
-nodes/node2.json
-roles/
-roles/role2.json
-users/
-users/user2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client2.json
+ cookbooks/
+ cookbooks/cookbook2/
+ cookbooks/cookbook2/metadata.rb
+ data_bags/
+ data_bags/bag2/
+ data_bags/bag2/item2.json
+ environments/
+ environments/env2.json
+ nodes/
+ nodes/node2.json
+ roles/
+ roles/role2.json
+ users/
+ users/user2.json
EOM
end
end
@@ -277,9 +277,9 @@ EOM
context "when cwd is inside data_bags2" do
before { cwd "data_bags2" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag2/
-bag2/item2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag2/
+ bag2/item2.json
EOM
end
end
@@ -310,23 +310,23 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client3.json
-cookbooks/
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env3.json
-nodes/
-nodes/node3.json
-roles/
-roles/role3.json
-users/
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env3.json
+ nodes/
+ nodes/node3.json
+ roles/
+ roles/role3.json
+ users/
+ users/user3.json
EOM
end
end
@@ -334,9 +334,9 @@ EOM
context "when cwd is inside chef_repo2/data_bags" do
before { cwd "chef_repo2/data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -359,11 +359,11 @@ EOM
file "clients2/blah.json", {}
end
it "knife show /clients/blah.json succeeds" do
- knife("show --local /clients/blah.json").should_succeed <<EOM
-/clients/blah.json:
-{
+ knife("show --local /clients/blah.json").should_succeed <<~EOM
+ /clients/blah.json:
+ {
-}
+ }
EOM
end
end
@@ -374,13 +374,13 @@ EOM
file "cookbooks2/blah/metadata.rb", ""
end
it "knife list -Rfp cookbooks shows files in blah" do
- knife("list --local -Rfp /cookbooks").should_succeed <<EOM
-/cookbooks/blah/
-/cookbooks/blah/metadata.rb
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
+ knife("list --local -Rfp /cookbooks").should_succeed <<~EOM
+ /cookbooks/blah/
+ /cookbooks/blah/metadata.rb
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
EOM
end
end
@@ -391,13 +391,13 @@ EOM
file "cookbooks2/blah/metadata.rb", ""
end
it "knife list -Rfp cookbooks shows files in blah" do
- knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n")
-/cookbooks/blah/
-/cookbooks/blah/metadata.rb
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
+ knife("list --local -Rfp /cookbooks").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n")
+ /cookbooks/blah/
+ /cookbooks/blah/metadata.rb
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
EOM
end
end
@@ -408,13 +408,13 @@ EOM
file "cookbooks2/blah/metadata.rb", ""
end
it "knife list -Rfp cookbooks shows files in the first cookbook and not the second" do
- knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n")
-/cookbooks/blah/
-/cookbooks/blah/metadata.json
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
+ knife("list --local -Rfp /cookbooks").should_succeed(<<~EOM, stderr: "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n")
+ /cookbooks/blah/
+ /cookbooks/blah/metadata.json
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
EOM
end
end
@@ -425,13 +425,13 @@ EOM
file "data_bags2/blah/item.json", ""
end
it "knife list -Rfp data_bags shows files in blah" do
- knife("list --local -Rfp /data_bags").should_succeed <<EOM
-/data_bags/bag/
-/data_bags/bag/item.json
-/data_bags/bag2/
-/data_bags/bag2/item2.json
-/data_bags/blah/
-/data_bags/blah/item.json
+ knife("list --local -Rfp /data_bags").should_succeed <<~EOM
+ /data_bags/bag/
+ /data_bags/bag/item.json
+ /data_bags/bag2/
+ /data_bags/bag2/item2.json
+ /data_bags/blah/
+ /data_bags/blah/item.json
EOM
end
end
@@ -442,13 +442,13 @@ EOM
file "data_bags2/blah/item2.json", ""
end
it "knife list -Rfp data_bags shows only items in data_bags1" do
- knife("list --local -Rfp /data_bags").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n")
-/data_bags/bag/
-/data_bags/bag/item.json
-/data_bags/bag2/
-/data_bags/bag2/item2.json
-/data_bags/blah/
-/data_bags/blah/item1.json
+ knife("list --local -Rfp /data_bags").should_succeed(<<~EOM, stderr: "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n")
+ /data_bags/bag/
+ /data_bags/bag/item.json
+ /data_bags/bag2/
+ /data_bags/bag2/item2.json
+ /data_bags/blah/
+ /data_bags/blah/item1.json
EOM
end
end
@@ -459,11 +459,11 @@ EOM
file "environments2/blah.json", {}
end
it "knife show /environments/blah.json succeeds" do
- knife("show --local /environments/blah.json").should_succeed <<EOM
-/environments/blah.json:
-{
+ knife("show --local /environments/blah.json").should_succeed <<~EOM
+ /environments/blah.json:
+ {
-}
+ }
EOM
end
end
@@ -474,11 +474,11 @@ EOM
file "nodes2/blah.json", {}
end
it "knife show /nodes/blah.json succeeds" do
- knife("show --local /nodes/blah.json").should_succeed <<EOM
-/nodes/blah.json:
-{
+ knife("show --local /nodes/blah.json").should_succeed <<~EOM
+ /nodes/blah.json:
+ {
-}
+ }
EOM
end
end
@@ -489,11 +489,11 @@ EOM
file "roles2/blah.json", {}
end
it "knife show /roles/blah.json succeeds" do
- knife("show --local /roles/blah.json").should_succeed <<EOM
-/roles/blah.json:
-{
+ knife("show --local /roles/blah.json").should_succeed <<~EOM
+ /roles/blah.json:
+ {
-}
+ }
EOM
end
end
@@ -504,11 +504,11 @@ EOM
file "users2/blah.json", {}
end
it "knife show /users/blah.json succeeds" do
- knife("show --local /users/blah.json").should_succeed <<EOM
-/users/blah.json:
-{
+ knife("show --local /users/blah.json").should_succeed <<~EOM
+ /users/blah.json:
+ {
-}
+ }
EOM
end
end
@@ -523,11 +523,11 @@ EOM
context "when cwd is inside the data_bags directory" do
before { cwd "data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag2/
-bag2/item2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag2/
+ bag2/item2.json
EOM
end
end
@@ -535,32 +535,32 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client1.json
-clients/client2.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook2/
-cookbooks/cookbook2/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-data_bags/bag2/
-data_bags/bag2/item2.json
-environments/
-environments/env1.json
-environments/env2.json
-nodes/
-nodes/node1.json
-nodes/node2.json
-roles/
-roles/role1.json
-roles/role2.json
-users/
-users/user1.json
-users/user2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client1.json
+ clients/client2.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook2/
+ cookbooks/cookbook2/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ data_bags/bag2/
+ data_bags/bag2/item2.json
+ environments/
+ environments/env1.json
+ environments/env2.json
+ nodes/
+ nodes/node1.json
+ nodes/node2.json
+ roles/
+ roles/role1.json
+ roles/role2.json
+ users/
+ users/user1.json
+ users/user2.json
EOM
end
end
@@ -568,11 +568,11 @@ EOM
context "when cwd is inside data_bags2" do
before { cwd "data_bags2" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag2/
-bag2/item2.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag2/
+ bag2/item2.json
EOM
end
end
@@ -592,32 +592,32 @@ EOM
context "when cwd is at the top level" do
before { cwd "." }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client1.json
-clients/client3.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env1.json
-environments/env3.json
-nodes/
-nodes/node1.json
-nodes/node3.json
-roles/
-roles/role1.json
-roles/role3.json
-users/
-users/user1.json
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client1.json
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env1.json
+ environments/env3.json
+ nodes/
+ nodes/node1.json
+ nodes/node3.json
+ roles/
+ roles/role1.json
+ roles/role3.json
+ users/
+ users/user1.json
+ users/user3.json
EOM
end
end
@@ -625,11 +625,11 @@ EOM
context "when cwd is inside the data_bags directory" do
before { cwd "data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -637,32 +637,32 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client1.json
-clients/client3.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env1.json
-environments/env3.json
-nodes/
-nodes/node1.json
-nodes/node3.json
-roles/
-roles/role1.json
-roles/role3.json
-users/
-users/user1.json
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client1.json
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env1.json
+ environments/env3.json
+ nodes/
+ nodes/node1.json
+ nodes/node3.json
+ roles/
+ roles/role1.json
+ roles/role3.json
+ users/
+ users/user1.json
+ users/user3.json
EOM
end
end
@@ -670,11 +670,11 @@ EOM
context "when cwd is inside chef_repo2/data_bags" do
before { cwd "chef_repo2/data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -706,23 +706,23 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client3.json
-cookbooks/
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env3.json
-nodes/
-nodes/node3.json
-roles/
-roles/role3.json
-users/
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env3.json
+ nodes/
+ nodes/node3.json
+ roles/
+ roles/role3.json
+ users/
+ users/user3.json
EOM
end
end
@@ -730,9 +730,9 @@ EOM
context "when cwd is inside chef_repo2/data_bags" do
before { cwd "chef_repo2/data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -753,32 +753,32 @@ EOM
context "when cwd is at the top level" do
before { cwd "." }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client1.json
-clients/client3.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env1.json
-environments/env3.json
-nodes/
-nodes/node1.json
-nodes/node3.json
-roles/
-roles/role1.json
-roles/role3.json
-users/
-users/user1.json
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client1.json
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env1.json
+ environments/env3.json
+ nodes/
+ nodes/node1.json
+ nodes/node3.json
+ roles/
+ roles/role1.json
+ roles/role3.json
+ users/
+ users/user1.json
+ users/user3.json
EOM
end
end
@@ -786,11 +786,11 @@ EOM
context "when cwd is inside the data_bags directory" do
before { cwd "data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -798,32 +798,32 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client1.json
-clients/client3.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-data_bags/bag3/
-data_bags/bag3/item3.json
-environments/
-environments/env1.json
-environments/env3.json
-nodes/
-nodes/node1.json
-nodes/node3.json
-roles/
-roles/role1.json
-roles/role3.json
-users/
-users/user1.json
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client1.json
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ data_bags/bag3/
+ data_bags/bag3/item3.json
+ environments/
+ environments/env1.json
+ environments/env3.json
+ nodes/
+ nodes/node1.json
+ nodes/node3.json
+ roles/
+ roles/role1.json
+ roles/role3.json
+ users/
+ users/user1.json
+ users/user3.json
EOM
end
end
@@ -831,11 +831,11 @@ EOM
context "when cwd is inside chef_repo2/data_bags" do
before { cwd "chef_repo2/data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
-bag3/
-bag3/item3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
+ bag3/
+ bag3/item3.json
EOM
end
end
@@ -860,9 +860,9 @@ EOM
context "when cwd is inside the data_bags directory" do
before { cwd "data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
EOM
end
end
@@ -870,23 +870,23 @@ EOM
context "when cwd is inside chef_repo2" do
before { cwd "chef_repo2" }
it "knife list --local -Rfp lists everything" do
- knife("list --local -Rfp").should_succeed <<EOM
-clients/
-clients/client3.json
-cookbooks/
-cookbooks/cookbook3/
-cookbooks/cookbook3/metadata.rb
-data_bags/
-data_bags/bag/
-data_bags/bag/item.json
-environments/
-environments/env3.json
-nodes/
-nodes/node3.json
-roles/
-roles/role3.json
-users/
-users/user3.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ clients/
+ clients/client3.json
+ cookbooks/
+ cookbooks/cookbook3/
+ cookbooks/cookbook3/metadata.rb
+ data_bags/
+ data_bags/bag/
+ data_bags/bag/item.json
+ environments/
+ environments/env3.json
+ nodes/
+ nodes/node3.json
+ roles/
+ roles/role3.json
+ users/
+ users/user3.json
EOM
end
end
@@ -911,26 +911,26 @@ EOM
end
it "knife list --local -Rfp / lists data bags" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/data_bags/
-/data_bags/bag/
-/data_bags/bag/item.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /data_bags/
+ /data_bags/bag/
+ /data_bags/bag/item.json
EOM
end
it "knife list --local -Rfp /data_bags lists data bags" do
- knife("list --local -Rfp /data_bags").should_succeed <<EOM
-/data_bags/bag/
-/data_bags/bag/item.json
+ knife("list --local -Rfp /data_bags").should_succeed <<~EOM
+ /data_bags/bag/
+ /data_bags/bag/item.json
EOM
end
context "when cwd is inside the data_bags directory" do
before { cwd "data_bags" }
it "knife list --local -Rfp lists data bags" do
- knife("list --local -Rfp").should_succeed <<EOM
-bag/
-bag/item.json
+ knife("list --local -Rfp").should_succeed <<~EOM
+ bag/
+ bag/item.json
EOM
end
end
diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb
index 222d3aee8a..538d6c5a63 100644
--- a/spec/integration/knife/chef_repository_file_system_spec.rb
+++ b/spec/integration/knife/chef_repository_file_system_spec.rb
@@ -32,11 +32,11 @@ describe "General chef_repo file system checks", :workstation do
end
it "knife list --local -Rfp / returns them" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/data_bags/
-/data_bags/bag1/
-/environments/
-/roles/
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /data_bags/
+ /data_bags/bag1/
+ /environments/
+ /roles/
EOM
end
end
@@ -53,8 +53,8 @@ EOM
before { directory "cookbooks/cookbook1" }
it "knife list --local -Rfp / does not return it" do
- knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
-/cookbooks/
+ knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
+ /cookbooks/
EOM
end
end
@@ -63,8 +63,8 @@ EOM
before { directory "cookbooks/cookbook1/recipes" }
it "knife list --local -Rfp / does not return it" do
- knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
-/cookbooks/
+ knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
+ /cookbooks/
EOM
end
end
@@ -76,12 +76,12 @@ EOM
end
it "knife list --local -Rfp / does not return the empty ones" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/templates/
-/cookbooks/cookbook1/templates/default/
-/cookbooks/cookbook1/templates/default/x.txt
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/templates/
+ /cookbooks/cookbook1/templates/default/
+ /cookbooks/cookbook1/templates/default/x.txt
EOM
end
end
@@ -90,8 +90,8 @@ EOM
before { directory "cookbooks/cookbook1/templates/default" }
it "knife list --local -Rfp / does not return it" do
- knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
-/cookbooks/
+ knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
+ /cookbooks/
EOM
end
end
@@ -104,12 +104,12 @@ EOM
end
it "knife list --local -Rfp / does not return the empty ones" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/templates/
-/cookbooks/cookbook1/templates/default/
-/cookbooks/cookbook1/templates/default/x.txt
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/templates/
+ /cookbooks/cookbook1/templates/default/
+ /cookbooks/cookbook1/templates/default/x.txt
EOM
end
end
@@ -146,14 +146,14 @@ EOM
end
it "knife list --local -Rfp / should NOT return them" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/environments/
-/environments/environment1.json
-/roles/
-/roles/role1.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /environments/
+ /environments/environment1.json
+ /roles/
+ /roles/role1.json
EOM
end
end
@@ -161,8 +161,8 @@ EOM
when_the_repository "has a file in cookbooks/" do
before { file "cookbooks/file", "" }
it "does not show up in list -Rfp" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
EOM
end
end
@@ -170,8 +170,8 @@ EOM
when_the_repository "has a file in data_bags/" do
before { file "data_bags/file", "" }
it "does not show up in list -Rfp" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/data_bags/
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /data_bags/
EOM
end
end
diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb
index aa5a3979cc..eb36f4675f 100644
--- a/spec/integration/knife/chefignore_spec.rb
+++ b/spec/integration/knife/chefignore_spec.rb
@@ -45,17 +45,17 @@ describe "chefignore tests", :workstation do
it "matching files and directories get ignored" do
# NOTE: many of the "chefignore" files should probably not show up
# themselves, but we have other tests that talk about that
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/chefignore
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/x.json
-/environments/
-/environments/x.json
-/roles/
-/roles/x.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/chefignore
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/x.json
+ /environments/
+ /environments/x.json
+ /roles/
+ /roles/x.json
EOM
end
end
@@ -69,8 +69,8 @@ EOM
end
it "the cookbook is not listed" do
- knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
-/cookbooks/
+ knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
+ /cookbooks/
EOM
end
end
@@ -87,12 +87,12 @@ EOM
before { file "cookbooks/chefignore", "x.json\n" }
it "matching files and directories get ignored in all cookbooks" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -104,12 +104,12 @@ EOM
end
it "matching files and directories get ignored in all cookbooks" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -122,16 +122,16 @@ EOM
end
it "matching directories get ignored" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/x.json
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/recipes/
-/cookbooks/cookbook2/recipes/y.rb
-/cookbooks/cookbook2/x.json
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/x.json
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/recipes/
+ /cookbooks/cookbook2/recipes/y.rb
+ /cookbooks/cookbook2/x.json
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -143,16 +143,16 @@ EOM
end
it "matching directories do NOT get ignored" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/recipes/
-/cookbooks/cookbook1/recipes/y.rb
-/cookbooks/cookbook1/x.json
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/x.json
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/recipes/
+ /cookbooks/cookbook1/recipes/y.rb
+ /cookbooks/cookbook1/x.json
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/x.json
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -165,14 +165,14 @@ EOM
end
it "ignores the subdirectory entirely" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/x.json
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/x.json
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/x.json
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/x.json
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -183,14 +183,14 @@ EOM
end
it "nothing is ignored" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/x.json
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/x.json
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/x.json
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/x.json
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -201,12 +201,12 @@ EOM
end
it "matching files and directories get ignored in all cookbooks" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/y.json
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/y.json
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/y.json
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/y.json
EOM
end
end
@@ -233,12 +233,12 @@ EOM
file "cookbooks2/chefignore", "x.json\n"
end
it "chefignores apply only to the directories they are in" do
- knife("list --local -Rfp /").should_succeed <<EOM
-/cookbooks/
-/cookbooks/mycookbook/
-/cookbooks/mycookbook/x.json
-/cookbooks/yourcookbook/
-/cookbooks/yourcookbook/metadata.rb
+ knife("list --local -Rfp /").should_succeed <<~EOM
+ /cookbooks/
+ /cookbooks/mycookbook/
+ /cookbooks/mycookbook/x.json
+ /cookbooks/yourcookbook/
+ /cookbooks/yourcookbook/metadata.rb
EOM
end
@@ -251,13 +251,13 @@ EOM
end
it "chefignores apply only to the winning cookbook" do
- knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n")
-/cookbooks/
-/cookbooks/mycookbook/
-/cookbooks/mycookbook/x.json
-/cookbooks/yourcookbook/
-/cookbooks/yourcookbook/onlyincookbooks1.rb
-/cookbooks/yourcookbook/x.json
+ knife("list --local -Rfp /").should_succeed(<<~EOM, stderr: "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n")
+ /cookbooks/
+ /cookbooks/mycookbook/
+ /cookbooks/mycookbook/x.json
+ /cookbooks/yourcookbook/
+ /cookbooks/yourcookbook/onlyincookbooks1.rb
+ /cookbooks/yourcookbook/x.json
EOM
end
end
@@ -269,9 +269,9 @@ EOM
file "cookbooks/chefignore/metadata.rb", {}
end
it "knife list -Rfp /cookbooks shows it" do
- knife("list --local -Rfp /cookbooks").should_succeed <<EOM
-/cookbooks/chefignore/
-/cookbooks/chefignore/metadata.rb
+ knife("list --local -Rfp /cookbooks").should_succeed <<~EOM
+ /cookbooks/chefignore/
+ /cookbooks/chefignore/metadata.rb
EOM
end
end
@@ -289,11 +289,11 @@ EOM
]
end
it "knife list -Rfp /cookbooks shows the chefignore cookbook" do
- knife("list --local -Rfp /cookbooks").should_succeed <<EOM
-/cookbooks/blah/
-/cookbooks/blah/metadata.rb
-/cookbooks/chefignore/
-/cookbooks/chefignore/metadata.rb
+ knife("list --local -Rfp /cookbooks").should_succeed <<~EOM
+ /cookbooks/blah/
+ /cookbooks/blah/metadata.rb
+ /cookbooks/chefignore/
+ /cookbooks/chefignore/metadata.rb
EOM
end
end
diff --git a/spec/integration/knife/client_bulk_delete_spec.rb b/spec/integration/knife/client_bulk_delete_spec.rb
index a422401af6..42bfe0396a 100644
--- a/spec/integration/knife/client_bulk_delete_spec.rb
+++ b/spec/integration/knife/client_bulk_delete_spec.rb
@@ -33,40 +33,40 @@ describe "knife client bulk delete", :workstation do
end
it "deletes all matching clients" do
- knife("client bulk delete ^ca.*", input: "Y").should_succeed <<EOM
-The following clients will be deleted:
+ knife("client bulk delete ^ca.*", input: "Y").should_succeed <<~EOM
+ The following clients will be deleted:
-car cat
+ car cat
-Are you sure you want to delete these clients? (Y/N) Deleted client car
-Deleted client cat
+ Are you sure you want to delete these clients? (Y/N) Deleted client car
+ Deleted client cat
EOM
- knife("client list").should_succeed <<EOM
-cdr
-chef-validator
-chef-webui
-concat
-cons
+ knife("client list").should_succeed <<~EOM
+ cdr
+ chef-validator
+ chef-webui
+ concat
+ cons
EOM
end
it "deletes all matching clients when unanchored" do
- knife("client bulk delete ca.*", input: "Y").should_succeed <<EOM
-The following clients will be deleted:
+ knife("client bulk delete ca.*", input: "Y").should_succeed <<~EOM
+ The following clients will be deleted:
-car cat concat
+ car cat concat
-Are you sure you want to delete these clients? (Y/N) Deleted client car
-Deleted client cat
-Deleted client concat
+ Are you sure you want to delete these clients? (Y/N) Deleted client car
+ Deleted client cat
+ Deleted client concat
EOM
- knife("client list").should_succeed <<EOM
-cdr
-chef-validator
-chef-webui
-cons
+ knife("client list").should_succeed <<~EOM
+ cdr
+ chef-validator
+ chef-webui
+ cons
EOM
end
end
@@ -81,49 +81,49 @@ EOM
end
it "refuses to delete a validator normally" do
- knife("client bulk delete ^ca.*", input: "Y").should_succeed <<EOM
-The following clients are validators and will not be deleted:
+ knife("client bulk delete ^ca.*", input: "Y").should_succeed <<~EOM
+ The following clients are validators and will not be deleted:
-car-validator
+ car-validator
-You must specify --delete-validators to delete the validator clients
-The following clients will be deleted:
+ You must specify --delete-validators to delete the validator clients
+ The following clients will be deleted:
-car cat
+ car cat
-Are you sure you want to delete these clients? (Y/N) Deleted client car
-Deleted client cat
+ Are you sure you want to delete these clients? (Y/N) Deleted client car
+ Deleted client cat
EOM
- knife("client list").should_succeed <<EOM
-car-validator
-cdr
-chef-validator
-chef-webui
-cons
+ knife("client list").should_succeed <<~EOM
+ car-validator
+ cdr
+ chef-validator
+ chef-webui
+ cons
EOM
end
it "deletes a validator when told to" do
- knife("client bulk delete ^ca.* -D", input: "Y\nY").should_succeed <<EOM
-The following validators will be deleted:
+ knife("client bulk delete ^ca.* -D", input: "Y\nY").should_succeed <<~EOM
+ The following validators will be deleted:
-car-validator
+ car-validator
-Are you sure you want to delete these validators? (Y/N) Deleted client car-validator
-The following clients will be deleted:
+ Are you sure you want to delete these validators? (Y/N) Deleted client car-validator
+ The following clients will be deleted:
-car cat
+ car cat
-Are you sure you want to delete these clients? (Y/N) Deleted client car
-Deleted client cat
+ Are you sure you want to delete these clients? (Y/N) Deleted client car
+ Deleted client cat
EOM
- knife("client list").should_succeed <<EOM
-cdr
-chef-validator
-chef-webui
-cons
+ knife("client list").should_succeed <<~EOM
+ cdr
+ chef-validator
+ chef-webui
+ cons
EOM
end
end
diff --git a/spec/integration/knife/client_create_spec.rb b/spec/integration/knife/client_create_spec.rb
index 10172833c8..d24755a48a 100644
--- a/spec/integration/knife/client_create_spec.rb
+++ b/spec/integration/knife/client_create_spec.rb
@@ -33,11 +33,11 @@ describe "knife client create", :workstation do
it "creates a new validator client" do
knife("client create -k --validator bah").should_succeed stderr: out
- knife("client show bah").should_succeed <<EOM
-admin: false
-chef_type: client
-name: bah
-validator: true
+ knife("client show bah").should_succeed <<~EOM
+ admin: false
+ chef_type: client
+ name: bah
+ validator: true
EOM
end
diff --git a/spec/integration/knife/client_delete_spec.rb b/spec/integration/knife/client_delete_spec.rb
index d135dd0a5b..914827cb46 100644
--- a/spec/integration/knife/client_delete_spec.rb
+++ b/spec/integration/knife/client_delete_spec.rb
@@ -33,29 +33,29 @@ describe "knife client delete", :workstation do
end
it "deletes a client" do
- knife("client delete car", input: "Y").should_succeed <<EOM
-Do you really want to delete car? (Y/N) Deleted client[car]
+ knife("client delete car", input: "Y").should_succeed <<~EOM
+ Do you really want to delete car? (Y/N) Deleted client[car]
EOM
- knife("client list").should_succeed <<EOM
-car-validator
-cat
-cdr
-chef-validator
-chef-webui
-cons
+ knife("client list").should_succeed <<~EOM
+ car-validator
+ cat
+ cdr
+ chef-validator
+ chef-webui
+ cons
EOM
end
it "refuses to delete a validator normally" do
- knife("client delete car-validator", input: "Y").should_fail exit_code: 2, stdout: "Do you really want to delete car-validator? (Y/N) ", stderr: <<EOM
-FATAL: You must specify --delete-validators to delete the validator client car-validator
+ knife("client delete car-validator", input: "Y").should_fail exit_code: 2, stdout: "Do you really want to delete car-validator? (Y/N) ", stderr: <<~EOM
+ FATAL: You must specify --delete-validators to delete the validator client car-validator
EOM
end
it "deletes a validator correctly" do
- knife("client delete car-validator -D", input: "Y").should_succeed <<EOM
-Do you really want to delete car-validator? (Y/N) Deleted client[car-validator]
+ knife("client delete car-validator -D", input: "Y").should_succeed <<~EOM
+ Do you really want to delete car-validator? (Y/N) Deleted client[car-validator]
EOM
end
diff --git a/spec/integration/knife/client_key_delete_spec.rb b/spec/integration/knife/client_key_delete_spec.rb
index d5827aa545..061a3fea76 100644
--- a/spec/integration/knife/client_key_delete_spec.rb
+++ b/spec/integration/knife/client_key_delete_spec.rb
@@ -31,8 +31,8 @@ describe "knife client key delete", :workstation do
it "deletes a client" do
out = "Do you really want to delete the key named new for the client named car? (Y/N) "
knife("client key create -k new car")
- knife("client key delete car new", input: "Y").should_succeed stdout: out, stderr: <<EOM
-Deleted key named new for the client named car
+ knife("client key delete car new", input: "Y").should_succeed stdout: out, stderr: <<~EOM
+ Deleted key named new for the client named car
EOM
knife("client key list car").should_succeed ""
diff --git a/spec/integration/knife/client_key_list_spec.rb b/spec/integration/knife/client_key_list_spec.rb
index de9894622e..0969d5fb98 100644
--- a/spec/integration/knife/client_key_list_spec.rb
+++ b/spec/integration/knife/client_key_list_spec.rb
@@ -41,10 +41,10 @@ describe "knife client key list", :workstation do
end
it "shows detailed output" do
- knife("client key list -w cons").should_succeed <<EOM
-expired: http://127.0.0.1:8900/clients/cons/keys/expired (expired)
-new: http://127.0.0.1:8900/clients/cons/keys/new
-next_month: http://127.0.0.1:8900/clients/cons/keys/next_month
+ knife("client key list -w cons").should_succeed <<~EOM
+ expired: http://127.0.0.1:8900/clients/cons/keys/expired (expired)
+ new: http://127.0.0.1:8900/clients/cons/keys/new
+ next_month: http://127.0.0.1:8900/clients/cons/keys/next_month
EOM
end
diff --git a/spec/integration/knife/client_list_spec.rb b/spec/integration/knife/client_list_spec.rb
index 4159df73f1..41cf8dcbb6 100644
--- a/spec/integration/knife/client_list_spec.rb
+++ b/spec/integration/knife/client_list_spec.rb
@@ -33,14 +33,14 @@ describe "knife client list", :workstation do
end
it "lists the clients" do
- knife("client list").should_succeed <<EOM
-car
-car-validator
-cat
-cdr
-chef-validator
-chef-webui
-cons
+ knife("client list").should_succeed <<~EOM
+ car
+ car-validator
+ cat
+ cdr
+ chef-validator
+ chef-webui
+ cons
EOM
end
diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb
index da1409456b..e0622eb801 100644
--- a/spec/integration/knife/common_options_spec.rb
+++ b/spec/integration/knife/common_options_spec.rb
@@ -67,34 +67,34 @@ describe "knife common options", :workstation do
context "and there is a private key" do
before do
- file "mykey.pem", <<EOM
------BEGIN RSA PRIVATE KEY-----
-MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
-0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
-NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
-0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
-AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
-HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
-8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
-zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
-k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
-i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
-G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
-ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
-awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
-7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
-g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
-Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
-HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
-V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
-fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
-lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
-c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
-fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
-YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
-syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
-+vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
------END RSA PRIVATE KEY-----
+ file "mykey.pem", <<~EOM
+ -----BEGIN RSA PRIVATE KEY-----
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
+ -----END RSA PRIVATE KEY-----
EOM
end
@@ -125,7 +125,7 @@ EOM
context "when the default port (8889) is already bound" do
before :each do
begin
- @server = ChefZero::Server.new(:host => "localhost", :port => 8889)
+ @server = ChefZero::Server.new(host: "localhost", port: 8889)
@server.start_background
rescue Errno::EADDRINUSE
# OK. Don't care who has it in use, as long as *someone* does.
@@ -144,7 +144,7 @@ EOM
context "when port 9999 is already bound" do
before :each do
begin
- @server = ChefZero::Server.new(:host => "localhost", :port => 9999)
+ @server = ChefZero::Server.new(host: "localhost", port: 9999)
@server.start_background
rescue Errno::EADDRINUSE
# OK. Don't care who has it in use, as long as *someone* does.
diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb
index 0a4a6a6e94..8c2b0208ae 100644
--- a/spec/integration/knife/cookbook_api_ipv6_spec.rb
+++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb
@@ -23,37 +23,37 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
include Chef::Mixin::ShellOut
when_the_chef_server "is bound to IPv6" do
- let(:chef_zero_opts) { { :host => "::1" } }
+ let(:chef_zero_opts) { { host: "::1" } }
let(:client_key) do
- <<-END_VALIDATION_PEM
------BEGIN RSA PRIVATE KEY-----
-MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
-0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
-NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
-0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
-AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
-HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
-8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
-zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
-k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
-i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
-G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
-ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
-awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
-7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
-g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
-Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
-HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
-V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
-fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
-lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
-c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
-fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
-YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
-syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
-+vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
------END RSA PRIVATE KEY-----
+ <<~END_VALIDATION_PEM
+ -----BEGIN RSA PRIVATE KEY-----
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
+ -----END RSA PRIVATE KEY-----
END_VALIDATION_PEM
end
@@ -74,12 +74,12 @@ END_VALIDATION_PEM
when_the_repository "has the cookbook to be uploaded" do
let(:knife_rb_content) do
- <<-END_CLIENT_RB
-chef_server_url "http://[::1]:8900"
-syntax_check_cache_path '#{cache_path}'
-client_key '#{path_to('config/knifeuser.pem')}'
-node_name 'whoisthisis'
-cookbook_path '#{CHEF_SPEC_DATA}/cookbooks'
+ <<~END_CLIENT_RB
+ chef_server_url "http://[::1]:8900"
+ syntax_check_cache_path '#{cache_path}'
+ client_key '#{path_to('config/knifeuser.pem')}'
+ node_name 'whoisthisis'
+ cookbook_path '#{CHEF_SPEC_DATA}/cookbooks'
END_CLIENT_RB
end
@@ -89,7 +89,7 @@ END_CLIENT_RB
end
it "successfully uploads a cookbook" do
- shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
+ shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", cwd: chef_dir)
versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8900").get("/cookbooks/apache2", "accept" => "application/json")
versions_list = Chef::JSONCompat.from_json(versions_list_json)
expect(versions_list["apache2"]["versions"]).not_to be_empty
@@ -97,11 +97,11 @@ END_CLIENT_RB
context "and the cookbook has been uploaded to the server" do
before do
- shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
+ shell_out!("#{knife} cookbook upload apache2 #{knife_config_flag}", cwd: chef_dir)
end
it "downloads the cookbook" do
- shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir)
+ shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", cwd: chef_dir)
expect(Dir["#{cache_path}/*"].map { |entry| File.basename(entry) }).to include("apache2-0.0.1")
end
end
diff --git a/spec/integration/knife/cookbook_bulk_delete_spec.rb b/spec/integration/knife/cookbook_bulk_delete_spec.rb
index 912bd3bed5..d3180c788f 100644
--- a/spec/integration/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/integration/knife/cookbook_bulk_delete_spec.rb
@@ -36,26 +36,26 @@ describe "knife cookbook bulk delete", :workstation do
# rubocop:disable Layout/TrailingWhitespace
it "knife cookbook bulk delete deletes all matching cookbooks" do
- stdout = <<EOM
-All versions of the following cookbooks will be deleted:
-
-foo fox
-
-Do you really want to delete these cookbooks? (Y/N)
+ stdout = <<~EOM
+ All versions of the following cookbooks will be deleted:
+
+ foo fox
+
+ Do you really want to delete these cookbooks? (Y/N)
EOM
- stderr = <<EOM
-Deleted cookbook foo [1.0.0]
-Deleted cookbook foo [0.6.5]
-Deleted cookbook fox [0.6.5]
-Deleted cookbook fox [0.6.0]
+ stderr = <<~EOM
+ Deleted cookbook foo [1.0.0]
+ Deleted cookbook foo [0.6.5]
+ Deleted cookbook fox [0.6.5]
+ Deleted cookbook fox [0.6.0]
EOM
knife("cookbook bulk delete ^fo.*", input: "Y").should_succeed(stderr: stderr, stdout: stdout)
- knife("cookbook list -a").should_succeed <<EOM
-fax 0.6.0
-zfa 0.6.5
+ knife("cookbook list -a").should_succeed <<~EOM
+ fax 0.6.0
+ zfa 0.6.5
EOM
end
# rubocop:enable Layout/TrailingWhitespace
diff --git a/spec/integration/knife/cookbook_download_spec.rb b/spec/integration/knife/cookbook_download_spec.rb
index 2e64cac133..57174a1548 100644
--- a/spec/integration/knife/cookbook_download_spec.rb
+++ b/spec/integration/knife/cookbook_download_spec.rb
@@ -33,18 +33,18 @@ describe "knife cookbook download", :workstation do
end
it "knife cookbook download downloads the latest version" do
- knife("cookbook download -d #{tmpdir} x").should_succeed stderr: <<EOM
-Downloading x cookbook version 1.0.1
-Downloading root_files
-Cookbook downloaded to #{tmpdir}/x-1.0.1
+ knife("cookbook download -d #{tmpdir} x").should_succeed stderr: <<~EOM
+ Downloading x cookbook version 1.0.1
+ Downloading root_files
+ Cookbook downloaded to #{tmpdir}/x-1.0.1
EOM
end
it "knife cookbook download with a version downloads the specified version" do
- knife("cookbook download -d #{tmpdir} x 1.0.1").should_succeed stderr: <<EOM
-Downloading x cookbook version 1.0.1
-Downloading root_files
-Cookbook downloaded to #{tmpdir}/x-1.0.1
+ knife("cookbook download -d #{tmpdir} x 1.0.1").should_succeed stderr: <<~EOM
+ Downloading x cookbook version 1.0.1
+ Downloading root_files
+ Cookbook downloaded to #{tmpdir}/x-1.0.1
EOM
end
@@ -60,10 +60,10 @@ EOM
end
it "knife cookbook download with no version prompts" do
- knife("cookbook download -d #{tmpdir} x", input: "2\n").should_succeed(stderr: <<EOM, stdout: "Which version do you want to download?\n1. x 1.0.0\n2. x 1.0.1\n\n"
-Downloading x cookbook version 1.0.1
-Downloading root_files
-Cookbook downloaded to #{tmpdir}/x-1.0.1
+ knife("cookbook download -d #{tmpdir} x", input: "2\n").should_succeed(stderr: <<~EOM, stdout: "Which version do you want to download?\n1. x 1.0.0\n2. x 1.0.1\n\n"
+ Downloading x cookbook version 1.0.1
+ Downloading root_files
+ Cookbook downloaded to #{tmpdir}/x-1.0.1
EOM
)
end
diff --git a/spec/integration/knife/cookbook_list_spec.rb b/spec/integration/knife/cookbook_list_spec.rb
index 65578696f2..afea745bce 100644
--- a/spec/integration/knife/cookbook_list_spec.rb
+++ b/spec/integration/knife/cookbook_list_spec.rb
@@ -35,18 +35,18 @@ describe "knife cookbook list", :workstation do
end
it "knife cookbook list shows all the cookbooks" do
- knife("cookbook list").should_succeed <<EOM
-x 1.0.0
-y 0.6.5
-z 0.6.5
+ knife("cookbook list").should_succeed <<~EOM
+ x 1.0.0
+ y 0.6.5
+ z 0.6.5
EOM
end
it "knife cookbook list -a shows all the versions of all the cookbooks" do
- knife("cookbook list -a").should_succeed <<EOM
-x 1.0.0 0.6.5 0.6.0
-y 0.6.5 0.6.0
-z 0.6.5
+ knife("cookbook list -a").should_succeed <<~EOM
+ x 1.0.0 0.6.5 0.6.0
+ y 0.6.5 0.6.0
+ z 0.6.5
EOM
end
diff --git a/spec/integration/knife/cookbook_show_spec.rb b/spec/integration/knife/cookbook_show_spec.rb
index b89a26198a..fe7e6fa930 100644
--- a/spec/integration/knife/cookbook_show_spec.rb
+++ b/spec/integration/knife/cookbook_show_spec.rb
@@ -36,95 +36,95 @@ describe "knife cookbook show", :workstation do
# rubocop:disable Layout/TrailingWhitespace
it "knife cookbook show x 1.0.0 shows the correct version" do
- knife("cookbook show x 1.0.0").should_succeed <<EOM
-cookbook_name: x
-frozen?: false
-metadata:
- attributes:
- chef_versions:
- dependencies:
- description:
- gems:
- issues_url:
- license: All rights reserved
- long_description:
- maintainer:
- maintainer_email:
- name: x
- ohai_versions:
- platforms:
- privacy: false
- providing:
- x: >= 0.0.0
- x::x: >= 0.0.0
- recipes:
- x:
- x::x:
- source_url:
- version: 1.0.0
-name: x-1.0.0
-recipes:
- checksum: 4631b34cf58de10c5ef1304889941b2e
- name: recipes/default.rb
- path: recipes/default.rb
- specificity: default
- url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
-
- checksum: d41d8cd98f00b204e9800998ecf8427e
- name: recipes/x.rb
- path: recipes/x.rb
- specificity: default
- url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
-root_files:
- checksum: 8226671f751ba102dea6a6b6bd32fa8d
- name: metadata.rb
- path: metadata.rb
- specificity: default
- url: http://127.0.0.1:8900/file_store/checksums/8226671f751ba102dea6a6b6bd32fa8d
-version: 1.0.0
+ knife("cookbook show x 1.0.0").should_succeed <<~EOM
+ cookbook_name: x
+ frozen?: false
+ metadata:
+ attributes:
+ chef_versions:
+ dependencies:
+ description:
+ gems:
+ issues_url:
+ license: All rights reserved
+ long_description:
+ maintainer:
+ maintainer_email:
+ name: x
+ ohai_versions:
+ platforms:
+ privacy: false
+ providing:
+ x: >= 0.0.0
+ x::x: >= 0.0.0
+ recipes:
+ x:
+ x::x:
+ source_url:
+ version: 1.0.0
+ name: x-1.0.0
+ recipes:
+ checksum: 4631b34cf58de10c5ef1304889941b2e
+ name: recipes/default.rb
+ path: recipes/default.rb
+ specificity: default
+ url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
+
+ checksum: d41d8cd98f00b204e9800998ecf8427e
+ name: recipes/x.rb
+ path: recipes/x.rb
+ specificity: default
+ url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
+ root_files:
+ checksum: 8226671f751ba102dea6a6b6bd32fa8d
+ name: metadata.rb
+ path: metadata.rb
+ specificity: default
+ url: http://127.0.0.1:8900/file_store/checksums/8226671f751ba102dea6a6b6bd32fa8d
+ version: 1.0.0
EOM
end
it "knife cookbook show x 1.0.0 metadata shows the metadata" do
- knife("cookbook show x 1.0.0 metadata").should_succeed <<EOM
-attributes:
-chef_versions:
-dependencies:
-description:
-gems:
-issues_url:
-license: All rights reserved
-long_description:
-maintainer:
-maintainer_email:
-name: x
-ohai_versions:
-platforms:
-privacy: false
-providing:
- x: >= 0.0.0
- x::x: >= 0.0.0
-recipes:
- x:
- x::x:
-source_url:
-version: 1.0.0
+ knife("cookbook show x 1.0.0 metadata").should_succeed <<~EOM
+ attributes:
+ chef_versions:
+ dependencies:
+ description:
+ gems:
+ issues_url:
+ license: All rights reserved
+ long_description:
+ maintainer:
+ maintainer_email:
+ name: x
+ ohai_versions:
+ platforms:
+ privacy: false
+ providing:
+ x: >= 0.0.0
+ x::x: >= 0.0.0
+ recipes:
+ x:
+ x::x:
+ source_url:
+ version: 1.0.0
EOM
end
it "knife cookbook show x 1.0.0 recipes shows all the recipes" do
- knife("cookbook show x 1.0.0 recipes").should_succeed <<EOM
-checksum: 4631b34cf58de10c5ef1304889941b2e
-name: recipes/default.rb
-path: recipes/default.rb
-specificity: default
-url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
-
-checksum: d41d8cd98f00b204e9800998ecf8427e
-name: recipes/x.rb
-path: recipes/x.rb
-specificity: default
-url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
+ knife("cookbook show x 1.0.0 recipes").should_succeed <<~EOM
+ checksum: 4631b34cf58de10c5ef1304889941b2e
+ name: recipes/default.rb
+ path: recipes/default.rb
+ specificity: default
+ url: http://127.0.0.1:8900/file_store/checksums/4631b34cf58de10c5ef1304889941b2e
+
+ checksum: d41d8cd98f00b204e9800998ecf8427e
+ name: recipes/x.rb
+ path: recipes/x.rb
+ specificity: default
+ url: http://127.0.0.1:8900/file_store/checksums/d41d8cd98f00b204e9800998ecf8427e
EOM
end
# rubocop:enable Layout/TrailingWhitespace
diff --git a/spec/integration/knife/cookbook_upload_spec.rb b/spec/integration/knife/cookbook_upload_spec.rb
index a0de725603..e96884e786 100644
--- a/spec/integration/knife/cookbook_upload_spec.rb
+++ b/spec/integration/knife/cookbook_upload_spec.rb
@@ -33,24 +33,24 @@ describe "knife cookbook upload", :workstation do
end
it "knife cookbook upload uploads the cookbook" do
- knife("cookbook upload x -o #{cb_dir}").should_succeed stderr: <<EOM
-Uploading x [1.0.0]
-Uploaded 1 cookbook.
+ knife("cookbook upload x -o #{cb_dir}").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploaded 1 cookbook.
EOM
end
it "knife cookbook upload --freeze uploads and freezes the cookbook" do
- knife("cookbook upload x -o #{cb_dir} --freeze").should_succeed stderr: <<EOM
-Uploading x [1.0.0]
-Uploaded 1 cookbook.
+ knife("cookbook upload x -o #{cb_dir} --freeze").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploaded 1 cookbook.
EOM
# Modify the file, attempt to reupload
file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different'
- knife("cookbook upload x -o #{cb_dir} --freeze").should_fail stderr: <<EOM
-Uploading x [1.0.0]
-ERROR: Version 1.0.0 of cookbook x is frozen. Use --force to override.
-WARNING: Not updating version constraints for x in the environment as the cookbook is frozen.
-ERROR: Failed to upload 1 cookbook.
+ knife("cookbook upload x -o #{cb_dir} --freeze").should_fail stderr: <<~EOM
+ Uploading x [1.0.0]
+ ERROR: Version 1.0.0 of cookbook x is frozen. Use --force to override.
+ WARNING: Not updating version constraints for x in the environment as the cookbook is frozen.
+ ERROR: Failed to upload 1 cookbook.
EOM
end
end
@@ -62,27 +62,27 @@ EOM
end
it "knife cookbook upload --include-dependencies uploads both cookbooks" do
- knife("cookbook upload --include-dependencies x -o #{cb_dir}").should_succeed stderr: <<EOM
-Uploading x [1.0.0]
-Uploading y [1.0.0]
-Uploaded 2 cookbooks.
+ knife("cookbook upload --include-dependencies x -o #{cb_dir}").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploading y [1.0.0]
+ Uploaded 2 cookbooks.
EOM
end
it "knife cookbook upload fails due to missing dependencies" do
- knife("cookbook upload x -o #{cb_dir}").should_fail stderr: <<EOM
-Uploading x [1.0.0]
-ERROR: Cookbook x depends on cookbooks which are not currently
-ERROR: being uploaded and cannot be found on the server.
-ERROR: The missing cookbook(s) are: 'y' version '>= 0.0.0'
+ knife("cookbook upload x -o #{cb_dir}").should_fail stderr: <<~EOM
+ Uploading x [1.0.0]
+ ERROR: Cookbook x depends on cookbooks which are not currently
+ ERROR: being uploaded and cannot be found on the server.
+ ERROR: The missing cookbook(s) are: 'y' version '>= 0.0.0'
EOM
end
it "knife cookbook upload -a uploads both cookbooks" do
- knife("cookbook upload -a -o #{cb_dir}").should_succeed stderr: <<EOM
-Uploading x [1.0.0]
-Uploading y [1.0.0]
-Uploaded all cookbooks.
+ knife("cookbook upload -a -o #{cb_dir}").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploading y [1.0.0]
+ Uploaded all cookbooks.
EOM
end
end
diff --git a/spec/integration/knife/data_bag_delete_spec.rb b/spec/integration/knife/data_bag_delete_spec.rb
index 96345b0d2b..f0ca05a3e4 100644
--- a/spec/integration/knife/data_bag_delete_spec.rb
+++ b/spec/integration/knife/data_bag_delete_spec.rb
@@ -32,26 +32,26 @@ describe "knife data bag delete", :workstation do
end
it "with an empty data bag" do
- knife("data bag delete canteloupe", input: "y").should_succeed <<EOM
-Do you really want to delete canteloupe? (Y/N) Deleted data_bag[canteloupe]
+ knife("data bag delete canteloupe", input: "y").should_succeed <<~EOM
+ Do you really want to delete canteloupe? (Y/N) Deleted data_bag[canteloupe]
EOM
end
it "with a bag with some items" do
- knife("data bag delete rocket", input: "y").should_succeed <<EOM
-Do you really want to delete rocket? (Y/N) Deleted data_bag[rocket]
+ knife("data bag delete rocket", input: "y").should_succeed <<~EOM
+ Do you really want to delete rocket? (Y/N) Deleted data_bag[rocket]
EOM
end
it "with a single item" do
- knife("data bag delete rocket falcon9", input: "y").should_succeed <<EOM
-Do you really want to delete falcon9? (Y/N) Deleted data_bag_item[falcon9]
+ knife("data bag delete rocket falcon9", input: "y").should_succeed <<~EOM
+ Do you really want to delete falcon9? (Y/N) Deleted data_bag_item[falcon9]
EOM
end
it "choosing not to delete" do
- knife("data bag delete rocket falcon9", input: "n").should_succeed <<EOM, exit_code: 3
-Do you really want to delete falcon9? (Y/N) You said no, so I'm done here.
+ knife("data bag delete rocket falcon9", input: "n").should_succeed <<~EOM, exit_code: 3
+ Do you really want to delete falcon9? (Y/N) You said no, so I'm done here.
EOM
end
end
diff --git a/spec/integration/knife/data_bag_from_file_spec.rb b/spec/integration/knife/data_bag_from_file_spec.rb
index ca8f743487..afaafc1e6b 100644
--- a/spec/integration/knife/data_bag_from_file_spec.rb
+++ b/spec/integration/knife/data_bag_from_file_spec.rb
@@ -37,76 +37,76 @@ describe "knife data bag from file", :workstation do
file "data_bags/foo/bzr.json", { "id" => "bzr", "foo" => "bar " }
file "data_bags/foo/cat.json", { "id" => "cat", "foo" => "bar " }
file "data_bags/foo/dog.json", { "id" => "dog", "foo" => "bar " }
- file "data_bags/foo/encrypted.json", <<EOM
-{
- "id": "encrypted",
- "password": {
- "encrypted_data": "H6ab5RY9a9JAkS8A0RCMspXtOJh0ai8cNeA4Q3gLO8s=\\n",
- "iv": "uWKKKxrJgtELlGMCOLJdkA==\\n",
- "version": 1,
- "cipher": "aes-256-cbc"
- }
-}
+ file "data_bags/foo/encrypted.json", <<~EOM
+ {
+ "id": "encrypted",
+ "password": {
+ "encrypted_data": "H6ab5RY9a9JAkS8A0RCMspXtOJh0ai8cNeA4Q3gLO8s=\\n",
+ "iv": "uWKKKxrJgtELlGMCOLJdkA==\\n",
+ "version": 1,
+ "cipher": "aes-256-cbc"
+ }
+ }
EOM
- file "data_bags/bar/round_trip.json", <<EOM
-{
- "name": "data_bag_item_bar_round_trip",
- "json_class": "Chef::DataBagItem",
- "chef_type": "data_bag_item",
- "data_bag": "bar",
- "raw_data": {
- "id": "round_trip",
- "root_password": {
- "encrypted_data": "noDOsTpsTAZlTU5sprhmYZzUDfr8du7hH/zRDOjRAmoTJHTZyfYoR221EOOW\\nXJ1D\\n",
- "iv": "Bnqhfy6n0Hx1wCe9pxHLoA==\\n",
- "version": 1,
- "cipher": "aes-256-cbc"
- },
- "admin_password": {
- "encrypted_data": "TcC7dU1gx6OnE5Ab4i/k42UEf0Nnr7cAyuTHId/LNjNOwpNf7XZc27DQSjuy\\nHPlt\\n",
- "iv": "+TAWJuPWCI2+WB8lGJAyvw==\\n",
- "version": 1,
- "cipher": "aes-256-cbc"
- }
- }
-}
+ file "data_bags/bar/round_trip.json", <<~EOM
+ {
+ "name": "data_bag_item_bar_round_trip",
+ "json_class": "Chef::DataBagItem",
+ "chef_type": "data_bag_item",
+ "data_bag": "bar",
+ "raw_data": {
+ "id": "round_trip",
+ "root_password": {
+ "encrypted_data": "noDOsTpsTAZlTU5sprhmYZzUDfr8du7hH/zRDOjRAmoTJHTZyfYoR221EOOW\\nXJ1D\\n",
+ "iv": "Bnqhfy6n0Hx1wCe9pxHLoA==\\n",
+ "version": 1,
+ "cipher": "aes-256-cbc"
+ },
+ "admin_password": {
+ "encrypted_data": "TcC7dU1gx6OnE5Ab4i/k42UEf0Nnr7cAyuTHId/LNjNOwpNf7XZc27DQSjuy\\nHPlt\\n",
+ "iv": "+TAWJuPWCI2+WB8lGJAyvw==\\n",
+ "version": 1,
+ "cipher": "aes-256-cbc"
+ }
+ }
+ }
EOM
end
it "uploads a single file" do
- knife("data bag from file foo #{db_dir}/foo/bar.json").should_succeed stderr: <<EOM
-Updated data_bag_item[foo::bar]
+ knife("data bag from file foo #{db_dir}/foo/bar.json").should_succeed stderr: <<~EOM
+ Updated data_bag_item[foo::bar]
EOM
end
it "uploads a single encrypted file" do
- knife("data bag from file foo #{db_dir}/foo/encrypted.json").should_succeed stderr: <<EOM
-Updated data_bag_item[foo::encrypted]
+ knife("data bag from file foo #{db_dir}/foo/encrypted.json").should_succeed stderr: <<~EOM
+ Updated data_bag_item[foo::encrypted]
EOM
end
it "uploads a file in chef's internal format" do
pending "chef/chef#4815"
- knife("data bag from file bar #{db_dir}/bar/round_trip.json").should_succeed stderr: <<EOM
-Updated data_bag_item[bar::round_trip]
+ knife("data bag from file bar #{db_dir}/bar/round_trip.json").should_succeed stderr: <<~EOM
+ Updated data_bag_item[bar::round_trip]
EOM
end
it "uploads many files" do
- knife("data bag from file foo #{db_dir}/foo/bar.json #{db_dir}/foo/bzr.json").should_succeed stderr: <<EOM
-Updated data_bag_item[foo::bar]
-Updated data_bag_item[foo::bzr]
+ knife("data bag from file foo #{db_dir}/foo/bar.json #{db_dir}/foo/bzr.json").should_succeed stderr: <<~EOM
+ Updated data_bag_item[foo::bar]
+ Updated data_bag_item[foo::bzr]
EOM
end
it "uploads a whole directory" do
knife("data bag from file foo #{db_dir}/foo")
- knife("data bag show foo").should_succeed <<EOM
-bar
-bzr
-cat
-dog
-encrypted
+ knife("data bag show foo").should_succeed <<~EOM
+ bar
+ bzr
+ cat
+ dog
+ encrypted
EOM
end
diff --git a/spec/integration/knife/data_bag_list_spec.rb b/spec/integration/knife/data_bag_list_spec.rb
index 7db9638660..4a2b740937 100644
--- a/spec/integration/knife/data_bag_list_spec.rb
+++ b/spec/integration/knife/data_bag_list_spec.rb
@@ -32,10 +32,10 @@ describe "knife data bag list", :workstation do
end
it "knife data bag list shows all the cookbooks" do
- knife("data bag list").should_succeed <<EOM
-canteloupe
-rocket
-x
+ knife("data bag list").should_succeed <<~EOM
+ canteloupe
+ rocket
+ x
EOM
end
diff --git a/spec/integration/knife/data_bag_show_spec.rb b/spec/integration/knife/data_bag_show_spec.rb
index 38dfd8730d..5fefec5266 100644
--- a/spec/integration/knife/data_bag_show_spec.rb
+++ b/spec/integration/knife/data_bag_show_spec.rb
@@ -36,17 +36,17 @@ describe "knife data bag show", :workstation do
end
it "with a bag with some items" do
- knife("data bag show rocket").should_succeed <<EOM
-ariane
-atlas
-falcon9
+ knife("data bag show rocket").should_succeed <<~EOM
+ ariane
+ atlas
+ falcon9
EOM
end
it "with a single item" do
- knife("data bag show rocket falcon9").should_succeed <<EOM
-heavy: true
-id: falcon9
+ knife("data bag show rocket falcon9").should_succeed <<~EOM
+ heavy: true
+ id: falcon9
EOM
end
end
diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb
index 1c69fbf9c9..2e3efcf693 100644
--- a/spec/integration/knife/delete_spec.rb
+++ b/spec/integration/knife/delete_spec.rb
@@ -25,76 +25,76 @@ describe "knife delete", :workstation do
include KnifeSupport
let :everything do
- <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
let :server_everything do
- <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
+ <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
EOM
end
let :server_nothing do
- <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/cookbooks
-/data_bags
-/environments
-/environments/_default.json
-/nodes
-/roles
-/users
-/users/admin.json
+ <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /cookbooks
+ /data_bags
+ /environments
+ /environments/_default.json
+ /nodes
+ /roles
+ /users
+ /users/admin.json
EOM
end
let :nothing do
- <<EOM
-/clients
-/cookbooks
-/data_bags
-/environments
-/nodes
-/roles
-/users
+ <<~EOM
+ /clients
+ /cookbooks
+ /data_bags
+ /environments
+ /nodes
+ /roles
+ /users
EOM
end
@@ -122,9 +122,9 @@ EOM
end
it "knife delete --both /cookbooks/x fails" do
- knife("delete --both /cookbooks/x").should_fail <<EOM
-ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.
-ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.
+ knife("delete --both /cookbooks/x").should_fail <<~EOM
+ ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.
+ ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.
EOM
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed everything
@@ -132,88 +132,88 @@ EOM
it "knife delete --both -r /cookbooks/x deletes x" do
knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete -r --local /cookbooks/x deletes x locally but not remotely" do
knife("delete -r --local /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
knife("list -Rf /").should_succeed server_everything
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete -r /cookbooks/x deletes x remotely but not locally" do
knife("delete -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
EOM
knife("list -Rf --local /").should_succeed everything
end
@@ -226,60 +226,60 @@ EOM
end
it "knife delete --both /data_bags/empty fails but deletes local version" do
- knife("delete --both /data_bags/empty").should_fail <<EOM
-ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete.
-ERROR: /data_bags/empty (local) must be deleted recursively! Pass -r to knife delete.
-EOM
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/empty
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/empty
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("delete --both /data_bags/empty").should_fail <<~EOM
+ ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete.
+ ERROR: /data_bags/empty (local) must be deleted recursively! Pass -r to knife delete.
+EOM
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/empty
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/empty
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
end
it "knife delete --both /data_bags/x fails" do
- knife("delete --both /data_bags/x").should_fail <<EOM
-ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.
-ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.
+ knife("delete --both /data_bags/x").should_fail <<~EOM
+ ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.
+ ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.
EOM
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed everything
@@ -287,151 +287,151 @@ EOM
it "knife delete --both -r /data_bags/x deletes x" do
knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /environments/x.json deletes x" do
knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /roles/x.json deletes x" do
knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/users
-/users/admin.json
-/users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/users
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /users
+ /users/admin.json
+ /users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /environments/_default.json fails but still deletes the local copy" do
- knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n"
+ knife("delete --both /environments/_default.json").should_fail stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", stdout: "Deleted /environments/_default.json\n"
knife("list -Rf /").should_succeed server_everything
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
@@ -442,32 +442,32 @@ EOM
end
it "knife delete --both / fails" do
- knife("delete --both /").should_fail <<EOM
-ERROR: / (remote) cannot be deleted.
-ERROR: / (local) cannot be deleted.
+ knife("delete --both /").should_fail <<~EOM
+ ERROR: / (remote) cannot be deleted.
+ ERROR: / (local) cannot be deleted.
EOM
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed everything
end
it "knife delete --both -r /* fails" do
- knife("delete --both -r /*").should_fail <<EOM
-ERROR: / (remote) cannot be deleted.
-ERROR: / (local) cannot be deleted.
-ERROR: /clients (remote) cannot be deleted.
-ERROR: /clients (local) cannot be deleted.
-ERROR: /cookbooks (remote) cannot be deleted.
-ERROR: /cookbooks (local) cannot be deleted.
-ERROR: /data_bags (remote) cannot be deleted.
-ERROR: /data_bags (local) cannot be deleted.
-ERROR: /environments (remote) cannot be deleted.
-ERROR: /environments (local) cannot be deleted.
-ERROR: /nodes (remote) cannot be deleted.
-ERROR: /nodes (local) cannot be deleted.
-ERROR: /roles (remote) cannot be deleted.
-ERROR: /roles (local) cannot be deleted.
-ERROR: /users (remote) cannot be deleted.
-ERROR: /users (local) cannot be deleted.
+ knife("delete --both -r /*").should_fail <<~EOM
+ ERROR: / (remote) cannot be deleted.
+ ERROR: / (local) cannot be deleted.
+ ERROR: /clients (remote) cannot be deleted.
+ ERROR: /clients (local) cannot be deleted.
+ ERROR: /cookbooks (remote) cannot be deleted.
+ ERROR: /cookbooks (local) cannot be deleted.
+ ERROR: /data_bags (remote) cannot be deleted.
+ ERROR: /data_bags (local) cannot be deleted.
+ ERROR: /environments (remote) cannot be deleted.
+ ERROR: /environments (local) cannot be deleted.
+ ERROR: /nodes (remote) cannot be deleted.
+ ERROR: /nodes (local) cannot be deleted.
+ ERROR: /roles (remote) cannot be deleted.
+ ERROR: /roles (local) cannot be deleted.
+ ERROR: /users (remote) cannot be deleted.
+ ERROR: /users (local) cannot be deleted.
EOM
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed everything
@@ -493,25 +493,25 @@ EOM
it "knife delete --both -r /cookbooks/x deletes x" do
knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
EOM
knife("list -Rf --local /").should_succeed nothing
end
@@ -524,83 +524,83 @@ EOM
it "knife delete --both -r /data_bags/x deletes x" do
knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
EOM
knife("list -Rf --local /").should_succeed nothing
end
it "knife delete --both /environments/x.json deletes x" do
knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/admin.json
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/admin.json
+ /users/x.json
EOM
knife("list -Rf --local /").should_succeed nothing
end
it "knife delete --both /roles/x.json deletes x" do
knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n"
- knife("list -Rf /").should_succeed <<EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/users
-/users/admin.json
-/users/x.json
+ knife("list -Rf /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /users
+ /users/admin.json
+ /users/x.json
EOM
knife("list -Rf --local /").should_succeed nothing
end
it "knife delete --both /environments/_default.json fails" do
- knife("delete --both /environments/_default.json").should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n"
+ knife("delete --both /environments/_default.json").should_fail "", stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n"
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed nothing
end
@@ -612,23 +612,23 @@ EOM
end
it "knife delete --both -r /* fails" do
- knife("delete --both -r /*").should_fail <<EOM
-ERROR: / (remote) cannot be deleted.
-ERROR: / (local) cannot be deleted.
-ERROR: /clients (remote) cannot be deleted.
-ERROR: /clients (local) cannot be deleted.
-ERROR: /cookbooks (remote) cannot be deleted.
-ERROR: /cookbooks (local) cannot be deleted.
-ERROR: /data_bags (remote) cannot be deleted.
-ERROR: /data_bags (local) cannot be deleted.
-ERROR: /environments (remote) cannot be deleted.
-ERROR: /environments (local) cannot be deleted.
-ERROR: /nodes (remote) cannot be deleted.
-ERROR: /nodes (local) cannot be deleted.
-ERROR: /roles (remote) cannot be deleted.
-ERROR: /roles (local) cannot be deleted.
-ERROR: /users (remote) cannot be deleted.
-ERROR: /users (local) cannot be deleted.
+ knife("delete --both -r /*").should_fail <<~EOM
+ ERROR: / (remote) cannot be deleted.
+ ERROR: / (local) cannot be deleted.
+ ERROR: /clients (remote) cannot be deleted.
+ ERROR: /clients (local) cannot be deleted.
+ ERROR: /cookbooks (remote) cannot be deleted.
+ ERROR: /cookbooks (local) cannot be deleted.
+ ERROR: /data_bags (remote) cannot be deleted.
+ ERROR: /data_bags (local) cannot be deleted.
+ ERROR: /environments (remote) cannot be deleted.
+ ERROR: /environments (local) cannot be deleted.
+ ERROR: /nodes (remote) cannot be deleted.
+ ERROR: /nodes (local) cannot be deleted.
+ ERROR: /roles (remote) cannot be deleted.
+ ERROR: /roles (local) cannot be deleted.
+ ERROR: /users (remote) cannot be deleted.
+ ERROR: /users (local) cannot be deleted.
EOM
knife("list -Rf /").should_succeed server_everything
knife("list -Rf --local /").should_succeed nothing
@@ -643,37 +643,37 @@ EOM
context "and cwd is at the top level" do
before { cwd "." }
it "knife delete fails" do
- knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", :stdout => /USAGE/
- knife("list -Rf /").should_succeed <<EOM
-clients
-clients/chef-validator.json
-clients/chef-webui.json
-clients/x.json
-cookbooks
-cookbooks/x
-cookbooks/x/metadata.rb
-data_bags
-data_bags/x
-data_bags/x/y.json
-environments
-environments/_default.json
-environments/x.json
-nodes
-nodes/x.json
-roles
-roles/x.json
-users
-users/admin.json
-users/x.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-clients
-cookbooks
-data_bags
-environments
-nodes
-roles
-users
+ knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", stdout: /USAGE/
+ knife("list -Rf /").should_succeed <<~EOM
+ clients
+ clients/chef-validator.json
+ clients/chef-webui.json
+ clients/x.json
+ cookbooks
+ cookbooks/x
+ cookbooks/x/metadata.rb
+ data_bags
+ data_bags/x
+ data_bags/x/y.json
+ environments
+ environments/_default.json
+ environments/x.json
+ nodes
+ nodes/x.json
+ roles
+ roles/x.json
+ users
+ users/admin.json
+ users/x.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ clients
+ cookbooks
+ data_bags
+ environments
+ nodes
+ roles
+ users
EOM
end
end
@@ -702,22 +702,22 @@ EOM
it "knife delete --both -r /cookbooks/x deletes x" do
knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
knife("list -Rf /").should_succeed server_nothing
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
@@ -730,91 +730,91 @@ EOM
it "knife delete --both -r /data_bags/x deletes x" do
knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n"
knife("list -Rf /").should_succeed server_nothing
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /environments/x.json deletes x" do
knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n"
knife("list -Rf /").should_succeed server_nothing
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /roles/x.json deletes x" do
knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n"
knife("list -Rf /").should_succeed server_nothing
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/_default.json
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/_default.json
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /users
+ /users/x.json
EOM
end
it "knife delete --both /environments/_default.json fails but still deletes the local copy" do
- knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n"
+ knife("delete --both /environments/_default.json").should_fail stderr: "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", stdout: "Deleted /environments/_default.json\n"
knife("list -Rf /").should_succeed server_nothing
- knife("list -Rf --local /").should_succeed <<EOM
-/clients
-/clients/x.json
-/cookbooks
-/cookbooks/x
-/cookbooks/x/metadata.rb
-/data_bags
-/data_bags/x
-/data_bags/x/y.json
-/environments
-/environments/x.json
-/nodes
-/nodes/x.json
-/roles
-/roles/x.json
-/users
-/users/x.json
+ knife("list -Rf --local /").should_succeed <<~EOM
+ /clients
+ /clients/x.json
+ /cookbooks
+ /cookbooks/x
+ /cookbooks/x/metadata.rb
+ /data_bags
+ /data_bags/x
+ /data_bags/x/y.json
+ /environments
+ /environments/x.json
+ /nodes
+ /nodes/x.json
+ /roles
+ /roles/x.json
+ /users
+ /users/x.json
EOM
end
@@ -825,23 +825,23 @@ EOM
end
it "knife delete --both -r /* fails" do
- knife("delete --both -r /*").should_fail <<EOM
-ERROR: / (remote) cannot be deleted.
-ERROR: / (local) cannot be deleted.
-ERROR: /clients (remote) cannot be deleted.
-ERROR: /clients (local) cannot be deleted.
-ERROR: /cookbooks (remote) cannot be deleted.
-ERROR: /cookbooks (local) cannot be deleted.
-ERROR: /data_bags (remote) cannot be deleted.
-ERROR: /data_bags (local) cannot be deleted.
-ERROR: /environments (remote) cannot be deleted.
-ERROR: /environments (local) cannot be deleted.
-ERROR: /nodes (remote) cannot be deleted.
-ERROR: /nodes (local) cannot be deleted.
-ERROR: /roles (remote) cannot be deleted.
-ERROR: /roles (local) cannot be deleted.
-ERROR: /users (remote) cannot be deleted.
-ERROR: /users (local) cannot be deleted.
+ knife("delete --both -r /*").should_fail <<~EOM
+ ERROR: / (remote) cannot be deleted.
+ ERROR: / (local) cannot be deleted.
+ ERROR: /clients (remote) cannot be deleted.
+ ERROR: /clients (local) cannot be deleted.
+ ERROR: /cookbooks (remote) cannot be deleted.
+ ERROR: /cookbooks (local) cannot be deleted.
+ ERROR: /data_bags (remote) cannot be deleted.
+ ERROR: /data_bags (local) cannot be deleted.
+ ERROR: /environments (remote) cannot be deleted.
+ ERROR: /environments (local) cannot be deleted.
+ ERROR: /nodes (remote) cannot be deleted.
+ ERROR: /nodes (local) cannot be deleted.
+ ERROR: /roles (remote) cannot be deleted.
+ ERROR: /roles (local) cannot be deleted.
+ ERROR: /users (remote) cannot be deleted.
+ ERROR: /users (local) cannot be deleted.
EOM
knife("list -Rf /").should_succeed server_nothing
knife("list -Rf --local /").should_succeed everything
@@ -856,38 +856,38 @@ EOM
context "and cwd is at the top level" do
before { cwd "." }
it "knife delete fails" do
- knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", :stdout => /USAGE/
- knife("list -Rf /").should_succeed <<EOM
-clients
-clients/chef-validator.json
-clients/chef-webui.json
-cookbooks
-data_bags
-environments
-environments/_default.json
-nodes
-roles
-users
-users/admin.json
-EOM
- knife("list -Rf --local /").should_succeed <<EOM
-clients
-clients/x.json
-cookbooks
-cookbooks/x
-cookbooks/x/metadata.rb
-data_bags
-data_bags/x
-data_bags/x/y.json
-environments
-environments/_default.json
-environments/x.json
-nodes
-nodes/x.json
-roles
-roles/x.json
-users
-users/x.json
+ knife("delete").should_fail "FATAL: You must specify at least one argument. If you want to delete everything in this directory, run \"knife delete --recurse .\"\n", stdout: /USAGE/
+ knife("list -Rf /").should_succeed <<~EOM
+ clients
+ clients/chef-validator.json
+ clients/chef-webui.json
+ cookbooks
+ data_bags
+ environments
+ environments/_default.json
+ nodes
+ roles
+ users
+ users/admin.json
+EOM
+ knife("list -Rf --local /").should_succeed <<~EOM
+ clients
+ clients/x.json
+ cookbooks
+ cookbooks/x
+ cookbooks/x/metadata.rb
+ data_bags
+ data_bags/x
+ data_bags/x/y.json
+ environments
+ environments/_default.json
+ environments/x.json
+ nodes
+ nodes/x.json
+ roles
+ roles/x.json
+ users
+ users/x.json
EOM
end
end
@@ -962,7 +962,7 @@ EOM
end
end
- when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do
+ when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do
before do
organization "foo" do
container "x", {}
diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb
index 3f200396ba..b7eafcbd1c 100644
--- a/spec/integration/knife/deps_spec.rb
+++ b/spec/integration/knife/deps_spec.rb
@@ -41,11 +41,11 @@ describe "knife deps", :workstation do
file "cookbooks/soup/recipes/chicken.rb", ""
end
it "knife deps reports all dependencies" do
- knife("deps /roles/starring.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
+ knife("deps /roles/starring.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
EOM
end
end
@@ -60,11 +60,11 @@ EOM
file "cookbooks/soup/recipes/chicken.rb", ""
end
it "knife deps reports all dependencies" do
- knife("deps /roles/starring.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
+ knife("deps /roles/starring.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
EOM
end
end
@@ -94,11 +94,11 @@ EOM
file "nodes/mort.json", { "run_list" => %w{role[minor] recipe[quiche] recipe[soup::chicken]} }
end
it "knife deps reports just the node" do
- knife("deps /nodes/mort.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/nodes/mort.json
+ knife("deps /nodes/mort.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /nodes/mort.json
EOM
end
end
@@ -148,56 +148,56 @@ depends "kettle"'
end
it "knife deps reports all dependencies" do
- knife("deps /nodes/mort.json").should_succeed <<EOM
-/environments/desert.json
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps /nodes/mort.json").should_succeed <<~EOM
+ /environments/desert.json
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps * reports all dependencies of all things" do
- knife("deps /nodes/*").should_succeed <<EOM
-/roles/minor.json
-/nodes/bart.json
-/environments/desert.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps /nodes/*").should_succeed <<~EOM
+ /roles/minor.json
+ /nodes/bart.json
+ /environments/desert.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps a b reports all dependencies of a and b" do
- knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<EOM
-/roles/minor.json
-/nodes/bart.json
-/environments/desert.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<~EOM
+ /roles/minor.json
+ /nodes/bart.json
+ /environments/desert.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps --tree /* shows dependencies in a tree" do
- knife("deps --tree /nodes/*").should_succeed <<EOM
-/nodes/bart.json
- /roles/minor.json
-/nodes/mort.json
- /environments/desert.json
- /roles/starring.json
- /roles/minor.json
- /cookbooks/quiche
- /cookbooks/soup
+ knife("deps --tree /nodes/*").should_succeed <<~EOM
+ /nodes/bart.json
+ /roles/minor.json
+ /nodes/mort.json
+ /environments/desert.json
+ /roles/starring.json
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
EOM
end
it "knife deps --tree --no-recurse shows only the first level of dependencies" do
- knife("deps --tree --no-recurse /nodes/*").should_succeed <<EOM
-/nodes/bart.json
- /roles/minor.json
-/nodes/mort.json
- /environments/desert.json
- /roles/starring.json
+ knife("deps --tree --no-recurse /nodes/*").should_succeed <<~EOM
+ /nodes/bart.json
+ /roles/minor.json
+ /nodes/mort.json
+ /environments/desert.json
+ /roles/starring.json
EOM
end
end
@@ -232,11 +232,11 @@ depends "foo"'
file "roles/self.json", { "run_list" => [ "role[self]" ] }
end
it "knife deps prints each once" do
- knife("deps /roles/foo.json /roles/self.json").should_succeed <<EOM
-/roles/baz.json
-/roles/bar.json
-/roles/foo.json
-/roles/self.json
+ knife("deps /roles/foo.json /roles/self.json").should_succeed <<~EOM
+ /roles/baz.json
+ /roles/bar.json
+ /roles/foo.json
+ /roles/self.json
EOM
end
it "knife deps --tree prints each once" do
@@ -252,44 +252,44 @@ EOM
when_the_repository "is empty" do
it "knife deps /blah reports an error" do
knife("deps /blah").should_fail(
- :exit_code => 2,
- :stdout => "/blah\n",
- :stderr => "ERROR: /blah: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/blah\n",
+ stderr: "ERROR: /blah: No such file or directory\n"
)
end
it "knife deps /roles/x.json reports an error" do
knife("deps /roles/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/roles/x.json\n",
- :stderr => "ERROR: /roles/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/roles/x.json\n",
+ stderr: "ERROR: /roles/x.json: No such file or directory\n"
)
end
it "knife deps /nodes/x.json reports an error" do
knife("deps /nodes/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/nodes/x.json\n",
- :stderr => "ERROR: /nodes/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/nodes/x.json\n",
+ stderr: "ERROR: /nodes/x.json: No such file or directory\n"
)
end
it "knife deps /environments/x.json reports an error" do
knife("deps /environments/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/environments/x.json\n",
- :stderr => "ERROR: /environments/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/environments/x.json\n",
+ stderr: "ERROR: /environments/x.json: No such file or directory\n"
)
end
it "knife deps /cookbooks/x reports an error" do
knife("deps /cookbooks/x").should_fail(
- :exit_code => 2,
- :stdout => "/cookbooks/x\n",
- :stderr => "ERROR: /cookbooks/x: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/cookbooks/x\n",
+ stderr: "ERROR: /cookbooks/x: No such file or directory\n"
)
end
it "knife deps /data_bags/bag/item.json reports an error" do
knife("deps /data_bags/bag/item.json").should_fail(
- :exit_code => 2,
- :stdout => "/data_bags/bag/item.json\n",
- :stderr => "ERROR: /data_bags/bag/item.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/data_bags/bag/item.json\n",
+ stderr: "ERROR: /data_bags/bag/item.json: No such file or directory\n"
)
end
end
@@ -299,9 +299,9 @@ EOM
end
it "knife deps reports the cookbook, along with an error" do
knife("deps /roles/starring.json").should_fail(
- :exit_code => 2,
- :stdout => "/cookbooks/quiche\n/roles/starring.json\n",
- :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/cookbooks/quiche\n/roles/starring.json\n",
+ stderr: "ERROR: /cookbooks/quiche: No such file or directory\n"
)
end
end
@@ -311,9 +311,9 @@ EOM
end
it "knife deps reports the environment, along with an error" do
knife("deps /nodes/mort.json").should_fail(
- :exit_code => 2,
- :stdout => "/environments/desert.json\n/nodes/mort.json\n",
- :stderr => "ERROR: /environments/desert.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/environments/desert.json\n/nodes/mort.json\n",
+ stderr: "ERROR: /environments/desert.json: No such file or directory\n"
)
end
end
@@ -323,9 +323,9 @@ EOM
end
it "knife deps reports the role, along with an error" do
knife("deps /roles/starring.json").should_fail(
- :exit_code => 2,
- :stdout => "/roles/minor.json\n/roles/starring.json\n",
- :stderr => "ERROR: /roles/minor.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/roles/minor.json\n/roles/starring.json\n",
+ stderr: "ERROR: /roles/minor.json: No such file or directory\n"
)
end
end
@@ -337,9 +337,9 @@ EOM
end
it "knife deps /roles reports an error" do
knife("deps /roles").should_fail(
- :exit_code => 2,
- :stderr => "ERROR: /roles: No such file or directory\n",
- :stdout => "/roles\n"
+ exit_code: 2,
+ stderr: "ERROR: /roles: No such file or directory\n",
+ stdout: "/roles\n"
)
end
end
@@ -378,11 +378,11 @@ EOM
cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } }
end
it "knife deps reports all dependencies" do
- knife("deps --remote /roles/starring.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
+ knife("deps --remote /roles/starring.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
EOM
end
end
@@ -395,11 +395,11 @@ EOM
cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } }
end
it "knife deps reports all dependencies" do
- knife("deps --remote /roles/starring.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
+ knife("deps --remote /roles/starring.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
EOM
end
end
@@ -427,11 +427,11 @@ EOM
node "mort", { "run_list" => %w{role[minor] recipe[quiche] recipe[soup::chicken]} }
end
it "knife deps reports just the node" do
- knife("deps --remote /nodes/mort.json").should_succeed <<EOM
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/nodes/mort.json
+ knife("deps --remote /nodes/mort.json").should_succeed <<~EOM
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /nodes/mort.json
EOM
end
end
@@ -477,56 +477,56 @@ depends "kettle"', "recipes" => { "default.rb" => "" } }
end
it "knife deps reports all dependencies" do
- knife("deps --remote /nodes/mort.json").should_succeed <<EOM
-/environments/desert.json
-/roles/minor.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps --remote /nodes/mort.json").should_succeed <<~EOM
+ /environments/desert.json
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps * reports all dependencies of all things" do
- knife("deps --remote /nodes/*").should_succeed <<EOM
-/roles/minor.json
-/nodes/bart.json
-/environments/desert.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps --remote /nodes/*").should_succeed <<~EOM
+ /roles/minor.json
+ /nodes/bart.json
+ /environments/desert.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps a b reports all dependencies of a and b" do
- knife("deps --remote /nodes/bart.json /nodes/mort.json").should_succeed <<EOM
-/roles/minor.json
-/nodes/bart.json
-/environments/desert.json
-/cookbooks/quiche
-/cookbooks/soup
-/roles/starring.json
-/nodes/mort.json
+ knife("deps --remote /nodes/bart.json /nodes/mort.json").should_succeed <<~EOM
+ /roles/minor.json
+ /nodes/bart.json
+ /environments/desert.json
+ /cookbooks/quiche
+ /cookbooks/soup
+ /roles/starring.json
+ /nodes/mort.json
EOM
end
it "knife deps --tree /* shows dependencies in a tree" do
- knife("deps --remote --tree /nodes/*").should_succeed <<EOM
-/nodes/bart.json
- /roles/minor.json
-/nodes/mort.json
- /environments/desert.json
- /roles/starring.json
- /roles/minor.json
- /cookbooks/quiche
- /cookbooks/soup
+ knife("deps --remote --tree /nodes/*").should_succeed <<~EOM
+ /nodes/bart.json
+ /roles/minor.json
+ /nodes/mort.json
+ /environments/desert.json
+ /roles/starring.json
+ /roles/minor.json
+ /cookbooks/quiche
+ /cookbooks/soup
EOM
end
it "knife deps --tree --no-recurse shows only the first level of dependencies" do
- knife("deps --remote --tree --no-recurse /nodes/*").should_succeed <<EOM
-/nodes/bart.json
- /roles/minor.json
-/nodes/mort.json
- /environments/desert.json
- /roles/starring.json
+ knife("deps --remote --tree --no-recurse /nodes/*").should_succeed <<~EOM
+ /nodes/bart.json
+ /roles/minor.json
+ /nodes/mort.json
+ /environments/desert.json
+ /roles/starring.json
EOM
end
end
@@ -544,21 +544,21 @@ depends "foo"' }
depends "self"' }
end
it "knife deps prints each once" do
- knife("deps --remote /cookbooks/foo /cookbooks/self").should_succeed <<EOM
-/cookbooks/baz
-/cookbooks/bar
-/cookbooks/foo
-/cookbooks/self
+ knife("deps --remote /cookbooks/foo /cookbooks/self").should_succeed <<~EOM
+ /cookbooks/baz
+ /cookbooks/bar
+ /cookbooks/foo
+ /cookbooks/self
EOM
end
it "knife deps --tree prints each once" do
- knife("deps --remote --tree /cookbooks/foo /cookbooks/self").should_succeed <<EOM
-/cookbooks/foo
- /cookbooks/bar
- /cookbooks/baz
- /cookbooks/foo
-/cookbooks/self
- /cookbooks/self
+ knife("deps --remote --tree /cookbooks/foo /cookbooks/self").should_succeed <<~EOM
+ /cookbooks/foo
+ /cookbooks/bar
+ /cookbooks/baz
+ /cookbooks/foo
+ /cookbooks/self
+ /cookbooks/self
EOM
end
end
@@ -570,11 +570,11 @@ EOM
role "self", { "run_list" => [ "role[self]" ] }
end
it "knife deps prints each once" do
- knife("deps --remote /roles/foo.json /roles/self.json").should_succeed <<EOM
-/roles/baz.json
-/roles/bar.json
-/roles/foo.json
-/roles/self.json
+ knife("deps --remote /roles/foo.json /roles/self.json").should_succeed <<~EOM
+ /roles/baz.json
+ /roles/bar.json
+ /roles/foo.json
+ /roles/self.json
EOM
end
it "knife deps --tree prints each once" do
@@ -590,44 +590,44 @@ EOM
when_the_chef_server "is empty" do
it "knife deps /blah reports an error" do
knife("deps --remote /blah").should_fail(
- :exit_code => 2,
- :stdout => "/blah\n",
- :stderr => "ERROR: /blah: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/blah\n",
+ stderr: "ERROR: /blah: No such file or directory\n"
)
end
it "knife deps /roles/x.json reports an error" do
knife("deps --remote /roles/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/roles/x.json\n",
- :stderr => "ERROR: /roles/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/roles/x.json\n",
+ stderr: "ERROR: /roles/x.json: No such file or directory\n"
)
end
it "knife deps /nodes/x.json reports an error" do
knife("deps --remote /nodes/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/nodes/x.json\n",
- :stderr => "ERROR: /nodes/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/nodes/x.json\n",
+ stderr: "ERROR: /nodes/x.json: No such file or directory\n"
)
end
it "knife deps /environments/x.json reports an error" do
knife("deps --remote /environments/x.json").should_fail(
- :exit_code => 2,
- :stdout => "/environments/x.json\n",
- :stderr => "ERROR: /environments/x.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/environments/x.json\n",
+ stderr: "ERROR: /environments/x.json: No such file or directory\n"
)
end
it "knife deps /cookbooks/x reports an error" do
knife("deps --remote /cookbooks/x").should_fail(
- :exit_code => 2,
- :stdout => "/cookbooks/x\n",
- :stderr => "ERROR: /cookbooks/x: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/cookbooks/x\n",
+ stderr: "ERROR: /cookbooks/x: No such file or directory\n"
)
end
it "knife deps /data_bags/bag/item reports an error" do
knife("deps --remote /data_bags/bag/item.json").should_fail(
- :exit_code => 2,
- :stdout => "/data_bags/bag/item.json\n",
- :stderr => "ERROR: /data_bags/bag/item.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/data_bags/bag/item.json\n",
+ stderr: "ERROR: /data_bags/bag/item.json: No such file or directory\n"
)
end
end
@@ -637,9 +637,9 @@ EOM
end
it "knife deps reports the cookbook, along with an error" do
knife("deps --remote /roles/starring.json").should_fail(
- :exit_code => 2,
- :stdout => "/cookbooks/quiche\n/roles/starring.json\n",
- :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/cookbooks/quiche\n/roles/starring.json\n",
+ stderr: "ERROR: /cookbooks/quiche: No such file or directory\n"
)
end
end
@@ -649,9 +649,9 @@ EOM
end
it "knife deps reports the environment, along with an error" do
knife("deps --remote /nodes/mort.json").should_fail(
- :exit_code => 2,
- :stdout => "/environments/desert.json\n/nodes/mort.json\n",
- :stderr => "ERROR: /environments/desert.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/environments/desert.json\n/nodes/mort.json\n",
+ stderr: "ERROR: /environments/desert.json: No such file or directory\n"
)
end
end
@@ -661,9 +661,9 @@ EOM
end
it "knife deps reports the role, along with an error" do
knife("deps --remote /roles/starring.json").should_fail(
- :exit_code => 2,
- :stdout => "/roles/minor.json\n/roles/starring.json\n",
- :stderr => "ERROR: /roles/minor.json: No such file or directory\n"
+ exit_code: 2,
+ stdout: "/roles/minor.json\n/roles/starring.json\n",
+ stderr: "ERROR: /roles/minor.json: No such file or directory\n"
)
end
end
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb
index b3bd23f48e..9e54558300 100644
--- a/spec/integration/knife/diff_spec.rb
+++ b/spec/integration/knife/diff_spec.rb
@@ -46,18 +46,18 @@ describe "knife diff", :workstation do
end
it "knife diff reports everything as deleted" do
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients/chef-validator.json
-D\t/clients/chef-webui.json
-D\t/clients/x.json
-D\t/cookbooks/x
-D\t/data_bags/x
-D\t/environments/_default.json
-D\t/environments/x.json
-D\t/nodes/x.json
-D\t/roles/x.json
-D\t/users/admin.json
-D\t/users/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients/chef-validator.json
+ D\t/clients/chef-webui.json
+ D\t/clients/x.json
+ D\t/cookbooks/x
+ D\t/data_bags/x
+ D\t/environments/_default.json
+ D\t/environments/x.json
+ D\t/nodes/x.json
+ D\t/roles/x.json
+ D\t/users/admin.json
+ D\t/users/x.json
EOM
end
end
@@ -92,16 +92,16 @@ EOM
context "except the role file" do
before do
- file "roles/x.json", <<EOM
-{
- "foo": "bar"
-}
+ file "roles/x.json", <<~EOM
+ {
+ "foo": "bar"
+ }
EOM
end
it "knife diff reports the role as different" do
- knife("diff --name-status /").should_succeed <<EOM
-M\t/roles/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ M\t/roles/x.json
EOM
end
end
@@ -120,31 +120,31 @@ EOM
end
it "knife diff reports the new files as added" do
- knife("diff --name-status /").should_succeed <<EOM
-A\t/clients/y.json
-A\t/cookbooks/x/blah.rb
-A\t/cookbooks/y
-A\t/data_bags/x/z.json
-A\t/data_bags/y
-A\t/environments/y.json
-A\t/nodes/y.json
-A\t/roles/y.json
-A\t/users/y.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ A\t/clients/y.json
+ A\t/cookbooks/x/blah.rb
+ A\t/cookbooks/y
+ A\t/data_bags/x/z.json
+ A\t/data_bags/y
+ A\t/environments/y.json
+ A\t/nodes/y.json
+ A\t/roles/y.json
+ A\t/users/y.json
EOM
end
context "when cwd is the data_bags directory" do
before { cwd "data_bags" }
it "knife diff reports different data bags" do
- knife("diff --name-status").should_succeed <<EOM
-A\tx/z.json
-A\ty
+ knife("diff --name-status").should_succeed <<~EOM
+ A\tx/z.json
+ A\ty
EOM
end
it "knife diff * reports different data bags" do
- knife("diff --name-status *").should_succeed <<EOM
-A\tx/z.json
-A\ty
+ knife("diff --name-status *").should_succeed <<~EOM
+ A\tx/z.json
+ A\ty
EOM
end
end
@@ -153,14 +153,14 @@ EOM
when_the_repository "is empty" do
it "knife diff reports everything as deleted" do
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
end
@@ -179,17 +179,17 @@ EOM
end
it "knife diff /cookbooks/x shows differences" do
- knife("diff --name-status /cookbooks/x").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks/x").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
it "knife diff --diff-filter=MAT does not show deleted files" do
- knife("diff --diff-filter=MAT --name-status /cookbooks/x").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --diff-filter=MAT --name-status /cookbooks/x").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
end
@@ -210,10 +210,10 @@ EOM
end
it "knife diff /cookbooks/x shows the differences" do
- knife("diff --name-status /cookbooks/x").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks/x").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
end
@@ -224,10 +224,10 @@ EOM
end
it "knife diff /cookbooks/x shows the differences" do
- knife("diff --name-status /cookbooks/x").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin0.9.9.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks/x").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin0.9.9.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
end
@@ -247,7 +247,7 @@ EOM
end
when_the_chef_server "has an environment with a different value" do
before { environment "x", { "description" => "hi" } }
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
- "name": "x",
@@ -277,7 +277,7 @@ EOM
environment "x", {}
end
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
- "name": "x"
@@ -291,7 +291,7 @@ EOM
before do
environment "x", { "description" => "lo" }
end
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
"name": "x",
@@ -311,7 +311,7 @@ EOM
it "knife diff reports an error and does a textual diff" do
error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
error_match = Regexp.new(Regexp.escape(error_text))
- knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match)
+ knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match)
end
end
end
@@ -341,18 +341,18 @@ EOM
end
it "knife diff reports everything as deleted" do
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients/chef-validator.json
-D\t/clients/chef-webui.json
-D\t/clients/x.json
-D\t/cookbooks/x-1.0.0
-D\t/data_bags/x
-D\t/environments/_default.json
-D\t/environments/x.json
-D\t/nodes/x.json
-D\t/roles/x.json
-D\t/users/admin.json
-D\t/users/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients/chef-validator.json
+ D\t/clients/chef-webui.json
+ D\t/clients/x.json
+ D\t/cookbooks/x-1.0.0
+ D\t/data_bags/x
+ D\t/environments/_default.json
+ D\t/environments/x.json
+ D\t/nodes/x.json
+ D\t/roles/x.json
+ D\t/users/admin.json
+ D\t/users/x.json
EOM
end
end
@@ -386,16 +386,16 @@ EOM
context "except the role file" do
before do
- file "roles/x.json", <<EOM
-{
- "foo": "bar"
-}
+ file "roles/x.json", <<~EOM
+ {
+ "foo": "bar"
+ }
EOM
end
it "knife diff reports the role as different" do
- knife("diff --name-status /").should_succeed <<EOM
-M\t/roles/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ M\t/roles/x.json
EOM
end
end
@@ -415,32 +415,32 @@ EOM
end
it "knife diff reports the new files as added" do
- knife("diff --name-status /").should_succeed <<EOM
-A\t/clients/y.json
-A\t/cookbooks/x-1.0.0/blah.rb
-A\t/cookbooks/x-2.0.0
-A\t/cookbooks/y-1.0.0
-A\t/data_bags/x/z.json
-A\t/data_bags/y
-A\t/environments/y.json
-A\t/nodes/y.json
-A\t/roles/y.json
-A\t/users/y.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ A\t/clients/y.json
+ A\t/cookbooks/x-1.0.0/blah.rb
+ A\t/cookbooks/x-2.0.0
+ A\t/cookbooks/y-1.0.0
+ A\t/data_bags/x/z.json
+ A\t/data_bags/y
+ A\t/environments/y.json
+ A\t/nodes/y.json
+ A\t/roles/y.json
+ A\t/users/y.json
EOM
end
context "when cwd is the data_bags directory" do
before { cwd "data_bags" }
it "knife diff reports different data bags" do
- knife("diff --name-status").should_succeed <<EOM
-A\tx/z.json
-A\ty
+ knife("diff --name-status").should_succeed <<~EOM
+ A\tx/z.json
+ A\ty
EOM
end
it "knife diff * reports different data bags" do
- knife("diff --name-status *").should_succeed <<EOM
-A\tx/z.json
-A\ty
+ knife("diff --name-status *").should_succeed <<~EOM
+ A\tx/z.json
+ A\ty
EOM
end
end
@@ -449,14 +449,14 @@ EOM
when_the_repository "is empty" do
it "knife diff reports everything as deleted" do
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
end
@@ -475,8 +475,8 @@ EOM
end
it "knife diff /cookbooks shows differences" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x-1.0.1
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x-1.0.1
EOM
end
@@ -501,9 +501,9 @@ EOM
end
it "knife diff /cookbooks shows the differences" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x-1.0.1
-A\t/cookbooks/x-1.0.0
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x-1.0.1
+ A\t/cookbooks/x-1.0.0
EOM
end
end
@@ -514,9 +514,9 @@ EOM
end
it "knife diff /cookbooks shows the differences" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x-0.9.9
-A\t/cookbooks/x-1.0.0
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x-0.9.9
+ A\t/cookbooks/x-1.0.0
EOM
end
end
@@ -533,7 +533,7 @@ EOM
end
when_the_chef_server "has an environment with a different value" do
before { environment "x", { "description" => "hi" } }
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
- "name": "x",
@@ -560,7 +560,7 @@ EOM
end
when_the_chef_server "has an environment with no value" do
before { environment "x", {} }
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
- "name": "x"
@@ -574,7 +574,7 @@ EOM
before do
environment "x", { "description" => "lo" }
end
- it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do
+ it "knife diff reports the difference", skip: (RUBY_VERSION < "1.9") do
knife("diff /environments/x.json").should_succeed(/
{
"name": "x",
@@ -594,7 +594,7 @@ EOM
it "knife diff reports an error and does a textual diff" do
error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
error_match = Regexp.new(Regexp.escape(error_text))
- knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match)
+ knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match)
end
end
end
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index be0fc9d708..04610ba4e7 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -48,20 +48,20 @@ describe "knife download", :workstation do
end
it "knife download downloads everything" do
- knife("download /").should_succeed <<EOM
-Created /clients/chef-validator.json
-Created /clients/chef-webui.json
-Created /clients/x.json
-Created /cookbooks/x
-Created /cookbooks/x/metadata.rb
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments/_default.json
-Created /environments/x.json
-Created /nodes/x.json
-Created /roles/x.json
-Created /users/admin.json
-Created /users/x.json
+ knife("download /").should_succeed <<~EOM
+ Created /clients/chef-validator.json
+ Created /clients/chef-webui.json
+ Created /clients/x.json
+ Created /cookbooks/x
+ Created /cookbooks/x/metadata.rb
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments/_default.json
+ Created /environments/x.json
+ Created /nodes/x.json
+ Created /roles/x.json
+ Created /users/admin.json
+ Created /users/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -94,22 +94,22 @@ EOM
context "except the role file" do
before do
- file "roles/x.json", <<EOM
-{
- "chef_type": "role",
- "default_attributes": {
- },
- "description": "blarghle",
- "env_run_lists": {
- },
- "json_class": "Chef::Role",
- "name": "x",
- "override_attributes": {
- },
- "run_list": [
-
- ]
-}
+ file "roles/x.json", <<~EOM
+ {
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "description": "blarghle",
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -126,22 +126,22 @@ EOM
context "except the role file is textually different, but not ACTUALLY different" do
before do
- file "roles/x.json", <<EOM
-{
- "chef_type": "role",
- "default_attributes": {
- },
- "env_run_lists": {
- },
- "json_class": "Chef::Role",
- "name": "x",
- "description": "",
- "override_attributes": {
- },
- "run_list": [
-
- ]
-}
+ file "roles/x.json", <<~EOM
+ {
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "description": "",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -166,30 +166,30 @@ EOM
it "knife download does nothing" do
knife("download /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-A\t/clients/y.json
-A\t/cookbooks/x/blah.rb
-A\t/cookbooks/y
-A\t/data_bags/x/z.json
-A\t/data_bags/y
-A\t/environments/y.json
-A\t/nodes/y.json
-A\t/roles/y.json
-A\t/users/y.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ A\t/clients/y.json
+ A\t/cookbooks/x/blah.rb
+ A\t/cookbooks/y
+ A\t/data_bags/x/z.json
+ A\t/data_bags/y
+ A\t/environments/y.json
+ A\t/nodes/y.json
+ A\t/roles/y.json
+ A\t/users/y.json
EOM
end
it "knife download --purge deletes the extra files" do
- knife("download --purge /").should_succeed <<EOM
-Deleted extra entry /clients/y.json (purge is on)
-Deleted extra entry /cookbooks/x/blah.rb (purge is on)
-Deleted extra entry /cookbooks/y (purge is on)
-Deleted extra entry /data_bags/x/z.json (purge is on)
-Deleted extra entry /data_bags/y (purge is on)
-Deleted extra entry /environments/y.json (purge is on)
-Deleted extra entry /nodes/y.json (purge is on)
-Deleted extra entry /roles/y.json (purge is on)
-Deleted extra entry /users/y.json (purge is on)
+ knife("download --purge /").should_succeed <<~EOM
+ Deleted extra entry /clients/y.json (purge is on)
+ Deleted extra entry /cookbooks/x/blah.rb (purge is on)
+ Deleted extra entry /cookbooks/y (purge is on)
+ Deleted extra entry /data_bags/x/z.json (purge is on)
+ Deleted extra entry /data_bags/y (purge is on)
+ Deleted extra entry /environments/y.json (purge is on)
+ Deleted extra entry /nodes/y.json (purge is on)
+ Deleted extra entry /roles/y.json (purge is on)
+ Deleted extra entry /users/y.json (purge is on)
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -198,53 +198,53 @@ EOM
when_the_repository "is empty" do
it "knife download creates the extra files" do
- knife("download /").should_succeed <<EOM
-Created /clients
-Created /clients/chef-validator.json
-Created /clients/chef-webui.json
-Created /clients/x.json
-Created /cookbooks
-Created /cookbooks/x
-Created /cookbooks/x/metadata.rb
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments
-Created /environments/_default.json
-Created /environments/x.json
-Created /nodes
-Created /nodes/x.json
-Created /roles
-Created /roles/x.json
-Created /users
-Created /users/admin.json
-Created /users/x.json
+ knife("download /").should_succeed <<~EOM
+ Created /clients
+ Created /clients/chef-validator.json
+ Created /clients/chef-webui.json
+ Created /clients/x.json
+ Created /cookbooks
+ Created /cookbooks/x
+ Created /cookbooks/x/metadata.rb
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments
+ Created /environments/_default.json
+ Created /environments/x.json
+ Created /nodes
+ Created /nodes/x.json
+ Created /roles
+ Created /roles/x.json
+ Created /users
+ Created /users/admin.json
+ Created /users/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
it "knife download --no-diff creates the extra files" do
- knife("download --no-diff /").should_succeed <<EOM
-Created /clients
-Created /clients/chef-validator.json
-Created /clients/chef-webui.json
-Created /clients/x.json
-Created /cookbooks
-Created /cookbooks/x
-Created /cookbooks/x/metadata.rb
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments
-Created /environments/_default.json
-Created /environments/x.json
-Created /nodes
-Created /nodes/x.json
-Created /roles
-Created /roles/x.json
-Created /users
-Created /users/admin.json
-Created /users/x.json
+ knife("download --no-diff /").should_succeed <<~EOM
+ Created /clients
+ Created /clients/chef-validator.json
+ Created /clients/chef-webui.json
+ Created /clients/x.json
+ Created /cookbooks
+ Created /cookbooks/x
+ Created /cookbooks/x/metadata.rb
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments
+ Created /environments/_default.json
+ Created /environments/x.json
+ Created /nodes
+ Created /nodes/x.json
+ Created /roles
+ Created /roles/x.json
+ Created /users
+ Created /users/admin.json
+ Created /users/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -255,7 +255,7 @@ EOM
end
it "knife download with no parameters reports an error" do
- knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/
+ knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/
end
end
end
@@ -269,22 +269,22 @@ EOM
end
it "knife download of one data bag item itself succeeds" do
- knife("download /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("download /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/z.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/z.json
EOM
end
it "knife download /data_bags/x /data_bags/x/y.json downloads x once" do
- knife("download /data_bags/x /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /data_bags/x/z.json
+ knife("download /data_bags/x /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /data_bags/x/z.json
EOM
end
end
@@ -292,20 +292,20 @@ EOM
when_the_repository "has three data bag items" do
before do
- file "data_bags/x/deleted.json", <<EOM
-{
- "id": "deleted"
-}
+ file "data_bags/x/deleted.json", <<~EOM
+ {
+ "id": "deleted"
+ }
EOM
- file "data_bags/x/modified.json", <<EOM
-{
- "id": "modified"
-}
+ file "data_bags/x/modified.json", <<~EOM
+ {
+ "id": "modified"
+ }
EOM
- file "data_bags/x/unmodified.json", <<EOM
-{
- "id": "unmodified"
-}
+ file "data_bags/x/unmodified.json", <<~EOM
+ {
+ "id": "unmodified"
+ }
EOM
end
@@ -319,62 +319,62 @@ EOM
end
it "knife download of the modified file succeeds" do
- knife("download /data_bags/x/modified.json").should_succeed <<EOM
-Updated /data_bags/x/modified.json
+ knife("download /data_bags/x/modified.json").should_succeed <<~EOM
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the unmodified file does nothing" do
knife("download /data_bags/x/unmodified.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the added file succeeds" do
- knife("download /data_bags/x/added.json").should_succeed <<EOM
-Created /data_bags/x/added.json
+ knife("download /data_bags/x/added.json").should_succeed <<~EOM
+ Created /data_bags/x/added.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the deleted file does nothing" do
knife("download /data_bags/x/deleted.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download --purge of the deleted file deletes it" do
- knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("download --purge /data_bags/x/deleted.json").should_succeed <<~EOM
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
EOM
end
it "knife download of the entire data bag downloads everything" do
- knife("download /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
+ knife("download /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download --purge of the entire data bag downloads everything" do
- knife("download --purge /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("download --purge /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -383,21 +383,21 @@ EOM
cwd "data_bags"
end
it "knife download fails" do
- knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/
+ knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/
end
it "knife download --purge . downloads everything" do
- knife("download --purge .").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("download --purge .").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
it "knife download --purge * downloads everything" do
- knife("download --purge *").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("download --purge *").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -418,47 +418,47 @@ EOM
it "knife download of a modified file succeeds" do
knife("download /cookbooks/x/metadata.rb").should_succeed "Updated /cookbooks/x/metadata.rb\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x/y.rb
-A\t/cookbooks/x/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x/y.rb
+ A\t/cookbooks/x/z.rb
EOM
end
it "knife download of a deleted file does nothing" do
knife("download /cookbooks/x/z.rb").should_succeed ""
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/y.rb
-A\t/cookbooks/x/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/y.rb
+ A\t/cookbooks/x/z.rb
EOM
end
it "knife download --purge of a deleted file succeeds" do
knife("download --purge /cookbooks/x/z.rb").should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/y.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/y.rb
EOM
end
it "knife download of an added file succeeds" do
knife("download /cookbooks/x/y.rb").should_succeed "Created /cookbooks/x/y.rb\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-A\t/cookbooks/x/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ A\t/cookbooks/x/z.rb
EOM
end
it "knife download of the cookbook itself succeeds" do
- knife("download /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/metadata.rb
-Created /cookbooks/x/y.rb
+ knife("download /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/metadata.rb
+ Created /cookbooks/x/y.rb
EOM
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-A\t/cookbooks/x/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ A\t/cookbooks/x/z.rb
EOM
end
it "knife download --purge of the cookbook itself succeeds" do
- knife("download --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/metadata.rb
-Created /cookbooks/x/y.rb
-Deleted extra entry /cookbooks/x/z.rb (purge is on)
+ knife("download --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/metadata.rb
+ Created /cookbooks/x/y.rb
+ Deleted extra entry /cookbooks/x/z.rb (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -478,10 +478,10 @@ EOM
end
it "knife download /cookbooks/x downloads the latest version" do
- knife("download --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/metadata.rb
-Created /cookbooks/x/onlyin1.0.1.rb
-Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+ knife("download --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/metadata.rb
+ Created /cookbooks/x/onlyin1.0.1.rb
+ Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -494,8 +494,8 @@ EOM
end
it "knife download /cookbooks/x downloads the updated file" do
- knife("download --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/onlyin1.0.0.rb
+ knife("download --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/onlyin1.0.0.rb
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -507,10 +507,10 @@ EOM
end
it "knife download /cookbooks/x downloads the latest version" do
- knife("download --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/metadata.rb
-Created /cookbooks/x/onlyin1.0.1.rb
-Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+ knife("download --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/metadata.rb
+ Created /cookbooks/x/onlyin1.0.1.rb
+ Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -522,10 +522,10 @@ EOM
end
it "knife download /cookbooks/x downloads the old version" do
- knife("download --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x/metadata.rb
-Created /cookbooks/x/onlyin0.9.9.rb
-Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+ knife("download --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x/metadata.rb
+ Created /cookbooks/x/onlyin0.9.9.rb
+ Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -538,14 +538,14 @@ EOM
end
when_the_repository "has the role in ruby" do
before do
- file "roles/x.rb", <<EOM
-name "x"
-description "x"
+ file "roles/x.rb", <<~EOM
+ name "x"
+ description "x"
EOM
end
it "knife download refuses to change the role" do
- knife("download /roles/x.json").should_succeed "", :stderr => "WARNING: /roles/x.rb cannot be updated (can't safely update ruby files).\n"
+ knife("download /roles/x.json").should_succeed "", stderr: "WARNING: /roles/x.rb cannot be updated (can't safely update ruby files).\n"
knife("diff --name-status /roles/x.json").should_succeed "M\t/roles/x.rb\n"
end
end
@@ -560,13 +560,13 @@ EOM
file "environments/x.json", "{"
end
it "knife download succeeds" do
- warning = <<-EOH
-WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
- {
- (right here) ------^
+ warning = <<~EOH
+ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ {
+ (right here) ------^
EOH
- knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", :stderr => warning
+ knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", stderr: warning
knife("diff --name-status /environments/x.json").should_succeed ""
end
end
@@ -617,20 +617,20 @@ EOH
end
it "knife download downloads everything" do
- knife("download /").should_succeed <<EOM
-Created /clients/chef-validator.json
-Created /clients/chef-webui.json
-Created /clients/x.json
-Created /cookbooks/x-1.0.0
-Created /cookbooks/x-1.0.0/metadata.rb
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments/_default.json
-Created /environments/x.json
-Created /nodes/x.json
-Created /roles/x.json
-Created /users/admin.json
-Created /users/x.json
+ knife("download /").should_succeed <<~EOM
+ Created /clients/chef-validator.json
+ Created /clients/chef-webui.json
+ Created /clients/x.json
+ Created /cookbooks/x-1.0.0
+ Created /cookbooks/x-1.0.0/metadata.rb
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments/_default.json
+ Created /environments/x.json
+ Created /nodes/x.json
+ Created /roles/x.json
+ Created /users/admin.json
+ Created /users/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -674,22 +674,22 @@ EOM
context "except the role file is textually different, but not ACTUALLY different" do
before do
- file "roles/x.json", <<EOM
-{
- "chef_type": "role" ,
- "default_attributes": {
- },
- "env_run_lists": {
- },
- "json_class": "Chef::Role",
- "name": "x",
- "description": "",
- "override_attributes": {
- },
- "run_list": [
-
- ]
-}
+ file "roles/x.json", <<~EOM
+ {
+ "chef_type": "role" ,
+ "default_attributes": {
+ },
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "description": "",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -715,32 +715,32 @@ EOM
it "knife download does nothing" do
knife("download /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-A\t/clients/y.json
-A\t/cookbooks/x-1.0.0/blah.rb
-A\t/cookbooks/x-2.0.0
-A\t/cookbooks/y-1.0.0
-A\t/data_bags/x/z.json
-A\t/data_bags/y
-A\t/environments/y.json
-A\t/nodes/y.json
-A\t/roles/y.json
-A\t/users/y.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ A\t/clients/y.json
+ A\t/cookbooks/x-1.0.0/blah.rb
+ A\t/cookbooks/x-2.0.0
+ A\t/cookbooks/y-1.0.0
+ A\t/data_bags/x/z.json
+ A\t/data_bags/y
+ A\t/environments/y.json
+ A\t/nodes/y.json
+ A\t/roles/y.json
+ A\t/users/y.json
EOM
end
it "knife download --purge deletes the extra files" do
- knife("download --purge /").should_succeed <<EOM
-Deleted extra entry /clients/y.json (purge is on)
-Deleted extra entry /cookbooks/x-1.0.0/blah.rb (purge is on)
-Deleted extra entry /cookbooks/x-2.0.0 (purge is on)
-Deleted extra entry /cookbooks/y-1.0.0 (purge is on)
-Deleted extra entry /data_bags/x/z.json (purge is on)
-Deleted extra entry /data_bags/y (purge is on)
-Deleted extra entry /environments/y.json (purge is on)
-Deleted extra entry /nodes/y.json (purge is on)
-Deleted extra entry /roles/y.json (purge is on)
-Deleted extra entry /users/y.json (purge is on)
+ knife("download --purge /").should_succeed <<~EOM
+ Deleted extra entry /clients/y.json (purge is on)
+ Deleted extra entry /cookbooks/x-1.0.0/blah.rb (purge is on)
+ Deleted extra entry /cookbooks/x-2.0.0 (purge is on)
+ Deleted extra entry /cookbooks/y-1.0.0 (purge is on)
+ Deleted extra entry /data_bags/x/z.json (purge is on)
+ Deleted extra entry /data_bags/y (purge is on)
+ Deleted extra entry /environments/y.json (purge is on)
+ Deleted extra entry /nodes/y.json (purge is on)
+ Deleted extra entry /roles/y.json (purge is on)
+ Deleted extra entry /users/y.json (purge is on)
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -749,27 +749,27 @@ EOM
when_the_repository "is empty" do
it "knife download creates the extra files" do
- knife("download /").should_succeed <<EOM
-Created /clients
-Created /clients/chef-validator.json
-Created /clients/chef-webui.json
-Created /clients/x.json
-Created /cookbooks
-Created /cookbooks/x-1.0.0
-Created /cookbooks/x-1.0.0/metadata.rb
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments
-Created /environments/_default.json
-Created /environments/x.json
-Created /nodes
-Created /nodes/x.json
-Created /roles
-Created /roles/x.json
-Created /users
-Created /users/admin.json
-Created /users/x.json
+ knife("download /").should_succeed <<~EOM
+ Created /clients
+ Created /clients/chef-validator.json
+ Created /clients/chef-webui.json
+ Created /clients/x.json
+ Created /cookbooks
+ Created /cookbooks/x-1.0.0
+ Created /cookbooks/x-1.0.0/metadata.rb
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments
+ Created /environments/_default.json
+ Created /environments/x.json
+ Created /nodes
+ Created /nodes/x.json
+ Created /roles
+ Created /roles/x.json
+ Created /users
+ Created /users/admin.json
+ Created /users/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -779,7 +779,7 @@ EOM
cwd "."
end
it "knife download with no parameters reports an error" do
- knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/
+ knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/
end
end
end
@@ -793,13 +793,13 @@ EOM
end
it "knife download of one data bag item itself succeeds" do
- knife("download /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("download /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/z.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/z.json
EOM
end
end
@@ -807,20 +807,20 @@ EOM
when_the_repository "has three data bag items" do
before do
- file "data_bags/x/deleted.json", <<EOM
-{
- "id": "deleted"
-}
+ file "data_bags/x/deleted.json", <<~EOM
+ {
+ "id": "deleted"
+ }
EOM
- file "data_bags/x/modified.json", <<EOM
-{
- "id": "modified"
-}
+ file "data_bags/x/modified.json", <<~EOM
+ {
+ "id": "modified"
+ }
EOM
- file "data_bags/x/unmodified.json", <<EOM
-{
- "id": "unmodified"
-}
+ file "data_bags/x/unmodified.json", <<~EOM
+ {
+ "id": "unmodified"
+ }
EOM
end
@@ -834,62 +834,62 @@ EOM
end
it "knife download of the modified file succeeds" do
- knife("download /data_bags/x/modified.json").should_succeed <<EOM
-Updated /data_bags/x/modified.json
+ knife("download /data_bags/x/modified.json").should_succeed <<~EOM
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the unmodified file does nothing" do
knife("download /data_bags/x/unmodified.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the added file succeeds" do
- knife("download /data_bags/x/added.json").should_succeed <<EOM
-Created /data_bags/x/added.json
+ knife("download /data_bags/x/added.json").should_succeed <<~EOM
+ Created /data_bags/x/added.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download of the deleted file does nothing" do
knife("download /data_bags/x/deleted.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download --purge of the deleted file deletes it" do
- knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("download --purge /data_bags/x/deleted.json").should_succeed <<~EOM
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/added.json
-M\t/data_bags/x/modified.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/added.json
+ M\t/data_bags/x/modified.json
EOM
end
it "knife download of the entire data bag downloads everything" do
- knife("download /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
+ knife("download /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-A\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ A\t/data_bags/x/deleted.json
EOM
end
it "knife download --purge of the entire data bag downloads everything" do
- knife("download --purge /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("download --purge /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -898,21 +898,21 @@ EOM
cwd "data_bags"
end
it "knife download fails" do
- knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", :stdout => /USAGE/
+ knife("download").should_fail "FATAL: You must specify at least one argument. If you want to download everything in this directory, run \"knife download .\"\n", stdout: /USAGE/
end
it "knife download --purge . downloads everything" do
- knife("download --purge .").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("download --purge .").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
it "knife download --purge * downloads everything" do
- knife("download --purge *").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("download --purge *").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -933,47 +933,47 @@ EOM
it "knife download of a modified file succeeds" do
knife("download /cookbooks/x-1.0.0/metadata.rb").should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x-1.0.0/y.rb
-A\t/cookbooks/x-1.0.0/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x-1.0.0/y.rb
+ A\t/cookbooks/x-1.0.0/z.rb
EOM
end
it "knife download of a deleted file does nothing" do
knife("download /cookbooks/x-1.0.0/z.rb").should_succeed ""
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x-1.0.0/metadata.rb
-D\t/cookbooks/x-1.0.0/y.rb
-A\t/cookbooks/x-1.0.0/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x-1.0.0/metadata.rb
+ D\t/cookbooks/x-1.0.0/y.rb
+ A\t/cookbooks/x-1.0.0/z.rb
EOM
end
it "knife download --purge of a deleted file succeeds" do
knife("download --purge /cookbooks/x-1.0.0/z.rb").should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x-1.0.0/metadata.rb
-D\t/cookbooks/x-1.0.0/y.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x-1.0.0/metadata.rb
+ D\t/cookbooks/x-1.0.0/y.rb
EOM
end
it "knife download of an added file succeeds" do
knife("download /cookbooks/x-1.0.0/y.rb").should_succeed "Created /cookbooks/x-1.0.0/y.rb\n"
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x-1.0.0/metadata.rb
-A\t/cookbooks/x-1.0.0/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x-1.0.0/metadata.rb
+ A\t/cookbooks/x-1.0.0/z.rb
EOM
end
it "knife download of the cookbook itself succeeds" do
- knife("download /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0/metadata.rb
-Created /cookbooks/x-1.0.0/y.rb
+ knife("download /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0/metadata.rb
+ Created /cookbooks/x-1.0.0/y.rb
EOM
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-A\t/cookbooks/x-1.0.0/z.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ A\t/cookbooks/x-1.0.0/z.rb
EOM
end
it "knife download --purge of the cookbook itself succeeds" do
- knife("download --purge /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0/metadata.rb
-Created /cookbooks/x-1.0.0/y.rb
-Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)
+ knife("download --purge /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0/metadata.rb
+ Created /cookbooks/x-1.0.0/y.rb
+ Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -993,11 +993,11 @@ EOM
end
it "knife download /cookbooks/x downloads the latest version" do
- knife("download --purge /cookbooks").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb
-Created /cookbooks/x-1.0.1
-Created /cookbooks/x-1.0.1/metadata.rb
-Created /cookbooks/x-1.0.1/onlyin1.0.1.rb
+ knife("download --purge /cookbooks").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb
+ Created /cookbooks/x-1.0.1
+ Created /cookbooks/x-1.0.1/metadata.rb
+ Created /cookbooks/x-1.0.1/onlyin1.0.1.rb
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1010,11 +1010,11 @@ EOM
end
it "knife download /cookbooks downloads the updated file" do
- knife("download --purge /cookbooks").should_succeed <<EOM
-Created /cookbooks/x-0.9.9
-Created /cookbooks/x-0.9.9/metadata.rb
-Created /cookbooks/x-0.9.9/onlyin0.9.9.rb
-Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb
+ knife("download --purge /cookbooks").should_succeed <<~EOM
+ Created /cookbooks/x-0.9.9
+ Created /cookbooks/x-0.9.9/metadata.rb
+ Created /cookbooks/x-0.9.9/onlyin0.9.9.rb
+ Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1026,11 +1026,11 @@ EOM
end
it "knife download /cookbooks/x downloads the latest version" do
- knife("download --purge /cookbooks").should_succeed <<EOM
-Created /cookbooks/x-1.0.1
-Created /cookbooks/x-1.0.1/metadata.rb
-Created /cookbooks/x-1.0.1/onlyin1.0.1.rb
-Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
+ knife("download --purge /cookbooks").should_succeed <<~EOM
+ Created /cookbooks/x-1.0.1
+ Created /cookbooks/x-1.0.1/metadata.rb
+ Created /cookbooks/x-1.0.1/onlyin1.0.1.rb
+ Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1042,11 +1042,11 @@ EOM
end
it "knife download --purge /cookbooks downloads the old version and deletes the new version" do
- knife("download --purge /cookbooks").should_succeed <<EOM
-Created /cookbooks/x-0.9.9
-Created /cookbooks/x-0.9.9/metadata.rb
-Created /cookbooks/x-0.9.9/onlyin0.9.9.rb
-Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
+ knife("download --purge /cookbooks").should_succeed <<~EOM
+ Created /cookbooks/x-0.9.9
+ Created /cookbooks/x-0.9.9/metadata.rb
+ Created /cookbooks/x-0.9.9/onlyin0.9.9.rb
+ Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1102,16 +1102,16 @@ EOM
new_result
}.at_least(:once)
- knife("download /cookbooks/x").should_succeed <<EOM
-Created /cookbooks
-Created /cookbooks/x
-Created /cookbooks/x/metadata.rb
+ knife("download /cookbooks/x").should_succeed <<~EOM
+ Created /cookbooks
+ Created /cookbooks/x
+ Created /cookbooks/x/metadata.rb
EOM
end
end
end
- when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do
+ when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do
before do
user "foo", {}
user "bar", {}
@@ -1125,70 +1125,70 @@ EOM
when_the_repository "has all the default stuff" do
before do
- knife("download /").should_succeed <<EOM
-Created /acls
-Created /acls/clients
-Created /acls/clients/foo-validator.json
-Created /acls/containers
-Created /acls/containers/clients.json
-Created /acls/containers/containers.json
-Created /acls/containers/cookbook_artifacts.json
-Created /acls/containers/cookbooks.json
-Created /acls/containers/data.json
-Created /acls/containers/environments.json
-Created /acls/containers/groups.json
-Created /acls/containers/nodes.json
-Created /acls/containers/policies.json
-Created /acls/containers/policy_groups.json
-Created /acls/containers/roles.json
-Created /acls/containers/sandboxes.json
-Created /acls/cookbook_artifacts
-Created /acls/cookbooks
-Created /acls/data_bags
-Created /acls/environments
-Created /acls/environments/_default.json
-Created /acls/groups
-Created /acls/groups/admins.json
-Created /acls/groups/billing-admins.json
-Created /acls/groups/clients.json
-Created /acls/groups/users.json
-Created /acls/nodes
-Created /acls/policies
-Created /acls/policy_groups
-Created /acls/roles
-Created /acls/organization.json
-Created /clients
-Created /clients/foo-validator.json
-Created /containers
-Created /containers/clients.json
-Created /containers/containers.json
-Created /containers/cookbook_artifacts.json
-Created /containers/cookbooks.json
-Created /containers/data.json
-Created /containers/environments.json
-Created /containers/groups.json
-Created /containers/nodes.json
-Created /containers/policies.json
-Created /containers/policy_groups.json
-Created /containers/roles.json
-Created /containers/sandboxes.json
-Created /cookbook_artifacts
-Created /cookbooks
-Created /data_bags
-Created /environments
-Created /environments/_default.json
-Created /groups
-Created /groups/admins.json
-Created /groups/billing-admins.json
-Created /groups/clients.json
-Created /groups/users.json
-Created /invitations.json
-Created /members.json
-Created /nodes
-Created /org.json
-Created /policies
-Created /policy_groups
-Created /roles
+ knife("download /").should_succeed <<~EOM
+ Created /acls
+ Created /acls/clients
+ Created /acls/clients/foo-validator.json
+ Created /acls/containers
+ Created /acls/containers/clients.json
+ Created /acls/containers/containers.json
+ Created /acls/containers/cookbook_artifacts.json
+ Created /acls/containers/cookbooks.json
+ Created /acls/containers/data.json
+ Created /acls/containers/environments.json
+ Created /acls/containers/groups.json
+ Created /acls/containers/nodes.json
+ Created /acls/containers/policies.json
+ Created /acls/containers/policy_groups.json
+ Created /acls/containers/roles.json
+ Created /acls/containers/sandboxes.json
+ Created /acls/cookbook_artifacts
+ Created /acls/cookbooks
+ Created /acls/data_bags
+ Created /acls/environments
+ Created /acls/environments/_default.json
+ Created /acls/groups
+ Created /acls/groups/admins.json
+ Created /acls/groups/billing-admins.json
+ Created /acls/groups/clients.json
+ Created /acls/groups/users.json
+ Created /acls/nodes
+ Created /acls/policies
+ Created /acls/policy_groups
+ Created /acls/roles
+ Created /acls/organization.json
+ Created /clients
+ Created /clients/foo-validator.json
+ Created /containers
+ Created /containers/clients.json
+ Created /containers/containers.json
+ Created /containers/cookbook_artifacts.json
+ Created /containers/cookbooks.json
+ Created /containers/data.json
+ Created /containers/environments.json
+ Created /containers/groups.json
+ Created /containers/nodes.json
+ Created /containers/policies.json
+ Created /containers/policy_groups.json
+ Created /containers/roles.json
+ Created /containers/sandboxes.json
+ Created /cookbook_artifacts
+ Created /cookbooks
+ Created /data_bags
+ Created /environments
+ Created /environments/_default.json
+ Created /groups
+ Created /groups/admins.json
+ Created /groups/billing-admins.json
+ Created /groups/clients.json
+ Created /groups/users.json
+ Created /invitations.json
+ Created /members.json
+ Created /nodes
+ Created /org.json
+ Created /policies
+ Created /policy_groups
+ Created /roles
EOM
end
@@ -1217,43 +1217,43 @@ EOM
end
before do
- knife("download /acls /groups/clients.json /groups/users.json").should_succeed <<-EOM
-Created /acls/clients/x.json
-Created /acls/containers/x.json
-Created /acls/cookbook_artifacts/x.json
-Created /acls/cookbooks/x.json
-Created /acls/data_bags/x.json
-Created /acls/environments/x.json
-Created /acls/groups/x.json
-Created /acls/nodes/x.json
-Created /acls/policies/blah.json
-Created /acls/policies/x.json
-Created /acls/policy_groups/x.json
-Created /acls/roles/x.json
-Updated /groups/clients.json
-Updated /groups/users.json
+ knife("download /acls /groups/clients.json /groups/users.json").should_succeed <<~EOM
+ Created /acls/clients/x.json
+ Created /acls/containers/x.json
+ Created /acls/cookbook_artifacts/x.json
+ Created /acls/cookbooks/x.json
+ Created /acls/data_bags/x.json
+ Created /acls/environments/x.json
+ Created /acls/groups/x.json
+ Created /acls/nodes/x.json
+ Created /acls/policies/blah.json
+ Created /acls/policies/x.json
+ Created /acls/policy_groups/x.json
+ Created /acls/roles/x.json
+ Updated /groups/clients.json
+ Updated /groups/users.json
EOM
end
it "knife download / downloads everything" do
- knife("download /").should_succeed <<EOM
-Created /clients/x.json
-Created /containers/x.json
-Created /cookbook_artifacts/x-1x1
-Created /cookbook_artifacts/x-1x1/metadata.rb
-Created /cookbooks/x
-Created /cookbooks/x/metadata.rb
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments/x.json
-Created /groups/x.json
-Updated /invitations.json
-Updated /members.json
-Created /nodes/x.json
-Created /policies/blah-1.0.0.json
-Created /policies/x-1.0.0.json
-Created /policy_groups/x.json
-Created /roles/x.json
+ knife("download /").should_succeed <<~EOM
+ Created /clients/x.json
+ Created /containers/x.json
+ Created /cookbook_artifacts/x-1x1
+ Created /cookbook_artifacts/x-1x1/metadata.rb
+ Created /cookbooks/x
+ Created /cookbooks/x/metadata.rb
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments/x.json
+ Created /groups/x.json
+ Updated /invitations.json
+ Updated /members.json
+ Created /nodes/x.json
+ Created /policies/blah-1.0.0.json
+ Created /policies/x-1.0.0.json
+ Created /policy_groups/x.json
+ Created /roles/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -1308,21 +1308,21 @@ EOM
end
it "knife download updates everything" do
- knife("download /").should_succeed <<EOM
-Updated /clients/x.json
-Updated /cookbook_artifacts/x-1x1/metadata.rb
-Updated /cookbooks/x/metadata.rb
-Updated /data_bags/x/y.json
-Updated /environments/x.json
-Updated /groups/x.json
-Updated /invitations.json
-Updated /members.json
-Updated /nodes/x.json
-Updated /org.json
-Created /policies/blah-1.0.0.json
-Updated /policies/x-1.0.0.json
-Updated /policy_groups/x.json
-Updated /roles/x.json
+ knife("download /").should_succeed <<~EOM
+ Updated /clients/x.json
+ Updated /cookbook_artifacts/x-1x1/metadata.rb
+ Updated /cookbooks/x/metadata.rb
+ Updated /data_bags/x/y.json
+ Updated /environments/x.json
+ Updated /groups/x.json
+ Updated /invitations.json
+ Updated /members.json
+ Updated /nodes/x.json
+ Updated /org.json
+ Created /policies/blah-1.0.0.json
+ Updated /policies/x-1.0.0.json
+ Updated /policy_groups/x.json
+ Updated /roles/x.json
EOM
knife("diff --name-status /").should_succeed ""
end
diff --git a/spec/integration/knife/environment_compare_spec.rb b/spec/integration/knife/environment_compare_spec.rb
index 720bead8c0..d3999fffa3 100644
--- a/spec/integration/knife/environment_compare_spec.rb
+++ b/spec/integration/knife/environment_compare_spec.rb
@@ -44,29 +44,29 @@ describe "knife environment compare", :workstation do
# rubocop:disable Layout/TrailingWhitespace
it "displays the cookbooks for a single environment" do
- knife("environment compare x").should_succeed <<EOM
- x
-blah = 1.0.0
-krad >= 1.0.0
-
+ knife("environment compare x").should_succeed <<~EOM
+ x
+ blah = 1.0.0
+ krad >= 1.0.0
+
EOM
end
it "compares the cookbooks for two environments" do
- knife("environment compare x y").should_succeed <<EOM
- x y
-blah = 1.0.0 = 1.1.0
-krad >= 1.0.0 >= 1.0.0
-
+ knife("environment compare x y").should_succeed <<~EOM
+ x y
+ blah = 1.0.0 = 1.1.0
+ krad >= 1.0.0 >= 1.0.0
+
EOM
end
it "compares the cookbooks for all environments" do
- knife("environment compare --all").should_succeed <<EOM
- x y
-blah = 1.0.0 = 1.1.0
-krad >= 1.0.0 >= 1.0.0
-
+ knife("environment compare --all").should_succeed <<~EOM
+ x y
+ blah = 1.0.0 = 1.1.0
+ krad >= 1.0.0 >= 1.0.0
+
EOM
end
# rubocop:enable Layout/TrailingWhitespace
diff --git a/spec/integration/knife/environment_from_file_spec.rb b/spec/integration/knife/environment_from_file_spec.rb
index 67d4373939..8948a3772c 100644
--- a/spec/integration/knife/environment_from_file_spec.rb
+++ b/spec/integration/knife/environment_from_file_spec.rb
@@ -29,84 +29,84 @@ describe "knife environment from file", :workstation do
when_the_repository "has some environments" do
before do
- file "environments/cons.json", <<EOM
-{
- "name": "cons",
- "description": "An environment",
- "cookbook_versions": {
-
- },
- "json_class": "Chef::Environment",
- "chef_type": "environment",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
-
- }
-}
+ file "environments/cons.json", <<~EOM
+ {
+ "name": "cons",
+ "description": "An environment",
+ "cookbook_versions": {
+
+ },
+ "json_class": "Chef::Environment",
+ "chef_type": "environment",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
+
+ }
+ }
EOM
- file "environments/car.json", <<EOM
-{
- "name": "car",
- "description": "An environment for list nodes",
- "cookbook_versions": {
-
- },
- "json_class": "Chef::Environment",
- "chef_type": "environment",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
-
- }
-}
+ file "environments/car.json", <<~EOM
+ {
+ "name": "car",
+ "description": "An environment for list nodes",
+ "cookbook_versions": {
+
+ },
+ "json_class": "Chef::Environment",
+ "chef_type": "environment",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
+
+ }
+ }
EOM
- file "environments/cdr.json", <<EOM
-{
- "name": "cdr",
- "description": "An environment for last nodes",
- "cookbook_versions": {
-
- },
- "json_class": "Chef::Environment",
- "chef_type": "environment",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
-
- }
-}
+ file "environments/cdr.json", <<~EOM
+ {
+ "name": "cdr",
+ "description": "An environment for last nodes",
+ "cookbook_versions": {
+
+ },
+ "json_class": "Chef::Environment",
+ "chef_type": "environment",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
+
+ }
+ }
EOM
end
it "uploads a single file" do
- knife("environment from file #{env_dir}/cons.json").should_succeed stderr: <<EOM
-Updated Environment cons
+ knife("environment from file #{env_dir}/cons.json").should_succeed stderr: <<~EOM
+ Updated Environment cons
EOM
end
it "uploads many files" do
- knife("environment from file #{env_dir}/cons.json #{env_dir}/car.json #{env_dir}/cdr.json").should_succeed stderr: <<EOM
-Updated Environment cons
-Updated Environment car
-Updated Environment cdr
+ knife("environment from file #{env_dir}/cons.json #{env_dir}/car.json #{env_dir}/cdr.json").should_succeed stderr: <<~EOM
+ Updated Environment cons
+ Updated Environment car
+ Updated Environment cdr
EOM
end
it "uploads all environments in the repository" do
cwd(".")
knife("environment from file --all")
- knife("environment list").should_succeed <<EOM
-_default
-car
-cdr
-cons
+ knife("environment list").should_succeed <<~EOM
+ _default
+ car
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/environment_list_spec.rb b/spec/integration/knife/environment_list_spec.rb
index 5e74453d1f..0ac2df6300 100644
--- a/spec/integration/knife/environment_list_spec.rb
+++ b/spec/integration/knife/environment_list_spec.rb
@@ -30,10 +30,10 @@ describe "knife environment list", :workstation do
end
it "lists all the environments" do
- knife("environment list").should_succeed <<EOM
-_default
-b
-y
+ knife("environment list").should_succeed <<~EOM
+ _default
+ b
+ y
EOM
end
diff --git a/spec/integration/knife/environment_show_spec.rb b/spec/integration/knife/environment_show_spec.rb
index dabdfac6a2..fdf41e70ce 100644
--- a/spec/integration/knife/environment_show_spec.rb
+++ b/spec/integration/knife/environment_show_spec.rb
@@ -32,44 +32,44 @@ describe "knife environment show", :workstation do
# rubocop:disable Layout/TrailingWhitespace
it "shows an environment" do
- knife("environment show b").should_succeed <<EOM
-chef_type: environment
-cookbook_versions:
-default_attributes:
- baz:
- raz.my: mataz
- foo: bar
-description:
-json_class: Chef::Environment
-name: b
-override_attributes:
+ knife("environment show b").should_succeed <<~EOM
+ chef_type: environment
+ cookbook_versions:
+ default_attributes:
+ baz:
+ raz.my: mataz
+ foo: bar
+ description:
+ json_class: Chef::Environment
+ name: b
+ override_attributes:
EOM
end
# rubocop:enable Layout/TrailingWhitespace
it "shows the requested attribute of an environment" do
- knife("environment show b -a default_attributes").should_succeed <<EOM
-b:
- default_attributes:
- baz:
- raz.my: mataz
- foo: bar
+ knife("environment show b -a default_attributes").should_succeed <<~EOM
+ b:
+ default_attributes:
+ baz:
+ raz.my: mataz
+ foo: bar
EOM
end
it "shows the requested nested attribute of an environment" do
- knife("environment show b -a default_attributes.baz").should_succeed <<EON
-b:
- default_attributes.baz:
- raz.my: mataz
+ knife("environment show b -a default_attributes.baz").should_succeed <<~EON
+ b:
+ default_attributes.baz:
+ raz.my: mataz
EON
end
it "shows the requested attribute of an environment with custom field separator" do
- knife("environment show b -S: -a default_attributes:baz").should_succeed <<EOT
-b:
- default_attributes:baz:
- raz.my: mataz
+ knife("environment show b -S: -a default_attributes:baz").should_succeed <<~EOT
+ b:
+ default_attributes:baz:
+ raz.my: mataz
EOT
end
end
diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb
index 4aa74f3f0e..39a3f77fc5 100644
--- a/spec/integration/knife/list_spec.rb
+++ b/spec/integration/knife/list_spec.rb
@@ -27,45 +27,45 @@ describe "knife list", :workstation do
when_the_chef_server "is empty" do
it "knife list / returns all top level directories" do
- knife("list /").should_succeed <<-EOM
-/clients
-/cookbooks
-/data_bags
-/environments
-/nodes
-/roles
-/users
+ knife("list /").should_succeed <<~EOM
+ /clients
+ /cookbooks
+ /data_bags
+ /environments
+ /nodes
+ /roles
+ /users
EOM
end
it "knife list -R / returns everything" do
- knife("list -R /").should_succeed <<-EOM
-/:
-clients
-cookbooks
-data_bags
-environments
-nodes
-roles
-users
+ knife("list -R /").should_succeed <<~EOM
+ /:
+ clients
+ cookbooks
+ data_bags
+ environments
+ nodes
+ roles
+ users
-/clients:
-chef-validator.json
-chef-webui.json
+ /clients:
+ chef-validator.json
+ chef-webui.json
-/cookbooks:
+ /cookbooks:
-/data_bags:
+ /data_bags:
-/environments:
-_default.json
+ /environments:
+ _default.json
-/nodes:
+ /nodes:
-/roles:
+ /roles:
-/users:
-admin.json
+ /users:
+ admin.json
EOM
end
end
@@ -92,160 +92,160 @@ EOM
end
it "knife list / returns all top level directories" do
- knife("list /").should_succeed <<-EOM
-/clients
-/cookbooks
-/data_bags
-/environments
-/nodes
-/roles
-/users
+ knife("list /").should_succeed <<~EOM
+ /clients
+ /cookbooks
+ /data_bags
+ /environments
+ /nodes
+ /roles
+ /users
EOM
end
it "knife list -R / returns everything" do
- knife("list -R /").should_succeed <<-EOM
-/:
-clients
-cookbooks
-data_bags
-environments
-nodes
-roles
-users
-
-/clients:
-chef-validator.json
-chef-webui.json
-client1.json
-client2.json
-
-/cookbooks:
-cookbook1
-cookbook2
-
-/cookbooks/cookbook1:
-metadata.rb
-
-/cookbooks/cookbook2:
-metadata.rb
-recipes
-
-/cookbooks/cookbook2/recipes:
-default.rb
-
-/data_bags:
-bag1
-bag2
-
-/data_bags/bag1:
-item1.json
-item2.json
-
-/data_bags/bag2:
-item1.json
-item2.json
-
-/environments:
-_default.json
-environment1.json
-environment2.json
-
-/nodes:
-node1.json
-node2.json
-
-/roles:
-role1.json
-role2.json
-
-/users:
-admin.json
-user1.json
-user2.json
+ knife("list -R /").should_succeed <<~EOM
+ /:
+ clients
+ cookbooks
+ data_bags
+ environments
+ nodes
+ roles
+ users
+
+ /clients:
+ chef-validator.json
+ chef-webui.json
+ client1.json
+ client2.json
+
+ /cookbooks:
+ cookbook1
+ cookbook2
+
+ /cookbooks/cookbook1:
+ metadata.rb
+
+ /cookbooks/cookbook2:
+ metadata.rb
+ recipes
+
+ /cookbooks/cookbook2/recipes:
+ default.rb
+
+ /data_bags:
+ bag1
+ bag2
+
+ /data_bags/bag1:
+ item1.json
+ item2.json
+
+ /data_bags/bag2:
+ item1.json
+ item2.json
+
+ /environments:
+ _default.json
+ environment1.json
+ environment2.json
+
+ /nodes:
+ node1.json
+ node2.json
+
+ /roles:
+ role1.json
+ role2.json
+
+ /users:
+ admin.json
+ user1.json
+ user2.json
EOM
end
it "knife list -R --flat / returns everything" do
- knife("list -R --flat /").should_succeed <<-EOM
-/clients
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/client1.json
-/clients/client2.json
-/cookbooks
-/cookbooks/cookbook1
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes
-/cookbooks/cookbook2/recipes/default.rb
-/data_bags
-/data_bags/bag1
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/nodes
-/nodes/node1.json
-/nodes/node2.json
-/roles
-/roles/role1.json
-/roles/role2.json
-/users
-/users/admin.json
-/users/user1.json
-/users/user2.json
+ knife("list -R --flat /").should_succeed <<~EOM
+ /clients
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/client1.json
+ /clients/client2.json
+ /cookbooks
+ /cookbooks/cookbook1
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes
+ /cookbooks/cookbook2/recipes/default.rb
+ /data_bags
+ /data_bags/bag1
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles
+ /roles/role1.json
+ /roles/role2.json
+ /users
+ /users/admin.json
+ /users/user1.json
+ /users/user2.json
EOM
end
it "knife list -Rfp / returns everything" do
- knife("list -Rfp /").should_succeed <<-EOM
-/clients/
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/client1.json
-/clients/client2.json
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes/
-/cookbooks/cookbook2/recipes/default.rb
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/nodes/
-/nodes/node1.json
-/nodes/node2.json
-/roles/
-/roles/role1.json
-/roles/role2.json
-/users/
-/users/admin.json
-/users/user1.json
-/users/user2.json
+ knife("list -Rfp /").should_succeed <<~EOM
+ /clients/
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/client1.json
+ /clients/client2.json
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes/
+ /cookbooks/cookbook2/recipes/default.rb
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes/
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles/
+ /roles/role1.json
+ /roles/role2.json
+ /users/
+ /users/admin.json
+ /users/user1.json
+ /users/user2.json
EOM
end
it "knife list /cookbooks returns the list of cookbooks" do
- knife("list /cookbooks").should_succeed <<-EOM
-/cookbooks/cookbook1
-/cookbooks/cookbook2
+ knife("list /cookbooks").should_succeed <<~EOM
+ /cookbooks/cookbook1
+ /cookbooks/cookbook2
EOM
end
@@ -254,50 +254,50 @@ EOM
end
it "knife list /**.rb returns all ruby files" do
- knife("list /**.rb").should_succeed <<-EOM
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes/default.rb
+ knife("list /**.rb").should_succeed <<~EOM
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes/default.rb
EOM
end
it "knife list /cookbooks/**.rb returns all ruby files" do
- knife("list /cookbooks/**.rb").should_succeed <<-EOM
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes/default.rb
+ knife("list /cookbooks/**.rb").should_succeed <<~EOM
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes/default.rb
EOM
end
it "knife list /**.json returns all json files" do
- knife("list /**.json").should_succeed <<-EOM
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/client1.json
-/clients/client2.json
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/nodes/node1.json
-/nodes/node2.json
-/roles/role1.json
-/roles/role2.json
-/users/admin.json
-/users/user1.json
-/users/user2.json
+ knife("list /**.json").should_succeed <<~EOM
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/client1.json
+ /clients/client2.json
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles/role1.json
+ /roles/role2.json
+ /users/admin.json
+ /users/user1.json
+ /users/user2.json
EOM
end
it "knife list /data**.json returns all data bag json files" do
- knife("list /data**.json").should_succeed <<-EOM
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
+ knife("list /data**.json").should_succeed <<~EOM
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
EOM
end
@@ -317,40 +317,40 @@ EOM
before { cwd "." }
it "knife list -Rfp returns everything" do
- knife("list -Rfp").should_succeed <<-EOM
-clients/
-clients/chef-validator.json
-clients/chef-webui.json
-clients/client1.json
-clients/client2.json
-cookbooks/
-cookbooks/cookbook1/
-cookbooks/cookbook1/metadata.rb
-cookbooks/cookbook2/
-cookbooks/cookbook2/metadata.rb
-cookbooks/cookbook2/recipes/
-cookbooks/cookbook2/recipes/default.rb
-data_bags/
-data_bags/bag1/
-data_bags/bag1/item1.json
-data_bags/bag1/item2.json
-data_bags/bag2/
-data_bags/bag2/item1.json
-data_bags/bag2/item2.json
-environments/
-environments/_default.json
-environments/environment1.json
-environments/environment2.json
-nodes/
-nodes/node1.json
-nodes/node2.json
-roles/
-roles/role1.json
-roles/role2.json
-users/
-users/admin.json
-users/user1.json
-users/user2.json
+ knife("list -Rfp").should_succeed <<~EOM
+ clients/
+ clients/chef-validator.json
+ clients/chef-webui.json
+ clients/client1.json
+ clients/client2.json
+ cookbooks/
+ cookbooks/cookbook1/
+ cookbooks/cookbook1/metadata.rb
+ cookbooks/cookbook2/
+ cookbooks/cookbook2/metadata.rb
+ cookbooks/cookbook2/recipes/
+ cookbooks/cookbook2/recipes/default.rb
+ data_bags/
+ data_bags/bag1/
+ data_bags/bag1/item1.json
+ data_bags/bag1/item2.json
+ data_bags/bag2/
+ data_bags/bag2/item1.json
+ data_bags/bag2/item2.json
+ environments/
+ environments/_default.json
+ environments/environment1.json
+ environments/environment2.json
+ nodes/
+ nodes/node1.json
+ nodes/node2.json
+ roles/
+ roles/role1.json
+ roles/role2.json
+ users/
+ users/admin.json
+ users/user1.json
+ users/user2.json
EOM
end
end
@@ -362,89 +362,89 @@ EOM
before { cwd "cookbooks" }
it "knife list -Rfp / returns everything" do
- knife("list -Rfp /").should_succeed <<-EOM
-/clients/
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/client1.json
-/clients/client2.json
-./
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/nodes/
-/nodes/node1.json
-/nodes/node2.json
-/roles/
-/roles/role1.json
-/roles/role2.json
-/users/
-/users/admin.json
-/users/user1.json
-/users/user2.json
+ knife("list -Rfp /").should_succeed <<~EOM
+ /clients/
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/client1.json
+ /clients/client2.json
+ ./
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes/
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles/
+ /roles/role1.json
+ /roles/role2.json
+ /users/
+ /users/admin.json
+ /users/user1.json
+ /users/user2.json
EOM
end
it "knife list -Rfp .. returns everything" do
- knife("list -Rfp ..").should_succeed <<-EOM
-/clients/
-/clients/chef-validator.json
-/clients/chef-webui.json
-/clients/client1.json
-/clients/client2.json
-./
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/nodes/
-/nodes/node1.json
-/nodes/node2.json
-/roles/
-/roles/role1.json
-/roles/role2.json
-/users/
-/users/admin.json
-/users/user1.json
-/users/user2.json
+ knife("list -Rfp ..").should_succeed <<~EOM
+ /clients/
+ /clients/chef-validator.json
+ /clients/chef-webui.json
+ /clients/client1.json
+ /clients/client2.json
+ ./
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes/
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles/
+ /roles/role1.json
+ /roles/role2.json
+ /users/
+ /users/admin.json
+ /users/user1.json
+ /users/user2.json
EOM
end
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
EOM
end
end
@@ -457,16 +457,16 @@ EOM
before { cwd "cookbooks/cookbook2" }
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-metadata.rb
-recipes/
-recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ metadata.rb
+ recipes/
+ recipes/default.rb
EOM
end
end
end
- when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", :skip => (Chef::Platform.windows?) do
+ when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (Chef::Platform.windows?) do
before do
directory "cookbooks"
symlink "symlinked", "cookbooks"
@@ -476,13 +476,13 @@ EOM
before { cwd "cookbooks" }
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
EOM
end
end
@@ -491,19 +491,19 @@ EOM
before { cwd "symlinked" }
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
EOM
end
end
end
- when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", :skip => (Chef::Platform.windows?) do
+ when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (Chef::Platform.windows?) do
before do
directory "real_cookbooks"
symlink "cookbooks", "real_cookbooks"
@@ -513,13 +513,13 @@ EOM
before { cwd "real_cookbooks" }
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
EOM
end
end
@@ -528,13 +528,13 @@ EOM
before { cwd "cookbooks" }
it "knife list -Rfp returns cookbooks" do
- knife("list -Rfp").should_succeed <<-EOM
-cookbook1/
-cookbook1/metadata.rb
-cookbook2/
-cookbook2/metadata.rb
-cookbook2/recipes/
-cookbook2/recipes/default.rb
+ knife("list -Rfp").should_succeed <<~EOM
+ cookbook1/
+ cookbook1/metadata.rb
+ cookbook2/
+ cookbook2/metadata.rb
+ cookbook2/recipes/
+ cookbook2/recipes/default.rb
EOM
end
end
@@ -589,36 +589,36 @@ EOM
end
it "knife list -Rfp / returns everything" do
- knife("list -Rp --local --flat /").should_succeed <<-EOM
-/clients/
-/clients/client1.json
-/clients/client2.json
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes/
-/cookbooks/cookbook2/recipes/default.rb
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/
-/environments/environment1.json
-/environments/environment2.json
-/nodes/
-/nodes/node1.json
-/nodes/node2.json
-/roles/
-/roles/role1.json
-/roles/role2.json
-/users/
-/users/user1.json
-/users/user2.json
+ knife("list -Rp --local --flat /").should_succeed <<~EOM
+ /clients/
+ /clients/client1.json
+ /clients/client2.json
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes/
+ /cookbooks/cookbook2/recipes/default.rb
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/
+ /environments/environment1.json
+ /environments/environment2.json
+ /nodes/
+ /nodes/node1.json
+ /nodes/node2.json
+ /roles/
+ /roles/role1.json
+ /roles/role2.json
+ /users/
+ /users/user1.json
+ /users/user2.json
EOM
end
@@ -638,7 +638,7 @@ EOM
end
end
- when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do
+ when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do
before do
organization "foo"
end
@@ -649,253 +649,253 @@ EOM
context "and is empty" do
it "knife list / returns all top level directories" do
- knife("list /").should_succeed <<-EOM
-/acls
-/clients
-/containers
-/cookbook_artifacts
-/cookbooks
-/data_bags
-/environments
-/groups
-/invitations.json
-/members.json
-/nodes
-/org.json
-/policies
-/policy_groups
-/roles
+ knife("list /").should_succeed <<~EOM
+ /acls
+ /clients
+ /containers
+ /cookbook_artifacts
+ /cookbooks
+ /data_bags
+ /environments
+ /groups
+ /invitations.json
+ /members.json
+ /nodes
+ /org.json
+ /policies
+ /policy_groups
+ /roles
EOM
end
it "knife list -R / returns everything" do
- knife("list -R /").should_succeed <<-EOM
-/:
-acls
-clients
-containers
-cookbook_artifacts
-cookbooks
-data_bags
-environments
-groups
-invitations.json
-members.json
-nodes
-org.json
-policies
-policy_groups
-roles
-
-/acls:
-clients
-containers
-cookbook_artifacts
-cookbooks
-data_bags
-environments
-groups
-nodes
-organization.json
-policies
-policy_groups
-roles
-
-/acls/clients:
-foo-validator.json
-
-/acls/containers:
-clients.json
-containers.json
-cookbook_artifacts.json
-cookbooks.json
-data.json
-environments.json
-groups.json
-nodes.json
-policies.json
-policy_groups.json
-roles.json
-sandboxes.json
-
-/acls/cookbook_artifacts:
-
-/acls/cookbooks:
-
-/acls/data_bags:
-
-/acls/environments:
-_default.json
-
-/acls/groups:
-admins.json
-billing-admins.json
-clients.json
-users.json
-
-/acls/nodes:
-
-/acls/policies:
-
-/acls/policy_groups:
-
-/acls/roles:
-
-/clients:
-foo-validator.json
-
-/containers:
-clients.json
-containers.json
-cookbook_artifacts.json
-cookbooks.json
-data.json
-environments.json
-groups.json
-nodes.json
-policies.json
-policy_groups.json
-roles.json
-sandboxes.json
-
-/cookbook_artifacts:
-
-/cookbooks:
-
-/data_bags:
-
-/environments:
-_default.json
-
-/groups:
-admins.json
-billing-admins.json
-clients.json
-users.json
-
-/nodes:
-
-/policies:
-
-/policy_groups:
-
-/roles:
+ knife("list -R /").should_succeed <<~EOM
+ /:
+ acls
+ clients
+ containers
+ cookbook_artifacts
+ cookbooks
+ data_bags
+ environments
+ groups
+ invitations.json
+ members.json
+ nodes
+ org.json
+ policies
+ policy_groups
+ roles
+
+ /acls:
+ clients
+ containers
+ cookbook_artifacts
+ cookbooks
+ data_bags
+ environments
+ groups
+ nodes
+ organization.json
+ policies
+ policy_groups
+ roles
+
+ /acls/clients:
+ foo-validator.json
+
+ /acls/containers:
+ clients.json
+ containers.json
+ cookbook_artifacts.json
+ cookbooks.json
+ data.json
+ environments.json
+ groups.json
+ nodes.json
+ policies.json
+ policy_groups.json
+ roles.json
+ sandboxes.json
+
+ /acls/cookbook_artifacts:
+
+ /acls/cookbooks:
+
+ /acls/data_bags:
+
+ /acls/environments:
+ _default.json
+
+ /acls/groups:
+ admins.json
+ billing-admins.json
+ clients.json
+ users.json
+
+ /acls/nodes:
+
+ /acls/policies:
+
+ /acls/policy_groups:
+
+ /acls/roles:
+
+ /clients:
+ foo-validator.json
+
+ /containers:
+ clients.json
+ containers.json
+ cookbook_artifacts.json
+ cookbooks.json
+ data.json
+ environments.json
+ groups.json
+ nodes.json
+ policies.json
+ policy_groups.json
+ roles.json
+ sandboxes.json
+
+ /cookbook_artifacts:
+
+ /cookbooks:
+
+ /data_bags:
+
+ /environments:
+ _default.json
+
+ /groups:
+ admins.json
+ billing-admins.json
+ clients.json
+ users.json
+
+ /nodes:
+
+ /policies:
+
+ /policy_groups:
+
+ /roles:
EOM
end
end
it "knife list -R / returns everything" do
- knife("list -R /").should_succeed <<-EOM
-/:
-acls
-clients
-containers
-cookbook_artifacts
-cookbooks
-data_bags
-environments
-groups
-invitations.json
-members.json
-nodes
-org.json
-policies
-policy_groups
-roles
-
-/acls:
-clients
-containers
-cookbook_artifacts
-cookbooks
-data_bags
-environments
-groups
-nodes
-organization.json
-policies
-policy_groups
-roles
-
-/acls/clients:
-foo-validator.json
-
-/acls/containers:
-clients.json
-containers.json
-cookbook_artifacts.json
-cookbooks.json
-data.json
-environments.json
-groups.json
-nodes.json
-policies.json
-policy_groups.json
-roles.json
-sandboxes.json
-
-/acls/cookbook_artifacts:
-
-/acls/cookbooks:
-
-/acls/data_bags:
-
-/acls/environments:
-_default.json
-
-/acls/groups:
-admins.json
-billing-admins.json
-clients.json
-users.json
-
-/acls/nodes:
-
-/acls/policies:
-
-/acls/policy_groups:
-
-/acls/roles:
-
-/clients:
-foo-validator.json
-
-/containers:
-clients.json
-containers.json
-cookbook_artifacts.json
-cookbooks.json
-data.json
-environments.json
-groups.json
-nodes.json
-policies.json
-policy_groups.json
-roles.json
-sandboxes.json
-
-/cookbook_artifacts:
-
-/cookbooks:
-
-/data_bags:
-
-/environments:
-_default.json
-
-/groups:
-admins.json
-billing-admins.json
-clients.json
-users.json
-
-/nodes:
-
-/policies:
-
-/policy_groups:
-
-/roles:
+ knife("list -R /").should_succeed <<~EOM
+ /:
+ acls
+ clients
+ containers
+ cookbook_artifacts
+ cookbooks
+ data_bags
+ environments
+ groups
+ invitations.json
+ members.json
+ nodes
+ org.json
+ policies
+ policy_groups
+ roles
+
+ /acls:
+ clients
+ containers
+ cookbook_artifacts
+ cookbooks
+ data_bags
+ environments
+ groups
+ nodes
+ organization.json
+ policies
+ policy_groups
+ roles
+
+ /acls/clients:
+ foo-validator.json
+
+ /acls/containers:
+ clients.json
+ containers.json
+ cookbook_artifacts.json
+ cookbooks.json
+ data.json
+ environments.json
+ groups.json
+ nodes.json
+ policies.json
+ policy_groups.json
+ roles.json
+ sandboxes.json
+
+ /acls/cookbook_artifacts:
+
+ /acls/cookbooks:
+
+ /acls/data_bags:
+
+ /acls/environments:
+ _default.json
+
+ /acls/groups:
+ admins.json
+ billing-admins.json
+ clients.json
+ users.json
+
+ /acls/nodes:
+
+ /acls/policies:
+
+ /acls/policy_groups:
+
+ /acls/roles:
+
+ /clients:
+ foo-validator.json
+
+ /containers:
+ clients.json
+ containers.json
+ cookbook_artifacts.json
+ cookbooks.json
+ data.json
+ environments.json
+ groups.json
+ nodes.json
+ policies.json
+ policy_groups.json
+ roles.json
+ sandboxes.json
+
+ /cookbook_artifacts:
+
+ /cookbooks:
+
+ /data_bags:
+
+ /environments:
+ _default.json
+
+ /groups:
+ admins.json
+ billing-admins.json
+ clients.json
+ users.json
+
+ /nodes:
+
+ /policies:
+
+ /policy_groups:
+
+ /roles:
EOM
end
@@ -931,127 +931,127 @@ EOM
end
it "knife list -Rfp / returns everything" do
- knife("list -Rfp /").should_succeed <<-EOM
-/acls/
-/acls/clients/
-/acls/clients/client1.json
-/acls/clients/client2.json
-/acls/clients/foo-validator.json
-/acls/containers/
-/acls/containers/clients.json
-/acls/containers/container1.json
-/acls/containers/container2.json
-/acls/containers/containers.json
-/acls/containers/cookbook_artifacts.json
-/acls/containers/cookbooks.json
-/acls/containers/data.json
-/acls/containers/environments.json
-/acls/containers/groups.json
-/acls/containers/nodes.json
-/acls/containers/policies.json
-/acls/containers/policy_groups.json
-/acls/containers/roles.json
-/acls/containers/sandboxes.json
-/acls/cookbook_artifacts/
-/acls/cookbook_artifacts/cookbook_artifact1.json
-/acls/cookbook_artifacts/cookbook_artifact2.json
-/acls/cookbooks/
-/acls/cookbooks/cookbook1.json
-/acls/cookbooks/cookbook2.json
-/acls/data_bags/
-/acls/data_bags/bag1.json
-/acls/data_bags/bag2.json
-/acls/environments/
-/acls/environments/_default.json
-/acls/environments/environment1.json
-/acls/environments/environment2.json
-/acls/groups/
-/acls/groups/admins.json
-/acls/groups/billing-admins.json
-/acls/groups/clients.json
-/acls/groups/group1.json
-/acls/groups/group2.json
-/acls/groups/users.json
-/acls/nodes/
-/acls/nodes/node1.json
-/acls/nodes/node2.json
-/acls/organization.json
-/acls/policies/
-/acls/policies/policy1.json
-/acls/policies/policy2.json
-/acls/policy_groups/
-/acls/policy_groups/policy_group1.json
-/acls/policy_groups/policy_group2.json
-/acls/roles/
-/acls/roles/role1.json
-/acls/roles/role2.json
-/clients/
-/clients/client1.json
-/clients/client2.json
-/clients/foo-validator.json
-/containers/
-/containers/clients.json
-/containers/container1.json
-/containers/container2.json
-/containers/containers.json
-/containers/cookbook_artifacts.json
-/containers/cookbooks.json
-/containers/data.json
-/containers/environments.json
-/containers/groups.json
-/containers/nodes.json
-/containers/policies.json
-/containers/policy_groups.json
-/containers/roles.json
-/containers/sandboxes.json
-/cookbook_artifacts/
-/cookbook_artifacts/cookbook_artifact1-1x1/
-/cookbook_artifacts/cookbook_artifact1-1x1/metadata.rb
-/cookbook_artifacts/cookbook_artifact2-2x2/
-/cookbook_artifacts/cookbook_artifact2-2x2/metadata.rb
-/cookbook_artifacts/cookbook_artifact2-2x2/recipes/
-/cookbook_artifacts/cookbook_artifact2-2x2/recipes/default.rb
-/cookbooks/
-/cookbooks/cookbook1/
-/cookbooks/cookbook1/metadata.rb
-/cookbooks/cookbook2/
-/cookbooks/cookbook2/metadata.rb
-/cookbooks/cookbook2/recipes/
-/cookbooks/cookbook2/recipes/default.rb
-/data_bags/
-/data_bags/bag1/
-/data_bags/bag1/item1.json
-/data_bags/bag1/item2.json
-/data_bags/bag2/
-/data_bags/bag2/item1.json
-/data_bags/bag2/item2.json
-/environments/
-/environments/_default.json
-/environments/environment1.json
-/environments/environment2.json
-/groups/
-/groups/admins.json
-/groups/billing-admins.json
-/groups/clients.json
-/groups/group1.json
-/groups/group2.json
-/groups/users.json
-/invitations.json
-/members.json
-/nodes/
-/nodes/node1.json
-/nodes/node2.json
-/org.json
-/policies/
-/policies/policy1-1.2.3.json
-/policies/policy2-1.2.3.json
-/policies/policy2-1.3.5.json
-/policy_groups/
-/policy_groups/policy_group1.json
-/policy_groups/policy_group2.json
-/roles/
-/roles/role1.json
-/roles/role2.json
+ knife("list -Rfp /").should_succeed <<~EOM
+ /acls/
+ /acls/clients/
+ /acls/clients/client1.json
+ /acls/clients/client2.json
+ /acls/clients/foo-validator.json
+ /acls/containers/
+ /acls/containers/clients.json
+ /acls/containers/container1.json
+ /acls/containers/container2.json
+ /acls/containers/containers.json
+ /acls/containers/cookbook_artifacts.json
+ /acls/containers/cookbooks.json
+ /acls/containers/data.json
+ /acls/containers/environments.json
+ /acls/containers/groups.json
+ /acls/containers/nodes.json
+ /acls/containers/policies.json
+ /acls/containers/policy_groups.json
+ /acls/containers/roles.json
+ /acls/containers/sandboxes.json
+ /acls/cookbook_artifacts/
+ /acls/cookbook_artifacts/cookbook_artifact1.json
+ /acls/cookbook_artifacts/cookbook_artifact2.json
+ /acls/cookbooks/
+ /acls/cookbooks/cookbook1.json
+ /acls/cookbooks/cookbook2.json
+ /acls/data_bags/
+ /acls/data_bags/bag1.json
+ /acls/data_bags/bag2.json
+ /acls/environments/
+ /acls/environments/_default.json
+ /acls/environments/environment1.json
+ /acls/environments/environment2.json
+ /acls/groups/
+ /acls/groups/admins.json
+ /acls/groups/billing-admins.json
+ /acls/groups/clients.json
+ /acls/groups/group1.json
+ /acls/groups/group2.json
+ /acls/groups/users.json
+ /acls/nodes/
+ /acls/nodes/node1.json
+ /acls/nodes/node2.json
+ /acls/organization.json
+ /acls/policies/
+ /acls/policies/policy1.json
+ /acls/policies/policy2.json
+ /acls/policy_groups/
+ /acls/policy_groups/policy_group1.json
+ /acls/policy_groups/policy_group2.json
+ /acls/roles/
+ /acls/roles/role1.json
+ /acls/roles/role2.json
+ /clients/
+ /clients/client1.json
+ /clients/client2.json
+ /clients/foo-validator.json
+ /containers/
+ /containers/clients.json
+ /containers/container1.json
+ /containers/container2.json
+ /containers/containers.json
+ /containers/cookbook_artifacts.json
+ /containers/cookbooks.json
+ /containers/data.json
+ /containers/environments.json
+ /containers/groups.json
+ /containers/nodes.json
+ /containers/policies.json
+ /containers/policy_groups.json
+ /containers/roles.json
+ /containers/sandboxes.json
+ /cookbook_artifacts/
+ /cookbook_artifacts/cookbook_artifact1-1x1/
+ /cookbook_artifacts/cookbook_artifact1-1x1/metadata.rb
+ /cookbook_artifacts/cookbook_artifact2-2x2/
+ /cookbook_artifacts/cookbook_artifact2-2x2/metadata.rb
+ /cookbook_artifacts/cookbook_artifact2-2x2/recipes/
+ /cookbook_artifacts/cookbook_artifact2-2x2/recipes/default.rb
+ /cookbooks/
+ /cookbooks/cookbook1/
+ /cookbooks/cookbook1/metadata.rb
+ /cookbooks/cookbook2/
+ /cookbooks/cookbook2/metadata.rb
+ /cookbooks/cookbook2/recipes/
+ /cookbooks/cookbook2/recipes/default.rb
+ /data_bags/
+ /data_bags/bag1/
+ /data_bags/bag1/item1.json
+ /data_bags/bag1/item2.json
+ /data_bags/bag2/
+ /data_bags/bag2/item1.json
+ /data_bags/bag2/item2.json
+ /environments/
+ /environments/_default.json
+ /environments/environment1.json
+ /environments/environment2.json
+ /groups/
+ /groups/admins.json
+ /groups/billing-admins.json
+ /groups/clients.json
+ /groups/group1.json
+ /groups/group2.json
+ /groups/users.json
+ /invitations.json
+ /members.json
+ /nodes/
+ /nodes/node1.json
+ /nodes/node2.json
+ /org.json
+ /policies/
+ /policies/policy1-1.2.3.json
+ /policies/policy2-1.2.3.json
+ /policies/policy2-1.3.5.json
+ /policy_groups/
+ /policy_groups/policy_group1.json
+ /policy_groups/policy_group2.json
+ /roles/
+ /roles/role1.json
+ /roles/role2.json
EOM
end
end
diff --git a/spec/integration/knife/node_bulk_delete_spec.rb b/spec/integration/knife/node_bulk_delete_spec.rb
index fa706cbd2b..501091c0e7 100644
--- a/spec/integration/knife/node_bulk_delete_spec.rb
+++ b/spec/integration/knife/node_bulk_delete_spec.rb
@@ -32,18 +32,18 @@ describe "knife node bulk delete", :workstation do
end
it "deletes all matching nodes" do
- knife("node bulk delete ^ca.*", input: "Y").should_succeed <<EOM
-The following nodes will be deleted:
+ knife("node bulk delete ^ca.*", input: "Y").should_succeed <<~EOM
+ The following nodes will be deleted:
-car cat
+ car cat
-Are you sure you want to delete these nodes? (Y/N) Deleted node car
-Deleted node cat
+ Are you sure you want to delete these nodes? (Y/N) Deleted node car
+ Deleted node cat
EOM
- knife("node list").should_succeed <<EOM
-cdr
-cons
+ knife("node list").should_succeed <<~EOM
+ cdr
+ cons
EOM
end
end
diff --git a/spec/integration/knife/node_delete_spec.rb b/spec/integration/knife/node_delete_spec.rb
index 5d88af6d4f..9d8f382690 100644
--- a/spec/integration/knife/node_delete_spec.rb
+++ b/spec/integration/knife/node_delete_spec.rb
@@ -32,14 +32,14 @@ describe "knife node delete", :workstation do
end
it "deletes a node" do
- knife("node delete car", input: "Y").should_succeed <<EOM
-Do you really want to delete car? (Y/N) Deleted node[car]
+ knife("node delete car", input: "Y").should_succeed <<~EOM
+ Do you really want to delete car? (Y/N) Deleted node[car]
EOM
- knife("node list").should_succeed <<EOM
-cat
-cdr
-cons
+ knife("node list").should_succeed <<~EOM
+ cat
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/node_environment_set_spec.rb b/spec/integration/knife/node_environment_set_spec.rb
index 10fec5723f..09d1828130 100644
--- a/spec/integration/knife/node_environment_set_spec.rb
+++ b/spec/integration/knife/node_environment_set_spec.rb
@@ -31,9 +31,9 @@ describe "knife node environment set", :workstation do
it "sets an environment on a node" do
knife("node environment set cons lisp").should_succeed /chef_environment:.*lisp/
- knife("node show cons -a chef_environment").should_succeed <<EOM
-cons:
- chef_environment: lisp
+ knife("node show cons -a chef_environment").should_succeed <<~EOM
+ cons:
+ chef_environment: lisp
EOM
end
diff --git a/spec/integration/knife/node_from_file_spec.rb b/spec/integration/knife/node_from_file_spec.rb
index 3430967a21..f7a4717e7c 100644
--- a/spec/integration/knife/node_from_file_spec.rb
+++ b/spec/integration/knife/node_from_file_spec.rb
@@ -29,27 +29,27 @@ describe "knife node from file", :workstation do
when_the_repository "has some nodes" do
before do
- file "nodes/cons.json", <<EOM
-{
- "name": "cons",
- "chef_environment": "_default",
- "run_list": [
- "recipe[cons]"
-]
-,
- "normal": {
- "tags": [
-
- ]
- }
-}
+ file "nodes/cons.json", <<~EOM
+ {
+ "name": "cons",
+ "chef_environment": "_default",
+ "run_list": [
+ "recipe[cons]"
+ ]
+ ,
+ "normal": {
+ "tags": [
+
+ ]
+ }
+ }
EOM
end
it "uploads a single file" do
- knife("node from file #{node_dir}/cons.json").should_succeed stderr: <<EOM
-Updated Node cons
+ knife("node from file #{node_dir}/cons.json").should_succeed stderr: <<~EOM
+ Updated Node cons
EOM
end
diff --git a/spec/integration/knife/node_list_spec.rb b/spec/integration/knife/node_list_spec.rb
index 76f5861e03..fd7394f00b 100644
--- a/spec/integration/knife/node_list_spec.rb
+++ b/spec/integration/knife/node_list_spec.rb
@@ -32,11 +32,11 @@ describe "knife node list", :workstation do
end
it "lists all cookbooks" do
- knife("node list").should_succeed <<EOM
-car
-cat
-cdr
-cons
+ knife("node list").should_succeed <<~EOM
+ car
+ cat
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb
index 5e0d3a3d11..1c8239746f 100644
--- a/spec/integration/knife/raw_spec.rb
+++ b/spec/integration/knife/raw_spec.rb
@@ -38,31 +38,31 @@ describe "knife raw", :workstation do
user "x", "{}"
end
- it "knife raw /nodes/x returns the node", :skip => (RUBY_VERSION < "1.9") do
- knife("raw /nodes/x").should_succeed <<EOM
-{
- "name": "x",
- "json_class": "Chef::Node",
- "chef_type": "node",
- "chef_environment": "_default",
- "override": {
-
- },
- "normal": {
- "tags": [
-
- ]
- },
- "default": {
-
- },
- "automatic": {
-
- },
- "run_list": [
-
- ]
-}
+ it "knife raw /nodes/x returns the node", skip: (RUBY_VERSION < "1.9") do
+ knife("raw /nodes/x").should_succeed <<~EOM
+ {
+ "name": "x",
+ "json_class": "Chef::Node",
+ "chef_type": "node",
+ "chef_environment": "_default",
+ "override": {
+
+ },
+ "normal": {
+ "tags": [
+
+ ]
+ },
+ "default": {
+
+ },
+ "automatic": {
+
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -70,116 +70,116 @@ EOM
knife("raw /blarghle").should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/)
end
- it "knife raw -m DELETE /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do
- knife("raw -m DELETE /roles/x").should_succeed <<EOM
-{
- "name": "x",
- "description": "",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
+ it "knife raw -m DELETE /roles/x succeeds", skip: (RUBY_VERSION < "1.9") do
+ knife("raw -m DELETE /roles/x").should_succeed <<~EOM
+ {
+ "name": "x",
+ "description": "",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
- },
- "override_attributes": {
+ },
+ "override_attributes": {
- },
- "run_list": [
+ },
+ "run_list": [
- ],
- "env_run_lists": {
+ ],
+ "env_run_lists": {
- }
-}
+ }
+ }
EOM
knife("show /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n"
end
- it "knife raw -m PUT -i blah.txt /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do
+ it "knife raw -m PUT -i blah.txt /roles/x succeeds", skip: (RUBY_VERSION < "1.9") do
Tempfile.open("raw_put_input") do |file|
- file.write <<EOM
-{
- "name": "x",
- "description": "eek",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
+ file.write <<~EOM
+ {
+ "name": "x",
+ "description": "eek",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
- },
- "override_attributes": {
+ },
+ "override_attributes": {
- },
- "run_list": [
+ },
+ "run_list": [
- ],
- "env_run_lists": {
+ ],
+ "env_run_lists": {
- }
-}
+ }
+ }
EOM
file.close
- knife("raw -m PUT -i #{file.path} /roles/x").should_succeed <<EOM
-{
- "name": "x",
- "description": "eek",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
+ knife("raw -m PUT -i #{file.path} /roles/x").should_succeed <<~EOM
+ {
+ "name": "x",
+ "description": "eek",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
- },
- "override_attributes": {
+ },
+ "override_attributes": {
- },
- "run_list": [
+ },
+ "run_list": [
- ],
- "env_run_lists": {
+ ],
+ "env_run_lists": {
- }
-}
+ }
+ }
EOM
- knife("show /roles/x.json").should_succeed <<EOM
-/roles/x.json:
-{
- "name": "x",
- "description": "eek"
-}
+ knife("show /roles/x.json").should_succeed <<~EOM
+ /roles/x.json:
+ {
+ "name": "x",
+ "description": "eek"
+ }
EOM
end
end
- it "knife raw -m POST -i blah.txt /roles succeeds", :skip => (RUBY_VERSION < "1.9") do
+ it "knife raw -m POST -i blah.txt /roles succeeds", skip: (RUBY_VERSION < "1.9") do
Tempfile.open("raw_put_input") do |file|
- file.write <<EOM
-{
- "name": "y",
- "description": "eek",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
- },
- "override_attributes": {
- },
- "run_list": [
-
- ],
- "env_run_lists": {
- }
-}
+ file.write <<~EOM
+ {
+ "name": "y",
+ "description": "eek",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ],
+ "env_run_lists": {
+ }
+ }
EOM
file.close
- knife("raw -m POST -i #{file.path} /roles").should_succeed <<EOM
-{
- "uri": "#{Chef::Config.chef_server_url}/roles/y"
-}
+ knife("raw -m POST -i #{file.path} /roles").should_succeed <<~EOM
+ {
+ "uri": "#{Chef::Config.chef_server_url}/roles/y"
+ }
EOM
- knife("show /roles/y.json").should_succeed <<EOM
-/roles/y.json:
-{
- "name": "y",
- "description": "eek"
-}
+ knife("show /roles/y.json").should_succeed <<~EOM
+ /roles/y.json:
+ {
+ "name": "y",
+ "description": "eek"
+ }
EOM
end
end
@@ -198,18 +198,18 @@ EOM
@raw_server_thread.kill if @raw_server_thread
end
- it "knife raw /blah returns the prettified json", :skip => (RUBY_VERSION < "1.9") do
- knife("raw /blah").should_succeed <<EOM
-{
- "x": "y",
- "a": "b"
-}
+ it "knife raw /blah returns the prettified json", skip: (RUBY_VERSION < "1.9") do
+ knife("raw /blah").should_succeed <<~EOM
+ {
+ "x": "y",
+ "a": "b"
+ }
EOM
end
it "knife raw --no-pretty /blah returns the raw json" do
- knife("raw --no-pretty /blah").should_succeed <<EOM
-{ "x": "y", "a": "b" }
+ knife("raw --no-pretty /blah").should_succeed <<~EOM
+ { "x": "y", "a": "b" }
EOM
end
end
@@ -229,14 +229,14 @@ EOM
end
it "knife raw /blah returns the raw text" do
- knife("raw /blah").should_succeed(<<EOM)
-{ "x": "y", "a": "b" }
+ knife("raw /blah").should_succeed(<<~EOM)
+ { "x": "y", "a": "b" }
EOM
end
it "knife raw --no-pretty /blah returns the raw text" do
- knife("raw --no-pretty /blah").should_succeed(<<EOM)
-{ "x": "y", "a": "b" }
+ knife("raw --no-pretty /blah").should_succeed(<<~EOM)
+ { "x": "y", "a": "b" }
EOM
end
end
diff --git a/spec/integration/knife/role_bulk_delete_spec.rb b/spec/integration/knife/role_bulk_delete_spec.rb
index 0e7ff941e2..5a88ef282e 100644
--- a/spec/integration/knife/role_bulk_delete_spec.rb
+++ b/spec/integration/knife/role_bulk_delete_spec.rb
@@ -32,18 +32,18 @@ describe "knife role bulk delete", :workstation do
end
it "deletes all matching roles" do
- knife("role bulk delete ^ca.*", input: "Y").should_succeed <<EOM
-The following roles will be deleted:
+ knife("role bulk delete ^ca.*", input: "Y").should_succeed <<~EOM
+ The following roles will be deleted:
-car cat
+ car cat
-Are you sure you want to delete these roles? (Y/N) Deleted role car
-Deleted role cat
+ Are you sure you want to delete these roles? (Y/N) Deleted role car
+ Deleted role cat
EOM
- knife("role list").should_succeed <<EOM
-cdr
-cons
+ knife("role list").should_succeed <<~EOM
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/role_delete_spec.rb b/spec/integration/knife/role_delete_spec.rb
index 9fbd3758b9..875f80cede 100644
--- a/spec/integration/knife/role_delete_spec.rb
+++ b/spec/integration/knife/role_delete_spec.rb
@@ -32,14 +32,14 @@ describe "knife role delete", :workstation do
end
it "deletes a role" do
- knife("role delete car", input: "Y").should_succeed <<EOM
-Do you really want to delete car? (Y/N) Deleted role[car]
+ knife("role delete car", input: "Y").should_succeed <<~EOM
+ Do you really want to delete car? (Y/N) Deleted role[car]
EOM
- knife("role list").should_succeed <<EOM
-cat
-cdr
-cons
+ knife("role list").should_succeed <<~EOM
+ cat
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/role_from_file_spec.rb b/spec/integration/knife/role_from_file_spec.rb
index 60caa3fa88..bc93d0f6e0 100644
--- a/spec/integration/knife/role_from_file_spec.rb
+++ b/spec/integration/knife/role_from_file_spec.rb
@@ -29,64 +29,64 @@ describe "knife role from file", :workstation do
when_the_repository "has some roles" do
before do
- file "roles/cons.json", <<EOM
-{
- "name": "cons",
- "description": "An role",
- "json_class": "Chef::role",
- "chef_type": "role",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
+ file "roles/cons.json", <<~EOM
+ {
+ "name": "cons",
+ "description": "An role",
+ "json_class": "Chef::role",
+ "chef_type": "role",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
- }
-}
+ }
+ }
EOM
- file "roles/car.json", <<EOM
-{
- "name": "car",
- "description": "A role for list nodes",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
+ file "roles/car.json", <<~EOM
+ {
+ "name": "car",
+ "description": "A role for list nodes",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
- }
-}
+ }
+ }
EOM
- file "roles/cdr.json", <<EOM
-{
- "name": "cdr",
- "description": "A role for last nodes",
- "json_class": "Chef::Role",
- "chef_type": "role",
- "default_attributes": {
- "hola": "Amigos!"
- },
- "override_attributes": {
+ file "roles/cdr.json", <<~EOM
+ {
+ "name": "cdr",
+ "description": "A role for last nodes",
+ "json_class": "Chef::Role",
+ "chef_type": "role",
+ "default_attributes": {
+ "hola": "Amigos!"
+ },
+ "override_attributes": {
- }
-}
+ }
+ }
EOM
end
it "uploads a single file" do
- knife("role from file #{role_dir}/cons.json").should_succeed stderr: <<EOM
-Updated Role cons
+ knife("role from file #{role_dir}/cons.json").should_succeed stderr: <<~EOM
+ Updated Role cons
EOM
end
it "uploads many files" do
- knife("role from file #{role_dir}/cons.json #{role_dir}/car.json #{role_dir}/cdr.json").should_succeed stderr: <<EOM
-Updated Role cons
-Updated Role car
-Updated Role cdr
+ knife("role from file #{role_dir}/cons.json #{role_dir}/car.json #{role_dir}/cdr.json").should_succeed stderr: <<~EOM
+ Updated Role cons
+ Updated Role car
+ Updated Role cdr
EOM
end
diff --git a/spec/integration/knife/role_list_spec.rb b/spec/integration/knife/role_list_spec.rb
index 36dc76be4c..db13e521b5 100644
--- a/spec/integration/knife/role_list_spec.rb
+++ b/spec/integration/knife/role_list_spec.rb
@@ -32,11 +32,11 @@ describe "knife role list", :workstation do
end
it "lists all cookbooks" do
- knife("role list").should_succeed <<EOM
-car
-cat
-cdr
-cons
+ knife("role list").should_succeed <<~EOM
+ car
+ cat
+ cdr
+ cons
EOM
end
diff --git a/spec/integration/knife/role_show_spec.rb b/spec/integration/knife/role_show_spec.rb
index f655c03e8d..c2f5efedaf 100644
--- a/spec/integration/knife/role_show_spec.rb
+++ b/spec/integration/knife/role_show_spec.rb
@@ -33,15 +33,15 @@ describe "knife role show", :workstation do
# rubocop:disable Layout/TrailingWhitespace
it "shows a cookbook" do
- knife("role show cons").should_succeed <<EOM
-chef_type: role
-default_attributes:
-description:
-env_run_lists:
-json_class: Chef::Role
-name: cons
-override_attributes:
-run_list:
+ knife("role show cons").should_succeed <<~EOM
+ chef_type: role
+ default_attributes:
+ description:
+ env_run_lists:
+ json_class: Chef::Role
+ name: cons
+ override_attributes:
+ run_list:
EOM
end
# rubocop:enable Layout/TrailingWhitespace
diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb
index ed4802fef9..df9f55fbf2 100644
--- a/spec/integration/knife/show_spec.rb
+++ b/spec/integration/knife/show_spec.rb
@@ -49,63 +49,63 @@ describe "knife show", :workstation do
end
it "knife show /cookbooks/x/metadata.rb shows the remote version" do
- knife("show /cookbooks/x/metadata.rb").should_succeed <<EOM
-/cookbooks/x/metadata.rb:
-name "x"; version "1.0.0"
+ knife("show /cookbooks/x/metadata.rb").should_succeed <<~EOM
+ /cookbooks/x/metadata.rb:
+ name "x"; version "1.0.0"
EOM
end
it "knife show --local /cookbooks/x/metadata.rb shows the local version" do
- knife("show --local /cookbooks/x/metadata.rb").should_succeed <<EOM
-/cookbooks/x/metadata.rb:
-name "x"; version "1.0.0"
+ knife("show --local /cookbooks/x/metadata.rb").should_succeed <<~EOM
+ /cookbooks/x/metadata.rb:
+ name "x"; version "1.0.0"
EOM
end
it "knife show /data_bags/x/y.json shows the remote version" do
- knife("show /data_bags/x/y.json").should_succeed <<EOM
-/data_bags/x/y.json:
-{
- "id": "y"
-}
+ knife("show /data_bags/x/y.json").should_succeed <<~EOM
+ /data_bags/x/y.json:
+ {
+ "id": "y"
+ }
EOM
end
it "knife show --local /data_bags/x/y.json shows the local version" do
- knife("show --local /data_bags/x/y.json").should_succeed <<EOM
-/data_bags/x/y.json:
-{
- "foo": "bar"
-}
+ knife("show --local /data_bags/x/y.json").should_succeed <<~EOM
+ /data_bags/x/y.json:
+ {
+ "foo": "bar"
+ }
EOM
end
- it "knife show /environments/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do
- knife("show /environments/x.json").should_succeed <<EOM
-/environments/x.json:
-{
- "name": "x"
-}
+ it "knife show /environments/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do
+ knife("show /environments/x.json").should_succeed <<~EOM
+ /environments/x.json:
+ {
+ "name": "x"
+ }
EOM
end
it "knife show --local /environments/x.json shows the local version" do
- knife("show --local /environments/x.json").should_succeed <<EOM
-/environments/x.json:
-{
- "foo": "bar"
-}
+ knife("show --local /environments/x.json").should_succeed <<~EOM
+ /environments/x.json:
+ {
+ "foo": "bar"
+ }
EOM
end
- it "knife show /roles/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do
- knife("show /roles/x.json").should_succeed <<EOM
-/roles/x.json:
-{
- "name": "x"
-}
+ it "knife show /roles/x.json shows the remote version", skip: (RUBY_VERSION < "1.9") do
+ knife("show /roles/x.json").should_succeed <<~EOM
+ /roles/x.json:
+ {
+ "name": "x"
+ }
EOM
end
it "knife show --local /roles/x.json shows the local version" do
- knife("show --local /roles/x.json").should_succeed <<EOM
-/roles/x.json:
-{
- "foo": "bar"
-}
+ knife("show --local /roles/x.json").should_succeed <<~EOM
+ /roles/x.json:
+ {
+ "foo": "bar"
+ }
EOM
end
# show directory
@@ -135,22 +135,22 @@ EOM
"name" => "x",
}
end
- it "knife show shows the attributes in a predetermined order", :skip => (RUBY_VERSION < "1.9") do
- knife("show /environments/x.json").should_succeed <<EOM
-/environments/x.json:
-{
- "name": "x",
- "description": "woo",
- "cookbook_versions": {
- "blah": "= 1.0.0"
- },
- "default_attributes": {
- "foo": "bar"
- },
- "override_attributes": {
- "x": "y"
- }
-}
+ it "knife show shows the attributes in a predetermined order", skip: (RUBY_VERSION < "1.9") do
+ knife("show /environments/x.json").should_succeed <<~EOM
+ /environments/x.json:
+ {
+ "name": "x",
+ "description": "woo",
+ "cookbook_versions": {
+ "blah": "= 1.0.0"
+ },
+ "default_attributes": {
+ "foo": "bar"
+ },
+ "override_attributes": {
+ "x": "y"
+ }
+ }
EOM
end
end
@@ -158,9 +158,9 @@ EOM
when_the_repository "has an environment with bad JSON" do
before { file "environments/x.json", "{" }
it "knife show succeeds" do
- knife("show --local /environments/x.json").should_succeed <<EOM
-/environments/x.json:
-{
+ knife("show --local /environments/x.json").should_succeed <<~EOM
+ /environments/x.json:
+ {
EOM
end
end
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index dc713d02b3..647c7773f9 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -52,36 +52,36 @@ describe "knife upload", :workstation do
it "knife upload does nothing" do
knife("upload /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients/chef-validator.json
-D\t/clients/chef-webui.json
-D\t/clients/x.json
-D\t/cookbooks/x
-D\t/data_bags/x
-D\t/environments/_default.json
-D\t/environments/x.json
-D\t/nodes/x.json
-D\t/roles/x.json
-D\t/users/admin.json
-D\t/users/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients/chef-validator.json
+ D\t/clients/chef-webui.json
+ D\t/clients/x.json
+ D\t/cookbooks/x
+ D\t/data_bags/x
+ D\t/environments/_default.json
+ D\t/environments/x.json
+ D\t/nodes/x.json
+ D\t/roles/x.json
+ D\t/users/admin.json
+ D\t/users/x.json
EOM
end
it "knife upload --purge deletes everything" do
- knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
-Deleted extra entry /clients/chef-validator.json (purge is on)
-Deleted extra entry /clients/chef-webui.json (purge is on)
-Deleted extra entry /clients/x.json (purge is on)
-Deleted extra entry /cookbooks/x (purge is on)
-Deleted extra entry /data_bags/x (purge is on)
-Deleted extra entry /environments/x.json (purge is on)
-Deleted extra entry /nodes/x.json (purge is on)
-Deleted extra entry /roles/x.json (purge is on)
-Deleted extra entry /users/admin.json (purge is on)
-Deleted extra entry /users/x.json (purge is on)
-EOM
- knife("diff --name-status /").should_succeed <<EOM
-D\t/environments/_default.json
+ knife("upload --purge /").should_succeed(<<~EOM, stderr: "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
+ Deleted extra entry /clients/chef-validator.json (purge is on)
+ Deleted extra entry /clients/chef-webui.json (purge is on)
+ Deleted extra entry /clients/x.json (purge is on)
+ Deleted extra entry /cookbooks/x (purge is on)
+ Deleted extra entry /data_bags/x (purge is on)
+ Deleted extra entry /environments/x.json (purge is on)
+ Deleted extra entry /nodes/x.json (purge is on)
+ Deleted extra entry /roles/x.json (purge is on)
+ Deleted extra entry /users/admin.json (purge is on)
+ Deleted extra entry /users/x.json (purge is on)
+EOM
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/environments/_default.json
EOM
end
end
@@ -129,22 +129,22 @@ EOM
context "except the role file is textually different, but not ACTUALLY different" do
before do
- file "roles/x.json", <<EOM
-{
- "chef_type": "role",
- "default_attributes": {
- },
- "env_run_lists": {
- },
- "json_class": "Chef::Role",
- "name": "x",
- "description": "",
- "override_attributes": {
- },
- "run_list": [
-
- ]
-}
+ file "roles/x.json", <<~EOM
+ {
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "description": "",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -156,9 +156,9 @@ EOM
context "the role is in ruby" do
before do
- file "roles/x.rb", <<EOM
-name "x"
-description "blargle"
+ file "roles/x.rb", <<~EOM
+ name "x"
+ description "blargle"
EOM
end
@@ -197,33 +197,33 @@ EOM
end
it "knife upload adds the new files" do
- knife("upload /").should_succeed <<EOM
-Created /clients/y.json
-Updated /cookbooks/x
-Created /cookbooks/y
-Created /data_bags/x/z.json
-Created /data_bags/y
-Created /data_bags/y/zz.json
-Created /environments/y.json
-Created /nodes/y.json
-Created /roles/y.json
-Created /users/y.json
+ knife("upload /").should_succeed <<~EOM
+ Created /clients/y.json
+ Updated /cookbooks/x
+ Created /cookbooks/y
+ Created /data_bags/x/z.json
+ Created /data_bags/y
+ Created /data_bags/y/zz.json
+ Created /environments/y.json
+ Created /nodes/y.json
+ Created /roles/y.json
+ Created /users/y.json
EOM
knife("diff /").should_succeed ""
end
it "knife upload --no-diff adds the new files" do
- knife("upload --no-diff /").should_succeed <<EOM
-Created /clients/y.json
-Updated /cookbooks/x
-Created /cookbooks/y
-Created /data_bags/x/z.json
-Created /data_bags/y
-Created /data_bags/y/zz.json
-Created /environments/y.json
-Created /nodes/y.json
-Created /roles/y.json
-Created /users/y.json
+ knife("upload --no-diff /").should_succeed <<~EOM
+ Created /clients/y.json
+ Updated /cookbooks/x
+ Created /cookbooks/y
+ Created /data_bags/x/z.json
+ Created /data_bags/y
+ Created /data_bags/y/zz.json
+ Created /environments/y.json
+ Created /nodes/y.json
+ Created /roles/y.json
+ Created /users/y.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -233,35 +233,35 @@ EOM
when_the_repository "is empty" do
it "knife upload does nothing" do
knife("upload /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
it "knife upload --purge deletes nothing" do
- knife("upload --purge /").should_fail <<EOM
-ERROR: /clients cannot be deleted.
-ERROR: /cookbooks cannot be deleted.
-ERROR: /data_bags cannot be deleted.
-ERROR: /environments cannot be deleted.
-ERROR: /nodes cannot be deleted.
-ERROR: /roles cannot be deleted.
-ERROR: /users cannot be deleted.
-EOM
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("upload --purge /").should_fail <<~EOM
+ ERROR: /clients cannot be deleted.
+ ERROR: /cookbooks cannot be deleted.
+ ERROR: /data_bags cannot be deleted.
+ ERROR: /environments cannot be deleted.
+ ERROR: /nodes cannot be deleted.
+ ERROR: /roles cannot be deleted.
+ ERROR: /users cannot be deleted.
+EOM
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
@@ -271,7 +271,7 @@ EOM
end
it "knife upload with no parameters reports an error" do
- knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/
+ knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/
end
end
end
@@ -285,19 +285,19 @@ EOM
end
it "knife upload of the data bag uploads only the values in the data bag item and no other" do
- knife("upload /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("upload /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
knife("diff --name-status /data_bags").should_succeed <<EOM
EOM
- expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false).keys.sort).to eq(%w{foo id})
+ expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false).keys.sort).to eq(%w{foo id})
end
it "knife upload /data_bags/x /data_bags/x/y.json uploads x once" do
- knife("upload /data_bags/x /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("upload /data_bags/x /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
end
end
@@ -309,12 +309,12 @@ EOM
end
it "upload preserves chef_type and data_bag" do
- knife("upload /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("upload /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
knife("diff --name-status /data_bags").should_succeed ""
- result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false)
+ result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, create_additions: false)
expect(result.keys.sort).to eq(%w{chef_type data_bag id})
expect(result["chef_type"]).to eq("aaa")
expect(result["data_bag"]).to eq("bbb")
@@ -328,12 +328,12 @@ EOM
file "data_bags/x/z.json", {}
end
it "knife upload of one data bag item itself succeeds" do
- knife("upload /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("upload /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-A\t/data_bags/x/z.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ A\t/data_bags/x/z.json
EOM
end
end
@@ -353,62 +353,62 @@ EOM
end
it "knife upload of the modified file succeeds" do
- knife("upload /data_bags/x/modified.json").should_succeed <<EOM
-Updated /data_bags/x/modified.json
+ knife("upload /data_bags/x/modified.json").should_succeed <<~EOM
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the unmodified file does nothing" do
knife("upload /data_bags/x/unmodified.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the added file succeeds" do
- knife("upload /data_bags/x/added.json").should_succeed <<EOM
-Created /data_bags/x/added.json
+ knife("upload /data_bags/x/added.json").should_succeed <<~EOM
+ Created /data_bags/x/added.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
EOM
end
it "knife upload of the deleted file does nothing" do
knife("upload /data_bags/x/deleted.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload --purge of the deleted file deletes it" do
- knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("upload --purge /data_bags/x/deleted.json").should_succeed <<~EOM
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the entire data bag uploads everything" do
- knife("upload /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
+ knife("upload /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
EOM
end
it "knife upload --purge of the entire data bag uploads everything" do
- knife("upload --purge /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("upload --purge /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -419,22 +419,22 @@ EOM
end
it "knife upload fails" do
- knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/
+ knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/
end
it "knife upload --purge . uploads everything" do
- knife("upload --purge .").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("upload --purge .").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
it "knife upload --purge * uploads everything" do
- knife("upload --purge *").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("upload --purge *").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -466,14 +466,14 @@ EOM
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
- knife("upload /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
it "knife upload --purge of the cookbook itself succeeds" do
- knife("upload /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -485,8 +485,8 @@ EOM
end
it "knife upload of the cookbook succeeds" do
- knife("upload /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -500,8 +500,8 @@ EOM
end
it "knife upload of the cookbook succeeds" do
- knife("upload /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -513,8 +513,8 @@ EOM
end
it "knife upload --freeze freezes the cookbook" do
- knife("upload --freeze /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload --freeze /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
# Modify a file and attempt to upload
file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different'
@@ -525,7 +525,7 @@ EOM
when_the_chef_server "has a frozen cookbook" do
before do
- cookbook "frozencook", "1.0.0", {}, :frozen => true
+ cookbook "frozencook", "1.0.0", {}, frozen: true
end
when_the_repository "has an update to said cookbook" do
@@ -538,8 +538,8 @@ EOM
knife("upload /cookbooks/frozencook").should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n"
end
it "knife upload --force uploads the frozen cookbook" do
- knife("upload --force /cookbooks/frozencook").should_succeed <<EOM
-Updated /cookbooks/frozencook
+ knife("upload --force /cookbooks/frozencook").should_succeed <<~EOM
+ Updated /cookbooks/frozencook
EOM
end
end
@@ -558,18 +558,18 @@ EOM
end
it "knife upload /cookbooks/x uploads the local version" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
- knife("upload --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
end
@@ -581,8 +581,8 @@ EOM
end
it "knife upload /cookbooks/x uploads the local version" do
- knife("upload --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -594,18 +594,18 @@ EOM
end
it "knife upload /cookbooks/x uploads the local version" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
- knife("upload --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x/metadata.rb
-D\t/cookbooks/x/onlyin1.0.1.rb
-A\t/cookbooks/x/onlyin1.0.0.rb
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x/metadata.rb
+ D\t/cookbooks/x/onlyin1.0.1.rb
+ A\t/cookbooks/x/onlyin1.0.0.rb
EOM
end
end
@@ -616,8 +616,8 @@ EOM
end
it "knife upload /cookbooks/x uploads the new version" do
- knife("upload --purge /cookbooks/x").should_succeed <<EOM
-Updated /cookbooks/x
+ knife("upload --purge /cookbooks/x").should_succeed <<~EOM
+ Updated /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -635,24 +635,24 @@ EOM
end
it "knife upload tries and fails" do
- error1 = <<-EOH
-WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
- {
- (right here) ------^
-
-ERROR: /environments/x.json failed to write: Parse error reading JSON: parse error: premature EOF
- {
- (right here) ------^
+ error1 = <<~EOH
+ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ {
+ (right here) ------^
+
+ ERROR: /environments/x.json failed to write: Parse error reading JSON: parse error: premature EOF
+ {
+ (right here) ------^
EOH
- warn = <<-EOH
-WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
- {
- (right here) ------^
+ warn = <<~EOH
+ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ {
+ (right here) ------^
EOH
knife("upload /environments/x.json").should_fail(error1)
- knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", :stderr => warn)
+ knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", stderr: warn)
end
end
@@ -716,8 +716,8 @@ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
- knife("upload /cookbooks/x").should_succeed <<EOM
-Created /cookbooks/x
+ knife("upload /cookbooks/x").should_succeed <<~EOM
+ Created /cookbooks/x
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -751,36 +751,36 @@ EOM
it "knife upload does nothing" do
knife("upload /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients/chef-validator.json
-D\t/clients/chef-webui.json
-D\t/clients/x.json
-D\t/cookbooks/x-1.0.0
-D\t/data_bags/x
-D\t/environments/_default.json
-D\t/environments/x.json
-D\t/nodes/x.json
-D\t/roles/x.json
-D\t/users/admin.json
-D\t/users/x.json
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients/chef-validator.json
+ D\t/clients/chef-webui.json
+ D\t/clients/x.json
+ D\t/cookbooks/x-1.0.0
+ D\t/data_bags/x
+ D\t/environments/_default.json
+ D\t/environments/x.json
+ D\t/nodes/x.json
+ D\t/roles/x.json
+ D\t/users/admin.json
+ D\t/users/x.json
EOM
end
it "knife upload --purge deletes everything" do
- knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
-Deleted extra entry /clients/chef-validator.json (purge is on)
-Deleted extra entry /clients/chef-webui.json (purge is on)
-Deleted extra entry /clients/x.json (purge is on)
-Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
-Deleted extra entry /data_bags/x (purge is on)
-Deleted extra entry /environments/x.json (purge is on)
-Deleted extra entry /nodes/x.json (purge is on)
-Deleted extra entry /roles/x.json (purge is on)
-Deleted extra entry /users/admin.json (purge is on)
-Deleted extra entry /users/x.json (purge is on)
-EOM
- knife("diff --name-status /").should_succeed <<EOM
-D\t/environments/_default.json
+ knife("upload --purge /").should_succeed(<<~EOM, stderr: "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
+ Deleted extra entry /clients/chef-validator.json (purge is on)
+ Deleted extra entry /clients/chef-webui.json (purge is on)
+ Deleted extra entry /clients/x.json (purge is on)
+ Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
+ Deleted extra entry /data_bags/x (purge is on)
+ Deleted extra entry /environments/x.json (purge is on)
+ Deleted extra entry /nodes/x.json (purge is on)
+ Deleted extra entry /roles/x.json (purge is on)
+ Deleted extra entry /users/admin.json (purge is on)
+ Deleted extra entry /users/x.json (purge is on)
+EOM
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/environments/_default.json
EOM
end
end
@@ -824,22 +824,22 @@ EOM
context "except the role file is textually different, but not ACTUALLY different" do
before do
- file "roles/x.json", <<EOM
-{
- "chef_type": "role",
- "default_attributes": {
- },
- "env_run_lists": {
- },
- "json_class": "Chef::Role",
- "name": "x",
- "description": "",
- "override_attributes": {
- },
- "run_list": [
-
- ]
-}
+ file "roles/x.json", <<~EOM
+ {
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "description": "",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+ }
EOM
end
@@ -864,18 +864,18 @@ EOM
end
it "knife upload adds the new files" do
- knife("upload /").should_succeed <<EOM
-Created /clients/y.json
-Updated /cookbooks/x-1.0.0
-Created /cookbooks/x-2.0.0
-Created /cookbooks/y-1.0.0
-Created /data_bags/x/z.json
-Created /data_bags/y
-Created /data_bags/y/zz.json
-Created /environments/y.json
-Created /nodes/y.json
-Created /roles/y.json
-Created /users/y.json
+ knife("upload /").should_succeed <<~EOM
+ Created /clients/y.json
+ Updated /cookbooks/x-1.0.0
+ Created /cookbooks/x-2.0.0
+ Created /cookbooks/y-1.0.0
+ Created /data_bags/x/z.json
+ Created /data_bags/y
+ Created /data_bags/y/zz.json
+ Created /environments/y.json
+ Created /nodes/y.json
+ Created /roles/y.json
+ Created /users/y.json
EOM
knife("diff --name-status /").should_succeed ""
end
@@ -885,35 +885,35 @@ EOM
when_the_repository "is empty" do
it "knife upload does nothing" do
knife("upload /").should_succeed ""
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
it "knife upload --purge deletes nothing" do
- knife("upload --purge /").should_fail <<EOM
-ERROR: /clients cannot be deleted.
-ERROR: /cookbooks cannot be deleted.
-ERROR: /data_bags cannot be deleted.
-ERROR: /environments cannot be deleted.
-ERROR: /nodes cannot be deleted.
-ERROR: /roles cannot be deleted.
-ERROR: /users cannot be deleted.
-EOM
- knife("diff --name-status /").should_succeed <<EOM
-D\t/clients
-D\t/cookbooks
-D\t/data_bags
-D\t/environments
-D\t/nodes
-D\t/roles
-D\t/users
+ knife("upload --purge /").should_fail <<~EOM
+ ERROR: /clients cannot be deleted.
+ ERROR: /cookbooks cannot be deleted.
+ ERROR: /data_bags cannot be deleted.
+ ERROR: /environments cannot be deleted.
+ ERROR: /nodes cannot be deleted.
+ ERROR: /roles cannot be deleted.
+ ERROR: /users cannot be deleted.
+EOM
+ knife("diff --name-status /").should_succeed <<~EOM
+ D\t/clients
+ D\t/cookbooks
+ D\t/data_bags
+ D\t/environments
+ D\t/nodes
+ D\t/roles
+ D\t/users
EOM
end
@@ -922,7 +922,7 @@ EOM
cwd "."
end
it "knife upload with no parameters reports an error" do
- knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/
+ knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/
end
end
end
@@ -937,12 +937,12 @@ EOM
end
it "knife upload of one data bag item itself succeeds" do
- knife("upload /data_bags/x/y.json").should_succeed <<EOM
-Created /data_bags/x
-Created /data_bags/x/y.json
+ knife("upload /data_bags/x/y.json").should_succeed <<~EOM
+ Created /data_bags/x
+ Created /data_bags/x/y.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-A\t/data_bags/x/z.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ A\t/data_bags/x/z.json
EOM
end
end
@@ -960,62 +960,62 @@ EOM
end
it "knife upload of the modified file succeeds" do
- knife("upload /data_bags/x/modified.json").should_succeed <<EOM
-Updated /data_bags/x/modified.json
+ knife("upload /data_bags/x/modified.json").should_succeed <<~EOM
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the unmodified file does nothing" do
knife("upload /data_bags/x/unmodified.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the added file succeeds" do
- knife("upload /data_bags/x/added.json").should_succeed <<EOM
-Created /data_bags/x/added.json
+ knife("upload /data_bags/x/added.json").should_succeed <<~EOM
+ Created /data_bags/x/added.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
EOM
end
it "knife upload of the deleted file does nothing" do
knife("upload /data_bags/x/deleted.json").should_succeed ""
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload --purge of the deleted file deletes it" do
- knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("upload --purge /data_bags/x/deleted.json").should_succeed <<~EOM
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-M\t/data_bags/x/modified.json
-A\t/data_bags/x/added.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ M\t/data_bags/x/modified.json
+ A\t/data_bags/x/added.json
EOM
end
it "knife upload of the entire data bag uploads everything" do
- knife("upload /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
+ knife("upload /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
EOM
- knife("diff --name-status /data_bags").should_succeed <<EOM
-D\t/data_bags/x/deleted.json
+ knife("diff --name-status /data_bags").should_succeed <<~EOM
+ D\t/data_bags/x/deleted.json
EOM
end
it "knife upload --purge of the entire data bag uploads everything" do
- knife("upload --purge /data_bags/x").should_succeed <<EOM
-Created /data_bags/x/added.json
-Updated /data_bags/x/modified.json
-Deleted extra entry /data_bags/x/deleted.json (purge is on)
+ knife("upload --purge /data_bags/x").should_succeed <<~EOM
+ Created /data_bags/x/added.json
+ Updated /data_bags/x/modified.json
+ Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -1024,21 +1024,21 @@ EOM
cwd "data_bags"
end
it "knife upload fails" do
- knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", :stdout => /USAGE/
+ knife("upload").should_fail "FATAL: You must specify at least one argument. If you want to upload everything in this directory, run \"knife upload .\"\n", stdout: /USAGE/
end
it "knife upload --purge . uploads everything" do
- knife("upload --purge .").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("upload --purge .").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
it "knife upload --purge * uploads everything" do
- knife("upload --purge *").should_succeed <<EOM
-Created x/added.json
-Updated x/modified.json
-Deleted extra entry x/deleted.json (purge is on)
+ knife("upload --purge *").should_succeed <<~EOM
+ Created x/added.json
+ Updated x/modified.json
+ Deleted extra entry x/deleted.json (purge is on)
EOM
knife("diff --name-status /data_bags").should_succeed ""
end
@@ -1070,15 +1070,15 @@ EOM
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
- knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
+ knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
it "knife upload --purge of the cookbook itself succeeds" do
- knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
+ knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1090,8 +1090,8 @@ EOM
end
it "knife upload of the cookbook succeeds" do
- knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
+ knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1105,8 +1105,8 @@ EOM
end
it "knife upload of the cookbook succeeds" do
- knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
+ knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1126,13 +1126,13 @@ EOM
end
it "knife upload /cookbooks uploads the local version" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb
-D\t/cookbooks/x-1.0.1
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb
+ D\t/cookbooks/x-1.0.1
EOM
- knife("upload --purge /cookbooks").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
-Deleted extra entry /cookbooks/x-1.0.1 (purge is on)
+ knife("upload --purge /cookbooks").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
+ Deleted extra entry /cookbooks/x-1.0.1 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1144,9 +1144,9 @@ EOM
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
it "knife upload /cookbooks uploads the local version" do
- knife("upload --purge /cookbooks").should_succeed <<EOM
-Updated /cookbooks/x-1.0.0
-Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
+ knife("upload --purge /cookbooks").should_succeed <<~EOM
+ Updated /cookbooks/x-1.0.0
+ Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1158,13 +1158,13 @@ EOM
end
it "knife upload /cookbooks/x uploads the local version" do
- knife("diff --name-status /cookbooks").should_succeed <<EOM
-D\t/cookbooks/x-1.0.1
-A\t/cookbooks/x-1.0.0
+ knife("diff --name-status /cookbooks").should_succeed <<~EOM
+ D\t/cookbooks/x-1.0.1
+ A\t/cookbooks/x-1.0.0
EOM
- knife("upload --purge /cookbooks").should_succeed <<EOM
-Created /cookbooks/x-1.0.0
-Deleted extra entry /cookbooks/x-1.0.1 (purge is on)
+ knife("upload --purge /cookbooks").should_succeed <<~EOM
+ Created /cookbooks/x-1.0.0
+ Deleted extra entry /cookbooks/x-1.0.1 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1176,9 +1176,9 @@ EOM
end
it "knife upload /cookbooks/x uploads the new version" do
- knife("upload --purge /cookbooks").should_succeed <<EOM
-Created /cookbooks/x-1.0.0
-Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
+ knife("upload --purge /cookbooks").should_succeed <<~EOM
+ Created /cookbooks/x-1.0.0
+ Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1250,8 +1250,8 @@ EOM
file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
- knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM
-Created /cookbooks/x-1.0.0
+ knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
+ Created /cookbooks/x-1.0.0
EOM
knife("diff --name-status /cookbooks").should_succeed ""
end
@@ -1274,7 +1274,7 @@ EOM
end
end
- when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do
+ when_the_chef_server "is in Enterprise mode", osc_compat: false, single_org: false do
before do
user "foo", {}
user "bar", {}
@@ -1313,24 +1313,24 @@ EOM
end
it "knife upload / uploads everything" do
- knife("upload /").should_succeed <<EOM
-Updated /acls/groups/blah.json
-Created /clients/x.json
-Created /containers/x.json
-Created /cookbook_artifacts/x-1x1
-Created /cookbooks/x
-Created /data_bags/x
-Created /data_bags/x/y.json
-Created /environments/x.json
-Created /groups/x.json
-Updated /invitations.json
-Updated /members.json
-Created /nodes/x.json
-Updated /org.json
-Created /policies/blah-1.0.0.json
-Created /policies/x-1.0.0.json
-Created /policy_groups/x.json
-Created /roles/x.json
+ knife("upload /").should_succeed <<~EOM
+ Updated /acls/groups/blah.json
+ Created /clients/x.json
+ Created /containers/x.json
+ Created /cookbook_artifacts/x-1x1
+ Created /cookbooks/x
+ Created /data_bags/x
+ Created /data_bags/x/y.json
+ Created /environments/x.json
+ Created /groups/x.json
+ Updated /invitations.json
+ Updated /members.json
+ Created /nodes/x.json
+ Updated /org.json
+ Created /policies/blah-1.0.0.json
+ Created /policies/x-1.0.0.json
+ Created /policy_groups/x.json
+ Created /roles/x.json
EOM
expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ])
expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ])
@@ -1366,8 +1366,8 @@ EOM
end
it "knife upload makes no changes" do
- knife("upload /").should_succeed <<EOM
-Updated /acls/groups/blah.json
+ knife("upload /").should_succeed <<~EOM
+ Updated /acls/groups/blah.json
EOM
end
end
@@ -1378,8 +1378,8 @@ EOM
end
it "should fail because policies are not updateable" do
- knife("upload /policies/x-1.0.0.json").should_fail <<EOM
-ERROR: /policies/x-1.0.0.json cannot be updated: policy revisions are immutable once uploaded. If you want to change the policy, create a new revision with your changes.
+ knife("upload /policies/x-1.0.0.json").should_fail <<~EOM
+ ERROR: /policies/x-1.0.0.json cannot be updated: policy revisions are immutable once uploaded. If you want to change the policy, create a new revision with your changes.
EOM
end
end
@@ -1390,8 +1390,8 @@ EOM
end
it "should fail because cookbook_artifacts cannot be updated" do
- knife("upload /cookbook_artifacts/x-1x1").should_fail <<EOM
-ERROR: /cookbook_artifacts/x-1x1 cannot be updated: cookbook artifacts are immutable once uploaded.
+ knife("upload /cookbook_artifacts/x-1x1").should_fail <<~EOM
+ ERROR: /cookbook_artifacts/x-1x1 cannot be updated: cookbook artifacts are immutable once uploaded.
EOM
end
end
@@ -1420,20 +1420,20 @@ EOM
end
it "knife upload updates everything" do
- knife("upload /").should_succeed <<EOM
-Updated /acls/groups/blah.json
-Updated /clients/x.json
-Updated /cookbooks/x
-Updated /data_bags/x/y.json
-Updated /environments/x.json
-Updated /groups/x.json
-Updated /invitations.json
-Updated /members.json
-Updated /nodes/x.json
-Updated /org.json
-Created /policies/blah-1.0.0.json
-Updated /policy_groups/x.json
-Updated /roles/x.json
+ knife("upload /").should_succeed <<~EOM
+ Updated /acls/groups/blah.json
+ Updated /clients/x.json
+ Updated /cookbooks/x
+ Updated /data_bags/x/y.json
+ Updated /environments/x.json
+ Updated /groups/x.json
+ Updated /invitations.json
+ Updated /members.json
+ Updated /nodes/x.json
+ Updated /org.json
+ Created /policies/blah-1.0.0.json
+ Updated /policy_groups/x.json
+ Updated /roles/x.json
EOM
knife("diff --name-status --diff-filter=AMT /").should_succeed ""
end
@@ -1472,7 +1472,7 @@ EOM
end
it "knife upload / emits a warning for bar and invites foobar" do
- knife("upload /").should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n"
+ knife("upload /").should_succeed "Updated /invitations.json\n", stderr: "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n"
expect(api.get("association_requests").map { |a| a["username"] }).to eq(%w{foo foobar})
expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ])
end
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index 4a193bd7f0..65a05fcdc5 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -119,7 +119,7 @@ describe "Accumulators" do
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
result.error!
# runs only a single template resource (in the outer run context, as a delayed resource)
expect(result.stdout.scan(/template\S+ action create/).size).to eql(1)
@@ -221,7 +221,7 @@ describe "Accumulators" do
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
result.error!
# runs only a single template resource (in the outer run context, as a delayed resource)
expect(result.stdout.scan(/template\S+ action create/).size).to eql(1)
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index 54ce94f263..bda4728449 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -105,9 +105,9 @@ describe "LWRPs with inline resources" do
r = lwrp_inline_resources_test2 "hi" do
action :b
end
- end.to have_updated("lwrp_inline_resources_test2[hi]", :b).
- and have_updated("ruby_block[run a]", :run).
- and have_updated("ruby_block[run b]", :run)
+ end.to have_updated("lwrp_inline_resources_test2[hi]", :b)
+ .and have_updated("ruby_block[run a]", :run)
+ .and have_updated("ruby_block[run b]", :run)
expect(r.ran_b).to eq "ran b: ran_a value was \"ran a\""
end
end
@@ -145,13 +145,13 @@ describe "LWRPs with inline resources" do
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
actual = result.stdout.lines.map { |l| l.chomp }.join("\n")
expected = <<EOM
* x_my_machine[me] action create
diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb
index 3bc008d4f8..3f591d4cfc 100644
--- a/spec/integration/recipes/lwrp_spec.rb
+++ b/spec/integration/recipes/lwrp_spec.rb
@@ -22,29 +22,29 @@ describe "LWRPs" do
before do
directory "cookbooks/l-w-r-p" do
- file "resources/foo.rb", <<EOM
-default_action :create
+ file "resources/foo.rb", <<~EOM
+ default_action :create
EOM
- file "providers/foo.rb", <<EOM
-action :create do
-end
+ file "providers/foo.rb", <<~EOM
+ action :create do
+ end
EOM
- file "recipes/default.rb", <<EOM
-l_w_r_p_foo "me"
+ file "recipes/default.rb", <<~EOM
+ l_w_r_p_foo "me"
EOM
end # directory 'cookbooks/x'
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* l_w_r_p_foo\[me\] action create \(up to date\)/)
expect(result.stdout).not_to match(/WARN: You are overriding l_w_r_p_foo/)
result.error!
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index b008e4ade7..d9e89e7f1e 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -26,13 +26,13 @@ describe "notifications" do
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* log\[foo\] action write\s+\* log\[bar\] action write\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/)
result.error!
@@ -43,37 +43,37 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, 'log[foo]', :delayed
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, 'log[foo]', :delayed
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-notifying_test "whatever"
-log "baz"
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ notifying_test "whatever"
+ log "baz"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
result.error!
@@ -84,39 +84,39 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, 'log[foo]', :delayed
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, 'log[foo]', :delayed
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-notifying_test "whatever"
-log "baz" do
- notifies :write, 'log[foo]', :delayed
-end
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ notifying_test "whatever"
+ log "baz" do
+ notifies :write, 'log[foo]', :delayed
+ end
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
# and only run once
@@ -129,41 +129,41 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, 'log[foo]', :delayed
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, 'log[foo]', :delayed
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-log "quux" do
- notifies :write, 'log[foo]', :delayed
- notifies :write, 'log[baz]', :delayed
-end
-notifying_test "whatever"
-log "baz"
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ log "quux" do
+ notifies :write, 'log[foo]', :delayed
+ notifies :write, 'log[baz]', :delayed
+ end
+ notifying_test "whatever"
+ log "baz"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
expect(result.stdout).to match(/\* log\[quux\] action write\s+\* notifying_test\[whatever\] action run\s+\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
# and only run once
@@ -175,29 +175,29 @@ EOM
when_the_repository "notifies delayed four" do
before do
directory "cookbooks/x" do
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-log "bar" do
- notifies :write, 'log[foo]', :delayed
-end
-log "baz" do
- notifies :write, 'log[foo]', :delayed
-end
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ log "bar" do
+ notifies :write, 'log[foo]', :delayed
+ end
+ log "baz" do
+ notifies :write, 'log[foo]', :delayed
+ end
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
# and only run once
@@ -210,37 +210,37 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, 'log[foo]', :immediately
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, 'log[foo]', :immediately
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-notifying_test "whatever"
-log "baz"
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ notifying_test "whatever"
+ log "baz"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
@@ -250,37 +250,37 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, resources(log: "foo"), :immediately
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, resources(log: "foo"), :immediately
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "foo" do
- action :nothing
-end
-notifying_test "whatever"
-log "baz"
+ file "recipes/default.rb", <<~EOM
+ log "foo" do
+ action :nothing
+ end
+ notifying_test "whatever"
+ log "baz"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
@@ -290,34 +290,34 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/notifying_test.rb", <<EOM
-default_action :run
-provides :notifying_test
-resource_name :notifying_test
+ file "resources/notifying_test.rb", <<~EOM
+ default_action :run
+ provides :notifying_test
+ resource_name :notifying_test
-action :run do
- log "bar" do
- notifies :write, "log[foo]"
- end
-end
+ action :run do
+ log "bar" do
+ notifies :write, "log[foo]"
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-notifying_test "whatever"
-log "baz"
+ file "recipes/default.rb", <<~EOM
+ notifying_test "whatever"
+ log "baz"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/Chef::Exceptions::ResourceNotFound/)
expect(result.exitstatus).not_to eql(0)
end
@@ -327,37 +327,37 @@ EOM
before do
directory "cookbooks/x" do
- file "resources/cloning_test.rb", <<EOM
-default_action :run
-provides :cloning_test
-resource_name :cloning_test
+ file "resources/cloning_test.rb", <<~EOM
+ default_action :run
+ provides :cloning_test
+ resource_name :cloning_test
-action :run do
- log "bar" do
- level :info
- end
-end
+ action :run do
+ log "bar" do
+ level :info
+ end
+ end
EOM
- file "recipes/default.rb", <<EOM
-log "bar" do
- level :warn
-end
+ file "recipes/default.rb", <<~EOM
+ log "bar" do
+ level :warn
+ end
-cloning_test "whatever"
+ cloning_test "whatever"
EOM
end
end
it "should complete with success" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).not_to match(/CHEF-3694/)
result.error!
end
@@ -379,13 +379,13 @@ EOM
end
it "notifying the resource should work" do
- file "config/client.rb", <<EOM
-local_mode true
-cookbook_path "#{path_to('cookbooks')}"
-log_level :warn
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match /\* log\[a, b\] action write/
result.error!
end
diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb
index 6a1287c7b1..6c50854038 100644
--- a/spec/integration/recipes/notifying_block_spec.rb
+++ b/spec/integration/recipes/notifying_block_spec.rb
@@ -55,7 +55,7 @@ describe "notifying_block" do
# 2. delayed notifications are de-dup'd in the subcontext
# 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext
it "should run alpha, beta, gamma, and delta in that order" do
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/)
result.error!
end
@@ -103,7 +103,7 @@ describe "notifying_block" do
# 1. notifying block will correctly update wrapping new_resource updated_by_last_action status
# 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context
it "should run foo, quux, bar, and baz in that order" do
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/)
result.error!
end
diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb
index 77fe183136..a0e3e23ef3 100644
--- a/spec/integration/recipes/remote_directory.rb
+++ b/spec/integration/recipes/remote_directory.rb
@@ -50,7 +50,7 @@ describe Chef::Resource::RemoteDirectory do
end
EOM
end
- shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", :cwd => chef_dir)
+ shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", cwd: chef_dir)
end
def mode_of(path)
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index f0ba4822a7..e1def5e191 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -65,8 +65,8 @@ describe "Resource::ActionClass#converge_if_changed" do
it "the resource updates nothing" do
expect(resource.converged).to eq 0
expect(resource.updated?).to be_falsey
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create (up to date)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create (up to date)
EOM
end
end
@@ -83,10 +83,10 @@ describe "Resource::ActionClass#converge_if_changed" do
it "the resource updates state1" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state1 to "new_state1" (was "current_state1")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to "new_state1" (was "current_state1")
EOM
end
end
@@ -104,11 +104,11 @@ describe "Resource::ActionClass#converge_if_changed" do
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state1 to "new_state1" (was "current_state1")
- - set state2 to "new_state2" (was "current_state2")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to "new_state1" (was "current_state1")
+ - set state2 to "new_state2" (was "current_state2")
EOM
end
end
@@ -127,11 +127,11 @@ EOM
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state1 to (suppressed sensitive property)
- - set state2 to (suppressed sensitive property)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to (suppressed sensitive property)
+ - set state2 to (suppressed sensitive property)
EOM
end
end
@@ -148,10 +148,10 @@ EOM
it "the resource updates sensitive1" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set sensitive1 to (suppressed sensitive property)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set sensitive1 to (suppressed sensitive property)
EOM
end
end
@@ -169,10 +169,10 @@ EOM
it "the resource updates state2" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state2 to "new_state2" (was "current_state2")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state2 to "new_state2" (was "current_state2")
EOM
end
end
@@ -190,8 +190,8 @@ EOM
it "the resource updates nothing" do
expect(resource.converged).to eq 0
expect(resource.updated?).to be_falsey
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create (up to date)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create (up to date)
EOM
end
end
@@ -211,8 +211,8 @@ EOM
it "the resource updates nothing" do
expect(resource.converged).to eq 0
expect(resource.updated?).to be_falsey
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create (up to date)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create (up to date)
EOM
end
end
@@ -241,10 +241,10 @@ EOM
it "the resource updates identity1" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update current_identity1
- - set identity1 to "new_identity1" (was "current_identity1")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update current_identity1
+ - set identity1 to "new_identity1" (was "current_identity1")
EOM
end
end
@@ -263,13 +263,13 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set identity1 to "default_identity1" (default value)
- - set state1 to "default_state1" (default value)
- - set state2 to "default_state2" (default value)
- - set sensitive1 to (suppressed sensitive property) (default value)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set identity1 to "default_identity1" (default value)
+ - set state1 to "default_state1" (default value)
+ - set state2 to "default_state2" (default value)
+ - set sensitive1 to (suppressed sensitive property) (default value)
EOM
end
end
@@ -288,13 +288,13 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set identity1 to "default_identity1" (default value)
- - set state1 to "new_state1"
- - set state2 to "new_state2"
- - set sensitive1 to (suppressed sensitive property)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set identity1 to "default_identity1" (default value)
+ - set state1 to "new_state1"
+ - set state2 to "new_state2"
+ - set sensitive1 to (suppressed sensitive property)
EOM
end
end
@@ -313,13 +313,13 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set identity1 to (suppressed sensitive property) (default value)
- - set state1 to (suppressed sensitive property)
- - set state2 to (suppressed sensitive property)
- - set sensitive1 to (suppressed sensitive property) (default value)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set identity1 to (suppressed sensitive property) (default value)
+ - set state1 to (suppressed sensitive property)
+ - set state2 to (suppressed sensitive property)
+ - set sensitive1 to (suppressed sensitive property) (default value)
EOM
end
end
@@ -355,8 +355,8 @@ EOM
it "the resource updates nothing" do
expect(resource.converged).to eq 0
expect(resource.updated?).to be_falsey
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create (up to date)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create (up to date)
EOM
end
end
@@ -374,10 +374,10 @@ EOM
it "the resource updates state1" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state1 to "new_state1" (was "current_state1")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to "new_state1" (was "current_state1")
EOM
end
end
@@ -395,12 +395,12 @@ EOM
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 2
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state1 to "new_state1" (was "current_state1")
- - update default_identity1
- - set state2 to "new_state2" (was "current_state2")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to "new_state1" (was "current_state1")
+ - update default_identity1
+ - set state2 to "new_state2" (was "current_state2")
EOM
end
end
@@ -418,10 +418,10 @@ EOM
it "the resource updates state2" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set state2 to "new_state2" (was "current_state2")
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set state2 to "new_state2" (was "current_state2")
EOM
end
end
@@ -439,8 +439,8 @@ EOM
it "the resource updates nothing" do
expect(resource.converged).to eq 0
expect(resource.updated?).to be_falsey
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create (up to date)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create (up to date)
EOM
end
end
@@ -457,10 +457,10 @@ EOM
it "the resource updates sensitive1" do
expect(resource.converged).to eq 1
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - update default_identity1
- - set sensitive1 to (suppressed sensitive property)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - update default_identity1
+ - set sensitive1 to (suppressed sensitive property)
EOM
end
end
@@ -481,14 +481,14 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 3
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set state1 to "default_state1" (default value)
- - create default_identity1
- - set state2 to "default_state2" (default value)
- - create default_identity1
- - set sensitive1 to (suppressed sensitive property) (default value)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set state1 to "default_state1" (default value)
+ - create default_identity1
+ - set state2 to "default_state2" (default value)
+ - create default_identity1
+ - set sensitive1 to (suppressed sensitive property) (default value)
EOM
end
end
@@ -507,14 +507,14 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 3
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set state1 to "new_state1"
- - create default_identity1
- - set state2 to "new_state2"
- - create default_identity1
- - set sensitive1 to (suppressed sensitive property)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set state1 to "new_state1"
+ - create default_identity1
+ - set state2 to "new_state2"
+ - create default_identity1
+ - set sensitive1 to (suppressed sensitive property)
EOM
end
end
@@ -533,14 +533,14 @@ EOM
it "the resource is created" do
expect(resource.converged).to eq 3
expect(resource.updated?).to be_truthy
- expect(converged_recipe.stdout).to eq <<-EOM
-* #{resource_name}[blah] action create
- - create default_identity1
- - set state1 to (suppressed sensitive property)
- - create default_identity1
- - set state2 to (suppressed sensitive property)
- - create default_identity1
- - set sensitive1 to (suppressed sensitive property) (default value)
+ expect(converged_recipe.stdout).to eq <<~EOM
+ * #{resource_name}[blah] action create
+ - create default_identity1
+ - set state1 to (suppressed sensitive property)
+ - create default_identity1
+ - set state2 to (suppressed sensitive property)
+ - create default_identity1
+ - set sensitive1 to (suppressed sensitive property) (default value)
EOM
end
end
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 4fc14c0687..79df1d6478 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -156,10 +156,10 @@ describe "Resource.load_current_value" do
context "And a child resource class with load_current_value" do
before do
subresource_class.load_current_value do
- y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
- select { |name, p| p.is_set?(self) }.
- map { |name, p| "#{name}=#{p.get(self)}" }.
- join(", ")})"
+ y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }
+ .select { |name, p| p.is_set?(self) }
+ .map { |name, p| "#{name}=#{p.get(self)}" }
+ .join(", ")})"
end
end
@@ -174,10 +174,10 @@ describe "Resource.load_current_value" do
before do
subresource_class.load_current_value do
super()
- y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
- select { |name, p| p.is_set?(self) }.
- map { |name, p| "#{name}=#{p.get(self)}" }.
- join(", ")})"
+ y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }
+ .select { |name, p| p.is_set?(self) }
+ .map { |name, p| "#{name}=#{p.get(self)}" }
+ .join(", ")})"
end
end
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 63525f0081..58314473e7 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -23,10 +23,10 @@ describe "chef-solo" do
let(:node_file) { Dir[File.join(nodes_dir, "*.json")][0] }
before do
- file "config/solo.rb", <<EOM
-chef_repo_path "#{@repository_dir}"
+ file "config/solo.rb", <<~EOM
+ chef_repo_path "#{@repository_dir}"
EOM
- result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", :cwd => chef_dir)
+ result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", cwd: chef_dir)
result.error!
end
@@ -74,26 +74,26 @@ EOM
end
it "should complete with success" do
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
result.error!
expect(result.stdout).to include("ITWORKS")
end
it "should evaluate its node.json file" do
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
- file "config/node.json", <<-E
-{"run_list":["x::default"]}
+ file "config/node.json", <<~E
+ {"run_list":["x::default"]}
E
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", :cwd => chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", cwd: chef_dir)
result.error!
expect(result.stdout).to include("ITWORKS")
end
@@ -110,11 +110,11 @@ E
end
it "should exit with an error" do
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(0) # For CHEF-5120 this becomes 1
expect(result.stdout).to include("WARN: MissingCookbookDependency")
end
@@ -124,14 +124,14 @@ EOM
before do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"'
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
end
it "should exit with an error" do
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(1)
expect(result.stdout).to include("Chef::Exceptions::CookbookChefVersionMismatch")
end
@@ -141,14 +141,14 @@ EOM
before do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nohai_version '~> 999.0'")
file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"'
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
end
it "should exit with an error" do
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(1)
expect(result.stdout).to include("Chef::Exceptions::CookbookOhaiVersionMismatch")
end
@@ -159,23 +159,23 @@ EOM
directory "logs"
file "logs/runs.log", ""
file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb
- file "cookbooks/x/recipes/default.rb", <<EOM
-ruby_block "sleeping" do
- block do
- retries = 200
- while IO.read(Chef::Config[:log_location]) !~ /Chef client .* is running, will wait for it to finish and then run./
- sleep 0.1
- raise "we ran out of retries" if ( retries -= 1 ) <= 0
- end
- end
-end
+ file "cookbooks/x/recipes/default.rb", <<~EOM
+ ruby_block "sleeping" do
+ block do
+ retries = 200
+ while IO.read(Chef::Config[:log_location]) !~ /Chef client .* is running, will wait for it to finish and then run./
+ sleep 0.1
+ raise "we ran out of retries" if ( retries -= 1 ) <= 0
+ end
+ end
+ end
EOM
end
it "while running solo concurrently" do
- file "config/solo.rb", <<EOM
-cookbook_path "#{path_to('cookbooks')}"
-file_cache_path "#{path_to('config/cache')}"
+ file "config/solo.rb", <<~EOM
+ cookbook_path "#{path_to('cookbooks')}"
+ file_cache_path "#{path_to('config/cache')}"
EOM
# We have a timeout protection here so that if due to some bug
# run_lock gets stuck we can discover it.
@@ -187,13 +187,13 @@ EOM
# Instantiate the first chef-solo run
threads << Thread.new do
- s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
+ s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir)
Process.waitpid(s1)
end
# Instantiate the second chef-solo run
threads << Thread.new do
- s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
+ s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir)
Process.waitpid(s2)
end
diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb
index 3f4e343926..5677e94d0a 100644
--- a/spec/scripts/ssl-serve.rb
+++ b/spec/scripts/ssl-serve.rb
@@ -20,26 +20,26 @@ key = OpenSSL::PKey::RSA.new(key_text)
server_opts = {}
if $ssl
- server_opts.merge!( { :SSLEnable => true,
- :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
- :SSLCertificate => cert,
- :SSLPrivateKey => key })
+ server_opts.merge!( { SSLEnable: true,
+ SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
+ SSLCertificate: cert,
+ SSLPrivateKey: key })
end
# 5 == debug, 3 == warning
LOGGER = WEBrick::Log.new(STDOUT, 5)
DEFAULT_OPTIONS = {
- :server => "webrick",
- :Port => 9000,
- :Host => "localhost",
- :environment => :none,
- :Logger => LOGGER,
- :DocumentRoot => File.expand_path("#{Dir.tmpdir}/chef-118-sampledata")
+ server: "webrick",
+ Port: 9000,
+ Host: "localhost",
+ environment: :none,
+ Logger: LOGGER,
+ DocumentRoot: File.expand_path("#{Dir.tmpdir}/chef-118-sampledata")
#:AccessLog => [] # Remove this option to enable the access log when debugging.
}
webrick_opts = DEFAULT_OPTIONS.merge(server_opts)
-pp :webrick_opts => webrick_opts
+pp webrick_opts: webrick_opts
server = WEBrick::HTTPServer.new(webrick_opts)
trap("INT") { server.shutdown }
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b4d337eecd..d900fc2f37 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -50,10 +50,10 @@ end
require "chef"
require "chef/knife"
-Dir["lib/chef/knife/**/*.rb"].
- map { |f| f.gsub("lib/", "") }.
- map { |f| f.gsub(%r{\.rb$}, "") }.
- each { |f| require f }
+Dir["lib/chef/knife/**/*.rb"]
+ .map { |f| f.gsub("lib/", "") }
+ .map { |f| f.gsub(%r{\.rb$}, "") }
+ .each { |f| require f }
require "chef/resource_resolver"
require "chef/provider_resolver"
@@ -90,12 +90,12 @@ require "spec/support/shared/unit/mock_shellout"
# Autoloads support files
# Excludes support/platforms by default
# Do not change the gsub.
-Dir["spec/support/**/*.rb"].
- reject { |f| f =~ %r{^spec/support/platforms} }.
- reject { |f| f =~ %r{^spec/support/pedant} }.
- map { |f| f.gsub(%r{.rb$}, "") }.
- map { |f| f.gsub(%r{spec/}, "") }.
- each { |f| require f }
+Dir["spec/support/**/*.rb"]
+ .reject { |f| f =~ %r{^spec/support/platforms} }
+ .reject { |f| f =~ %r{^spec/support/pedant} }
+ .map { |f| f.gsub(%r{.rb$}, "") }
+ .map { |f| f.gsub(%r{spec/}, "") }
+ .each { |f| require f }
OHAI_SYSTEM = Ohai::System.new
OHAI_SYSTEM.all_plugins(["platform", "hostname", "languages/powershell"])
@@ -119,8 +119,8 @@ resource_handler_map ||= nil
RSpec.configure do |config|
config.include(Matchers)
config.include(MockShellout::RSpec)
- config.filter_run :focus => true
- config.filter_run_excluding :external => true
+ config.filter_run focus: true
+ config.filter_run_excluding external: true
# Explicitly disable :should syntax
config.expect_with :rspec do |c|
@@ -134,83 +134,83 @@ RSpec.configure do |config|
config.filter_run_excluding :workstation if solaris? || aix?
# Tests that randomly fail, but may have value.
- config.filter_run_excluding :volatile => true
- config.filter_run_excluding :volatile_on_solaris => true if solaris?
- config.filter_run_excluding :volatile_from_verify => false
-
- config.filter_run_excluding :skip_appveyor => true if ENV["APPVEYOR"]
- config.filter_run_excluding :appveyor_only => true unless ENV["APPVEYOR"]
- config.filter_run_excluding :skip_travis => true if ENV["TRAVIS"]
-
- config.filter_run_excluding :windows_only => true unless windows?
- config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106?
- config.filter_run_excluding :not_supported_on_mac_osx => true if mac_osx?
- config.filter_run_excluding :mac_osx_only => true if !mac_osx?
- config.filter_run_excluding :not_supported_on_aix => true if aix?
- config.filter_run_excluding :not_supported_on_solaris => true if solaris?
- config.filter_run_excluding :not_supported_on_gce => true if gce?
- config.filter_run_excluding :not_supported_on_nano => true if windows_nano_server?
- config.filter_run_excluding :win2012r2_only => true unless windows_2012r2?
- config.filter_run_excluding :windows_2008r2_or_later => true unless windows_2008r2_or_later?
- config.filter_run_excluding :windows64_only => true unless windows64?
- config.filter_run_excluding :windows32_only => true unless windows32?
- config.filter_run_excluding :windows_nano_only => true unless windows_nano_server?
- config.filter_run_excluding :windows_gte_10 => true unless windows_gte_10?
- config.filter_run_excluding :windows_lt_10 => true if windows_gte_10?
- config.filter_run_excluding :ruby64_only => true unless ruby_64bit?
- config.filter_run_excluding :ruby32_only => true unless ruby_32bit?
- config.filter_run_excluding :windows_powershell_dsc_only => true unless windows_powershell_dsc?
- config.filter_run_excluding :windows_powershell_no_dsc_only => true unless ! windows_powershell_dsc?
- config.filter_run_excluding :windows_domain_joined_only => true unless windows_domain_joined?
- config.filter_run_excluding :windows_not_domain_joined_only => true if windows_domain_joined?
+ config.filter_run_excluding volatile: true
+ config.filter_run_excluding volatile_on_solaris: true if solaris?
+ config.filter_run_excluding volatile_from_verify: false
+
+ config.filter_run_excluding skip_appveyor: true if ENV["APPVEYOR"]
+ config.filter_run_excluding appveyor_only: true unless ENV["APPVEYOR"]
+ config.filter_run_excluding skip_travis: true if ENV["TRAVIS"]
+
+ config.filter_run_excluding windows_only: true unless windows?
+ config.filter_run_excluding not_supported_on_mac_osx_106: true if mac_osx_106?
+ config.filter_run_excluding not_supported_on_mac_osx: true if mac_osx?
+ config.filter_run_excluding mac_osx_only: true if !mac_osx?
+ config.filter_run_excluding not_supported_on_aix: true if aix?
+ config.filter_run_excluding not_supported_on_solaris: true if solaris?
+ config.filter_run_excluding not_supported_on_gce: true if gce?
+ config.filter_run_excluding not_supported_on_nano: true if windows_nano_server?
+ config.filter_run_excluding win2012r2_only: true unless windows_2012r2?
+ config.filter_run_excluding windows_2008r2_or_later: true unless windows_2008r2_or_later?
+ config.filter_run_excluding windows64_only: true unless windows64?
+ config.filter_run_excluding windows32_only: true unless windows32?
+ config.filter_run_excluding windows_nano_only: true unless windows_nano_server?
+ config.filter_run_excluding windows_gte_10: true unless windows_gte_10?
+ config.filter_run_excluding windows_lt_10: true if windows_gte_10?
+ config.filter_run_excluding ruby64_only: true unless ruby_64bit?
+ config.filter_run_excluding ruby32_only: true unless ruby_32bit?
+ config.filter_run_excluding windows_powershell_dsc_only: true unless windows_powershell_dsc?
+ config.filter_run_excluding windows_powershell_no_dsc_only: true unless ! windows_powershell_dsc?
+ config.filter_run_excluding windows_domain_joined_only: true unless windows_domain_joined?
+ config.filter_run_excluding windows_not_domain_joined_only: true if windows_domain_joined?
# We think this line was causing rspec tests to not run on the Jenkins windows
# testers. If we ever fix it we should restore it.
# config.filter_run_excluding :windows_service_requires_assign_token => true if !STDOUT.isatty && !windows_user_right?("SeAssignPrimaryTokenPrivilege")
- config.filter_run_excluding :windows_service_requires_assign_token => true
- config.filter_run_excluding :solaris_only => true unless solaris?
- config.filter_run_excluding :system_windows_service_gem_only => true unless system_windows_service_gem?
- config.filter_run_excluding :unix_only => true unless unix?
- config.filter_run_excluding :linux_only => true unless linux?
- config.filter_run_excluding :aix_only => true unless aix?
- config.filter_run_excluding :debian_family_only => true unless debian_family?
- config.filter_run_excluding :supports_cloexec => true unless supports_cloexec?
- config.filter_run_excluding :selinux_only => true unless selinux_enabled?
- config.filter_run_excluding :requires_root => true unless root?
- config.filter_run_excluding :requires_root_or_running_windows => true unless root? || windows?
- config.filter_run_excluding :requires_unprivileged_user => true if root?
- config.filter_run_excluding :uses_diff => true unless has_diff?
- config.filter_run_excluding :openssl_gte_101 => true unless openssl_gte_101?
- config.filter_run_excluding :openssl_lt_101 => true unless openssl_lt_101?
- config.filter_run_excluding :aes_256_gcm_only => true unless aes_256_gcm?
- config.filter_run_excluding :broken => true
- config.filter_run_excluding :not_wpar => true unless wpar?
- config.filter_run_excluding :not_supported_under_fips => true if fips?
- config.filter_run_excluding :rhel => true unless rhel?
- config.filter_run_excluding :rhel5 => true unless rhel5?
- config.filter_run_excluding :rhel6 => true unless rhel6?
- config.filter_run_excluding :rhel7 => true unless rhel7?
- config.filter_run_excluding :intel_64bit => true unless intel_64bit?
- config.filter_run_excluding :not_rhel => true if rhel?
- config.filter_run_excluding :not_rhel5 => true if rhel5?
- config.filter_run_excluding :not_rhel6 => true if rhel6?
- config.filter_run_excluding :not_rhel7 => true if rhel7?
- config.filter_run_excluding :not_intel_64bit => true if intel_64bit?
+ config.filter_run_excluding windows_service_requires_assign_token: true
+ config.filter_run_excluding solaris_only: true unless solaris?
+ config.filter_run_excluding system_windows_service_gem_only: true unless system_windows_service_gem?
+ config.filter_run_excluding unix_only: true unless unix?
+ config.filter_run_excluding linux_only: true unless linux?
+ config.filter_run_excluding aix_only: true unless aix?
+ config.filter_run_excluding debian_family_only: true unless debian_family?
+ config.filter_run_excluding supports_cloexec: true unless supports_cloexec?
+ config.filter_run_excluding selinux_only: true unless selinux_enabled?
+ config.filter_run_excluding requires_root: true unless root?
+ config.filter_run_excluding requires_root_or_running_windows: true unless root? || windows?
+ config.filter_run_excluding requires_unprivileged_user: true if root?
+ config.filter_run_excluding uses_diff: true unless has_diff?
+ config.filter_run_excluding openssl_gte_101: true unless openssl_gte_101?
+ config.filter_run_excluding openssl_lt_101: true unless openssl_lt_101?
+ config.filter_run_excluding aes_256_gcm_only: true unless aes_256_gcm?
+ config.filter_run_excluding broken: true
+ config.filter_run_excluding not_wpar: true unless wpar?
+ config.filter_run_excluding not_supported_under_fips: true if fips?
+ config.filter_run_excluding rhel: true unless rhel?
+ config.filter_run_excluding rhel5: true unless rhel5?
+ config.filter_run_excluding rhel6: true unless rhel6?
+ config.filter_run_excluding rhel7: true unless rhel7?
+ config.filter_run_excluding intel_64bit: true unless intel_64bit?
+ config.filter_run_excluding not_rhel: true if rhel?
+ config.filter_run_excluding not_rhel5: true if rhel5?
+ config.filter_run_excluding not_rhel6: true if rhel6?
+ config.filter_run_excluding not_rhel7: true if rhel7?
+ config.filter_run_excluding not_intel_64bit: true if intel_64bit?
# these let us use chef: ">= 13" or ruby: "~> 2.0.0" or any other Gem::Dependency-style constraint
config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION)
config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION)
- config.filter_run_excluding :choco_installed => true unless choco_installed?
+ config.filter_run_excluding choco_installed: true unless choco_installed?
running_platform_arch = `uname -m`.strip unless windows?
- config.filter_run_excluding :arch => lambda { |target_arch|
+ config.filter_run_excluding arch: lambda { |target_arch|
running_platform_arch != target_arch
}
# Functional Resource tests that are provider-specific:
# context "on platforms that use useradd", :provider => {:user => Chef::Provider::User::Useradd}} do #...
- config.filter_run_excluding :provider => lambda { |criteria|
+ config.filter_run_excluding provider: lambda { |criteria|
type, target_provider = criteria.first
node = TEST_NODE.dup
diff --git a/spec/stress/win32/file_spec.rb b/spec/stress/win32/file_spec.rb
index f1c81eb9c6..49dd8694f5 100644
--- a/spec/stress/win32/file_spec.rb
+++ b/spec/stress/win32/file_spec.rb
@@ -26,12 +26,12 @@ describe "Chef::ReservedNames::Win32::File", :windows_only do
it "should not leak significant memory", :volatile do
test = lambda { Chef::ReservedNames::Win32::File.symlink?(@path) }
- expect(test).not_to leak_memory(:warmup => 50000, :iterations => 50000)
+ expect(test).not_to leak_memory(warmup: 50000, iterations: 50000)
end
it "should not leak handles", :volatile do
test = lambda { Chef::ReservedNames::Win32::File.symlink?(@path) }
- expect(test).not_to leak_handles(:warmup => 50, :iterations => 100)
+ expect(test).not_to leak_handles(warmup: 50, iterations: 100)
end
end
diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb
index 3c03a657b2..0280398ad5 100644
--- a/spec/stress/win32/security_spec.rb
+++ b/spec/stress/win32/security_spec.rb
@@ -52,7 +52,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do
expect do
sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid }
GC.start
- end.not_to leak_memory(:warmup => 50, :iterations => 100)
+ end.not_to leak_memory(warmup: 50, iterations: 100)
end
it "should not leak when creating a new ACL and setting it on a file", :volatile do
@@ -63,7 +63,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do
Chef::ReservedNames::Win32::Security::ACE.access_denied(Chef::ReservedNames::Win32::Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL),
])
GC.start
- end.not_to leak_memory(:warmup => 50, :iterations => 100)
+ end.not_to leak_memory(warmup: 50, iterations: 100)
end
end
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 8569523e05..6ae052ba1d 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -202,7 +202,7 @@ def selinux_enabled?
# specs independent of product.
selinuxenabled_path = which("selinuxenabled")
if selinuxenabled_path
- cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0, 1])
+ cmd = Mixlib::ShellOut.new(selinuxenabled_path, returns: [0, 1])
cmd_result = cmd.run_command
case cmd_result.exitstatus
when 1
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 4b90fcaedd..0054058d0f 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -11,16 +11,16 @@ shared_context "client" do
let(:ohai_data) do
{
- :fqdn => fqdn,
- :hostname => hostname,
- :machinename => machinename,
- :platform => platform,
- :platform_version => platform_version,
+ fqdn: fqdn,
+ hostname: hostname,
+ machinename: machinename,
+ platform: platform,
+ platform_version: platform_version,
}
end
let(:ohai_system) do
- ohai = instance_double("Ohai::System", :all_plugins => true, :data => ohai_data, logger: logger)
+ ohai = instance_double("Ohai::System", all_plugins: true, data: ohai_data, logger: logger)
allow(ohai).to receive(:[]) do |k|
ohai_data[k]
end
@@ -80,17 +80,17 @@ shared_context "a client run" do
let(:reporting_rest_client) { double("Chef::ServerAPI (reporting client)") }
let(:runner) { instance_double("Chef::Runner") }
- let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => false) }
+ let(:audit_runner) { instance_double("Chef::Audit::Runner", failed?: false) }
def stub_for_register
# --Client.register
# Make sure Client#register thinks the client key doesn't
# exist, so it tries to register and create one.
allow(File).to receive(:exists?).and_call_original
- expect(File).to receive(:exists?).
- with(Chef::Config[:client_key]).
- exactly(:once).
- and_return(api_client_exists?)
+ expect(File).to receive(:exists?)
+ .with(Chef::Config[:client_key])
+ .exactly(:once)
+ .and_return(api_client_exists?)
unless api_client_exists?
# Client.register will register with the validation client name.
@@ -99,21 +99,21 @@ shared_context "a client run" do
end
def stub_for_data_collector_init
- expect(Chef::ServerAPI).to receive(:new).
- with(Chef::Config[:data_collector][:server_url], validate_utf8: false).
- exactly(:once).
- and_return(http_data_collector)
+ expect(Chef::ServerAPI).to receive(:new)
+ .with(Chef::Config[:data_collector][:server_url], validate_utf8: false)
+ .exactly(:once)
+ .and_return(http_data_collector)
end
def stub_for_node_load
# Client.register will then turn around create another
# Chef::ServerAPI object, this time with the client key it got from the
# previous step.
- expect(Chef::ServerAPI).to receive(:new).
- with(Chef::Config[:chef_server_url], client_name: fqdn,
- signing_key_filename: Chef::Config[:client_key]).
- exactly(:once).
- and_return(http_node_load)
+ expect(Chef::ServerAPI).to receive(:new)
+ .with(Chef::Config[:chef_server_url], client_name: fqdn,
+ signing_key_filename: Chef::Config[:client_key])
+ .exactly(:once)
+ .and_return(http_node_load)
# --Client#build_node
# looks up the node, which we will return, then later saves it.
@@ -135,9 +135,9 @@ shared_context "a client run" do
#
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync)
- expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", { :run_list => [] }).
- and_return({})
+ expect(http_cookbook_sync).to receive(:post)
+ .with("environments/_default/cookbook_versions", { run_list: [] })
+ .and_return({})
end
def stub_for_required_recipe
@@ -250,8 +250,8 @@ end
shared_context "audit phase completed with failed controls" do
let(:audit_runner) do
- instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) end
+ instance_double("Chef::Audit::Runner", failed?: true,
+ num_failed: 1, num_total: 3) end
let(:audit_error) do
err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 65f512b5bf..2abae030c2 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -95,7 +95,7 @@ shared_context "use Windows permissions", :windows_only do
def extract_ace_properties(aces)
hashes = []
aces.each do |ace|
- hashes << { :mask => ace.mask, :type => ace.type, :flags => ace.flags }
+ hashes << { mask: ace.mask, type: ace.type, flags: ace.flags }
end
hashes
end
@@ -103,36 +103,36 @@ shared_context "use Windows permissions", :windows_only do
# Standard expected rights
let(:expected_read_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
}
end
let(:expected_read_execute_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE,
}
end
let(:expected_write_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE,
}
end
let(:expected_modify_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
}
end
let(:expected_full_control_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS,
}
end
@@ -443,8 +443,8 @@ shared_examples_for "a securable resource without existing target" do
end
it "respects mode in string form as an octal number" do
- #on windows, mode cannot modify owner and/or group permissons
- #unless the owner and/or group as appropriate is specified
+ # on windows, mode cannot modify owner and/or group permissons
+ # unless the owner and/or group as appropriate is specified
resource.mode "400"
resource.owner "Guest"
resource.group "Everyone"
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index 0bec29783a..cd2b83fda1 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -36,7 +36,7 @@ shared_examples_for "a securable resource with reporting" do
# umask
# let(:default_mode) { (0666 & ~File.umask).to_s(8) }
- describe "reading file security metadata for reporting on unix", :unix_only => true do
+ describe "reading file security metadata for reporting on unix", unix_only: true do
# According to POSIX standard created files get either the
# effective gid of the process or inherits the gid of the parent
# directory based on file system. Since it's hard to guess what
@@ -70,7 +70,7 @@ shared_examples_for "a securable resource with reporting" do
end
end
- context "and owner is specified with a String (username) in new_resource", :requires_root => true do
+ context "and owner is specified with a String (username) in new_resource", requires_root: true do
# TODO/bug: duplicated from the "securable resource" tests
@@ -91,7 +91,7 @@ shared_examples_for "a securable resource with reporting" do
end
- context "and owner is specified with an Integer (uid) in new_resource", :requires_root => true do
+ context "and owner is specified with an Integer (uid) in new_resource", requires_root: true do
# TODO: duplicated from "securable resource"
if ohai[:platform] == "aix"
@@ -113,7 +113,7 @@ shared_examples_for "a securable resource with reporting" do
end
end
- context "and group is specified with a String (group name)", :requires_root => true do
+ context "and group is specified with a String (group name)", requires_root: true do
let(:expected_group_name) { Etc.getgrent.name }
@@ -128,7 +128,7 @@ shared_examples_for "a securable resource with reporting" do
end
- context "and group is specified with an Integer (gid)", :requires_root => true do
+ context "and group is specified with an Integer (gid)", requires_root: true do
let(:expected_gid) { Etc.getgrent.gid }
before do
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 3199caa34f..a528db4a53 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -39,11 +39,11 @@ shared_context "using Win32::Service" do
let(:test_service) do
{
- :service_name => "spec-service",
- :service_display_name => "Spec Test Service",
- :service_description => "Service for testing Chef::Application::WindowsServiceManager.",
- :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
- :delayed_start => true,
+ service_name: "spec-service",
+ service_display_name: "Spec Test Service",
+ service_description: "Service for testing Chef::Application::WindowsServiceManager.",
+ service_file_path: File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
+ delayed_start: true,
}
end
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index e5ac0741bd..5eb68952d7 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -93,7 +93,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 64-bit" do
let (:guard_architecture) { :x86_64 }
it "executes a 64-bit guard", :windows64_only do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
expect(get_guard_process_architecture).to eq("amd64")
end
@@ -102,7 +102,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 32-bit", :not_supported_on_nano do
let (:guard_architecture) { :i386 }
it "executes a 32-bit guard" do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
expect(get_guard_process_architecture).to eq("x86")
end
@@ -111,7 +111,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 32-bit", :windows_nano_only do
let (:guard_architecture) { :i386 }
it "raises an error" do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb
index e2bb3812ea..c0b24d9443 100644
--- a/spec/support/shared/integration/app_server_support.rb
+++ b/spec/support/shared/integration/app_server_support.rb
@@ -25,9 +25,9 @@ module AppServerSupport
server = nil
thread = Thread.new do
Rack::Handler::WEBrick.run(app,
- :Port => 9018,
- :AccessLog => [],
- :Logger => WEBrick::Log.new(StringIO.new, 7)
+ Port: 9018,
+ AccessLog: [],
+ Logger: WEBrick::Log.new(StringIO.new, 7)
) do |found_server|
server = found_server
end
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 29f2eef50f..5fc9de4de7 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -140,12 +140,12 @@ module IntegrationSupport
# Versioned cookbooks
- RSpec.shared_context "with versioned cookbooks", :versioned_cookbooks => true do
+ RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do
before(:each) { Chef::Config[:versioned_cookbooks] = true }
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
end
- RSpec.shared_context "without versioned cookbooks", :versioned_cookbooks => false do
+ RSpec.shared_context "without versioned cookbooks", versioned_cookbooks: false do
# Just make sure this goes back to default
before(:each) { Chef::Config[:versioned_cookbooks] = false }
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index 86764cad66..5058b7b278 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -40,8 +40,8 @@ module KnifeSupport
# Work on machines where we can't access /var
Dir.mktmpdir("checksums") do |checksums_cache_dir|
Chef::Config[:cache_options] = {
- :path => checksums_cache_dir,
- :skip_expires => true,
+ path: checksums_cache_dir,
+ skip_expires: true,
}
# This is Chef::Knife.run without load_commands--we'll load stuff
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index 45bfcc67da..15c122e3dc 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -28,15 +28,15 @@ shared_examples_for "an api error inspector" do
before do
@node_name = "test-node.example.com"
@config = {
- :validation_client_name => "testorg-validator",
- :validation_key => "/etc/chef/testorg-validator.pem",
- :chef_server_url => "https://chef-api.example.com",
- :node_name => "testnode-name",
- :client_key => "/etc/chef/client.pem",
+ validation_client_name: "testorg-validator",
+ validation_key: "/etc/chef/testorg-validator.pem",
+ chef_server_url: "https://chef-api.example.com",
+ node_name: "testnode-name",
+ client_key: "/etc/chef/client.pem",
}
@description = Chef::Formatters::ErrorDescription.new("Error registering the node:")
@outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index 28141b73b1..9c179efa82 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -19,7 +19,7 @@
require "chef/exceptions"
shared_examples_for "version handling" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
before do
@@ -38,7 +38,7 @@ shared_examples_for "version handling" do
end # version handling
shared_examples_for "user and client reregister" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb
index c97577107e..05c2fc4a9a 100644
--- a/spec/support/shared/unit/execute_resource.rb
+++ b/spec/support/shared/unit/execute_resource.rb
@@ -57,7 +57,7 @@ shared_examples_for "an execute resource" do
end
it "should accept a hash for the environment" do
- test_hash = { :one => :two }
+ test_hash = { one: :two }
@resource.environment(test_hash)
expect(@resource.environment).to eql(test_hash)
end
@@ -155,7 +155,7 @@ shared_examples_for "an execute resource" do
before do
@resource.command("grep")
@resource.cwd("/tmp/")
- @resource.environment({ :one => :two })
+ @resource.environment({ one: :two })
@resource.group("legos")
@resource.returns(1)
@resource.user("root")
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index d508e76b24..a7c7af92f6 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -258,11 +258,11 @@ shared_examples_for Chef::Provider::File do
allow(ChefConfig).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
resource_real_path = File.realpath(resource.path)
expect(File).to receive(:stat).with(resource_real_path).at_least(:once).and_return(stat_struct)
- allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
- allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
+ allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel"))
+ allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root"))
end
context "when the new_resource does not specify any state" do
@@ -383,11 +383,11 @@ shared_examples_for Chef::Provider::File do
allow(ChefConfig).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
resource_real_path = File.realpath(resource.path)
allow(File).to receive(:stat).with(resource_real_path).and_return(stat_struct)
- allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
- allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
+ allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel"))
+ allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root"))
provider.send(:load_resource_attributes_from_file, resource)
end
@@ -460,7 +460,7 @@ shared_examples_for Chef::Provider::File do
before { setup_normal_file }
let(:tempfile) do
- t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true)
+ t = double("Tempfile", path: "/tmp/foo-bar-baz", closed?: true)
allow(content).to receive(:tempfile).and_return(t)
t
end
@@ -515,7 +515,7 @@ shared_examples_for Chef::Provider::File do
before do
setup_normal_file
provider.load_current_resource
- tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
+ tempfile = double("Tempfile", path: "/tmp/foo-bar-baz")
allow(content).to receive(:tempfile).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true)
expect(tempfile).to receive(:close).once
@@ -528,8 +528,8 @@ shared_examples_for Chef::Provider::File do
let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" }
before do
allow(provider).to receive(:contents_changed?).and_return(true)
- diff = double("Diff", :for_output => ["+++", "---", "+foo", "-bar"],
- :for_reporting => diff_for_reporting )
+ diff = double("Diff", for_output: ["+++", "---", "+foo", "-bar"],
+ for_reporting: diff_for_reporting )
allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true)
expect(provider).to receive(:diff).at_least(:once).and_return(diff)
expect(provider).to receive(:checksum).with(tempfile_path).and_return(tempfile_sha256)
@@ -592,13 +592,13 @@ shared_examples_for Chef::Provider::File do
end
it "raises an exception when the content object returns a tempfile with a nil path" do
- tempfile = double("Tempfile", :path => nil)
+ tempfile = double("Tempfile", path: nil)
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect { provider.send(:do_contents_changes) }.to raise_error(RuntimeError)
end
it "raises an exception when the content object returns a tempfile that does not exist" do
- tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
+ tempfile = double("Tempfile", path: "/tmp/foo-bar-baz")
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false)
expect { provider.send(:do_contents_changes) }.to raise_error(RuntimeError)
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index caa76e4ad6..a30f543e72 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -68,8 +68,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do
- allow(@new_resource).to receive(:supports).and_return({ :manage_home => false,
- :non_unique => false })
+ allow(@new_resource).to receive(:supports).and_return({ manage_home: false,
+ non_unique: false })
allow(@new_resource).to receive(attribute).and_return("hola")
expect(provider.universal_options).to eql([option, "hola"])
end
@@ -257,7 +257,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when checking the lock" do
# lazy initialize so we can modify stdout and stderr strings
let(:passwd_s_status) do
- double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => @stdout, :stderr => @stderr, :error! => nil)
+ double("Mixlib::ShellOut command", exitstatus: 0, stdout: @stdout, stderr: @stderr, error!: nil)
end
before(:each) do
@@ -266,57 +266,57 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
# :nil_object => true,
# :username => "adam"
# )
- #provider = Chef::Provider::User::Useradd.new(@node, @new_resource)
+ # provider = Chef::Provider::User::Useradd.new(@node, @new_resource)
@stdout = "root P 09/02/2008 0 99999 7 -1"
@stderr = ""
end
it "should return false if status begins with P" do
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_s_status)
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
it "should return false if status begins with N" do
@stdout = "root N"
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_s_status)
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
it "should return true if status begins with L" do
@stdout = "root L"
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_s_status)
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_s_status)
expect(provider.check_lock).to eql(true)
end
it "should raise a ShellCommandFailed exception if passwd -S exits with something other than 0 or 1" do
expect(passwd_s_status).to receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_s_status)
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_s_status)
expect { provider.check_lock }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
it "should raise an error if the output isn't parsable" do
expect(passwd_s_status).to receive(:stdout).and_return("")
expect(passwd_s_status).to receive(:stderr).and_return("")
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_s_status)
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_s_status)
expect { provider.check_lock }.to raise_error(Chef::Exceptions::User)
end
context "when in why run mode" do
before do
- passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
- expect(provider).to receive(:shell_out).
- with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
- and_return(passwd_status)
+ passwd_status = double("Mixlib::ShellOut command", exitstatus: 0, stdout: "", stderr: "passwd: user 'chef-test' does not exist\n")
+ expect(provider).to receive(:shell_out)
+ .with("passwd", "-S", @new_resource.username, { returns: [0, 1] })
+ .and_return(passwd_status)
# ubuntu returns 252 on user-does-not-exist so will raise if #error! is called or if
# shell_out! is used
allow(passwd_status).to receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index 6c31ca22d1..40042933e2 100644
--- a/spec/support/shared/unit/user_and_client_shared.rb
+++ b/spec/support/shared/unit/user_and_client_shared.rb
@@ -27,7 +27,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v1).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ public_key: "some_public_key" })).and_return({})
object.create
end
@@ -49,7 +49,7 @@ shared_examples_for "user or client create" do
end
it "creates a new object via the API with create_key" do
- expect(rest_v1).to receive(:post).with(url, payload.merge({ :create_key => true })).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ create_key: true })).and_return({})
object.create
end
end
@@ -104,7 +104,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v0).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
+ expect(rest_v0).to receive(:post).with(url, payload.merge({ public_key: "some_public_key" })).and_return({})
object.create
end
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb
index 83c5bf4a42..c3eab76d8e 100644
--- a/spec/tiny_server.rb
+++ b/spec/tiny_server.rb
@@ -136,8 +136,8 @@ module TinyServer
if response = response_for_request(env)
response.call
else
- debug_info = { :message => "no data matches the request for #{env['REQUEST_URI']}",
- :available_routes => @routes, :request => env }
+ debug_info = { message: "no data matches the request for #{env['REQUEST_URI']}",
+ available_routes: @routes, request: env }
# Uncomment me for glorious debugging
# pp :not_found => debug_info
[404, { "Content-Type" => "application/json" }, [ Chef::JSONCompat.to_json(debug_info) ]]
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb
index 0f036766da..407c2c9f07 100644
--- a/spec/unit/api_client/registration_spec.rb
+++ b/spec/unit/api_client/registration_spec.rb
@@ -38,11 +38,11 @@ describe Chef::ApiClient::Registration do
let(:http_mock) { double("Chef::ServerAPI mock") }
let(:expected_post_data) do
- { :name => client_name, :admin => false, :public_key => generated_public_key.to_pem }
+ { name: client_name, admin: false, public_key: generated_public_key.to_pem }
end
let(:expected_put_data) do
- { :name => client_name, :admin => false, :public_key => generated_public_key.to_pem }
+ { name: client_name, admin: false, public_key: generated_public_key.to_pem }
end
let(:server_v10_response) do
@@ -108,28 +108,28 @@ describe Chef::ApiClient::Registration do
end
it "posts a locally generated public key to the server to create a client" do
- expect(http_mock).to receive(:post).
- with("clients", expected_post_data).
- and_return(create_with_pkey_response)
+ expect(http_mock).to receive(:post)
+ .with("clients", expected_post_data)
+ .and_return(create_with_pkey_response)
expect(registration.run.public_key).to eq(create_with_pkey_response["chef_key"]["public_key"])
expect(OpenSSL::PKey::RSA.new(registration.private_key).to_s).to eq(OpenSSL::PKey::RSA.new(generated_private_key_pem).to_s)
end
it "puts a locally generated public key to the server to update a client" do
- expect(http_mock).to receive(:post).
- with("clients", expected_post_data).
- and_raise(exception_409)
- expect(http_mock).to receive(:put).
- with("clients/#{client_name}", expected_put_data).
- and_return(update_with_pkey_response)
+ expect(http_mock).to receive(:post)
+ .with("clients", expected_post_data)
+ .and_raise(exception_409)
+ expect(http_mock).to receive(:put)
+ .with("clients/#{client_name}", expected_put_data)
+ .and_return(update_with_pkey_response)
expect(registration.run.public_key).to eq(update_with_pkey_response["public_key"].to_pem)
expect(OpenSSL::PKey::RSA.new(registration.private_key).to_s).to eq(OpenSSL::PKey::RSA.new(generated_private_key_pem).to_s)
end
it "writes the generated private key to disk" do
- expect(http_mock).to receive(:post).
- with("clients", expected_post_data).
- and_return(create_with_pkey_response)
+ expect(http_mock).to receive(:post)
+ .with("clients", expected_post_data)
+ .and_return(create_with_pkey_response)
registration.run
expect(OpenSSL::PKey::RSA.new(IO.read(key_location)).to_s).to eq(OpenSSL::PKey::RSA.new(generated_private_key_pem).to_s)
end
@@ -137,9 +137,9 @@ describe Chef::ApiClient::Registration do
context "and the client already exists on a Chef 11 server" do
it "requests a new key from the server and saves it" do
expect(http_mock).to receive(:post).and_raise(exception_409)
- expect(http_mock).to receive(:put).
- with("clients/#{client_name}", expected_put_data).
- and_return(update_with_pkey_response)
+ expect(http_mock).to receive(:put)
+ .with("clients/#{client_name}", expected_put_data)
+ .and_return(update_with_pkey_response)
expect(registration.run.public_key).to eq(update_with_pkey_response["public_key"].to_pem)
expect(OpenSSL::PKey::RSA.new(registration.private_key).to_s).to eq(OpenSSL::PKey::RSA.new(generated_private_key_pem).to_s)
end
@@ -148,11 +148,11 @@ describe Chef::ApiClient::Registration do
context "when local key generation is disabled" do
let(:expected_post_data) do
- { :name => client_name, :admin => false }
+ { name: client_name, admin: false }
end
let(:expected_put_data) do
- { :name => client_name, :admin => false, :private_key => true }
+ { name: client_name, admin: false, private_key: true }
end
before do
@@ -161,9 +161,9 @@ describe Chef::ApiClient::Registration do
end
it "creates a new ApiClient on the server using the validator identity" do
- expect(http_mock).to receive(:post).
- with("clients", expected_post_data).
- and_return(server_v10_response)
+ expect(http_mock).to receive(:post)
+ .with("clients", expected_post_data)
+ .and_return(server_v10_response)
expect(registration.run.private_key).to eq(server_v10_response["private_key"])
expect(registration.private_key).to eq("--begin rsa key etc--")
end
@@ -171,9 +171,9 @@ describe Chef::ApiClient::Registration do
context "and the client already exists on a Chef 11 server" do
it "requests a new key from the server and saves it" do
expect(http_mock).to receive(:post).and_raise(exception_409)
- expect(http_mock).to receive(:put).
- with("clients/#{client_name}", expected_put_data).
- and_return(server_v11_response)
+ expect(http_mock).to receive(:put)
+ .with("clients/#{client_name}", expected_put_data)
+ .and_return(server_v11_response)
expect(registration.run).to eq(server_v11_response)
expect(registration.private_key).to eq("--begin rsa key etc--")
end
@@ -181,11 +181,11 @@ describe Chef::ApiClient::Registration do
context "and the client already exists on a Chef 10 server" do
it "requests a new key from the server and saves it" do
- expect(http_mock).to receive(:post).with("clients", expected_post_data).
- and_raise(exception_409)
- expect(http_mock).to receive(:put).
- with("clients/#{client_name}", expected_put_data).
- and_return(server_v10_response)
+ expect(http_mock).to receive(:post).with("clients", expected_post_data)
+ .and_raise(exception_409)
+ expect(http_mock).to receive(:put)
+ .with("clients/#{client_name}", expected_put_data)
+ .and_return(server_v10_response)
expect(registration.run.private_key).to eq(server_v10_response["private_key"])
expect(registration.private_key).to eq("--begin rsa key etc--")
end
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index a8ac4f747b..e83906e712 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -302,9 +302,9 @@ describe Chef::ApiClient do
@api_client_with_key = Chef::ApiClient.new
@api_client_with_key.name("lost-my-key")
@api_client_with_key.private_key("the new private key")
- expect(@http_client).to receive(:put).
- with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :validator => false, :private_key => true).
- and_return(@api_client_with_key)
+ expect(@http_client).to receive(:put)
+ .with("clients/lost-my-key", name: "lost-my-key", admin: false, validator: false, private_key: true)
+ .and_return(@api_client_with_key)
end
it "returns an ApiClient with a private key" do
@@ -320,9 +320,9 @@ describe Chef::ApiClient do
context "and the client exists on a Chef 10-like server" do
before do
@api_client_with_key = { "name" => "lost-my-key", "private_key" => "the new private key" }
- expect(@http_client).to receive(:put).
- with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :validator => false, :private_key => true).
- and_return(@api_client_with_key)
+ expect(@http_client).to receive(:put)
+ .with("clients/lost-my-key", name: "lost-my-key", admin: false, validator: false, private_key: true)
+ .and_return(@api_client_with_key)
end
it "returns an ApiClient with a private key" do
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index 9c643fa492..802384534b 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -324,13 +324,13 @@ describe Chef::ApiClientV1 do
end
describe "Versioned API Interactions" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
let(:payload) do
{
- :name => "some_name",
- :validator => true,
- :admin => true,
+ name: "some_name",
+ validator: true,
+ admin: true,
}
end
@@ -389,7 +389,7 @@ describe Chef::ApiClientV1 do
end
it "updates the client with only the name" do
- expect(rest). to receive(:put).with("clients/some_name", { :name => "some_name" }).and_return({ :name => "some_name" })
+ expect(rest). to receive(:put).with("clients/some_name", { name: "some_name" }).and_return({ name: "some_name" })
@client.update
end
end
@@ -437,7 +437,7 @@ describe Chef::ApiClientV1 do
describe "reregister" do
context "when server API V0 is valid on the Chef Server receiving the request" do
it "creates a new object via the API" do
- expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ :private_key => true })).and_return({})
+ expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ private_key: true })).and_return({})
@client.reregister
end
end # when server API V0 is valid on the Chef Server receiving the request
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index 0af3916134..b659f13fe8 100644
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Application::Apply do
before do
@recipe_file_name = "foo.rb"
@recipe_path = File.expand_path(@recipe_file_name)
- @recipe_file = double("Tempfile (mock)", :read => @recipe_text)
+ @recipe_file = double("Tempfile (mock)", read: @recipe_text)
allow(@app).to receive(:open).with(@recipe_path).and_return(@recipe_file)
allow(File).to receive(:exist?).with(@recipe_path).and_return(true)
allow(Chef::Application).to receive(:fatal!).and_return(true)
@@ -96,13 +96,13 @@ describe Chef::Application::Apply do
end
describe "when the json_attribs configuration option is specified" do
let(:json_attribs) { { "a" => "b" } }
- let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
+ let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
before do
Chef::Config[:json_attribs] = json_source
- expect(Chef::ConfigFetcher).to receive(:new).with(json_source).
- and_return(config_fetcher)
+ expect(Chef::ConfigFetcher).to receive(:new).with(json_source)
+ .and_return(config_fetcher)
end
it "reads the JSON attributes from the specified source" do
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index de6972b625..40f690abb1 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -121,27 +121,27 @@ describe Chef::Application::Client, "reconfigure" do
describe "--named-run-list" do
it_behaves_like "sets the configuration",
"--named-run-list arglebargle-example",
- :named_run_list => "arglebargle-example"
+ named_run_list: "arglebargle-example"
end
describe "--no-listen" do
- it_behaves_like "sets the configuration", "--no-listen", :listen => false
+ it_behaves_like "sets the configuration", "--no-listen", listen: false
end
describe "--daemonize", :unix_only do
context "with no value" do
it_behaves_like "sets the configuration", "--daemonize",
- :daemonize => true
+ daemonize: true
end
context "with an integer value" do
it_behaves_like "sets the configuration", "--daemonize 5",
- :daemonize => 5
+ daemonize: 5
end
context "with a non-integer value" do
it_behaves_like "sets the configuration", "--daemonize foo",
- :daemonize => true
+ daemonize: true
end
end
@@ -178,17 +178,17 @@ describe Chef::Application::Client, "reconfigure" do
describe "--config-option" do
context "with a single value" do
it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example",
- :chef_server_url => "http://example"
+ chef_server_url: "http://example"
end
context "with two values" do
it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example --config-option policy_name=web",
- :chef_server_url => "http://example", :policy_name => "web"
+ chef_server_url: "http://example", policy_name: "web"
end
context "with a boolean value" do
it_behaves_like "sets the configuration", "--config-option minimal_ohai=true",
- :minimal_ohai => true
+ minimal_ohai: true
end
context "with an empty value" do
@@ -321,14 +321,14 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
describe "when the json_attribs configuration option is specified" do
let(:json_attribs) { { "a" => "b" } }
- let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
+ let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
before do
allow(app).to receive(:configure_chef).and_return(true)
Chef::Config[:json_attribs] = json_source
- expect(Chef::ConfigFetcher).to receive(:new).with(json_source).
- and_return(config_fetcher)
+ expect(Chef::ConfigFetcher).to receive(:new).with(json_source)
+ .and_return(config_fetcher)
end
it "reads the JSON attributes from the specified source" do
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 90ecde608e..8a574b4d0f 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -24,9 +24,9 @@ describe Chef::Application::Knife do
before(:all) do
class NoopKnifeCommand < Chef::Knife
option :opt_with_default,
- :short => "-D VALUE",
- :long => "-optwithdefault VALUE",
- :default => "default-value"
+ short: "-D VALUE",
+ long: "-optwithdefault VALUE",
+ default: "default-value"
def run
end
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 5b9dbeaafd..31114261c8 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -93,13 +93,13 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
describe "when the json_attribs configuration option is specified" do
let(:json_attribs) { { "a" => "b" } }
- let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
+ let(:config_fetcher) { double(Chef::ConfigFetcher, fetch_json: json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
before do
Chef::Config[:json_attribs] = json_source
- expect(Chef::ConfigFetcher).to receive(:new).with(json_source).
- and_return(config_fetcher)
+ expect(Chef::ConfigFetcher).to receive(:new).with(json_source)
+ .and_return(config_fetcher)
end
it "reads the JSON attributes from the specified source" do
@@ -130,7 +130,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
it "fetches the recipe_url first when both json_attribs and recipe_url are specified" do
json_attribs = { "a" => "b" }
- config_fetcher = instance_double("Chef::ConfigFetcher", :fetch_json => json_attribs)
+ config_fetcher = instance_double("Chef::ConfigFetcher", fetch_json: json_attribs)
Chef::Config[:json_attribs] = "https://foo.com/foo.json"
Chef::Config[:recipe_url] = "http://icanhas.cheezburger.com/lolcats"
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index 76be387c22..b8d7242466 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -107,7 +107,7 @@ describe Chef::Application do
it "should parse the commandline options" do
expect(@app).to receive(:parse_options).and_return(true)
- @app.config[:config_file] = "/etc/chef/default.rb" #have a config file set, to prevent triggering error block
+ @app.config[:config_file] = "/etc/chef/default.rb" # have a config file set, to prevent triggering error block
@app.configure_chef
end
@@ -127,9 +127,9 @@ describe Chef::Application do
# force let binding to get evaluated or else we stub Pathname.new before we try to use it.
config_location_pathname
allow(Pathname).to receive(:new).with(config_location).and_return(config_location_pathname)
- expect(File).to receive(:read).
- with(config_location).
- and_return(config_content)
+ expect(File).to receive(:read)
+ .with(config_location)
+ .and_return(config_content)
end
it "should configure chef::config from a file" do
@@ -138,7 +138,7 @@ describe Chef::Application do
end
it "should merge the local config hash into chef::config" do
- #File.should_receive(:open).with("/etc/chef/default.rb").and_yield(@config_file)
+ # File.should_receive(:open).with("/etc/chef/default.rb").and_yield(@config_file)
@app.configure_chef
expect(Chef::Config.rspec_ran).to eq("true")
end
@@ -393,11 +393,11 @@ describe Chef::Application do
def raises_informative_fatals_on_configure_chef
config_file_regexp = Regexp.new @app.config[:config_file]
- expect(Chef::Log).to receive(:fatal).
- with(/Configuration error/)
- expect(Chef::Log).to receive(:fatal).
- with(config_file_regexp).
- at_least(1).times
+ expect(Chef::Log).to receive(:fatal)
+ .with(/Configuration error/)
+ expect(Chef::Log).to receive(:fatal)
+ .with(config_file_regexp)
+ .at_least(1).times
@app.configure_chef
end
@@ -447,7 +447,7 @@ describe Chef::Application do
ARGV.replace(@original_argv)
end
- let(:fake_config_fetcher) { instance_double(Chef::ConfigFetcher, expanded_path: "/thisbetternotexist", :"config_missing?" => false, read_config: "" ) }
+ let(:fake_config_fetcher) { instance_double(Chef::ConfigFetcher, expanded_path: "/thisbetternotexist", "config_missing?": false, read_config: "" ) }
it "reading a mixlib-config default works" do
@app.parse_options
diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb
index 0e35343352..a9b27f238e 100644
--- a/spec/unit/audit/audit_event_proxy_spec.rb
+++ b/spec/unit/audit/audit_event_proxy_spec.rb
@@ -35,19 +35,19 @@ describe Chef::Audit::AuditEventProxy do
let(:description) { "poots" }
let(:group) do
- double("ExampleGroup", :parent_groups => parents,
- :description => description) end
- let(:notification) { double("Notification", :group => group) }
+ double("ExampleGroup", parent_groups: parents,
+ description: description) end
+ let(:notification) { double("Notification", group: group) }
context "when notified from a top-level example group" do
let(:parents) { [double("ExampleGroup")] }
it "notifies control_group_started event" do
- expect(Chef::Log).to receive(:trace).
- with("Entered \`control_group\` block named poots")
- expect(events).to receive(:control_group_started).
- with(description)
+ expect(Chef::Log).to receive(:trace)
+ .with("Entered \`control_group\` block named poots")
+ expect(events).to receive(:control_group_started)
+ .with(description)
audit_event_proxy.example_group_started(notification)
end
end
@@ -66,9 +66,9 @@ describe Chef::Audit::AuditEventProxy do
describe "#stop" do
let(:examples) { [] }
- let(:notification) { double("Notification", :examples => examples) }
+ let(:notification) { double("Notification", examples: examples) }
let(:exception) { nil }
- let(:example) { double("Example", :exception => exception) }
+ let(:example) { double("Example", exception: exception) }
let(:control_group_name) { "audit test" }
let(:control_data) { double("ControlData") }
@@ -87,14 +87,14 @@ describe Chef::Audit::AuditEventProxy do
let(:excpetion) { nil }
before do
- allow(audit_event_proxy).to receive(:build_control_from).
- with(example).
- and_return([control_group_name, control_data])
+ allow(audit_event_proxy).to receive(:build_control_from)
+ .with(example)
+ .and_return([control_group_name, control_data])
end
it "notifies events" do
- expect(events).to receive(:control_example_success).
- with(control_group_name, control_data)
+ expect(events).to receive(:control_example_success)
+ .with(control_group_name, control_data)
audit_event_proxy.stop(notification)
end
end
@@ -105,14 +105,14 @@ describe Chef::Audit::AuditEventProxy do
let(:exception) { double("ExpectationNotMet") }
before do
- allow(audit_event_proxy).to receive(:build_control_from).
- with(example).
- and_return([control_group_name, control_data])
+ allow(audit_event_proxy).to receive(:build_control_from)
+ .with(example)
+ .and_return([control_group_name, control_data])
end
it "notifies events" do
- expect(events).to receive(:control_example_failure).
- with(control_group_name, control_data, exception)
+ expect(events).to receive(:control_example_failure)
+ .with(control_group_name, control_data, exception)
audit_event_proxy.stop(notification)
end
end
@@ -122,29 +122,29 @@ describe Chef::Audit::AuditEventProxy do
let(:examples) { [example] }
let(:example) do
- double("Example", :metadata => metadata,
- :description => example_description,
- :full_description => full_description, :exception => nil) end
+ double("Example", metadata: metadata,
+ description: example_description,
+ full_description: full_description, exception: nil) end
let(:metadata) do
{
- :described_class => described_class,
- :example_group => example_group,
- :line_number => line,
+ described_class: described_class,
+ example_group: example_group,
+ line_number: line,
}
end
let(:example_group) do
{
- :description => group_description,
- :parent_example_group => parent_group,
+ description: group_description,
+ parent_example_group: parent_group,
}
end
let(:parent_group) do
{
- :description => control_group_name,
- :parent_example_group => nil,
+ description: control_group_name,
+ parent_example_group: nil,
}
end
@@ -152,12 +152,12 @@ describe Chef::Audit::AuditEventProxy do
let(:control_data) do
{
- :name => example_description,
- :desc => full_description,
- :resource_type => resource_type,
- :resource_name => resource_name,
- :context => context,
- :line_number => line,
+ name: example_description,
+ desc: full_description,
+ resource_type: resource_type,
+ resource_name: resource_name,
+ context: context,
+ line_number: line,
}
end
@@ -165,17 +165,17 @@ describe Chef::Audit::AuditEventProxy do
before do
if described_class
- allow(described_class).to receive(:instance_variable_get).
- with(:@name).
- and_return(resource_name)
- allow(described_class.class).to receive(:name).
- and_return(described_class.class)
+ allow(described_class).to receive(:instance_variable_get)
+ .with(:@name)
+ .and_return(resource_name)
+ allow(described_class.class).to receive(:name)
+ .and_return(described_class.class)
end
end
it "returns the controls block name and example metadata for reporting" do
- expect(events).to receive(:control_example_success).
- with(control_group_name, control_data)
+ expect(events).to receive(:control_example_success)
+ .with(control_group_name, control_data)
audit_event_proxy.stop(notification)
end
end
@@ -227,7 +227,7 @@ describe Chef::Audit::AuditEventProxy do
# Metadata fields
let(:described_class) do
double("Serverspec::Type::Port",
- :class => "Serverspec::Type::Port", :name => resource_name) end
+ class: "Serverspec::Type::Port", name: resource_name) end
# Control data fields
let(:resource_type) { "Port" }
@@ -288,20 +288,20 @@ describe Chef::Audit::AuditEventProxy do
# Metadata parts
let(:described_class) do
double("Serverspec::Type::File",
- :class => "Serverspec::Type::File", :name => resource_name) end
+ class: "Serverspec::Type::File", name: resource_name) end
# Example group parts
let(:parent_group) do
{
- :description => outer_group_description,
- :parent_example_group => control_group,
+ description: outer_group_description,
+ parent_example_group: control_group,
}
end
let(:control_group) do
{
- :description => control_group_name,
- :parent_example_group => nil,
+ description: control_group_name,
+ parent_example_group: nil,
}
end
diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb
index 3edee46932..4c13eca390 100644
--- a/spec/unit/audit/audit_reporter_spec.rb
+++ b/spec/unit/audit/audit_reporter_spec.rb
@@ -24,13 +24,13 @@ describe Chef::Audit::AuditReporter do
let(:rest) { double("rest") }
let(:reporter) { described_class.new(rest) }
- let(:node) { double("node", :name => "sofreshsoclean") }
+ let(:node) { double("node", name: "sofreshsoclean") }
let(:run_id) { 0 }
let(:start_time) { Time.new(2014, 12, 3, 9, 31, 05, "-08:00") }
let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") }
let(:run_status) do
- instance_double(Chef::RunStatus, :node => node, :run_id => run_id,
- :start_time => start_time, :end_time => end_time) end
+ instance_double(Chef::RunStatus, node: node, run_id: run_id,
+ start_time: start_time, end_time: end_time) end
describe "#audit_phase_start" do
@@ -79,17 +79,17 @@ describe Chef::Audit::AuditReporter do
"X-Ops-Audit-Report-Protocol-Version" => Chef::Audit::AuditReporter::PROTOCOL_VERSION,
}
- expect(rest).to receive(:post).
- with("controls", run_data, headers)
+ expect(rest).to receive(:post)
+ .with("controls", run_data, headers)
reporter.run_completed(node)
end
context "when audit phase failed" do
let(:audit_error) do
- double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
+ double("AuditError", class: "Chef::Exceptions::AuditError",
+ message: "Audit phase failed with error message: derpderpderp",
+ backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end
before do
reporter.instance_variable_set(:@audit_phase_error, audit_error)
@@ -99,10 +99,10 @@ describe Chef::Audit::AuditReporter do
reporter.run_completed(node)
expect(run_data).to have_key(:error)
expect(run_data).to have_key(:error)
- expect(run_data[:error]).to eq <<-EOM.strip!
-Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp
-/path/recipe.rb:57
-/path/library.rb:106
+ expect(run_data[:error]).to eq <<~EOM.strip!
+ Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp
+ /path/recipe.rb:57
+ /path/library.rb:106
EOM
end
@@ -123,7 +123,7 @@ EOM
context "the error is an http error" do
- let(:response) { double("response", :code => code) }
+ let(:response) { double("response", code: code) }
before do
expect(Chef::Log).to receive(:trace).with(/Sending audit report/)
@@ -145,12 +145,12 @@ EOM
shared_examples "non-404 error code" do
it "saves the error report" do
- expect(Chef::FileCache).to receive(:store).
- with("failed-audit-data.json", an_instance_of(String), 0640).
- and_return(true)
- expect(Chef::FileCache).to receive(:load).
- with("failed-audit-data.json", false).
- and_return(true)
+ expect(Chef::FileCache).to receive(:store)
+ .with("failed-audit-data.json", an_instance_of(String), 0640)
+ .and_return(true)
+ expect(Chef::FileCache).to receive(:load)
+ .with("failed-audit-data.json", false)
+ .and_return(true)
expect(Chef::Log).to receive(:error).with(/Failed to post audit report to server/)
reporter.run_completed(node)
end
@@ -184,9 +184,9 @@ EOM
context "when reporting url fatals are enabled" do
before do
- allow(Chef::Config).to receive(:[]).
- with(:enable_reporting_url_fatals).
- and_return(true)
+ allow(Chef::Config).to receive(:[])
+ .with(:enable_reporting_url_fatals)
+ .and_return(true)
end
it "raises the error" do
@@ -236,14 +236,14 @@ EOM
let(:run_data) { audit_data.to_hash }
let(:audit_error) do
- double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
+ double("AuditError", class: "Chef::Exceptions::AuditError",
+ message: "Audit phase failed with error message: derpderpderp",
+ backtrace: ["/path/recipe.rb:57", "/path/library.rb:106"]) end
let(:run_error) do
- double("RunError", :class => "Chef::Exceptions::RunError",
- :message => "This error shouldn't be reported.",
- :backtrace => ["fix it", "fix it", "fix it"]) end
+ double("RunError", class: "Chef::Exceptions::RunError",
+ message: "This error shouldn't be reported.",
+ backtrace: ["fix it", "fix it", "fix it"]) end
before do
allow(reporter).to receive(:auditing_enabled?).and_return(true)
@@ -269,10 +269,10 @@ EOM
expect(rest).to receive(:post)
reporter.run_failed(run_error)
expect(run_data).to have_key(:error)
- expect(run_data[:error]).to eq <<-EOM.strip!
-Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp
-/path/recipe.rb:57
-/path/library.rb:106
+ expect(run_data[:error]).to eq <<~EOM.strip!
+ Chef::Exceptions::AuditError: Audit phase failed with error message: derpderpderp
+ /path/recipe.rb:57
+ /path/library.rb:106
EOM
end
end
@@ -282,10 +282,10 @@ EOM
let(:control_group_foo) do
instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("foo metadata")) end
+ metadata: double("foo metadata")) end
let(:control_group_bar) do
instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("bar metadata")) end
+ metadata: double("bar metadata")) end
let(:ordered_control_groups) do
{
@@ -296,11 +296,11 @@ EOM
let(:audit_data) do
instance_double(Chef::Audit::AuditData,
- :add_control_group => true) end
+ add_control_group: true) end
let(:run_context) do
instance_double(Chef::RunContext,
- :audits => ordered_control_groups) end
+ audits: ordered_control_groups) end
before do
allow(reporter).to receive(:ordered_control_groups).and_return(ordered_control_groups)
@@ -350,20 +350,20 @@ EOM
let(:name) { "bat" }
let(:control_group) do
instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("metadata")) end
+ metadata: double("metadata")) end
before do
- allow(Chef::Audit::ControlGroupData).to receive(:new).
- with(name, control_group.metadata).
- and_return(control_group)
+ allow(Chef::Audit::ControlGroupData).to receive(:new)
+ .with(name, control_group.metadata)
+ .and_return(control_group)
end
it "stores the control group" do
expect(ordered_control_groups).to receive(:has_key?).with(name).and_return(false)
allow(run_context.audits).to receive(:[]).with(name).and_return(control_group)
- expect(ordered_control_groups).to receive(:store).
- with(name, control_group).
- and_call_original
+ expect(ordered_control_groups).to receive(:store)
+ .with(name, control_group)
+ .and_call_original
reporter.control_group_started(name)
# stubbed :has_key? above, which is used by the have_key matcher,
# so instead we check the response to Hash's #key? because luckily
@@ -397,11 +397,11 @@ EOM
let(:name) { "bar" }
let(:example_data) { double("example data") }
- let(:error) { double("Exception", :message => "oopsie") }
+ let(:error) { double("Exception", message: "oopsie") }
it "notifies the control group the example failed" do
- expect(control_group_bar).to receive(:example_failure).
- with(example_data, error.message)
+ expect(control_group_bar).to receive(:example_failure)
+ .with(example_data, error.message)
reporter.control_example_failure(name, example_data, error)
end
end
@@ -410,9 +410,9 @@ EOM
shared_examples "enabled?" do |true_or_false|
it "returns #{true_or_false}" do
- expect(Chef::Config).to receive(:[]).
- with(:audit_mode).
- and_return(audit_setting)
+ expect(Chef::Config).to receive(:[])
+ .with(:audit_mode)
+ .and_return(audit_setting)
expect(reporter.auditing_enabled?).to be true_or_false
end
end
diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb
index ea4ac260f9..82af77dcea 100644
--- a/spec/unit/audit/control_group_data_spec.rb
+++ b/spec/unit/audit/control_group_data_spec.rb
@@ -72,8 +72,8 @@ describe Chef::Audit::AuditData do
describe ":control_groups" do
- let(:control_hash_1) { { :name => "control group 1" } }
- let(:control_hash_2) { { :name => "control group 2" } }
+ let(:control_hash_1) { { name: "control group 1" } }
+ let(:control_hash_2) { { name: "control group 2" } }
let(:control_groups) { audit_data_hash[:control_groups] }
@@ -174,11 +174,11 @@ describe Chef::Audit::ControlGroupData do
let(:control_data) do
{
- :name => name,
- :resource_type => resource_type,
- :resource_name => resource_name,
- :context => context,
- :line_number => line_number,
+ name: name,
+ resource_type: resource_type,
+ resource_name: resource_name,
+ context: context,
+ line_number: line_number,
}
end
@@ -193,11 +193,11 @@ describe Chef::Audit::ControlGroupData do
context: context, line_number: line_number) end
before do
- allow(Chef::Audit::ControlData).to receive(:new).
- with(name: name, resource_type: resource_type,
+ allow(Chef::Audit::ControlData).to receive(:new)
+ .with(name: name, resource_type: resource_type,
resource_name: resource_name, context: context,
- line_number: line_number).
- and_return(control)
+ line_number: line_number)
+ .and_return(control)
end
end
@@ -434,22 +434,22 @@ describe Chef::Audit::ControlGroupData do
context "with multiple controls added" do
- let(:control_hash_1) { { :line_number => 27 } }
- let(:control_hash_2) { { :line_number => 13 } }
- let(:control_hash_3) { { :line_number => 35 } }
+ let(:control_hash_1) { { line_number: 27 } }
+ let(:control_hash_2) { { line_number: 13 } }
+ let(:control_hash_3) { { line_number: 35 } }
let(:control_1) do
double("control 1",
- :line_number => control_hash_1[:line_number],
- :to_hash => control_hash_1) end
+ line_number: control_hash_1[:line_number],
+ to_hash: control_hash_1) end
let(:control_2) do
double("control 2",
- :line_number => control_hash_2[:line_number],
- :to_hash => control_hash_2) end
+ line_number: control_hash_2[:line_number],
+ to_hash: control_hash_2) end
let(:control_3) do
double("control 3",
- :line_number => control_hash_3[:line_number],
- :to_hash => control_hash_3) end
+ line_number: control_hash_3[:line_number],
+ to_hash: control_hash_3) end
let(:control_list) { [control_1, control_2, control_3] }
let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] }
diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb
index 4c03cab1d3..902ede62ed 100644
--- a/spec/unit/audit/runner_spec.rb
+++ b/spec/unit/audit/runner_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Audit::Runner do
include RSpec::Support::InSubProcess
let(:events) { double("events") }
- let(:run_context) { instance_double(Chef::RunContext, :events => events) }
+ let(:run_context) { instance_double(Chef::RunContext, events: events) }
let(:runner) { Chef::Audit::Runner.new(run_context) }
around(:each) do |ex|
@@ -89,7 +89,7 @@ describe Chef::Audit::Runner do
describe "#register_control_groups" do
let(:audits) { [] }
- let(:run_context) { instance_double(Chef::RunContext, :audits => audits) }
+ let(:run_context) { instance_double(Chef::RunContext, audits: audits) }
it "adds the control group aliases" do
runner.send(:register_control_groups)
diff --git a/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb b/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb
index 6d6e2fb0e6..60cd5c6cb7 100644
--- a/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb
+++ b/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb
@@ -68,7 +68,7 @@ describe Chef::ChefFS::DataHandler::DataBagItemDataHandler do
context "using a reserved word as part of the data bag name" do
%w{xnode rolex xenvironmentx xclientx}.each do |bag_name|
- let(:entry) { TestDataBagItem.new("#{bag_name}", "bag") }
+ let(:entry) { TestDataBagItem.new(bag_name.to_s, "bag") }
let(:object) do
{ "raw_data" => { "id" => "bag" } }
end
diff --git a/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb b/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb
index a5d177c878..b4cb5a33f2 100644
--- a/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb
+++ b/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb
@@ -25,7 +25,7 @@ describe Chef::ChefFS::DataHandler::DataHandlerBase do
{ "name" => "grizzly",
"gender" => "female",
"age" => 3,
- "food" => "honey"
+ "food" => "honey",
}
end
@@ -33,7 +33,7 @@ describe Chef::ChefFS::DataHandler::DataHandlerBase do
{ "family" => "ursidae",
"hibernate" => true,
"food" => "berries",
- "avg_lifespan_years" => 22
+ "avg_lifespan_years" => 22,
}
end
@@ -44,7 +44,7 @@ describe Chef::ChefFS::DataHandler::DataHandlerBase do
"hibernate" => true,
"avg_lifespan_years" => 22,
"age" => 3,
- "food" => "honey"
+ "food" => "honey",
}
end
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index d946fcb9e7..229a48c2db 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -28,62 +28,62 @@ def remove_os_differences(diff)
diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS")
end
-describe "diff", :uses_diff => true do
+describe "diff", uses_diff: true do
include FileSystemSupport
context "with two filesystems with all types of difference" do
let(:a) do
memory_fs("a", {
- :both_dirs => {
- :sub_both_dirs => { :subsub => nil },
- :sub_both_files => nil,
- :sub_both_files_different => "a\n",
- :sub_both_dirs_empty => {},
- :sub_dirs_empty_in_a_filled_in_b => {},
- :sub_dirs_empty_in_b_filled_in_a => { :subsub => nil },
- :sub_a_only_dir => { :subsub => nil },
- :sub_a_only_file => nil,
- :sub_dir_in_a_file_in_b => {},
- :sub_file_in_a_dir_in_b => nil,
+ both_dirs: {
+ sub_both_dirs: { subsub: nil },
+ sub_both_files: nil,
+ sub_both_files_different: "a\n",
+ sub_both_dirs_empty: {},
+ sub_dirs_empty_in_a_filled_in_b: {},
+ sub_dirs_empty_in_b_filled_in_a: { subsub: nil },
+ sub_a_only_dir: { subsub: nil },
+ sub_a_only_file: nil,
+ sub_dir_in_a_file_in_b: {},
+ sub_file_in_a_dir_in_b: nil,
},
- :both_files => nil,
- :both_files_different => "a\n",
- :both_dirs_empty => {},
- :dirs_empty_in_a_filled_in_b => {},
- :dirs_empty_in_b_filled_in_a => { :subsub => nil },
- :dirs_in_a_cannot_be_in_b => {},
- :file_in_a_cannot_be_in_b => nil,
- :a_only_dir => { :subsub => nil },
- :a_only_file => nil,
- :dir_in_a_file_in_b => {},
- :file_in_a_dir_in_b => nil,
+ both_files: nil,
+ both_files_different: "a\n",
+ both_dirs_empty: {},
+ dirs_empty_in_a_filled_in_b: {},
+ dirs_empty_in_b_filled_in_a: { subsub: nil },
+ dirs_in_a_cannot_be_in_b: {},
+ file_in_a_cannot_be_in_b: nil,
+ a_only_dir: { subsub: nil },
+ a_only_file: nil,
+ dir_in_a_file_in_b: {},
+ file_in_a_dir_in_b: nil,
}, /cannot_be_in_a/)
end
let(:b) do
memory_fs("b", {
- :both_dirs => {
- :sub_both_dirs => { :subsub => nil },
- :sub_both_files => nil,
- :sub_both_files_different => "b\n",
- :sub_both_dirs_empty => {},
- :sub_dirs_empty_in_a_filled_in_b => { :subsub => nil },
- :sub_dirs_empty_in_b_filled_in_a => {},
- :sub_b_only_dir => { :subsub => nil },
- :sub_b_only_file => nil,
- :sub_dir_in_a_file_in_b => nil,
- :sub_file_in_a_dir_in_b => {},
+ both_dirs: {
+ sub_both_dirs: { subsub: nil },
+ sub_both_files: nil,
+ sub_both_files_different: "b\n",
+ sub_both_dirs_empty: {},
+ sub_dirs_empty_in_a_filled_in_b: { subsub: nil },
+ sub_dirs_empty_in_b_filled_in_a: {},
+ sub_b_only_dir: { subsub: nil },
+ sub_b_only_file: nil,
+ sub_dir_in_a_file_in_b: nil,
+ sub_file_in_a_dir_in_b: {},
},
- :both_files => nil,
- :both_files_different => "b\n",
- :both_dirs_empty => {},
- :dirs_empty_in_a_filled_in_b => { :subsub => nil },
- :dirs_empty_in_b_filled_in_a => {},
- :dirs_in_b_cannot_be_in_a => {},
- :file_in_b_cannot_be_in_a => nil,
- :b_only_dir => { :subsub => nil },
- :b_only_file => nil,
- :dir_in_a_file_in_b => nil,
- :file_in_a_dir_in_b => {},
+ both_files: nil,
+ both_files_different: "b\n",
+ both_dirs_empty: {},
+ dirs_empty_in_a_filled_in_b: { subsub: nil },
+ dirs_empty_in_b_filled_in_a: {},
+ dirs_in_b_cannot_be_in_a: {},
+ file_in_b_cannot_be_in_a: nil,
+ b_only_dir: { subsub: nil },
+ b_only_file: nil,
+ dir_in_a_file_in_b: nil,
+ file_in_a_dir_in_b: {},
}, /cannot_be_in_b/)
end
it "Chef::ChefFS::CommandLine.diff_print(/)" do
diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb
index c4d076ef90..58cdbb28c2 100644
--- a/spec/unit/chef_fs/file_pattern_spec.rb
+++ b/spec/unit/chef_fs/file_pattern_spec.rb
@@ -157,7 +157,7 @@ describe Chef::ChefFS::FilePattern do
end
end
- context 'with simple pattern "a\*\b"', :skip => (Chef::Platform.windows?) do
+ context 'with simple pattern "a\*\b"', skip: (Chef::Platform.windows?) do
let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') }
it "match?" do
expect(pattern.match?("a*b")).to be_truthy
@@ -264,7 +264,7 @@ describe Chef::ChefFS::FilePattern do
end
end
- context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', :skip => (Chef::Platform.windows?) do
+ context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (Chef::Platform.windows?) do
let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") }
it "match?" do
expect(pattern.match?("/abc/de1f/ghi")).to be_truthy
diff --git a/spec/unit/chef_fs/file_system/repository/directory_spec.rb b/spec/unit/chef_fs/file_system/repository/directory_spec.rb
index e44cc15167..efd17204e0 100644
--- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb
+++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb
@@ -88,7 +88,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do
end
it "returns a non existent object otherwise" do
- file_double = instance_double(TestFile, :name_valid? => false)
+ file_double = instance_double(TestFile, name_valid?: false)
expect(TestFile).to receive(:new).with("test_child", test_directory).and_return(file_double)
expect(test_directory.child("test_child")).to be_an_instance_of(Chef::ChefFS::FileSystem::NonexistentFSObject)
end
diff --git a/spec/unit/chef_fs/file_system_spec.rb b/spec/unit/chef_fs/file_system_spec.rb
index c7ed83524b..fed468f2cd 100644
--- a/spec/unit/chef_fs/file_system_spec.rb
+++ b/spec/unit/chef_fs/file_system_spec.rb
@@ -57,17 +57,17 @@ describe Chef::ChefFS::FileSystem do
context "with a populated filesystem" do
let(:fs) do
memory_fs("", {
- :a => {
- :aa => {
- :c => "",
- :zz => "",
+ a: {
+ aa: {
+ c: "",
+ zz: "",
},
- :ab => {
- :c => "",
+ ab: {
+ c: "",
},
},
- :x => "",
- :y => {},
+ x: "",
+ y: {},
})
end
context "list" do
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 84637f7283..cbfa3402fa 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -20,7 +20,7 @@ describe Chef::ChefFS::Parallelizer do
end
def parallelize(inputs, options = {}, &block)
- parallelizer.parallelize(inputs, { :main_thread_processing => false }.merge(options), &block)
+ parallelizer.parallelize(inputs, { main_thread_processing: false }.merge(options), &block)
end
it "parallel_do creates unordered output as soon as it is available" do
@@ -35,14 +35,14 @@ describe Chef::ChefFS::Parallelizer do
context "With :ordered => false (unordered output)" do
it "An empty input produces an empty output" do
- expect(parallelize([], :ordered => false) do
+ expect(parallelize([], ordered: false) do
sleep 10
end.to_a).to eql([])
expect(elapsed_time).to be < 0.1
end
it "10 sleep(0.2)s complete within 0.5 seconds" do
- expect(parallelize(1.upto(10), :ordered => false) do |i|
+ expect(parallelize(1.upto(10), ordered: false) do |i|
sleep 0.2
"x"
end.to_a).to eq(%w{x x x x x x x x x x})
@@ -50,7 +50,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "The output comes as soon as it is available" do
- enum = parallelize([0.5, 0.3, 0.1], :ordered => false) do |val|
+ enum = parallelize([0.5, 0.3, 0.1], ordered: false) do |val|
sleep val
val
end
@@ -64,7 +64,7 @@ describe Chef::ChefFS::Parallelizer do
input = TestEnumerable.new(0.5, 0.3, 0.1) do
raise "hi"
end
- enum = parallelize(input, :ordered => false) { |x| sleep(x); x }
+ enum = parallelize(input, ordered: false) { |x| sleep(x); x }
results = []
expect { enum.each { |value| results << value } }.to raise_error "hi"
expect(results).to eq([ 0.1, 0.3, 0.5 ])
@@ -73,7 +73,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions in output are raised after all processing is done" do
processed = 0
- enum = parallelize([1, 2, "x", 3], :ordered => false) do |x|
+ enum = parallelize([1, 2, "x", 3], ordered: false) do |x|
if x == "x"
sleep 0.1
raise "hi"
@@ -91,7 +91,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
- parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x|
+ parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], ordered: false, stop_on_exception: true) do |x|
if x == "x"
sleep(0.1)
raise "hi"
@@ -114,7 +114,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "10 sleep(0.2)s complete within 0.5 seconds" do
- expect(parallelize(1.upto(10), :ordered => true) do |i|
+ expect(parallelize(1.upto(10), ordered: true) do |i|
sleep 0.2
"x"
end.to_a).to eq(%w{x x x x x x x x x x})
@@ -163,7 +163,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
- parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x|
+ parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], ordered: false, stop_on_exception: true) do |x|
if x == "x"
sleep(0.1)
raise "hi"
@@ -205,7 +205,7 @@ describe Chef::ChefFS::Parallelizer do
started = false
@occupying_job_finished = occupying_job_finished = [ false ]
@thread = Thread.new do
- parallelizer.parallelize([0], :main_thread_processing => false) do |x|
+ parallelizer.parallelize([0], main_thread_processing: false) do |x|
started = true
sleep(0.3)
occupying_job_finished[0] = true
@@ -229,7 +229,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "parallelize with :main_thread_processing = false waits for the job to finish" do
- expect(parallelizer.parallelize([1], :main_thread_processing => false) do |x|
+ expect(parallelizer.parallelize([1], main_thread_processing: false) do |x|
sleep(0.1)
x + 1
end.to_a).to eq([ 2 ])
@@ -434,7 +434,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "does not have contention issues with large numbers of inputs with ordering off" do
- expect(parallelizer.parallelize(1.upto(500), :ordered => false) { |x| x + 1 }.to_a.sort).to eq(2.upto(501).to_a)
+ expect(parallelizer.parallelize(1.upto(500), ordered: false) { |x| x + 1 }.to_a.sort).to eq(2.upto(501).to_a)
end
it "does not have contention issues with large numbers of jobs and inputs with ordering off" do
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 001be10e0b..4f9d66d776 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -179,12 +179,12 @@ describe Chef::Client do
context "when an override run list is given" do
it "permits spaces in overriding run list" do
- Chef::Client.new(nil, :override_runlist => "role[a], role[b]")
+ Chef::Client.new(nil, override_runlist: "role[a], role[b]")
end
describe "calling run" do
include_examples "a successful client run" do
- let(:client_opts) { { :override_runlist => "recipe[override_recipe]" } }
+ let(:client_opts) { { override_runlist: "recipe[override_recipe]" } }
def stub_for_sync_cookbooks
# --Client#setup_run_context
@@ -192,9 +192,9 @@ describe Chef::Client do
#
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync)
- expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", { :run_list => ["override_recipe"] }).
- and_return({})
+ expect(http_cookbook_sync).to receive(:post)
+ .with("environments/_default/cookbook_versions", { run_list: ["override_recipe"] })
+ .and_return({})
end
def stub_for_node_save
@@ -218,7 +218,7 @@ describe Chef::Client do
include_examples "a successful client run" do
let(:new_runlist) { "recipe[new_run_list_recipe]" }
- let(:client_opts) { { :runlist => new_runlist } }
+ let(:client_opts) { { runlist: new_runlist } }
def stub_for_sync_cookbooks
# --Client#setup_run_context
@@ -226,9 +226,9 @@ describe Chef::Client do
#
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], version_class: Chef::CookbookManifestVersions).and_return(http_cookbook_sync)
- expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", { :run_list => ["new_run_list_recipe"] }).
- and_return({})
+ expect(http_cookbook_sync).to receive(:post)
+ .with("environments/_default/cookbook_versions", { run_list: ["new_run_list_recipe"] })
+ .and_return({})
end
before do
@@ -293,7 +293,7 @@ describe Chef::Client do
describe "when handling run failures" do
it "should remove the run_lock on failure of #load_node" do
- @run_lock = double("Chef::RunLock", :acquire => true)
+ @run_lock = double("Chef::RunLock", acquire: true)
allow(Chef::RunLock).to receive(:new).and_return(@run_lock)
@events = double("Chef::EventDispatch::Dispatcher").as_null_object
@@ -410,8 +410,8 @@ describe Chef::Client do
let(:run_context) { double("Chef::RunContext") }
let(:recipe) { double("Chef::Recipe (required recipe)") }
let(:required_recipe) do
- <<EOM
-fake_recipe_variable = "for reals"
+ <<~EOM
+ fake_recipe_variable = "for reals"
EOM
end
@@ -429,8 +429,8 @@ EOM
context "when the required_recipe has bad contents" do
let(:required_recipe) do
- <<EOM
-this is not a recipe
+ <<~EOM
+ this is not a recipe
EOM
end
it "should not raise an error" do
@@ -488,7 +488,7 @@ EOM
context "fatal admin check is configured" do
it "should not raise an exception" do
- client.do_windows_admin_check #should not raise
+ client.do_windows_admin_check # should not raise
end
end
end
diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb
index a674d4de33..abaea6b2dc 100644
--- a/spec/unit/config_fetcher_spec.rb
+++ b/spec/unit/config_fetcher_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
require "chef/config_fetcher"
describe Chef::ConfigFetcher do
- let(:valid_json) { Chef::JSONCompat.to_json({ :a => "b" }) }
+ let(:valid_json) { Chef::JSONCompat.to_json({ a: "b" }) }
let(:invalid_json) { %q[{"syntax-error": "missing quote}] }
let(:http) { double("Chef::HTTP::Simple") }
@@ -16,9 +16,9 @@ describe Chef::ConfigFetcher do
let(:config_content) { "# The client.rb content" }
it "reads the file from disk" do
- expect(::File).to receive(:read).
- with(config_location).
- and_return(config_content)
+ expect(::File).to receive(:read)
+ .with(config_location)
+ .and_return(config_content)
expect(fetcher.read_config).to eq(config_content)
end
@@ -42,9 +42,9 @@ describe Chef::ConfigFetcher do
let(:config_location) { "/etc/chef/first-boot.json" }
it "returns the parsed JSON" do
- expect(::File).to receive(:read).
- with(config_location).
- and_return(valid_json)
+ expect(::File).to receive(:read)
+ .with(config_location)
+ .and_return(valid_json)
expect(fetcher.fetch_json).to eq({ "a" => "b" })
end
@@ -53,12 +53,12 @@ describe Chef::ConfigFetcher do
it "reports the JSON error" do
- expect(::File).to receive(:read).
- with(config_location).
- and_return(invalid_json)
+ expect(::File).to receive(:read)
+ .with(config_location)
+ .and_return(invalid_json)
- expect(Chef::Application).to receive(:fatal!).
- with(invalid_json_error_regex)
+ expect(Chef::Application).to receive(:fatal!)
+ .with(invalid_json_error_regex)
fetcher.fetch_json
end
end
@@ -78,14 +78,14 @@ describe Chef::ConfigFetcher do
describe "reading the file" do
before do
- expect(Chef::HTTP::Simple).to receive(:new).
- with(config_location).
- and_return(http)
+ expect(Chef::HTTP::Simple).to receive(:new)
+ .with(config_location)
+ .and_return(http)
end
it "reads the file over HTTP" do
- expect(http).to receive(:get).
- with("").and_return(config_content)
+ expect(http).to receive(:get)
+ .with("").and_return(config_content)
expect(fetcher.read_config).to eq(config_content)
end
@@ -93,18 +93,18 @@ describe Chef::ConfigFetcher do
let(:config_location) { "https://example.com/foo.json" }
it "fetches the file and parses it" do
- expect(http).to receive(:get).
- with("").and_return(valid_json)
+ expect(http).to receive(:get)
+ .with("").and_return(valid_json)
expect(fetcher.fetch_json).to eq({ "a" => "b" })
end
context "and the JSON is invalid" do
it "reports the JSON error" do
- expect(http).to receive(:get).
- with("").and_return(invalid_json)
+ expect(http).to receive(:get)
+ .with("").and_return(invalid_json)
- expect(Chef::Application).to receive(:fatal!).
- with(invalid_json_error_regex)
+ expect(Chef::Application).to receive(:fatal!)
+ .with(invalid_json_error_regex)
fetcher.fetch_json
end
end
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 68cb589251..c36f66f18a 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -7,8 +7,8 @@ RSpec.describe Chef::Config do
shared_examples_for "deprecated by ohai but not deprecated" do
it "does not emit a deprecation warning when set" do
- expect(Chef::Log).to_not receive(:warn).
- with(/Ohai::Config\[:#{option}\] is deprecated/)
+ expect(Chef::Log).to_not receive(:warn)
+ .with(/Ohai::Config\[:#{option}\] is deprecated/)
Chef::Config[option] = value
expect(Chef::Config[option]).to eq(value)
end
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index a2cb35e60d..4da1c57964 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -175,15 +175,15 @@ describe Chef::Cookbook::Metadata do
describe "meta-data attributes" do
params = {
- :maintainer => "Adam Jacob",
- :maintainer_email => "adam@opscode.com",
- :license => "Apache v2.0",
- :description => "Foobar!",
- :long_description => "Much Longer\nSeriously",
- :version => "0.6.0",
- :source_url => "http://example.com",
- :issues_url => "http://example.com/issues",
- :privacy => true,
+ maintainer: "Adam Jacob",
+ maintainer_email: "adam@opscode.com",
+ license: "Apache v2.0",
+ description: "Foobar!",
+ long_description: "Much Longer\nSeriously",
+ version: "0.6.0",
+ source_url: "http://example.com",
+ issues_url: "http://example.com/issues",
+ privacy: true,
}
params.sort_by(&:to_s).each do |field, field_value|
describe field do
@@ -212,8 +212,8 @@ describe Chef::Cookbook::Metadata do
describe "describing dependencies" do
dep_types = {
- :depends => [ :dependencies, "foo::bar", "> 0.2" ],
- :provides => [ :providing, "foo::bar", "<= 0.2" ],
+ depends: [ :dependencies, "foo::bar", "> 0.2" ],
+ provides: [ :providing, "foo::bar", "<= 0.2" ],
}
dep_types.sort_by(&:to_s).each do |dep, dep_args|
check_with = dep_args.shift
@@ -229,8 +229,8 @@ describe Chef::Cookbook::Metadata do
end
dep_types = {
- :depends => [ :dependencies, "foo::bar", ">0.2", "> 0.2" ],
- :provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
+ depends: [ :dependencies, "foo::bar", ">0.2", "> 0.2" ],
+ provides: [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
}
dep_types.sort_by(&:to_s).each do |dep, dep_args|
check_with = dep_args.shift
@@ -248,8 +248,8 @@ describe Chef::Cookbook::Metadata do
describe "in the obsoleted format" do
dep_types = {
- :depends => [ "foo::bar", "> 0.2", "< 1.0" ],
- :provides => [ "foo::bar", "> 0.2", "< 1.0" ],
+ depends: [ "foo::bar", "> 0.2", "< 1.0" ],
+ provides: [ "foo::bar", "> 0.2", "< 1.0" ],
}
dep_types.each do |dep, dep_args|
@@ -261,8 +261,8 @@ describe Chef::Cookbook::Metadata do
describe "with obsolete operators" do
dep_types = {
- :depends => [ "foo::bar", ">> 0.2"],
- :provides => [ "foo::bar", ">> 0.2"],
+ depends: [ "foo::bar", ">> 0.2"],
+ provides: [ "foo::bar", ">> 0.2"],
}
dep_types.each do |dep, dep_args|
@@ -435,61 +435,61 @@ describe Chef::Cookbook::Metadata do
it "should not accept anything but a string for display_name" do
expect do
- metadata.attribute("db/mysql/databases", :display_name => "foo")
+ metadata.attribute("db/mysql/databases", display_name: "foo")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :display_name => Hash.new)
+ metadata.attribute("db/mysql/databases", display_name: Hash.new)
end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the description" do
expect do
- metadata.attribute("db/mysql/databases", :description => "foo")
+ metadata.attribute("db/mysql/databases", description: "foo")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :description => Hash.new)
+ metadata.attribute("db/mysql/databases", description: Hash.new)
end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the source_url" do
expect do
- metadata.attribute("db/mysql/databases", :source_url => "foo")
+ metadata.attribute("db/mysql/databases", source_url: "foo")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :source_url => Hash.new)
+ metadata.attribute("db/mysql/databases", source_url: Hash.new)
end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the issues_url" do
expect do
- metadata.attribute("db/mysql/databases", :issues_url => "foo")
+ metadata.attribute("db/mysql/databases", issues_url: "foo")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :issues_url => Hash.new)
+ metadata.attribute("db/mysql/databases", issues_url: Hash.new)
end.to raise_error(ArgumentError)
end
it "should not accept anything but true or false for the privacy flag" do
expect do
- metadata.attribute("db/mysql/databases", :privacy => true)
+ metadata.attribute("db/mysql/databases", privacy: true)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :privacy => false)
+ metadata.attribute("db/mysql/databases", privacy: false)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :privacy => "true")
+ metadata.attribute("db/mysql/databases", privacy: "true")
end.to raise_error(ArgumentError)
end
it "should not accept anything but an array of strings for choice" do
expect do
- metadata.attribute("db/mysql/databases", :choice => %w{dedicated shared})
+ metadata.attribute("db/mysql/databases", choice: %w{dedicated shared})
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :choice => [10, "shared"])
+ metadata.attribute("db/mysql/databases", choice: [10, "shared"])
end.to raise_error(ArgumentError)
expect do
- metadata.attribute("db/mysql/databases", :choice => Hash.new)
+ metadata.attribute("db/mysql/databases", choice: Hash.new)
end.to raise_error(ArgumentError)
end
@@ -500,13 +500,13 @@ describe Chef::Cookbook::Metadata do
it "should let calculated be true or false" do
expect do
- metadata.attribute("db/mysql/databases", :calculated => true)
+ metadata.attribute("db/mysql/databases", calculated: true)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :calculated => false)
+ metadata.attribute("db/mysql/databases", calculated: false)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :calculated => Hash.new)
+ metadata.attribute("db/mysql/databases", calculated: Hash.new)
end.to raise_error(ArgumentError)
end
@@ -517,55 +517,55 @@ describe Chef::Cookbook::Metadata do
it "accepts String for the attribute type" do
expect do
- metadata.attribute("db/mysql/databases", :type => "string")
+ metadata.attribute("db/mysql/databases", type: "string")
end.not_to raise_error
end
it "accepts Array for the attribute type" do
expect do
- metadata.attribute("db/mysql/databases", :type => "array")
+ metadata.attribute("db/mysql/databases", type: "array")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :type => Array.new)
+ metadata.attribute("db/mysql/databases", type: Array.new)
end.to raise_error(ArgumentError)
end
it "accepts symbol for the attribute type" do
expect do
- metadata.attribute("db/mysql/databases", :type => "symbol")
+ metadata.attribute("db/mysql/databases", type: "symbol")
end.not_to raise_error
end
it "should let type be hash (backwards compatibility only)" do
expect do
- metadata.attribute("db/mysql/databases", :type => "hash")
+ metadata.attribute("db/mysql/databases", type: "hash")
end.not_to raise_error
end
it "should let required be required, recommended or optional" do
expect do
- metadata.attribute("db/mysql/databases", :required => "required")
+ metadata.attribute("db/mysql/databases", required: "required")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :required => "recommended")
+ metadata.attribute("db/mysql/databases", required: "recommended")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :required => "optional")
+ metadata.attribute("db/mysql/databases", required: "optional")
end.not_to raise_error
end
it "should convert required true to required" do
expect do
- metadata.attribute("db/mysql/databases", :required => true)
+ metadata.attribute("db/mysql/databases", required: true)
end.not_to raise_error
- #attrib = metadata.attributes["db/mysql/databases"][:required].should == "required"
+ # attrib = metadata.attributes["db/mysql/databases"][:required].should == "required"
end
it "should convert required false to optional" do
expect do
- metadata.attribute("db/mysql/databases", :required => false)
+ metadata.attribute("db/mysql/databases", required: false)
end.not_to raise_error
- #attrib = metadata.attributes["db/mysql/databases"][:required].should == "optional"
+ # attrib = metadata.attributes["db/mysql/databases"][:required].should == "optional"
end
it "should set required to 'optional' by default" do
@@ -575,10 +575,10 @@ describe Chef::Cookbook::Metadata do
it "should make sure recipes is an array" do
expect do
- metadata.attribute("db/mysql/databases", :recipes => [])
+ metadata.attribute("db/mysql/databases", recipes: [])
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :required => Hash.new)
+ metadata.attribute("db/mysql/databases", required: Hash.new)
end.to raise_error(ArgumentError)
end
@@ -589,57 +589,57 @@ describe Chef::Cookbook::Metadata do
it "should allow the default value to be a string, array, hash, boolean or numeric" do
expect do
- metadata.attribute("db/mysql/databases", :default => [])
+ metadata.attribute("db/mysql/databases", default: [])
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :default => {})
+ metadata.attribute("db/mysql/databases", default: {})
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :default => "alice in chains")
+ metadata.attribute("db/mysql/databases", default: "alice in chains")
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :default => 1337)
+ metadata.attribute("db/mysql/databases", default: 1337)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :default => true)
+ metadata.attribute("db/mysql/databases", default: true)
end.not_to raise_error
expect do
- metadata.attribute("db/mysql/databases", :required => :not_gonna_do_it)
+ metadata.attribute("db/mysql/databases", required: :not_gonna_do_it)
end.to raise_error(ArgumentError)
end
it "should limit the types allowed in the choice array" do
options = {
- :type => "string",
- :choice => %w{test1 test2},
- :default => "test1",
+ type: "string",
+ choice: %w{test1 test2},
+ default: "test1",
}
expect do
metadata.attribute("test_cookbook/test", options)
end.not_to raise_error
options = {
- :type => "boolean",
- :choice => [ true, false ],
- :default => true,
+ type: "boolean",
+ choice: [ true, false ],
+ default: true,
}
expect do
metadata.attribute("test_cookbook/test", options)
end.not_to raise_error
options = {
- :type => "numeric",
- :choice => [ 1337, 420 ],
- :default => 1337,
+ type: "numeric",
+ choice: [ 1337, 420 ],
+ default: 1337,
}
expect do
metadata.attribute("test_cookbook/test", options)
end.not_to raise_error
options = {
- :type => "numeric",
- :choice => [ true, "false" ],
- :default => false,
+ type: "numeric",
+ choice: [ true, "false" ],
+ default: false,
}
expect do
metadata.attribute("test_cookbook/test", options)
@@ -649,15 +649,15 @@ describe Chef::Cookbook::Metadata do
it "should error if default used with calculated" do
expect do
attrs = {
- :calculated => true,
- :default => [ "I thought you said calculated" ],
+ calculated: true,
+ default: [ "I thought you said calculated" ],
}
metadata.attribute("db/mysql/databases", attrs)
end.to raise_error(ArgumentError)
expect do
attrs = {
- :calculated => true,
- :default => "I thought you said calculated",
+ calculated: true,
+ default: "I thought you said calculated",
}
metadata.attribute("db/mysql/databases", attrs)
end.to raise_error(ArgumentError)
@@ -666,15 +666,15 @@ describe Chef::Cookbook::Metadata do
it "should allow a default that is a choice" do
expect do
attrs = {
- :choice => %w{a b c},
- :default => "b",
+ choice: %w{a b c},
+ default: "b",
}
metadata.attribute("db/mysql/databases", attrs)
end.not_to raise_error
expect do
attrs = {
- :choice => %w{a b c d e},
- :default => %w{b d},
+ choice: %w{a b c d e},
+ default: %w{b d},
}
metadata.attribute("db/mysql/databases", attrs)
end.not_to raise_error
@@ -683,15 +683,15 @@ describe Chef::Cookbook::Metadata do
it "should error if default is not a choice" do
expect do
attrs = {
- :choice => %w{a b c},
- :default => "d",
+ choice: %w{a b c},
+ default: "d",
}
metadata.attribute("db/mysql/databases", attrs)
end.to raise_error(ArgumentError)
expect do
attrs = {
- :choice => %w{a b c d e},
- :default => %w{b z},
+ choice: %w{a b c d e},
+ default: %w{b z},
}
metadata.attribute("db/mysql/databases", attrs)
end.to raise_error(ArgumentError)
@@ -743,7 +743,7 @@ describe Chef::Cookbook::Metadata do
metadata.provides "foo(:bar, :baz)"
metadata.recipe "test_cookbook::enlighten", "is your buddy"
metadata.attribute "bizspark/has_login",
- :display_name => "You have nothing"
+ display_name: "You have nothing"
metadata.version "1.2.3"
metadata.gem "foo", "~> 1.2"
metadata.gem "bar", ">= 2.2", "< 4.0"
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 1e6c9ef48c..dce2383a16 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -198,223 +198,223 @@ describe Chef::CookbookSynchronizer do
let(:cookbook_a_default_recipe_tempfile) do
double("Tempfile for cookbook_a default.rb recipe",
- :path => "/tmp/cookbook_a_recipes_default_rb")
+ path: "/tmp/cookbook_a_recipes_default_rb")
end
let(:cookbook_a_default_attribute_tempfile) do
double("Tempfile for cookbook_a default.rb attr file",
- :path => "/tmp/cookbook_a_attributes_default_rb")
+ path: "/tmp/cookbook_a_attributes_default_rb")
end
let(:cookbook_a_file_default_tempfile) do
double("Tempfile for cookbook_a megaman.conf file",
- :path => "/tmp/cookbook_a_file_default_tempfile")
+ path: "/tmp/cookbook_a_file_default_tempfile")
end
let(:cookbook_a_template_default_tempfile) do
double("Tempfile for cookbook_a apache.conf.erb template",
- :path => "/tmp/cookbook_a_template_default_tempfile")
+ path: "/tmp/cookbook_a_template_default_tempfile")
end
def setup_common_files_missing_expectations
# Files are not in the cache:
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/recipes/default.rb").
- and_return(false)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/attributes/default.rb").
- and_return(false)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/recipes/default.rb")
+ .and_return(false)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/attributes/default.rb")
+ .and_return(false)
# Fetch and copy default.rb recipe
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/abc123").
- and_return(cookbook_a_default_recipe_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/recipes/default.rb", false).
- and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/abc123")
+ .and_return(cookbook_a_default_recipe_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/recipes/default.rb", false)
+ .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
# Fetch and copy default.rb attribute file
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/abc456").
- and_return(cookbook_a_default_attribute_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/attributes/default.rb", false).
- and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/abc456")
+ .and_return(cookbook_a_default_attribute_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/attributes/default.rb", false)
+ .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_missing_expectations
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/files/default/megaman.conf").
- and_return(false)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb").
- and_return(false)
-
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/megaman.conf").
- and_return(cookbook_a_file_default_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/files/default/megaman.conf", false).
- and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
-
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/ffffff").
- and_return(cookbook_a_template_default_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false).
- and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return(false)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return(false)
+
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/megaman.conf")
+ .and_return(cookbook_a_file_default_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf", false)
+ .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/ffffff")
+ .and_return(cookbook_a_template_default_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
+ .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
end
def setup_common_files_chksum_mismatch_expectations
# Files are in the cache:
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/recipes/default.rb").
- and_return(true)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/attributes/default.rb").
- and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/recipes/default.rb")
+ .and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/attributes/default.rb")
+ .and_return(true)
# Fetch and copy default.rb recipe
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/abc123").
- and_return(cookbook_a_default_recipe_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/recipes/default.rb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/abc123")
+ .and_return(cookbook_a_default_recipe_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/recipes/default.rb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
# Current file has fff000, want abc123
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/recipes/default.rb").
- and_return("fff000").at_least(:once)
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("fff000").at_least(:once)
# Fetch and copy default.rb attribute file
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/abc456").
- and_return(cookbook_a_default_attribute_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/attributes/default.rb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/abc456")
+ .and_return(cookbook_a_default_attribute_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/attributes/default.rb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
# Current file has fff000, want abc456
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/attributes/default.rb").
- and_return("fff000").at_least(:once)
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("fff000").at_least(:once)
end
def setup_no_lazy_files_and_templates_chksum_mismatch_expectations
# Files are in the cache:
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/files/default/megaman.conf").
- and_return(true)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb").
- and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return(true)
# Fetch and copy megaman.conf
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/megaman.conf").
- and_return(cookbook_a_file_default_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/files/default/megaman.conf", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/megaman.conf")
+ .and_return(cookbook_a_file_default_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
# Fetch and copy apache2.conf template
- expect(server_api).to receive(:streaming_request).
- with("http://chef.example.com/ffffff").
- and_return(cookbook_a_template_default_tempfile)
- expect(file_cache).to receive(:move_to).
- with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(server_api).to receive(:streaming_request)
+ .with("http://chef.example.com/ffffff")
+ .and_return(cookbook_a_template_default_tempfile)
+ expect(file_cache).to receive(:move_to)
+ .with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
# Current file has fff000
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/default/megaman.conf").
- and_return("fff000")
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("fff000")
# Current file has fff000
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb").
- and_return("fff000")
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("fff000")
end
def setup_common_files_present_expectations
# Files are in the cache:
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/recipes/default.rb").
- and_return(true)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/attributes/default.rb").
- and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/recipes/default.rb")
+ .and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/attributes/default.rb")
+ .and_return(true)
# Current file has abc123, want abc123
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/recipes/default.rb").
- and_return("abc123").at_least(:once)
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("abc123").at_least(:once)
# Current file has abc456, want abc456
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/attributes/default.rb").
- and_return("abc456").at_least(:once)
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("abc456").at_least(:once)
# :load called twice
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/recipes/default.rb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/attributes/default.rb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/recipes/default.rb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/attributes/default.rb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_present_expectations
# Files are in the cache:
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/files/default/megaman.conf").
- and_return(true)
- expect(file_cache).to receive(:has_key?).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb").
- and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return(true)
+ expect(file_cache).to receive(:has_key?)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return(true)
# Current file has abc124, want abc124
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/default/megaman.conf").
- and_return("abc124")
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("abc124")
# Current file has abc125, want abc125
- expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file).
- with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb").
- and_return("abc125")
+ expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
+ .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("abc125")
# :load called twice
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/files/default/megaman.conf", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false).
- twice.
- and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
+ .twice
+ .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
end
describe "#server_api" do
@@ -451,8 +451,8 @@ describe Chef::CookbookSynchronizer do
it "does not fetch templates or cookbook files" do
# Implicitly tested in previous test; this test is just for behavior specification.
- expect(server_api).not_to receive(:streaming_request).
- with("http://chef.example.com/ffffff")
+ expect(server_api).not_to receive(:streaming_request)
+ .with("http://chef.example.com/ffffff")
synchronizer.sync_cookbooks
end
@@ -531,25 +531,25 @@ describe Chef::CookbookSynchronizer do
let(:skip_cookbook_sync) { true }
it "loads the cookbook files and warns the user that this isn't supported" do
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/recipes/default.rb", false).
- once.
- and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/attributes/default.rb", false).
- once.
- and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false).
- once.
- and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
- expect(file_cache).to receive(:load).
- with("cookbooks/cookbook_a/files/default/megaman.conf", false).
- once.
- and_return("/file-cache/cookbooks/cookbook_a/files/default/megaman.conf")
- expect(Chef::Log).to receive(:warn).
- with("skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!").
- once
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/recipes/default.rb", false)
+ .once
+ .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/attributes/default.rb", false)
+ .once
+ .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
+ .once
+ .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ expect(file_cache).to receive(:load)
+ .with("cookbooks/cookbook_a/files/default/megaman.conf", false)
+ .once
+ .and_return("/file-cache/cookbooks/cookbook_a/files/default/megaman.conf")
+ expect(Chef::Log).to receive(:warn)
+ .with("skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!")
+ .once
synchronizer.sync_cookbooks
end
end
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index 8bc215360a..6553dad433 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -44,10 +44,10 @@ describe Chef::CookbookLoader do
cookbook_paths.delete_if { |path| File.basename(path) == "chefignore" }
cookbook_paths.each do |cookbook_path|
- expect(Chef::Cookbook::CookbookVersionLoader).to receive(:new).
- with(cookbook_path, anything).
- once.
- and_call_original
+ expect(Chef::Cookbook::CookbookVersionLoader).to receive(:new)
+ .with(cookbook_path, anything)
+ .once
+ .and_call_original
end
expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./)
cookbook_loader.load_cookbooks
diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb
index 0e9c277b11..87ff7abdd7 100644
--- a/spec/unit/cookbook_site_streaming_uploader_spec.rb
+++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb
@@ -102,22 +102,22 @@ describe Chef::CookbookSiteStreamingUploader do
it "should be able to receive files to attach as argument" do
Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
- :myfile => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file
+ myfile: File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file
})
end
it "should be able to receive strings to attach as argument" do
Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
- :mystring => "Lorem ipsum",
+ mystring: "Lorem ipsum",
})
end
it "should be able to receive strings and files as argument at the same time" do
Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
- :myfile1 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
- :mystring1 => "Lorem ipsum",
- :myfile2 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
- :mystring2 => "Dummy text",
+ myfile1: File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
+ mystring1: "Lorem ipsum",
+ myfile2: File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
+ mystring2: "Dummy text",
})
end
diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb
index 2c36c2c9c7..26e8d28454 100644
--- a/spec/unit/cookbook_uploader_spec.rb
+++ b/spec/unit/cookbook_uploader_spec.rb
@@ -85,9 +85,9 @@ describe Chef::CookbookUploader do
end
def expect_sandbox_create
- expect(http_client).to receive(:post).
- with("sandboxes", { :checksums => checksums_set }).
- and_return(sandbox_response)
+ expect(http_client).to receive(:post)
+ .with("sandboxes", { checksums: checksums_set })
+ .and_return(sandbox_response)
end
def expect_checksum_upload
@@ -100,8 +100,8 @@ describe Chef::CookbookUploader do
"accept" => "application/json",
}
- expect(http_client).to receive(:put).
- with(url_for(md5), IO.binread(file_path), upload_headers)
+ expect(http_client).to receive(:put)
+ .with(url_for(md5), IO.binread(file_path), upload_headers)
end
end
@@ -111,14 +111,14 @@ describe Chef::CookbookUploader do
end
def expect_sandbox_commit
- expect(http_client).to receive(:put).with(sandbox_commit_uri, { :is_completed => true })
+ expect(http_client).to receive(:put).with(sandbox_commit_uri, { is_completed: true })
end
def expect_cookbook_create
cookbooks_to_upload.each do |cookbook|
- expect(http_client).to receive(:put).
- with(expected_save_url(cookbook), cookbook)
+ expect(http_client).to receive(:put)
+ .with(expected_save_url(cookbook), cookbook)
end
end
diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb
index ba7aaa59f5..b7d5a9b288 100644
--- a/spec/unit/cookbook_version_file_specificity_spec.rb
+++ b/spec/unit/cookbook_version_file_specificity_spec.rb
@@ -27,202 +27,202 @@ describe Chef::CookbookVersion, "file specificity" do
[
# afile.rb
{
- :name => "files/afile.rb",
- :path => "files/host-examplehost.example.org/afile.rb",
- :full_path => "/cookbook-folder/files/host-examplehost.example.org/afile.rb",
- :checksum => "csum-host",
- :specificity => "host-examplehost.example.org",
+ name: "files/afile.rb",
+ path: "files/host-examplehost.example.org/afile.rb",
+ full_path: "/cookbook-folder/files/host-examplehost.example.org/afile.rb",
+ checksum: "csum-host",
+ specificity: "host-examplehost.example.org",
},
{
- :name => "files/afile.rb",
- :path => "files/ubuntu-9.10/afile.rb",
- :full_path => "/cookbook-folder/files/ubuntu-9.10/afile.rb",
- :checksum => "csum-platver-full",
- :specificity => "ubuntu-9.10",
+ name: "files/afile.rb",
+ path: "files/ubuntu-9.10/afile.rb",
+ full_path: "/cookbook-folder/files/ubuntu-9.10/afile.rb",
+ checksum: "csum-platver-full",
+ specificity: "ubuntu-9.10",
},
{
- :name => "files/afile.rb",
- :path => "files/newubuntu-9/afile.rb",
- :full_path => "/cookbook-folder/files/newubuntu-9/afile.rb",
- :checksum => "csum-platver-partial",
- :specificity => "newubuntu-9",
+ name: "files/afile.rb",
+ path: "files/newubuntu-9/afile.rb",
+ full_path: "/cookbook-folder/files/newubuntu-9/afile.rb",
+ checksum: "csum-platver-partial",
+ specificity: "newubuntu-9",
},
{
- :name => "files/afile.rb",
- :path => "files/ubuntu/afile.rb",
- :full_path => "/cookbook-folder/files/ubuntu/afile.rb",
- :checksum => "csum-plat",
- :specificity => "ubuntu",
+ name: "files/afile.rb",
+ path: "files/ubuntu/afile.rb",
+ full_path: "/cookbook-folder/files/ubuntu/afile.rb",
+ checksum: "csum-plat",
+ specificity: "ubuntu",
},
{
- :name => "files/afile.rb",
- :path => "files/default/afile.rb",
- :full_path => "/cookbook-folder/files/default/afile.rb",
- :checksum => "csum-default",
- :specificity => "default",
+ name: "files/afile.rb",
+ path: "files/default/afile.rb",
+ full_path: "/cookbook-folder/files/default/afile.rb",
+ checksum: "csum-default",
+ specificity: "default",
},
# for different/odd platform_versions
{
- :name => "files/bfile.rb",
- :path => "files/fakeos-2.0.rc.1/bfile.rb",
- :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/bfile.rb",
- :checksum => "csum2-platver-full",
- :specificity => "fakeos-2.0.rc.1",
+ name: "files/bfile.rb",
+ path: "files/fakeos-2.0.rc.1/bfile.rb",
+ full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/bfile.rb",
+ checksum: "csum2-platver-full",
+ specificity: "fakeos-2.0.rc.1",
},
{
- :name => "files/bfile.rb",
- :path => "files/newfakeos-2.0.rc/bfile.rb",
- :full_path => "/cookbook-folder/files/newfakeos-2.0.rc/bfile.rb",
- :checksum => "csum2-platver-partial",
- :specificity => "newfakeos-2.0.rc",
+ name: "files/bfile.rb",
+ path: "files/newfakeos-2.0.rc/bfile.rb",
+ full_path: "/cookbook-folder/files/newfakeos-2.0.rc/bfile.rb",
+ checksum: "csum2-platver-partial",
+ specificity: "newfakeos-2.0.rc",
},
{
- :name => "files/bfile.rb",
- :path => "files/fakeos-maple tree/bfile.rb",
- :full_path => "/cookbook-folder/files/fakeos-maple tree/bfile.rb",
- :checksum => "csum3-platver-full",
- :specificity => "maple tree",
+ name: "files/bfile.rb",
+ path: "files/fakeos-maple tree/bfile.rb",
+ full_path: "/cookbook-folder/files/fakeos-maple tree/bfile.rb",
+ checksum: "csum3-platver-full",
+ specificity: "maple tree",
},
{
- :name => "files/bfile.rb",
- :path => "files/fakeos-1/bfile.rb",
- :full_path => "/cookbook-folder/files/fakeos-1/bfile.rb",
- :checksum => "csum4-platver-full",
- :specificity => "fakeos-1",
+ name: "files/bfile.rb",
+ path: "files/fakeos-1/bfile.rb",
+ full_path: "/cookbook-folder/files/fakeos-1/bfile.rb",
+ checksum: "csum4-platver-full",
+ specificity: "fakeos-1",
},
# directory adirectory
{
- :name => "files/anotherfile1.rb",
- :path => "files/host-examplehost.example.org/adirectory/anotherfile1.rb.host",
- :full_path => "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile1.rb.host",
- :checksum => "csum-host-1",
- :specificity => "host-examplehost.example.org",
+ name: "files/anotherfile1.rb",
+ path: "files/host-examplehost.example.org/adirectory/anotherfile1.rb.host",
+ full_path: "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile1.rb.host",
+ checksum: "csum-host-1",
+ specificity: "host-examplehost.example.org",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/host-examplehost.example.org/adirectory/anotherfile2.rb.host",
- :full_path => "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile2.rb.host",
- :checksum => "csum-host-2",
- :specificity => "host-examplehost.example.org",
+ name: "files/anotherfile2.rb",
+ path: "files/host-examplehost.example.org/adirectory/anotherfile2.rb.host",
+ full_path: "/cookbook-folder/files/host-examplehost.example.org/adirectory/anotherfile2.rb.host",
+ checksum: "csum-host-2",
+ specificity: "host-examplehost.example.org",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version",
- :checksum => "csum-platver-full-1",
- :specificity => "ubuntu-9.10",
+ name: "files/anotherfile1.rb",
+ path: "files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile1.rb.platform-full-version",
+ checksum: "csum-platver-full-1",
+ specificity: "ubuntu-9.10",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version",
- :checksum => "csum-platver-full-2",
- :specificity => "ubuntu-9.10",
+ name: "files/anotherfile2.rb",
+ path: "files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/ubuntu-9.10/adirectory/anotherfile2.rb.platform-full-version",
+ checksum: "csum-platver-full-2",
+ specificity: "ubuntu-9.10",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version",
- :full_path => "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version",
- :checksum => "csum-platver-partial-1",
- :specificity => "newubuntu-9",
+ name: "files/anotherfile1.rb",
+ path: "files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version",
+ full_path: "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile1.rb.platform-partial-version",
+ checksum: "csum-platver-partial-1",
+ specificity: "newubuntu-9",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version",
- :full_path => "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version",
- :checksum => "csum-platver-partial-2",
- :specificity => "nweubuntu-9",
+ name: "files/anotherfile2.rb",
+ path: "files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version",
+ full_path: "/cookbook-folder/files/newubuntu-9/adirectory/anotherfile2.rb.platform-partial-version",
+ checksum: "csum-platver-partial-2",
+ specificity: "nweubuntu-9",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/ubuntu/adirectory/anotherfile1.rb.platform",
- :full_path => "/cookbook-folder/files/ubuntu/adirectory/anotherfile1.rb.platform",
- :checksum => "csum-plat-1",
- :specificity => "ubuntu",
+ name: "files/anotherfile1.rb",
+ path: "files/ubuntu/adirectory/anotherfile1.rb.platform",
+ full_path: "/cookbook-folder/files/ubuntu/adirectory/anotherfile1.rb.platform",
+ checksum: "csum-plat-1",
+ specificity: "ubuntu",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/ubuntu/adirectory/anotherfile2.rb.platform",
- :full_path => "/cookbook-folder/files/ubuntu/adirectory/anotherfile2.rb.platform",
- :checksum => "csum-plat-2",
- :specificity => "ubuntu",
+ name: "files/anotherfile2.rb",
+ path: "files/ubuntu/adirectory/anotherfile2.rb.platform",
+ full_path: "/cookbook-folder/files/ubuntu/adirectory/anotherfile2.rb.platform",
+ checksum: "csum-plat-2",
+ specificity: "ubuntu",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/default/adirectory/anotherfile1.rb.default",
- :full_path => "/cookbook-folder/files/default/adirectory/anotherfile1.rb.default",
- :checksum => "csum-default-1",
- :specificity => "default",
+ name: "files/anotherfile1.rb",
+ path: "files/default/adirectory/anotherfile1.rb.default",
+ full_path: "/cookbook-folder/files/default/adirectory/anotherfile1.rb.default",
+ checksum: "csum-default-1",
+ specificity: "default",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/default/adirectory/anotherfile2.rb.default",
- :full_path => "/cookbook-folder/files/default/adirectory/anotherfile2.rb.default",
- :checksum => "csum-default-2",
- :specificity => "default",
+ name: "files/anotherfile2.rb",
+ path: "files/default/adirectory/anotherfile2.rb.default",
+ full_path: "/cookbook-folder/files/default/adirectory/anotherfile2.rb.default",
+ checksum: "csum-default-2",
+ specificity: "default",
},
# for different/odd platform_versions
{
- :name => "files/anotherfile1.rb",
- :path => "files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version",
- :checksum => "csum2-platver-full-1",
- :specificity => "fakeos-2.0.rc.1",
+ name: "files/anotherfile1.rb",
+ path: "files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-full-version",
+ checksum: "csum2-platver-full-1",
+ specificity: "fakeos-2.0.rc.1",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version",
- :checksum => "csum2-platver-full-2",
- :specificity => "fakeos-2.0.rc.1",
+ name: "files/anotherfile2.rb",
+ path: "files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-full-version",
+ checksum: "csum2-platver-full-2",
+ specificity: "fakeos-2.0.rc.1",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version",
- :full_path => "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version",
- :checksum => "csum2-platver-partial-1",
- :specificity => "newfakeos-2.0.rc",
+ name: "files/anotherfile1.rb",
+ path: "files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version",
+ full_path: "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile1.rb.platform-partial-version",
+ checksum: "csum2-platver-partial-1",
+ specificity: "newfakeos-2.0.rc",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version",
- :full_path => "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version",
- :checksum => "csum2-platver-partial-2",
- :specificity => "newfakeos-2.0.rc",
+ name: "files/anotherfile2.rb",
+ path: "files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version",
+ full_path: "/cookbook-folder/files/newfakeos-2.0.rc.1/adirectory/anotherfile2.rb.platform-partial-version",
+ checksum: "csum2-platver-partial-2",
+ specificity: "newfakeos-2.0.rc",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version",
- :checksum => "csum3-platver-full-1",
- :specificity => "fakeos-maple tree",
+ name: "files/anotherfile1.rb",
+ path: "files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile1.rb.platform-full-version",
+ checksum: "csum3-platver-full-1",
+ specificity: "fakeos-maple tree",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version",
- :checksum => "csum3-platver-full-2",
- :specificity => "fakeos-maple tree",
+ name: "files/anotherfile2.rb",
+ path: "files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-maple tree/adirectory/anotherfile2.rb.platform-full-version",
+ checksum: "csum3-platver-full-2",
+ specificity: "fakeos-maple tree",
},
{
- :name => "files/anotherfile1.rb",
- :path => "files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version",
- :checksum => "csum4-platver-full-1",
- :specificity => "fakeos-1",
+ name: "files/anotherfile1.rb",
+ path: "files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-1/adirectory/anotherfile1.rb.platform-full-version",
+ checksum: "csum4-platver-full-1",
+ specificity: "fakeos-1",
},
{
- :name => "files/anotherfile2.rb",
- :path => "files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version",
- :full_path => "/cookbook-folder/files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version",
- :checksum => "csum4-platver-full-2",
- :specificity => "fakeos-1",
+ name: "files/anotherfile2.rb",
+ path: "files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version",
+ full_path: "/cookbook-folder/files/fakeos-1/adirectory/anotherfile2.rb.platform-full-version",
+ checksum: "csum4-platver-full-2",
+ specificity: "fakeos-1",
},
],
}
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index 02736a1daf..6722fbe12c 100644
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -24,8 +24,8 @@ describe Chef::Daemon do
before do
if windows?
- mock_struct = #Struct::Passwd.new(nil, nil, 111, 111)
- mock_struct = OpenStruct.new(:uid => 2342, :gid => 2342)
+ mock_struct = # Struct::Passwd.new(nil, nil, 111, 111)
+ mock_struct = OpenStruct.new(uid: 2342, gid: 2342)
allow(Etc).to receive(:getpwnam).and_return mock_struct
allow(Etc).to receive(:getgrnam).and_return mock_struct
# mock unimplemented methods
@@ -126,8 +126,8 @@ describe Chef::Daemon do
allow(Process::UID).to receive(:change_privilege).and_return(nil)
allow(Process::GID).to receive(:change_privilege).and_return(nil)
- @pw_user = double("Struct::Passwd", :uid => 501)
- @pw_group = double("Struct::Group", :gid => 20)
+ @pw_user = double("Struct::Passwd", uid: 501)
+ @pw_group = double("Struct::Group", gid: 20)
allow(Process).to receive(:initgroups).and_return(true)
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 7094a7b1f7..a32ba147f8 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -53,7 +53,7 @@ describe Chef::DataBagItem do
end
it "should let you set the raw_data with a hash containing symbols" do
- expect { data_bag_item.raw_data = { :id => "octahedron" } }.not_to raise_error
+ expect { data_bag_item.raw_data = { id: "octahedron" } }.not_to raise_error
end
it "should let you set the raw_data from a mash" do
@@ -297,7 +297,7 @@ describe Chef::DataBagItem do
end
it "should create if the item is not found" do
- exception = double("404 error", :code => "404")
+ exception = double("404 error", code: "404")
expect(server).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception))
expect(server).to receive(:post).with("data/books", data_bag_item)
data_bag_item.save
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index cadd60936e..f20148de72 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -88,7 +88,7 @@ describe Chef::DataBag do
end
it "should silently proceed when the data bag already exists" do
- exception = double("409 error", :code => "409")
+ exception = double("409 error", code: "409")
expect(@rest).to receive(:post).and_raise(Net::HTTPServerException.new("foo", exception))
@data_bag.save
end
diff --git a/spec/unit/data_collector/resource_report_spec.rb b/spec/unit/data_collector/resource_report_spec.rb
index 278e94b53b..1a5eab796e 100644
--- a/spec/unit/data_collector/resource_report_spec.rb
+++ b/spec/unit/data_collector/resource_report_spec.rb
@@ -133,7 +133,7 @@ describe Chef::DataCollector::ResourceReport do
}
end
let(:conditional) do
- double("Chef::Resource::Conditional", :to_text => "because")
+ double("Chef::Resource::Conditional", to_text: "because")
end
it "should handle any Exception and throw a helpful message by mocking the identity" do
diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb
index f8a9e374e5..87729d8652 100644
--- a/spec/unit/data_collector_spec.rb
+++ b/spec/unit/data_collector_spec.rb
@@ -805,14 +805,14 @@ describe Chef::DataCollector::Reporter do
context "when valid output_locations are provided" do
it "does not raise an exception" do
expect(reporter).to receive(:open).with("data_collection.json", "a")
- Chef::Config[:data_collector][:output_locations] = { :urls => ["http://data_collector"], :files => ["data_collection.json"] }
+ Chef::Config[:data_collector][:output_locations] = { urls: ["http://data_collector"], files: ["data_collection.json"] }
expect { reporter.send(:validate_data_collector_output_locations!) }.not_to raise_error(Chef::Exceptions::ConfigurationError)
end
end
context "when output_locations contains an invalid URI" do
it "raises an exception" do
- Chef::Config[:data_collector][:output_locations] = { :urls => ["this is not a url"], :files => ["/tmp/data_collection.json"] }
+ Chef::Config[:data_collector][:output_locations] = { urls: ["this is not a url"], files: ["/tmp/data_collection.json"] }
expect { reporter.send(:validate_data_collector_output_locations!) }.to raise_error(Chef::Exceptions::ConfigurationError)
end
end
diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb
index 42e543fdb2..e24fbc4589 100644
--- a/spec/unit/dsl/audit_spec.rb
+++ b/spec/unit/dsl/audit_spec.rb
@@ -12,7 +12,7 @@ end
describe Chef::DSL::Audit do
let(:auditor) { AuditDSLTester.new("cookbook_name", "recipe_name", run_context) }
- let(:run_context) { instance_double(Chef::RunContext, :audits => audits, :cookbook_collection => cookbook_collection) }
+ let(:run_context) { instance_double(Chef::RunContext, audits: audits, cookbook_collection: cookbook_collection) }
let(:audits) { {} }
let(:cookbook_collection) { {} }
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index fd1f9b23b5..51123ba930 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -39,8 +39,8 @@ end
describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
before do
platform_hash = {
- :openbsd => { :default => "free, functional, secure" },
- [:redhat, :centos, :fedora, :scientific] => { :default => '"stable"' },
+ :openbsd => { default: "free, functional, secure" },
+ [:redhat, :centos, :fedora, :scientific] => { default: '"stable"' },
:ubuntu => { "10.04" => "using upstart more", :default => "using init more" },
:default => "bork da bork",
}
@@ -48,24 +48,24 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "returns the default value when the platform doesn't match" do
- expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq("bork da bork")
+ expect(@platform_specific_value.value_for_node(platform: :dos)).to eq("bork da bork")
end
it "returns a value for a platform set as a group" do
- expect(@platform_specific_value.value_for_node(:platform => :centos)).to eq('"stable"')
+ expect(@platform_specific_value.value_for_node(platform: :centos)).to eq('"stable"')
end
it "returns a value for the platform when it was set as a symbol but fetched as a string" do
- expect(@platform_specific_value.value_for_node(:platform => "centos")).to eq('"stable"')
+ expect(@platform_specific_value.value_for_node(platform: "centos")).to eq('"stable"')
end
it "returns a value for a specific platform version" do
- node = { :platform => "ubuntu", :platform_version => "10.04" }
+ node = { platform: "ubuntu", platform_version: "10.04" }
expect(@platform_specific_value.value_for_node(node)).to eq("using upstart more")
end
it "returns a platform-default value if the platform version doesn't match an explicit one" do
- node = { :platform => "ubuntu", :platform_version => "9.10" }
+ node = { platform: "ubuntu", platform_version: "9.10" }
expect(@platform_specific_value.value_for_node(node)).to eq("using init more")
end
@@ -73,11 +73,11 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
# this matches the behavior in the original implementation.
# whether or not it's correct is another matter.
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new({})
- expect(platform_specific_value.value_for_node(:platform => "foo")).to be_nil
+ expect(platform_specific_value.value_for_node(platform: "foo")).to be_nil
end
it "raises an argument error if the platform hash is not correctly structured" do
- bad_hash = { :ubuntu => :foo } # should be :ubuntu => {:default => 'foo'}
+ bad_hash = { ubuntu: :foo } # should be :ubuntu => {:default => 'foo'}
expect { Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash) }.to raise_error(ArgumentError)
end
@@ -98,32 +98,32 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
end
it "returns the default value when the platform family doesn't match" do
- expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq("default value")
+ expect(@platform_family_value.value_for_node(platform_family: :os2)).to eq("default value")
end
it "returns a value for the platform family when it was set as a string but fetched as a symbol" do
- expect(@platform_family_value.value_for_node(:platform_family => :debian)).to eq("debian value")
+ expect(@platform_family_value.value_for_node(platform_family: :debian)).to eq("debian value")
end
it "returns a value for the platform family when it was set as a symbol but fetched as a string" do
- expect(@platform_family_value.value_for_node(:platform_family => "gentoo")).to eq("gentoo value")
+ expect(@platform_family_value.value_for_node(platform_family: "gentoo")).to eq("gentoo value")
end
it "returns an array value stored for a platform family" do
- expect(@platform_family_value.value_for_node(:platform_family => "suse")).to eq(@array_values)
+ expect(@platform_family_value.value_for_node(platform_family: "suse")).to eq(@array_values)
end
it "returns a value for the platform family when it was set within an array hash key as a symbol" do
- expect(@platform_family_value.value_for_node(:platform_family => :rhel)).to eq("redhatty value")
+ expect(@platform_family_value.value_for_node(platform_family: :rhel)).to eq("redhatty value")
end
it "returns a value for the platform family when it was set within an array hash key as a string" do
- expect(@platform_family_value.value_for_node(:platform_family => "fedora")).to eq("redhatty value")
+ expect(@platform_family_value.value_for_node(platform_family: "fedora")).to eq("redhatty value")
end
it "returns nil if there is no default and no platforms match" do
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue.new({})
- expect(platform_specific_value.value_for_node(:platform_family => "foo")).to be_nil
+ expect(platform_specific_value.value_for_node(platform_family: "foo")).to be_nil
end
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 2a12e27610..4f9e0b764b 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending do
end
it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do
- allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }).and_return(true)
+ allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }).and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index c604148ec8..a342d6d7cd 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -73,12 +73,12 @@ describe Chef::Environment do
describe "default attributes" do
it "should let you set the attributes hash explicitly" do
- expect(@environment.default_attributes({ :one => "two" })).to eq({ :one => "two" })
+ expect(@environment.default_attributes({ one: "two" })).to eq({ one: "two" })
end
it "should let you return the attributes hash" do
- @environment.default_attributes({ :one => "two" })
- expect(@environment.default_attributes).to eq({ :one => "two" })
+ @environment.default_attributes({ one: "two" })
+ expect(@environment.default_attributes).to eq({ one: "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -88,12 +88,12 @@ describe Chef::Environment do
describe "override attributes" do
it "should let you set the attributes hash explicitly" do
- expect(@environment.override_attributes({ :one => "two" })).to eq({ :one => "two" })
+ expect(@environment.override_attributes({ one: "two" })).to eq({ one: "two" })
end
it "should let you return the attributes hash" do
- @environment.override_attributes({ :one => "two" })
- expect(@environment.override_attributes).to eq({ :one => "two" })
+ @environment.override_attributes({ one: "two" })
+ expect(@environment.override_attributes).to eq({ one: "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -167,7 +167,7 @@ describe Chef::Environment do
before(:each) do
@environment.name("spec")
@environment.description("Where we run the spec tests")
- @environment.cookbook_versions({ :apt => "= 1.2.3" })
+ @environment.cookbook_versions({ apt: "= 1.2.3" })
@hash = @environment.to_hash
end
@@ -190,7 +190,7 @@ describe Chef::Environment do
before(:each) do
@environment.name("spec")
@environment.description("Where we run the spec tests")
- @environment.cookbook_versions({ :apt => "= 1.2.3" })
+ @environment.cookbook_versions({ apt: "= 1.2.3" })
@json = @environment.to_json
end
@@ -311,17 +311,17 @@ describe Chef::Environment do
end
it "updates the name from parameters[:name]" do
- @environment.update_from_params(:name => "kurrupt")
+ @environment.update_from_params(name: "kurrupt")
expect(@environment.name).to eq("kurrupt")
end
it "validates the name given in the params" do
- expect(@environment.update_from_params(:name => "@$%^&*()")).to be_falsey
+ expect(@environment.update_from_params(name: "@$%^&*()")).to be_falsey
expect(@environment.invalid_fields[:name]).to eq(%q{Option name's value @$%^&*() does not match regular expression /^[\-[:alnum:]_]+$/})
end
it "updates the description from parameters[:description]" do
- @environment.update_from_params(:description => "wow, writing your own object mapper is kinda painful")
+ @environment.update_from_params(description: "wow, writing your own object mapper is kinda painful")
expect(@environment.description).to eq("wow, writing your own object mapper is kinda painful")
end
@@ -329,13 +329,13 @@ describe Chef::Environment do
# NOTE: I'm only choosing this (admittedly weird) structure for the hash b/c the better more obvious
# one, i.e, {:cookbook_version_constraints => {COOKBOOK_NAME => CONSTRAINT}} is difficult to implement
# the way merb does params
- params = { :name => "superbowl", :cookbook_version => { "0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0" } }
+ params = { name: "superbowl", cookbook_version: { "0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0" } }
@environment.update_from_params(params)
expect(@environment.cookbook_versions).to eq({ "apache2" => "~> 1.0.0", "nginx" => "< 2.0.0" })
end
it "validates the cookbook constraints" do
- params = { :cookbook_version => { "0" => "apache2 >>> 1.0.0" } }
+ params = { cookbook_version: { "0" => "apache2 >>> 1.0.0" } }
expect(@environment.update_from_params(params)).to be_falsey
err_msg = @environment.invalid_fields[:cookbook_version]["0"]
expect(err_msg).to eq("apache2 >>> 1.0.0 is not a valid cookbook constraint")
@@ -352,12 +352,12 @@ describe Chef::Environment do
end
it "updates default attributes from a JSON string in params[:attributes]" do
- @environment.update_from_params(:name => "fuuu", :default_attributes => %q|{"fuuu":"RAGE"}|)
+ @environment.update_from_params(name: "fuuu", default_attributes: %q|{"fuuu":"RAGE"}|)
expect(@environment.default_attributes).to eq({ "fuuu" => "RAGE" })
end
it "updates override attributes from a JSON string in params[:attributes]" do
- @environment.update_from_params(:name => "fuuu", :override_attributes => %q|{"foo":"override"}|)
+ @environment.update_from_params(name: "fuuu", override_attributes: %q|{"foo":"override"}|)
expect(@environment.override_attributes).to eq({ "foo" => "override" })
end
@@ -374,7 +374,7 @@ describe Chef::Environment do
describe "list" do
describe "inflated" do
it "should return a hash of environment names and objects" do
- e1 = double("Chef::Environment", :name => "one")
+ e1 = double("Chef::Environment", name: "one")
expect(@query).to receive(:search).with(:environment).and_yield(e1)
r = Chef::Environment.list(true)
expect(r["one"]).to eq(e1)
diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb
index ee806b5c3a..b9ef45dd5c 100644
--- a/spec/unit/file_access_control_spec.rb
+++ b/spec/unit/file_access_control_spec.rb
@@ -36,7 +36,7 @@ describe Chef::FileAccessControl do
@run_context = Chef::RunContext.new(@node, {}, @events)
@current_resource = Chef::Resource::File.new("/tmp/different_file.txt")
@provider_requirements = Chef::Provider::ResourceRequirements.new(@resource, @run_context)
- @provider = double("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false)
+ @provider = double("File provider", requirements: @provider_requirements, manage_symlink_access?: false)
@fac = Chef::FileAccessControl.new(@current_resource, @resource, @provider)
end
@@ -61,7 +61,7 @@ describe Chef::FileAccessControl do
end
it "determines the uid of the owner specified by the resource" do
- expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(:uid => 2342))
+ expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(uid: 2342))
expect(@fac.target_uid).to eq(2342)
end
@@ -99,7 +99,7 @@ describe Chef::FileAccessControl do
# uids. So we have to get ruby and negative uids to smoke the peace pipe
# with each other.
@resource.owner("nobody")
- expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(:uid => (4294967294)))
+ expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(uid: (4294967294)))
expect(@fac.target_uid).to eq(-2)
end
@@ -107,7 +107,7 @@ describe Chef::FileAccessControl do
# More: when OSX userIDs are created by ActiveDirectory sync, it tends to use huge numbers
# which had been incorrectly wrapped. It does not look like the OSX IDs go below -2
@resource.owner("bigdude")
- expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(:uid => (4294967286)))
+ expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(uid: (4294967286)))
expect(@fac.target_uid).to eq(4294967286)
end
@@ -153,7 +153,7 @@ describe Chef::FileAccessControl do
end
it "determines the gid of the group specified by the resource" do
- expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(:gid => 2342))
+ expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(gid: 2342))
expect(@fac.target_gid).to eq(2342)
end
@@ -273,7 +273,7 @@ describe Chef::FileAccessControl do
it "sets the file's mode as specified in the resource when the current modes are incorrect" do
# stat returns modes like 0100644 (octal) => 33188 (decimal)
- #@fac.stub(:stat).and_return(OpenStruct.new(:mode => 33188))
+ # @fac.stub(:stat).and_return(OpenStruct.new(:mode => 33188))
@current_resource.mode("0644")
expect(File).to receive(:chmod).with(256, "/tmp/different_file.txt")
@fac.set_mode
@@ -286,7 +286,7 @@ describe Chef::FileAccessControl do
end
it "does not set the file's mode when the current modes are correct" do
- #@fac.stub(:stat).and_return(OpenStruct.new(:mode => 0100400))
+ # @fac.stub(:stat).and_return(OpenStruct.new(:mode => 0100400))
@current_resource.mode("0400")
expect(File).not_to receive(:chmod)
@fac.set_mode
@@ -294,7 +294,7 @@ describe Chef::FileAccessControl do
end
it "sets all access controls on a file" do
- allow(@fac).to receive(:stat).and_return(OpenStruct.new(:owner => 99, :group => 99, :mode => 0100444))
+ allow(@fac).to receive(:stat).and_return(OpenStruct.new(owner: 99, group: 99, mode: 0100444))
@resource.mode(0400)
@resource.owner(0)
@resource.group(0)
diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
index 569fd898a7..6c8736ae38 100644
--- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
@@ -38,9 +38,9 @@ describe Chef::FileContentManagement::Deploy::MvUnix do
let(:target_file_mode) { 0644 }
let(:target_file_stat) do
double "File::Stat struct for target file",
- :mode => target_file_mode,
- :uid => target_file_uid,
- :gid => target_file_gid
+ mode: target_file_mode,
+ uid: target_file_uid,
+ gid: target_file_gid
end
before do
diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
index 30a62c4da9..80155f131c 100644
--- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
@@ -59,10 +59,10 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
end
before do
- allow(Chef::ReservedNames::Win32::Security::SecurableObject).
- to receive(:new).
- with(target_file_path).
- and_return(target_file_security_object, updated_target_security_object)
+ allow(Chef::ReservedNames::Win32::Security::SecurableObject)
+ .to receive(:new)
+ .with(target_file_path)
+ .and_return(target_file_security_object, updated_target_security_object)
end
@@ -84,8 +84,8 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
let(:target_file_security_descriptor) do
double "security descriptor for target file",
- :group => original_target_file_group,
- :owner => original_target_file_owner
+ group: original_target_file_group,
+ owner: original_target_file_owner
end
let(:updated_target_security_descriptor) do
@@ -147,19 +147,19 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(false)
allow(target_file_security_descriptor).to receive(:dacl).and_return(original_target_file_dacl)
- expect(Chef::ReservedNames::Win32::Security::ACL).
- to receive(:create).
- with([]).
- and_return(empty_dacl)
+ expect(Chef::ReservedNames::Win32::Security::ACL)
+ .to receive(:create)
+ .with([])
+ .and_return(empty_dacl)
allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true)
allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false)
allow(target_file_security_descriptor).to receive(:sacl).and_return(original_target_file_sacl)
- expect(Chef::ReservedNames::Win32::Security::ACL).
- to receive(:create).
- with([]).
- and_return(empty_sacl)
+ expect(Chef::ReservedNames::Win32::Security::ACL)
+ .to receive(:create)
+ .with([])
+ .and_return(empty_sacl)
expect(updated_target_security_object).to receive(:set_dacl).with(empty_dacl, false)
expect(updated_target_security_object).to receive(:set_sacl).with(empty_sacl, false)
@@ -171,13 +171,13 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
end
context "and the target has a dacl and sacl" do
- let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", :inherited? => true) }
- let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", :inherited? => false) }
+ let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", inherited?: true) }
+ let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", inherited?: false) }
let(:original_target_file_dacl) { [inherited_dacl_ace, not_inherited_dacl_ace] }
- let(:inherited_sacl_ace) { double("Windows sacl ace (inherited)", :inherited? => true) }
- let(:not_inherited_sacl_ace) { double("Windows sacl ace (not inherited)", :inherited? => false) }
+ let(:inherited_sacl_ace) { double("Windows sacl ace (inherited)", inherited?: true) }
+ let(:not_inherited_sacl_ace) { double("Windows sacl ace (not inherited)", inherited?: false) }
let(:original_target_file_sacl) { [inherited_sacl_ace, not_inherited_sacl_ace] }
let(:custom_dacl) { double("Windows ACL for non-inherited dacl aces") }
@@ -188,19 +188,19 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(dacl_inherits?)
allow(target_file_security_descriptor).to receive(:dacl).and_return(original_target_file_dacl)
- expect(Chef::ReservedNames::Win32::Security::ACL).
- to receive(:create).
- with([not_inherited_dacl_ace]).
- and_return(custom_dacl)
+ expect(Chef::ReservedNames::Win32::Security::ACL)
+ .to receive(:create)
+ .with([not_inherited_dacl_ace])
+ .and_return(custom_dacl)
allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true)
allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(sacl_inherits?)
allow(target_file_security_descriptor).to receive(:sacl).and_return(original_target_file_sacl)
- expect(Chef::ReservedNames::Win32::Security::ACL).
- to receive(:create).
- with([not_inherited_sacl_ace]).
- and_return(custom_sacl)
+ expect(Chef::ReservedNames::Win32::Security::ACL)
+ .to receive(:create)
+ .with([not_inherited_sacl_ace])
+ .and_return(custom_sacl)
expect(updated_target_security_object).to receive(:set_dacl).with(custom_dacl, dacl_inherits?)
expect(updated_target_security_object).to receive(:set_sacl).with(custom_sacl, sacl_inherits?)
diff --git a/spec/unit/formatters/error_description_spec.rb b/spec/unit/formatters/error_description_spec.rb
index cf6372ed49..772ad84481 100644
--- a/spec/unit/formatters/error_description_spec.rb
+++ b/spec/unit/formatters/error_description_spec.rb
@@ -69,17 +69,17 @@ describe Chef::Formatters::ErrorDescription do
context "when no sections have been added" do
it "should output only the title and the Platform section" do
subject.display(out)
- expect(out.out.string).to eq <<-END
-================================================================================
-test title
-================================================================================
-
-System Info:
-------------
-chef_version=1.2.3
-ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
-program_name=chef-client
-executable=/test/bin/chef-client
+ expect(out.out.string).to eq <<~END
+ ================================================================================
+ test title
+ ================================================================================
+
+ System Info:
+ ------------
+ chef_version=1.2.3
+ ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
+ program_name=chef-client
+ executable=/test/bin/chef-client
END
end
@@ -92,21 +92,21 @@ executable=/test/bin/chef-client
it "should output the expected sections" do
subject.display(out)
- expect(out.out.string).to eq <<-END
-================================================================================
-test title
-================================================================================
-
-test heading
-------------
-test text
-
-System Info:
-------------
-chef_version=1.2.3
-ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
-program_name=chef-client
-executable=/test/bin/chef-client
+ expect(out.out.string).to eq <<~END
+ ================================================================================
+ test title
+ ================================================================================
+
+ test heading
+ ------------
+ test text
+
+ System Info:
+ ------------
+ chef_version=1.2.3
+ ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
+ program_name=chef-client
+ executable=/test/bin/chef-client
END
end
@@ -119,19 +119,19 @@ executable=/test/bin/chef-client
# reset on global values.
Chef.set_node({ "platform" => "openvms", "platform_version" => "8.4-2L1" })
subject.display(out)
- expect(out.out.string).to eq <<-END
-================================================================================
-test title
-================================================================================
-
-System Info:
-------------
-chef_version=1.2.3
-platform=openvms
-platform_version=8.4-2L1
-ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
-program_name=chef-client
-executable=/test/bin/chef-client
+ expect(out.out.string).to eq <<~END
+ ================================================================================
+ test title
+ ================================================================================
+
+ System Info:
+ ------------
+ chef_version=1.2.3
+ platform=openvms
+ platform_version=8.4-2L1
+ ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
+ program_name=chef-client
+ executable=/test/bin/chef-client
END
end
diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
index 2c1da7345b..a09b192b6d 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -18,22 +18,22 @@
require "spec_helper"
-BAD_RECIPE = <<-E
-#
-# Cookbook Name:: syntax-err
-# Recipe:: default
-#
-# Copyright 2012-2016, YOUR_COMPANY_NAME
-#
-# All rights reserved - Do Not Redistribute
-#
-
-
-file "/tmp/explode-me" do
- mode 0655
- owner "root"
- this_is_not_a_valid_method
-end
+BAD_RECIPE = <<~E
+ #
+ # Cookbook Name:: syntax-err
+ # Recipe:: default
+ #
+ # Copyright 2012-2016, YOUR_COMPANY_NAME
+ #
+ # All rights reserved - Do Not Redistribute
+ #
+
+
+ file "/tmp/explode-me" do
+ mode 0655
+ owner "root"
+ this_is_not_a_valid_method
+ end
E
describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
diff --git a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
index 02846af24a..437cc3ee49 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector do
before do
@description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
@outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when explaining a 502 error" do
diff --git a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
index 93aac417fa..84a3804dc2 100644
--- a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
# spec_helper loads the shared examples already.
-#require 'support/shared/unit/api_error_inspector_spec'
+# require 'support/shared/unit/api_error_inspector_spec'
describe Chef::Formatters::ErrorInspectors::NodeLoadErrorInspector do
it_behaves_like "an api error inspector"
diff --git a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
index cea93888eb..63a841ccda 100644
--- a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
# spec_helper loads the shared examples already.
-#require 'support/shared/unit/api_error_inspector_spec'
+# require 'support/shared/unit/api_error_inspector_spec'
describe Chef::Formatters::ErrorInspectors::RegistrationErrorInspector do
it_behaves_like "an api error inspector"
diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
index 072dcfef28..0cdb06c3b3 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
@description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
@stdout = StringIO.new
@outputter = Chef::Formatters::IndentableOutputStream.new(@stdout, STDERR)
- #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
allow(Chef::Config).to receive(:cookbook_path).and_return([ "/var/chef/cache" ])
end
diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
index 3e988c584d..70cf96f7c9 100644
--- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@description = Chef::Formatters::ErrorDescription.new("Error Expanding RunList:")
@outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
- #@outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
+ # @outputter = Chef::Formatters::IndentableOutputStream.new(STDOUT, STDERR)
end
describe "when explaining a missing role error" do
@@ -57,7 +57,7 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
allow(@response).to receive(:body).and_return(@response_body)
@exception = Net::HTTPServerException.new("(exception) forbidden", @response)
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
- allow(@inspector).to receive(:config).and_return(:node_name => "unit-test.example.com")
+ allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com")
@inspector.add_explanation(@description)
end
@@ -76,9 +76,9 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
- allow(@inspector).to receive(:config).and_return(:node_name => "unit-test.example.com",
- :client_key => "/etc/chef/client.pem",
- :chef_server_url => "http://chef.example.com")
+ allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com",
+ client_key: "/etc/chef/client.pem",
+ chef_server_url: "http://chef.example.com")
@inspector.add_explanation(@description)
end
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index 746b343e9c..b2ca8704b0 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -106,7 +106,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
let(:shell_out) do
- instance_double(Mixlib::ShellOut, :live_stream => true, :run_command => true, :error! => nil)
+ instance_double(Mixlib::ShellOut, live_stream: true, run_command: true, error!: nil)
end
before do
@@ -118,7 +118,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :code" do
- expect(command_opts).to receive(:merge).with({ :code => "exit 0" }).and_call_original
+ expect(command_opts).to receive(:merge).with({ code: "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
@@ -131,7 +131,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :code" do
- expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original
+ expect(command_opts).to receive(:merge).with({ command: "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
@@ -145,7 +145,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :command" do
- expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original
+ expect(command_opts).to receive(:merge).with({ command: "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
diff --git a/spec/unit/handler/json_file_spec.rb b/spec/unit/handler/json_file_spec.rb
index 4be448690a..f10c6a6701 100644
--- a/spec/unit/handler/json_file_spec.rb
+++ b/spec/unit/handler/json_file_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Handler::JsonFile do
before(:each) do
- @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => "/tmp/foobarbazqux")
+ @handler = Chef::Handler::JsonFile.new(the_sun: "will rise", path: "/tmp/foobarbazqux")
end
it "accepts arbitrary config options" do
diff --git a/spec/unit/http/api_versions_spec.rb b/spec/unit/http/api_versions_spec.rb
index 2ccb847acc..2b52e87cae 100644
--- a/spec/unit/http/api_versions_spec.rb
+++ b/spec/unit/http/api_versions_spec.rb
@@ -43,7 +43,7 @@ describe Chef::HTTP::APIVersions do
end
let(:response) do
- m = double("HttpResponse", :body => response_body)
+ m = double("HttpResponse", body: response_body)
allow(m).to receive(:key?).with("x-ops-server-api-version").and_return(true)
allow(m).to receive(:code).and_return(return_value)
allow(m).to receive(:[]) do |key|
diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb
index 548fc0158c..4a919ad492 100644
--- a/spec/unit/http/authenticator_spec.rb
+++ b/spec/unit/http/authenticator_spec.rb
@@ -34,8 +34,8 @@ describe Chef::HTTP::Authenticator do
it "merges the default version of X-Ops-Server-API-Version into the headers" do
# headers returned
- expect(class_instance.handle_request(method, url, headers, data)[2]).
- to include({ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION })
+ expect(class_instance.handle_request(method, url, headers, data)[2])
+ .to include({ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION })
end
context "when version_class is provided" do
@@ -53,17 +53,17 @@ describe Chef::HTTP::Authenticator do
it "uses it to select the correct http version" do
Chef::ServerAPIVersions.instance.reset!
expect(AuthFactoryClass).to receive(:best_request_version).and_call_original
- expect(class_instance.handle_request(method, url, headers, data)[2]).
- to include({ "X-Ops-Server-API-Version" => "2" })
+ expect(class_instance.handle_request(method, url, headers, data)[2])
+ .to include({ "X-Ops-Server-API-Version" => "2" })
end
end
context "when api_version is set to something other than the default" do
- let(:class_instance) { Chef::HTTP::Authenticator.new({ :api_version => "-10" }) }
+ let(:class_instance) { Chef::HTTP::Authenticator.new({ api_version: "-10" }) }
it "merges the requested version of X-Ops-Server-API-Version into the headers" do
- expect(class_instance.handle_request(method, url, headers, data)[2]).
- to include({ "X-Ops-Server-API-Version" => "-10" })
+ expect(class_instance.handle_request(method, url, headers, data)[2])
+ .to include({ "X-Ops-Server-API-Version" => "-10" })
end
end
end
@@ -98,16 +98,16 @@ describe Chef::HTTP::Authenticator do
end
context "when ssh_agent_signing" do
- let(:public_key) { <<-EOH }
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA49TA0y81ps0zxkOpmf5V
-4/c4IeR5yVyQFpX3JpxO4TquwnRh8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE
-6915kXSuk/cWIcNozujLK7tkuPEyYVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXr
-WqYCnhxgOjxocenREYNhZ/OETIeiPbOku47vB4nJK/0GhKBytL2XnsRgfKgDxf42
-BqAi1jglIdeq8lAWZNF9TbNBU21AO1iuT7Pm6LyQujhggPznR5FJhXKRUARXBJZa
-wxpGV4dGtdcahwXNE4601aXPra+xPcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1Q
-YwIDAQAB
------END PUBLIC KEY-----
+ let(:public_key) { <<~EOH }
+ -----BEGIN PUBLIC KEY-----
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA49TA0y81ps0zxkOpmf5V
+ 4/c4IeR5yVyQFpX3JpxO4TquwnRh8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE
+ 6915kXSuk/cWIcNozujLK7tkuPEyYVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXr
+ WqYCnhxgOjxocenREYNhZ/OETIeiPbOku47vB4nJK/0GhKBytL2XnsRgfKgDxf42
+ BqAi1jglIdeq8lAWZNF9TbNBU21AO1iuT7Pm6LyQujhggPznR5FJhXKRUARXBJZa
+ wxpGV4dGtdcahwXNE4601aXPra+xPcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1Q
+ YwIDAQAB
+ -----END PUBLIC KEY-----
EOH
let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test", raw_key: public_key, ssh_agent_signing: true) }
diff --git a/spec/unit/http/ssl_policies_spec.rb b/spec/unit/http/ssl_policies_spec.rb
index df6dee1198..b67ecc84de 100644
--- a/spec/unit/http/ssl_policies_spec.rb
+++ b/spec/unit/http/ssl_policies_spec.rb
@@ -145,7 +145,7 @@ describe "HTTP SSL Policy" do
# For whatever reason, OpenSSL errors out when adding a
# cert you already have to the certificate store.
ssl_policy.set_custom_certs
- ssl_policy.set_custom_certs #should not raise an error
+ ssl_policy.set_custom_certs # should not raise an error
end
end
end
diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb
index 1f24acb94a..673e03f7f4 100644
--- a/spec/unit/http/validate_content_length_spec.rb
+++ b/spec/unit/http/validate_content_length_spec.rb
@@ -44,7 +44,7 @@ describe Chef::HTTP::ValidateContentLength do
end
let(:response) do
- m = double("HttpResponse", :body => response_body)
+ m = double("HttpResponse", body: response_body)
allow(m).to receive(:[]) do |key|
response_headers[key]
end
@@ -67,7 +67,7 @@ describe Chef::HTTP::ValidateContentLength do
data_length = streaming_length
while data_length > 0
chunk_size = data_length > 10 ? 10 : data_length
- stream_handler.handle_chunk(double("Chunk", :bytesize => chunk_size))
+ stream_handler.handle_chunk(double("Chunk", bytesize: chunk_size))
data_length -= chunk_size
end
diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb
index 4af506d227..ea2eae3df7 100644
--- a/spec/unit/key_spec.rb
+++ b/spec/unit/key_spec.rb
@@ -24,16 +24,16 @@ describe Chef::Key do
# whether user or client irrelevent to these tests
let(:key) { Chef::Key.new("original_actor", "user") }
let(:public_key_string) do
- <<EOS
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
-KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
-WrlqpI3yv/5DOP8HTMCxnFuMJQtDwMcevlqebX4bCxcByuBpNYDcAHjjfLGSfMjn
-E5lZpgYWwnpic4kSjYcL9ORK9nYvlWV9P/kCYmRhIjB4AhtpWRiOfY/TKi3P2LxT
-IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
-Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
-0wIDAQAB
------END PUBLIC KEY-----
+ <<~EOS
+ -----BEGIN PUBLIC KEY-----
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
+ KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
+ WrlqpI3yv/5DOP8HTMCxnFuMJQtDwMcevlqebX4bCxcByuBpNYDcAHjjfLGSfMjn
+ E5lZpgYWwnpic4kSjYcL9ORK9nYvlWV9P/kCYmRhIjB4AhtpWRiOfY/TKi3P2LxT
+ IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
+ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
+ 0wIDAQAB
+ -----END PUBLIC KEY-----
EOS
end
@@ -564,7 +564,7 @@ EOS
end
end
- end #update
+ end # update
describe "load" do
shared_examples_for "load" do
@@ -592,7 +592,7 @@ EOS
end
end
- end #load
+ end # load
describe "destroy" do
shared_examples_for "destroy key" do
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 97ba0fc48e..f259002b20 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
end
context "#sanity_check!" do
- let(:response_404) { OpenStruct.new(:code => "404") }
+ let(:response_404) { OpenStruct.new(code: "404") }
let(:exception_404) { Net::HTTPServerException.new("404 not found", response_404) }
context "in cases where the prompting fails" do
@@ -180,8 +180,8 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
end
it "builds a node with first_boot_attributes if they're given" do
- knife_config[:first_boot_attributes] = { :baz => :quux }
- expect(node).to receive(:normal_attrs=).with({ :baz => :quux })
+ knife_config[:first_boot_attributes] = { baz: :quux }
+ expect(node).to receive(:normal_attrs=).with({ baz: :quux })
expect(node).to receive(:run_list).with([])
client_builder.run
end
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index 994f4d33a4..feebab4986 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -128,7 +128,7 @@ describe Chef::Knife::ClientBulkDelete do
end
describe "with --delete-validators" do
- let(:option_args) { { :delete_validators => true } }
+ let(:option_args) { { delete_validators: true } }
it "should mention that validator clients will be deleted" do
knife.run
diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb
index b05a487d62..41a83b05e4 100644
--- a/spec/unit/knife/client_delete_spec.rb
+++ b/spec/unit/knife/client_delete_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::ClientDelete do
@knife = Chef::Knife::ClientDelete.new
# defaults
@knife.config = {
- :delete_validators => false,
+ delete_validators: false,
}
@knife.name_args = [ "adam" ]
end
diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb
index 6776cafa0a..6b6519d44f 100644
--- a/spec/unit/knife/client_reregister_spec.rb
+++ b/spec/unit/knife/client_reregister_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Knife::ClientReregister do
before(:each) do
@knife = Chef::Knife::ClientReregister.new
@knife.name_args = [ "adam" ]
- @client_mock = double("client_mock", :private_key => "foo_key")
+ @client_mock = double("client_mock", private_key: "foo_key")
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index 0f83897564..c83ceed6cb 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -43,10 +43,10 @@ describe Chef::Knife::ConfigureClient do
@knife.name_args = ["/home/bob/.chef"]
@client_file = StringIO.new
@validation_file = StringIO.new
- expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w").
- and_yield(@client_file)
- expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w").
- and_yield(@validation_file)
+ expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w")
+ .and_yield(@client_file)
+ expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w")
+ .and_yield(@validation_file)
expect(IO).to receive(:read).and_return("foo_bar_baz")
end
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 27bb0d9a3f..1cdad0cd0e 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -6,7 +6,7 @@ describe Chef::Knife::Configure do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::Configure.new
- @rest_client = double("null rest client", :post => { :result => :true })
+ @rest_client = double("null rest client", post: { result: :true })
allow(@knife).to receive(:rest).and_return(@rest_client)
@out = StringIO.new
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb
index 62b8c9fe51..c8c1873081 100644
--- a/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::CookbookBulkDelete do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::CookbookBulkDelete.new
- @knife.config = { :print_after => nil }
+ @knife.config = { print_after: nil }
@knife.name_args = ["."]
@stdout = StringIO.new
@stderr = StringIO.new
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index 9bf4c81a73..7277b63c28 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -62,8 +62,8 @@ describe Chef::Knife::CookbookDelete do
describe "with -p or --purge" do
it "should prompt to purge the files" do
@knife.config[:purge] = true
- expect(@knife).to receive(:confirm).
- with(/.+Are you sure you want to purge files.+/)
+ expect(@knife).to receive(:confirm)
+ .with(/.+Are you sure you want to purge files.+/)
expect(@knife).to receive(:delete_without_explicit_version)
@knife.run
end
@@ -146,8 +146,8 @@ describe Chef::Knife::CookbookDelete do
describe "if the cookbook can't be found" do
before(:each) do
- expect(@rest_mock).to receive(:get).
- and_raise(Net::HTTPServerException.new("404 Not Found", "404"))
+ expect(@rest_mock).to receive(:get)
+ .and_raise(Net::HTTPServerException.new("404 Not Found", "404"))
end
it "should print an error" do
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 1fb995f71d..122c284b93 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -47,13 +47,13 @@ describe Chef::Knife::CookbookDownload do
@rest_mock = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_mock)
- expect(Chef::CookbookVersion).to receive(:load).with("foobar", "1.0.0").
- and_return(cookbook)
+ expect(Chef::CookbookVersion).to receive(:load).with("foobar", "1.0.0")
+ .and_return(cookbook)
end
let(:manifest_data) do
{
- :all_files => [
+ all_files: [
{
"path" => "recipes/foo.rb",
"name" => "recipes/foo.rb",
@@ -119,18 +119,18 @@ describe Chef::Knife::CookbookDownload do
describe "when downloading the cookbook" do
before(:each) do
@files.map { |f| File.dirname(f) }.flatten.uniq.each do |dir|
- expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}").
- at_least(:once)
+ expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}")
+ .at_least(:once)
end
@files_mocks.each_pair do |file, mock|
- expect(@rest_mock).to receive(:streaming_request).with("http://example.org/files/#{file}").
- and_return(mock)
+ expect(@rest_mock).to receive(:streaming_request).with("http://example.org/files/#{file}")
+ .and_return(mock)
end
@files.each do |f|
- expect(FileUtils).to receive(:mv).
- with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}")
+ expect(FileUtils).to receive(:mv)
+ .with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}")
end
end
@@ -182,8 +182,8 @@ describe Chef::Knife::CookbookDownload do
describe "with -N or --latest" do
it "should return and set the version to the latest version" do
@knife.config[:latest] = true
- expect(@knife).to receive(:available_versions).at_least(:once).
- and_return(["1.0.0", "1.1.0", "2.0.0"])
+ expect(@knife).to receive(:available_versions).at_least(:once)
+ .and_return(["1.0.0", "1.1.0", "2.0.0"])
@knife.determine_version
expect(@knife.version.to_s).to eq("2.0.0")
end
@@ -196,26 +196,26 @@ describe Chef::Knife::CookbookDownload do
end
it "should return nil if there are no versions" do
- expect(Chef::CookbookVersion).to receive(:available_versions).
- with("foobar").
- and_return(nil)
+ expect(Chef::CookbookVersion).to receive(:available_versions)
+ .with("foobar")
+ .and_return(nil)
expect(@knife.available_versions).to eq(nil)
end
it "should return the available versions" do
- expect(Chef::CookbookVersion).to receive(:available_versions).
- with("foobar").
- and_return(["1.1.0", "2.0.0", "1.0.0"])
+ expect(Chef::CookbookVersion).to receive(:available_versions)
+ .with("foobar")
+ .and_return(["1.1.0", "2.0.0", "1.0.0"])
expect(@knife.available_versions).to eq([Chef::Version.new("1.0.0"),
Chef::Version.new("1.1.0"),
Chef::Version.new("2.0.0")])
end
it "should avoid multiple API calls to the server" do
- expect(Chef::CookbookVersion).to receive(:available_versions).
- once.
- with("foobar").
- and_return(["1.1.0", "2.0.0", "1.0.0"])
+ expect(Chef::CookbookVersion).to receive(:available_versions)
+ .once
+ .with("foobar")
+ .and_return(["1.1.0", "2.0.0", "1.0.0"])
@knife.available_versions
@knife.available_versions
end
diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb
index fce6bc9593..e34b58b672 100644
--- a/spec/unit/knife/cookbook_list_spec.rb
+++ b/spec/unit/knife/cookbook_list_spec.rb
@@ -37,8 +37,8 @@ describe Chef::Knife::CookbookList do
describe "run" do
it "should display the latest version of the cookbooks" do
- expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=1").
- and_return(@cookbook_data)
+ expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=1")
+ .and_return(@cookbook_data)
@knife.run
@cookbook_names.each do |item|
expect(@stdout.string).to match /#{item}\s+1\.0\.1/
@@ -47,9 +47,9 @@ describe Chef::Knife::CookbookList do
it "should query cookbooks for the configured environment" do
@knife.config[:environment] = "production"
- expect(@rest_mock).to receive(:get).
- with("/environments/production/cookbooks?num_versions=1").
- and_return(@cookbook_data)
+ expect(@rest_mock).to receive(:get)
+ .with("/environments/production/cookbooks?num_versions=1")
+ .and_return(@cookbook_data)
@knife.run
end
@@ -75,8 +75,8 @@ describe Chef::Knife::CookbookList do
it "should display all versions of the cookbooks" do
@knife.config[:all_versions] = true
- expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all").
- and_return(@cookbook_data)
+ expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all")
+ .and_return(@cookbook_data)
@knife.run
@cookbook_names.each do |item|
expect(@stdout.string).to match /#{item}\s+1\.0\.1\s+1\.0\.0/
diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb
index bd952c215f..6642e0690d 100644
--- a/spec/unit/knife/cookbook_show_spec.rb
+++ b/spec/unit/knife/cookbook_show_spec.rb
@@ -49,10 +49,10 @@ describe Chef::Knife::CookbookShow do
{
"all_files" => [
{
- :name => "recipes/default.rb",
- :path => "recipes/default.rb",
- :checksum => "1234",
- :url => "http://example.org/files/default.rb",
+ name: "recipes/default.rb",
+ path: "recipes/default.rb",
+ checksum: "1234",
+ url: "http://example.org/files/default.rb",
},
],
}
@@ -172,32 +172,32 @@ describe Chef::Knife::CookbookShow do
cb.manifest = {
"all_files" => [
{
- :name => "files/afile.rb",
- :path => "files/host-examplehost.example.org/afile.rb",
- :checksum => "1111",
- :specificity => "host-examplehost.example.org",
- :url => "http://example.org/files/1111",
+ name: "files/afile.rb",
+ path: "files/host-examplehost.example.org/afile.rb",
+ checksum: "1111",
+ specificity: "host-examplehost.example.org",
+ url: "http://example.org/files/1111",
},
{
- :name => "files/afile.rb",
- :path => "files/ubuntu-9.10/afile.rb",
- :checksum => "2222",
- :specificity => "ubuntu-9.10",
- :url => "http://example.org/files/2222",
+ name: "files/afile.rb",
+ path: "files/ubuntu-9.10/afile.rb",
+ checksum: "2222",
+ specificity: "ubuntu-9.10",
+ url: "http://example.org/files/2222",
},
{
- :name => "files/afile.rb",
- :path => "files/ubuntu/afile.rb",
- :checksum => "3333",
- :specificity => "ubuntu",
- :url => "http://example.org/files/3333",
+ name: "files/afile.rb",
+ path: "files/ubuntu/afile.rb",
+ checksum: "3333",
+ specificity: "ubuntu",
+ url: "http://example.org/files/3333",
},
{
- :name => "files/afile.rb",
- :path => "files/default/afile.rb",
- :checksum => "4444",
- :specificity => "default",
- :url => "http://example.org/files/4444",
+ name: "files/afile.rb",
+ path: "files/default/afile.rb",
+ checksum: "4444",
+ specificity: "default",
+ url: "http://example.org/files/4444",
},
],
}
diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb
index 0ab6a8a9b4..9bf10859c0 100644
--- a/spec/unit/knife/cookbook_site_download_spec.rb
+++ b/spec/unit/knife/cookbook_site_download_spec.rb
@@ -35,9 +35,9 @@ describe Chef::Knife::CookbookSiteDownload do
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
- expect(@noauth_rest).to receive(:get).
- with("#{@cookbook_api_url}/apache2").
- and_return(@current_data)
+ expect(@noauth_rest).to receive(:get)
+ .with("#{@cookbook_api_url}/apache2")
+ .and_return(@current_data)
@knife.configure_chef
end
@@ -47,10 +47,10 @@ describe Chef::Knife::CookbookSiteDownload do
end
it "should warn with info about the replacement" do
- expect(@knife.ui).to receive(:warn).
- with(/.+deprecated.+replaced by other_apache2.+/i)
- expect(@knife.ui).to receive(:warn).
- with(/use --force.+download.+/i)
+ expect(@knife.ui).to receive(:warn)
+ .with(/.+deprecated.+replaced by other_apache2.+/i)
+ expect(@knife.ui).to receive(:warn)
+ .with(/use --force.+download.+/i)
@knife.run
end
end
@@ -59,18 +59,18 @@ describe Chef::Knife::CookbookSiteDownload do
before do
@cookbook_data = { "version" => @version,
"file" => "http://example.com/apache2_#{@version_us}.tgz" }
- @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" )
+ @temp_file = double( path: "/tmp/apache2_#{@version_us}.tgz" )
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
end
context "downloading the latest version" do
before do
- expect(@noauth_rest).to receive(:get).
- with(@current_data["latest_version"]).
- and_return(@cookbook_data)
- expect(@noauth_rest).to receive(:streaming_request).
- with(@cookbook_data["file"]).
- and_return(@temp_file)
+ expect(@noauth_rest).to receive(:get)
+ .with(@current_data["latest_version"])
+ .and_return(@cookbook_data)
+ expect(@noauth_rest).to receive(:streaming_request)
+ .with(@cookbook_data["file"])
+ .and_return(@temp_file)
end
context "and it is deprecated and with --force" do
@@ -80,8 +80,8 @@ describe Chef::Knife::CookbookSiteDownload do
end
it "should download the latest version" do
- expect(@knife.ui).to receive(:warn).
- with(/.+deprecated.+replaced by other_apache2.+/i)
+ expect(@knife.ui).to receive(:warn)
+ .with(/.+deprecated.+replaced by other_apache2.+/i)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
@@ -124,18 +124,18 @@ describe Chef::Knife::CookbookSiteDownload do
@version_us = @version.tr ".", "_"
@cookbook_data = { "version" => @version,
"file" => "http://example.com/apache2_#{@version_us}.tgz" }
- @temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz")
+ @temp_file = double(path: "/tmp/apache2_#{@version_us}.tgz")
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
@knife.name_args << @version
end
it "should download the desired version" do
- expect(@noauth_rest).to receive(:get).
- with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
- and_return(@cookbook_data)
- expect(@noauth_rest).to receive(:streaming_request).
- with(@cookbook_data["file"]).
- and_return(@temp_file)
+ expect(@noauth_rest).to receive(:get)
+ .with("#{@cookbook_api_url}/apache2/versions/#{@version_us}")
+ .and_return(@cookbook_data)
+ expect(@noauth_rest).to receive(:streaming_request)
+ .with(@cookbook_data["file"])
+ .and_return(@temp_file)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index d93af10761..4e9c7b6265 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -25,9 +25,9 @@ describe Chef::Knife::CookbookSiteInstall do
let(:downloader) { Hash.new }
let(:archive) { double(Mixlib::Archive, extract: true) }
let(:repo) do
- double(:sanity_check => true, :reset_to_default_state => true,
- :prepare_to_import => true, :finalize_updates_to => true,
- :merge_updates_from => true) end
+ double(sanity_check: true, reset_to_default_state: true,
+ prepare_to_import: true, finalize_updates_to: true,
+ merge_updates_from: true) end
let(:install_path) do
if Chef::Platform.windows?
"C:/tmp/chef"
@@ -173,7 +173,7 @@ describe Chef::Knife::CookbookSiteInstall do
it "returns a populated Metadata object if metadata.json exists" do
allow(File).to receive(:exist?).with(json_metadata_path).and_return(true)
- #expect(IO).to receive(:read).with(json_metadata_path)
+ # expect(IO).to receive(:read).with(json_metadata_path)
allow(IO).to receive(:read)
expect(metadata).to receive(:from_json)
knife.preferred_metadata
diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb
index 823eff8b04..773c1a78c3 100644
--- a/spec/unit/knife/cookbook_site_share_spec.rb
+++ b/spec/unit/knife/cookbook_site_share_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Knife::CookbookSiteShare do
@noauth_rest = double(Chef::ServerAPI)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
- @cookbook_uploader = Chef::CookbookUploader.new("herpderp", :rest => "norest")
+ @cookbook_uploader = Chef::CookbookUploader.new("herpderp", rest: "norest")
allow(Chef::CookbookUploader).to receive(:new).and_return(@cookbook_uploader)
allow(@cookbook_uploader).to receive(:validate_cookbooks).and_return(true)
allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir)
@@ -139,14 +139,14 @@ describe Chef::Knife::CookbookSiteShare do
context "when the --dry-run flag is specified" do
before do
allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
- @knife.config = { :dry_run => true }
+ @knife.config = { dry_run: true }
allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file")
end
it "should list files in the tarball" do
allow(@knife).to receive(:tar_cmd).and_return("footar")
- expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { :cwd => "/var/tmp/dummy" })
- expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { :cwd => "/var/tmp/dummy" })
+ expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { cwd: "/var/tmp/dummy" })
+ expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { cwd: "/var/tmp/dummy" })
@knife.run
end
@@ -172,7 +172,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it 'should post the cookbook to "https://supermarket.chef.io"' do
- response_text = Chef::JSONCompat.to_json({ :uri => "https://supermarket.chef.io/cookbooks/cookbook_name" })
+ response_text = Chef::JSONCompat.to_json({ uri: "https://supermarket.chef.io/cookbooks/cookbook_name" })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(201)
expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything())
@@ -180,7 +180,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should alert the user when a version already exists" do
- response_text = Chef::JSONCompat.to_json({ :error_messages => ["Version already exists"] })
+ response_text = Chef::JSONCompat.to_json({ error_messages: ["Version already exists"] })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(409)
expect { @knife.run }.to raise_error(SystemExit)
@@ -188,7 +188,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should pass any errors on to the user" do
- response_text = Chef::JSONCompat.to_json({ :error_messages => ["You're holding it wrong"] })
+ response_text = Chef::JSONCompat.to_json({ error_messages: ["You're holding it wrong"] })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(403)
expect { @knife.run }.to raise_error(SystemExit)
@@ -196,11 +196,11 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should print the body if no errors are exposed on failure" do
- response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" })
+ response_text = Chef::JSONCompat.to_json({ system_error: "Your call was dropped", reason: "There's a map for that" })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(500)
- expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/) #.ordered
- expect(@knife.ui).to receive(:error).with(/Unknown error/) #.ordered
+ expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/) # .ordered
+ expect(@knife.ui).to receive(:error).with(/Unknown error/) # .ordered
expect { @knife.run }.to raise_error(SystemExit)
end
diff --git a/spec/unit/knife/cookbook_site_unshare_spec.rb b/spec/unit/knife/cookbook_site_unshare_spec.rb
index 8e4358226d..7797fdb3f8 100644
--- a/spec/unit/knife/cookbook_site_unshare_spec.rb
+++ b/spec/unit/knife/cookbook_site_unshare_spec.rb
@@ -55,14 +55,14 @@ describe Chef::Knife::CookbookSiteUnshare do
end
it "should log an error and exit when forbidden" do
- exception = double('403 "Forbidden"', :code => "403")
+ exception = double('403 "Forbidden"', code: "403")
allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception))
expect(@knife.ui).to receive(:error)
expect { @knife.run }.to raise_error(SystemExit)
end
it "should re-raise any non-forbidden errors on delete" do
- exception = double('500 "Application Error"', :code => "500")
+ exception = double('500 "Application Error"', code: "500")
allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception))
expect { @knife.run }.to raise_error(Net::HTTPServerException)
end
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index 9e07497c57..74612f520d 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Knife::CookbookUpload do
cookbook_loader
end
- let(:cookbook_uploader) { double(:upload_cookbooks => nil) }
+ let(:cookbook_uploader) { double(upload_cookbooks: nil) }
let(:output) { StringIO.new }
@@ -61,16 +61,16 @@ describe Chef::Knife::CookbookUpload do
test_cookbook = Chef::CookbookVersion.new("test_cookbook", "/tmp/blah")
allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook)
allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"])
- expect(Chef::CookbookUploader).to receive(:new).
- with( kind_of(Array), { :force => nil, :concurrency => 3 }).
- and_return(double("Chef::CookbookUploader", :upload_cookbooks => true))
+ expect(Chef::CookbookUploader).to receive(:new)
+ .with( kind_of(Array), { force: nil, concurrency: 3 })
+ .and_return(double("Chef::CookbookUploader", upload_cookbooks: true))
knife.run
end
end
describe "run" do
before(:each) do
- allow(Chef::CookbookUploader).to receive_messages(:new => cookbook_uploader)
+ allow(Chef::CookbookUploader).to receive_messages(new: cookbook_uploader)
allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({})
end
@@ -106,22 +106,22 @@ describe Chef::Knife::CookbookUpload do
before do
allow(cookbook_loader).to receive(:merged_cookbooks).and_return(["test_cookbook"])
- allow(cookbook_loader).to receive(:merged_cookbook_paths).
- and_return({ "test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook} })
+ allow(cookbook_loader).to receive(:merged_cookbook_paths)
+ .and_return({ "test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook} })
end
it "emits a warning" do
knife.run
- expected_message = <<-E
-WARNING: The cookbooks: test_cookbook exist in multiple places in your cookbook_path.
-A composite version of these cookbooks has been compiled for uploading.
-
-IMPORTANT: In a future version of Chef, this behavior will be removed and you will no longer
-be able to have the same version of a cookbook in multiple places in your cookbook_path.
-WARNING: The affected cookbooks are located:
-test_cookbook:
- /path/one/test_cookbook
- /path/two/test_cookbook
+ expected_message = <<~E
+ WARNING: The cookbooks: test_cookbook exist in multiple places in your cookbook_path.
+ A composite version of these cookbooks has been compiled for uploading.
+
+ IMPORTANT: In a future version of Chef, this behavior will be removed and you will no longer
+ be able to have the same version of a cookbook in multiple places in your cookbook_path.
+ WARNING: The affected cookbooks are located:
+ test_cookbook:
+ /path/one/test_cookbook
+ /path/two/test_cookbook
E
expect(output.string).to include(expected_message)
end
@@ -310,8 +310,8 @@ E
describe "when a frozen cookbook exists on the server" do
it "should fail to replace it" do
exception = Chef::Exceptions::CookbookFrozen.new
- expect(cookbook_uploader).to receive(:upload_cookbooks).
- and_raise(exception)
+ expect(cookbook_uploader).to receive(:upload_cookbooks)
+ .and_raise(exception)
allow(knife.ui).to receive(:error)
expect(knife.ui).to receive(:error).with(exception)
expect { knife.run }.to raise_error(SystemExit)
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 3a32155063..bd48709a93 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -26,15 +26,15 @@ describe Chef::Knife::Core::BootstrapContext do
Chef::Config[:fips] = false
end
- let(:config) { { :foo => :bar, :color => true } }
+ let(:config) { { foo: :bar, color: true } }
let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") }
let(:chef_config) do
{
- :config_log_level => "info",
- :config_log_location => "/tmp/log",
- :validation_key => File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"),
- :chef_server_url => "http://chef.example.com:4444",
- :validation_client_name => "chef-validator-testing",
+ config_log_level: "info",
+ config_log_location: "/tmp/log",
+ validation_key: File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"),
+ chef_server_url: "http://chef.example.com:4444",
+ validation_client_name: "chef-validator-testing",
}
end
@@ -51,14 +51,14 @@ describe Chef::Knife::Core::BootstrapContext do
end
describe "when in verbosity mode" do
- let(:config) { { :verbosity => 2, :color => true } }
+ let(:config) { { verbosity: 2, color: true } }
it "adds '-l debug' when verbosity is >= 2" do
expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug"
end
end
describe "when no color value has been set in config" do
- let(:config) { { :color => false } }
+ let(:config) { { color: false } }
it "adds '--no-color' when color is false" do
expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json --no-color"
end
@@ -69,25 +69,25 @@ describe Chef::Knife::Core::BootstrapContext do
end
it "generates the config file data" do
- expected = <<-EXPECTED
-chef_server_url "http://chef.example.com:4444"
-validation_client_name "chef-validator-testing"
-log_level :info
-log_location "/tmp/log"
-# Using default node name (fqdn)
+ expected = <<~EXPECTED
+ chef_server_url "http://chef.example.com:4444"
+ validation_client_name "chef-validator-testing"
+ log_level :info
+ log_location "/tmp/log"
+ # Using default node name (fqdn)
EXPECTED
expect(bootstrap_context.config_content).to eq expected
end
describe "alternate chef-client path" do
- let(:chef_config) { { :chef_client_path => "/usr/local/bin/chef-client" } }
+ let(:chef_config) { { chef_client_path: "/usr/local/bin/chef-client" } }
it "runs chef-client from another path when specified" do
expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json"
end
end
describe "validation key path that contains a ~" do
- let(:chef_config) { { :validation_key => "~/my.key" } }
+ let(:chef_config) { { validation_key: "~/my.key" } }
it "reads the validation key when it contains a ~" do
expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV["HOME"])).and_return(true)
expect(IO).to receive(:read).with(File.expand_path("my.key", ENV["HOME"]))
@@ -96,36 +96,36 @@ EXPECTED
end
describe "when an explicit node name is given" do
- let(:config) { { :chef_node_name => "foobar.example.com" } }
+ let(:config) { { chef_node_name: "foobar.example.com" } }
it "sets the node name in the client.rb" do
expect(bootstrap_context.config_content).to match(/node_name "foobar\.example\.com"/)
end
end
describe "when bootstrapping into a specific environment" do
- let(:config) { { :environment => "prodtastic", :color => true } }
+ let(:config) { { environment: "prodtastic", color: true } }
it "starts chef in the configured environment" do
expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic")
end
end
describe "when tags are given" do
- let(:config) { { :tags => [ "unicorn" ] } }
+ let(:config) { { tags: [ "unicorn" ] } }
it "adds the attributes to first_boot" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list, :tags => ["unicorn"] }))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ run_list: run_list, tags: ["unicorn"] }))
end
end
describe "when JSON attributes are given" do
- let(:config) { { :first_boot_attributes => { :baz => :quux } } }
+ let(:config) { { first_boot_attributes: { baz: :quux } } }
it "adds the attributes to first_boot" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :baz => :quux, :run_list => run_list }))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ baz: :quux, run_list: run_list }))
end
end
describe "when JSON attributes are NOT given" do
it "sets first_boot equal to run_list" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list }))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ run_list: run_list }))
end
end
@@ -159,7 +159,7 @@ EXPECTED
describe "when a bootstrap_version is specified" do
let(:chef_config) do
{
- :knife => { :bootstrap_version => "11.12.4" },
+ knife: { bootstrap_version: "11.12.4" },
}
end
@@ -171,7 +171,7 @@ EXPECTED
describe "when a pre-release bootstrap_version is specified" do
let(:chef_config) do
{
- :knife => { :bootstrap_version => "11.12.4.rc.0" },
+ knife: { bootstrap_version: "11.12.4.rc.0" },
}
end
@@ -195,7 +195,7 @@ EXPECTED
describe "when configured in config" do
let(:chef_config) do
{
- :knife => { :ssl_verify_mode => :verify_peer },
+ knife: { ssl_verify_mode: :verify_peer },
}
end
@@ -204,7 +204,7 @@ EXPECTED
end
describe "when configured via CLI" do
- let(:config) { { :node_ssl_verify_mode => "none" } }
+ let(:config) { { node_ssl_verify_mode: "none" } }
it "uses CLI value" do
expect(bootstrap_context.config_content).to include("ssl_verify_mode :verify_none")
@@ -238,7 +238,7 @@ EXPECTED
describe "when configured in config" do
let(:chef_config) do
{
- :knife => { :verify_api_cert => :false },
+ knife: { verify_api_cert: :false },
}
end
@@ -247,7 +247,7 @@ EXPECTED
end
describe "when configured via CLI" do
- let(:config) { { :node_verify_api_cert => true } }
+ let(:config) { { node_verify_api_cert: true } }
it "uses CLI value" do
expect(bootstrap_context.config_content).to include("verify_api_cert true")
@@ -262,7 +262,7 @@ EXPECTED
end
describe "when configured via cli" do
- let(:config) { { :prerelease => true } }
+ let(:config) { { prerelease: true } }
it "uses CLI value" do
expect(bootstrap_context.latest_current_chef_version_string).to eq("-p")
@@ -272,49 +272,49 @@ EXPECTED
describe "#config_log_location" do
context "when config_log_location is nil" do
- let(:chef_config) { { :config_log_location => nil } }
+ let(:chef_config) { { config_log_location: nil } }
it "sets the default config_log_location in the client.rb" do
expect(bootstrap_context.get_log_location).to eq "STDOUT"
end
end
context "when config_log_location is empty" do
- let(:chef_config) { { :config_log_location => "" } }
+ let(:chef_config) { { config_log_location: "" } }
it "sets the default config_log_location in the client.rb" do
expect(bootstrap_context.get_log_location).to eq "STDOUT"
end
end
context "when config_log_location is :win_evt" do
- let(:chef_config) { { :config_log_location => :win_evt } }
+ let(:chef_config) { { config_log_location: :win_evt } }
it "raise error when config_log_location is :win_evt " do
expect { bootstrap_context.get_log_location }.to raise_error("The value :win_evt is not supported for config_log_location on Linux Platforms \n")
end
end
context "when config_log_location is :syslog" do
- let(:chef_config) { { :config_log_location => :syslog } }
+ let(:chef_config) { { config_log_location: :syslog } }
it "sets the config_log_location value as :syslog in the client.rb" do
expect(bootstrap_context.get_log_location).to eq ":syslog"
end
end
context "When config_log_location is STDOUT" do
- let(:chef_config) { { :config_log_location => STDOUT } }
+ let(:chef_config) { { config_log_location: STDOUT } }
it "Sets the config_log_location value as STDOUT in the client.rb" do
expect(bootstrap_context.get_log_location).to eq "STDOUT"
end
end
context "when config_log_location is STDERR" do
- let(:chef_config) { { :config_log_location => STDERR } }
+ let(:chef_config) { { config_log_location: STDERR } }
it "sets the config_log_location value as STDERR in the client.rb" do
expect(bootstrap_context.get_log_location).to eq "STDERR"
end
end
context "when config_log_location is a path" do
- let(:chef_config) { { :config_log_location => "/tmp/ChefLogFile" } }
+ let(:chef_config) { { config_log_location: "/tmp/ChefLogFile" } }
it "sets the config_log_location path in the client.rb" do
expect(bootstrap_context.get_log_location).to eq "\"/tmp/ChefLogFile\""
end
diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
index 3c16f93533..a530dbcdaa 100644
--- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb
+++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::CookbookSCMRepo do
@repo_path = File.join(CHEF_SPEC_DATA, "cookbooks")
@stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new
@ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {})
- @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "master")
+ @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, default_branch: "master")
@branch_list = Mixlib::ShellOut.new
@branch_list.stdout.replace(<<-BRANCHES)
@@ -69,7 +69,7 @@ BRANCHES
it "exits when the default branch doesn't exist" do
@nobranches = Mixlib::ShellOut.new.tap { |s| s.stdout.replace "\n" }
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@nobranches)
expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
@@ -77,7 +77,7 @@ BRANCHES
before do
@master_branch = Mixlib::ShellOut.new
@master_branch.stdout.replace "* master\n"
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@master_branch)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@master_branch)
end
it "exits when the git repo is dirty" do
@@ -85,14 +85,14 @@ BRANCHES
@dirty_status.stdout.replace(<<-DIRTY)
M chef/lib/chef/knife/cookbook_site_install.rb
DIRTY
- expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", cwd: @repo_path).and_return(@dirty_status)
expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
describe "and the repo is clean" do
before do
@clean_status = Mixlib::ShellOut.new.tap { |s| s.stdout.replace("\n") }
- allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", cwd: @repo_path).and_return(@clean_status)
end
it "passes the sanity check" do
@@ -106,35 +106,35 @@ DIRTY
end
it "resets to default state by checking out the default branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", cwd: @repo_path)
@cookbook_repo.reset_to_default_state
end
it "determines if a the pristine copy branch exists" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list)
expect(@cookbook_repo.branch_exists?("chef-vendor-apache2")).to be_truthy
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list)
expect(@cookbook_repo.branch_exists?("chef-vendor-nginx")).to be_falsey
end
it "determines if a the branch not exists correctly without substring search" do
- expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", cwd: @repo_path).and_return(@branch_list)
expect(@cookbook_repo).not_to be_branch_exists("chef-vendor-absent")
expect(@cookbook_repo).to be_branch_exists("chef-vendor-absent-new")
end
describe "when the pristine copy branch does not exist" do
it "prepares for import by creating the pristine copy branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
- expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", cwd: @repo_path)
@cookbook_repo.prepare_to_import("nginx")
end
end
describe "when the pristine copy branch does exist" do
it "prepares for import by checking out the pristine copy branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
- expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", cwd: @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", cwd: @repo_path)
@cookbook_repo.prepare_to_import("apache2")
end
end
@@ -143,7 +143,7 @@ DIRTY
before do
@updates = Mixlib::ShellOut.new
@updates.stdout.replace("\n")
- allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", cwd: @repo_path).and_return(@updates)
end
it "shows no changes in the pristine copy" do
@@ -159,7 +159,7 @@ DIRTY
before do
@updates = Mixlib::ShellOut.new
@updates.stdout.replace(" M cookbooks/apache2/recipes/default.rb\n")
- allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", cwd: @repo_path).and_return(@updates)
end
it "shows changes in the pristine copy" do
@@ -167,20 +167,20 @@ DIRTY
end
it "commits the changes to the repo and tags the commit" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git add apache2", :cwd => @repo_path)
- expect(@cookbook_repo).to receive(:shell_out!).with("git commit -m \"Import apache2 version 1.2.3\" -- apache2", :cwd => @repo_path)
- expect(@cookbook_repo).to receive(:shell_out!).with("git tag -f cookbook-site-imported-apache2-1.2.3", :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git add apache2", cwd: @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git commit -m \"Import apache2 version 1.2.3\" -- apache2", cwd: @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git tag -f cookbook-site-imported-apache2-1.2.3", cwd: @repo_path)
expect(@cookbook_repo.finalize_updates_to("apache2", "1.2.3")).to be_truthy
end
end
describe "when a custom default branch is specified" do
before do
- @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "develop")
+ @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, default_branch: "develop")
end
it "resets to default state by checking out the default branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", cwd: @repo_path)
@cookbook_repo.reset_to_default_state
end
end
diff --git a/spec/unit/knife/core/object_loader_spec.rb b/spec/unit/knife/core/object_loader_spec.rb
index 9cabf2ba63..6eb392acae 100644
--- a/spec/unit/knife/core/object_loader_spec.rb
+++ b/spec/unit/knife/core/object_loader_spec.rb
@@ -57,7 +57,7 @@ describe Chef::Knife::Core::ObjectLoader do
it_behaves_like "Chef object", chef_class
end
- #NOTE: This is check for the bug described at CHEF-2352
+ # NOTE: This is check for the bug described at CHEF-2352
describe "when the file is a JSON" do
describe "and it has defined 'json_class'" do
before do
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 0b986258b7..025c1ecd91 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -25,10 +25,10 @@ describe Chef::Knife::UI do
before do
@out, @err, @in = StringIO.new, StringIO.new, StringIO.new
@config = {
- :verbosity => 0,
- :yes => nil,
- :format => "summary",
- :field_separator => ".",
+ verbosity: 0,
+ yes: nil,
+ format: "summary",
+ field_separator: ".",
}
@ui = Chef::Knife::UI.new(@out, @err, @in, @config)
end
@@ -171,12 +171,12 @@ describe Chef::Knife::UI do
describe "format_list_for_display" do
it "should print the full hash if --with-uri is true" do
@ui.config[:with_uri] = true
- expect(@ui.format_list_for_display({ :marcy => :playground })).to eq({ :marcy => :playground })
+ expect(@ui.format_list_for_display({ marcy: :playground })).to eq({ marcy: :playground })
end
it "should print only the keys if --with-uri is false" do
@ui.config[:with_uri] = false
- expect(@ui.format_list_for_display({ :marcy => :playground })).to eq([ :marcy ])
+ expect(@ui.format_list_for_display({ marcy: :playground })).to eq([ :marcy ])
end
end
@@ -211,9 +211,9 @@ describe Chef::Knife::UI do
it "formats hashes appropriately" do
@ui.output({ "hi" => "a", "lo" => "b" })
- expect(@out.string).to eq <<EOM
-hi: a
-lo: b
+ expect(@out.string).to eq <<~EOM
+ hi: a
+ lo: b
EOM
end
@@ -224,9 +224,9 @@ EOM
it "formats arrays appropriately" do
@ui.output(%w{a b})
- expect(@out.string).to eq <<EOM
-a
-b
+ expect(@out.string).to eq <<~EOM
+ a
+ b
EOM
end
@@ -247,74 +247,74 @@ EOM
it "formats nested arrays appropriately" do
@ui.output([ %w{a b}, %w{c d}])
- expect(@out.string).to eq <<EOM
-a
-b
+ expect(@out.string).to eq <<~EOM
+ a
+ b
-c
-d
+ c
+ d
EOM
end
it "formats nested arrays with single- and empty subarrays appropriately" do
@ui.output([ %w{a b}, [ "c" ], [], %w{d e}])
- expect(@out.string).to eq <<EOM
-a
-b
+ expect(@out.string).to eq <<~EOM
+ a
+ b
-c
+ c
-d
-e
+ d
+ e
EOM
end
it "formats arrays of hashes with extra lines in between for readability" do
@ui.output([ { "a" => "b", "c" => "d" }, { "x" => "y" }, { "m" => "n", "o" => "p" }])
- expect(@out.string).to eq <<EOM
-a: b
-c: d
+ expect(@out.string).to eq <<~EOM
+ a: b
+ c: d
-x: y
+ x: y
-m: n
-o: p
+ m: n
+ o: p
EOM
end
it "formats hashes with empty array members appropriately" do
@ui.output({ "a" => [], "b" => "c" })
- expect(@out.string).to eq <<EOM
-a:
-b: c
+ expect(@out.string).to eq <<~EOM
+ a:
+ b: c
EOM
end
it "formats hashes with single-member array values appropriately" do
@ui.output({ "a" => [ "foo" ], "b" => "c" })
- expect(@out.string).to eq <<EOM
-a: foo
-b: c
+ expect(@out.string).to eq <<~EOM
+ a: foo
+ b: c
EOM
end
it "formats hashes with array members appropriately" do
@ui.output({ "a" => %w{foo bar}, "b" => "c" })
- expect(@out.string).to eq <<EOM
-a:
- foo
- bar
-b: c
+ expect(@out.string).to eq <<~EOM
+ a:
+ foo
+ bar
+ b: c
EOM
end
it "formats hashes with single-member nested array values appropriately" do
@ui.output({ "a" => [ [ "foo" ] ], "b" => "c" })
- expect(@out.string).to eq <<EOM
-a:
- foo
-b: c
+ expect(@out.string).to eq <<~EOM
+ a:
+ foo
+ b: c
EOM
end
@@ -327,19 +327,19 @@ EOM
it "formats hashes with hash values appropriately" do
@ui.output({ "a" => { "aa" => "bb", "cc" => "dd" }, "b" => "c" })
- expect(@out.string).to eq <<EOM
-a:
- aa: bb
- cc: dd
-b: c
+ expect(@out.string).to eq <<~EOM
+ a:
+ aa: bb
+ cc: dd
+ b: c
EOM
end
it "formats hashes with empty hash values appropriately" do
@ui.output({ "a" => {}, "b" => "c" })
- expect(@out.string).to eq <<EOM
-a:
-b: c
+ expect(@out.string).to eq <<~EOM
+ a:
+ b: c
EOM
end
end
@@ -358,7 +358,7 @@ EOM
describe "format_for_display" do
it "should return the raw data" do
- input = { :gi => :go }
+ input = { gi: :go }
expect(@ui.format_for_display(input)).to eq(input)
end
@@ -480,7 +480,7 @@ EOM
context "when running on Windows" do
before(:each) do
- stdout = double("StringIO", :tty? => true)
+ stdout = double("StringIO", tty?: true)
allow(@ui).to receive(:stdout).and_return(stdout)
allow(ChefConfig).to receive(:windows?) { true }
Chef::Config.reset
@@ -631,7 +631,7 @@ EOM
out = StringIO.new
allow(@ui).to receive(:stdout).and_return(out)
allow(@ui).to receive(:stdin).and_return(StringIO.new(" \n"))
- expect(@ui.ask_question("your chef server URL? ", :default => "http://localhost:4000")).to eq("http://localhost:4000")
+ expect(@ui.ask_question("your chef server URL? ", default: "http://localhost:4000")).to eq("http://localhost:4000")
expect(out.string).to eq("your chef server URL? [http://localhost:4000] ")
end
end
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index 169c6e1845..6624fb70ab 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -60,7 +60,7 @@ describe Chef::Knife::DataBagCreate do
context "when data_bag doesn't exist" do
before do
# Data bag doesn't exist by default so we mock the GET request to return 404
- exception = double("404 error", :code => "404")
+ exception = double("404 error", code: "404")
allow(rest).to receive(:get)
.with("data/#{bag_name}")
.and_raise(Net::HTTPServerException.new("404", exception))
@@ -82,7 +82,7 @@ describe Chef::Knife::DataBagCreate do
context "when part of the name is a reserved name" do
before do
- exception = double("404 error", :code => "404")
+ exception = double("404 error", code: "404")
%w{node role client environment}.each do |name|
allow(rest).to receive(:get)
.with("data/sudoing_#{name}_admins")
diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb
index 635dc63489..ff131a7d91 100644
--- a/spec/unit/knife/data_bag_edit_spec.rb
+++ b/spec/unit/knife/data_bag_edit_spec.rb
@@ -74,7 +74,7 @@ describe Chef::Knife::DataBagEdit do
end
context "when config[:print_after] is set" do
- let(:config) { { :print_after => true } }
+ let(:config) { { print_after: true } }
before do
expect(knife.ui).to receive(:output).with(raw_edited_hash)
end
diff --git a/spec/unit/knife/data_bag_secret_options_spec.rb b/spec/unit/knife/data_bag_secret_options_spec.rb
index 2f4d8c8a88..5aa34029e9 100644
--- a/spec/unit/knife/data_bag_secret_options_spec.rb
+++ b/spec/unit/knife/data_bag_secret_options_spec.rb
@@ -73,13 +73,13 @@ describe Chef::Knife::DataBagSecretOptions do
it "returns the secret first" do
Chef::Config[:knife][:cl_secret] = secret
- expect(example_db).to receive(:config).and_return({ :secret => secret })
+ expect(example_db).to receive(:config).and_return({ secret: secret })
expect(example_db.read_secret).to eq(secret)
end
it "returns the secret_file only if secret does not exist" do
Chef::Config[:knife][:cl_secret_file] = secret_file.path
- expect(example_db).to receive(:config).and_return({ :secret_file => secret_file.path })
+ expect(example_db).to receive(:config).and_return({ secret_file: secret_file.path })
expect(Chef::EncryptedDataBagItem).to receive(:load_secret).with(secret_file.path).and_return("secret file contents")
expect(example_db.read_secret).to eq("secret file contents")
end
@@ -111,19 +111,19 @@ describe Chef::Knife::DataBagSecretOptions do
end
it "returns true if --encrypt is passed on the CL and :secret is in config" do
- expect(example_db).to receive(:config).and_return({ :encrypt => true })
+ expect(example_db).to receive(:config).and_return({ encrypt: true })
Chef::Config[:knife][:secret] = secret
expect(example_db.encryption_secret_provided?).to eq(true)
end
it "returns true if --encrypt is passed on the CL and :secret_file is in config" do
- expect(example_db).to receive(:config).and_return({ :encrypt => true })
+ expect(example_db).to receive(:config).and_return({ encrypt: true })
Chef::Config[:knife][:secret_file] = secret_file.path
expect(example_db.encryption_secret_provided?).to eq(true)
end
it "throws an error if --encrypt is passed and there is not :secret or :secret_file in the config" do
- expect(example_db).to receive(:config).and_return({ :encrypt => true })
+ expect(example_db).to receive(:config).and_return({ encrypt: true })
expect(example_db).to receive(:exit).with(1)
expect(example_db.ui).to receive(:fatal).with("No secret or secret_file specified in config, unable to encrypt item.")
example_db.encryption_secret_provided?
diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb
index 4505da3637..11e05cb922 100644
--- a/spec/unit/knife/environment_from_file_spec.rb
+++ b/spec/unit/knife/environment_from_file_spec.rb
@@ -61,7 +61,7 @@ describe Chef::Knife::EnvironmentFromFile do
allow(File).to receive(:expand_path).with("./environments/").and_return("/tmp/environments")
allow(Dir).to receive(:glob).with("/tmp/environments/*.{json,rb}").and_return(["spec.rb", "apple.rb"])
@knife.name_args = []
- allow(@knife).to receive(:config).and_return({ :all => true })
+ allow(@knife).to receive(:config).and_return({ all: true })
expect(@environment).to receive(:save).twice
@knife.run
end
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 5b00c6ea31..fcbfd40381 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -44,9 +44,9 @@ describe "key create commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyCreate with the correct args" do
- expect(Chef::Knife::KeyCreate).to receive(:new).
- with("charmander", command.actor_field_name, command.ui, command.config).
- and_return(service_object)
+ expect(Chef::Knife::KeyCreate).to receive(:new)
+ .with("charmander", command.actor_field_name, command.ui, command.config)
+ .and_return(service_object)
command.service_object
end
end # when the service object is called
@@ -207,7 +207,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
end # when the server returns a private key
end # when the command is run
- end #key create run command"
+ end # key create run command"
context "when actor_field_name is 'user'" do
it_should_behave_like "key create run command" do
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index 0176f3c71e..87969198dc 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -44,9 +44,9 @@ describe "key delete commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyDelete with the correct args" do
- expect(Chef::Knife::KeyDelete).to receive(:new).
- with("charmander-key", "charmander", command.actor_field_name, command.ui).
- and_return(service_object)
+ expect(Chef::Knife::KeyDelete).to receive(:new)
+ .with("charmander-key", "charmander", command.actor_field_name, command.ui)
+ .and_return(service_object)
command.service_object
end
end # when the service object is called
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 244d8bdcc7..1650386da6 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -44,9 +44,9 @@ describe "key edit commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyEdit with the correct args" do
- expect(Chef::Knife::KeyEdit).to receive(:new).
- with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config).
- and_return(service_object)
+ expect(Chef::Knife::KeyEdit).to receive(:new)
+ .with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config)
+ .and_return(service_object)
command.service_object
end
end # when the service object is called
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 82fd1e4a09..e221a4da72 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -44,9 +44,9 @@ describe "key list commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyList with the correct args" do
- expect(Chef::Knife::KeyList).to receive(:new).
- with("charmander", command.list_method, command.ui, command.config).
- and_return(service_object)
+ expect(Chef::Knife::KeyList).to receive(:new)
+ .with("charmander", command.list_method, command.ui, command.config)
+ .and_return(service_object)
command.service_object
end
end # when the service object is called
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index 139d4f91a2..f2eb244b23 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -44,9 +44,9 @@ describe "key show commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyShow with the correct args" do
- expect(Chef::Knife::KeyShow).to receive(:new).
- with("charmander-key", "charmander", command.load_method, command.ui).
- and_return(service_object)
+ expect(Chef::Knife::KeyShow).to receive(:new)
+ .with("charmander-key", "charmander", command.load_method, command.ui)
+ .and_return(service_object)
command.service_object
end
end # when the service object is called
diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb
index 1a6b277dbb..cc2e0b23af 100644
--- a/spec/unit/knife/node_delete_spec.rb
+++ b/spec/unit/knife/node_delete_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::NodeDelete do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeDelete.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = %w{ adam ben }
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index e5fa9317b1..dfc0986ebe 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -30,9 +30,9 @@ describe Chef::Knife::NodeEdit do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeEdit.new
@knife.config = {
- :editor => "cat",
- :attribute => nil,
- :print_after => nil,
+ editor: "cat",
+ attribute: nil,
+ print_after: nil,
}
@knife.name_args = [ "adam" ]
@node = Chef::Node.new()
@@ -48,10 +48,10 @@ describe Chef::Knife::NodeEdit do
@knife.config[:all_attributes] = false
allow(@knife).to receive(:node).and_return(@node)
- @node.automatic_attrs = { :go => :away }
- @node.default_attrs = { :hide => :me }
- @node.override_attrs = { :dont => :show }
- @node.normal_attrs = { :do_show => :these }
+ @node.automatic_attrs = { go: :away }
+ @node.default_attrs = { hide: :me }
+ @node.override_attrs = { dont: :show }
+ @node.normal_attrs = { do_show: :these }
@node.chef_environment("prod")
@node.run_list("recipe[foo]")
end
diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb
index 61c63c150e..cf128a80a0 100644
--- a/spec/unit/knife/node_from_file_spec.rb
+++ b/spec/unit/knife/node_from_file_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::NodeFromFile do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeFromFile.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "adam.rb" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb
index e11bf78029..03c89ff9eb 100644
--- a/spec/unit/knife/node_run_list_add_spec.rb
+++ b/spec/unit/knife/node_run_list_add_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::NodeRunListAdd do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeRunListAdd.new
@knife.config = {
- :after => nil,
+ after: nil,
}
@knife.name_args = [ "adam", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/osc_user_edit_spec.rb b/spec/unit/knife/osc_user_edit_spec.rb
index 59fb152b5b..1792e38027 100644
--- a/spec/unit/knife/osc_user_edit_spec.rb
+++ b/spec/unit/knife/osc_user_edit_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Knife::OscUserEdit do
end
it "loads and edits the user" do
- data = { :name => "my_user" }
+ data = { name: "my_user" }
allow(Chef::User).to receive(:load).with("my_user").and_return(data)
expect(@knife).to receive(:edit_hash).with(data).and_return(data)
@knife.run
diff --git a/spec/unit/knife/osc_user_reregister_spec.rb b/spec/unit/knife/osc_user_reregister_spec.rb
index de706dfa42..b0ac92568e 100644
--- a/spec/unit/knife/osc_user_reregister_spec.rb
+++ b/spec/unit/knife/osc_user_reregister_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::OscUserReregister do
Chef::Knife::OscUserReregister.load_deps
@knife = Chef::Knife::OscUserReregister.new
@knife.name_args = [ "a_user" ]
- @user_mock = double("user_mock", :private_key => "private_key")
+ @user_mock = double("user_mock", private_key: "private_key")
allow(Chef::User).to receive(:load).and_return(@user_mock)
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb
index e9054c1d00..d49adb9354 100644
--- a/spec/unit/knife/role_bulk_delete_spec.rb
+++ b/spec/unit/knife/role_bulk_delete_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::RoleBulkDelete do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleBulkDelete.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = ["."]
@stdout = StringIO.new
diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb
index 9466d9642c..5e2b2caeb5 100644
--- a/spec/unit/knife/role_create_spec.rb
+++ b/spec/unit/knife/role_create_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::RoleCreate do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleCreate.new
@knife.config = {
- :description => nil,
+ description: nil,
}
@knife.name_args = [ "adam" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb
index f095e5ba2d..98c0cde9b2 100644
--- a/spec/unit/knife/role_delete_spec.rb
+++ b/spec/unit/knife/role_delete_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::RoleDelete do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleDelete.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "adam" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb
index 4738101f90..242beeb4a2 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::RoleEnvRunListAdd do
# Chef::Config[:env_name] = "QA"
@knife = Chef::Knife::RoleEnvRunListAdd.new
@knife.config = {
- :after => nil,
+ after: nil,
}
@knife.name_args = [ "will", "QA", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
@@ -85,17 +85,17 @@ describe Chef::Knife::RoleEnvRunListAdd do
end
it "should add to the run list after the specified entries in the QA run list" do
- #Setup
+ # Setup
@role.run_list_for("_default") << "role[acorns]"
@role.run_list_for("_default") << "role[barn]"
@knife.run
@role.run_list_for("QA") << "role[pencil]"
@role.run_list_for("QA") << "role[pen]"
- #Configuration we are testing
+ # Configuration we are testing
@knife.config[:after] = "role[pencil]"
@knife.name_args = [ "will", "QA", "role[pad]", "role[whackadoo]" ]
@knife.run
- #The actual tests
+ # The actual tests
expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
expect(@role.run_list_for("QA")[1]).to eq("role[pencil]")
expect(@role.run_list_for("QA")[2]).to eq("role[pad]")
diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb
index c9c24858c0..7a580ecd4a 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListClear do
@knife = Chef::Knife::RoleEnvRunListClear.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = %w{will QA}
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb
index 8a077f1de3..afbabec528 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListRemove do
@knife = Chef::Knife::RoleEnvRunListRemove.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "QA", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb
index 08dcdd90e2..c4d231d638 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListReplace do
@knife = Chef::Knife::RoleEnvRunListReplace.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "QA", "role[dude]", "role[person]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb
index aed1c9fe1e..79bd3b152e 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::RoleEnvRunListSet do
@knife = Chef::Knife::RoleEnvRunListSet.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "QA", "role[owen]", "role[mauntel]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb
index 104894df17..827b8ae04d 100644
--- a/spec/unit/knife/role_from_file_spec.rb
+++ b/spec/unit/knife/role_from_file_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::RoleFromFile do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleFromFile.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "adam.rb" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index fe7318c040..a38b6de9da 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::RoleRunListAdd do
# Chef::Config[:env_name] = "QA"
@knife = Chef::Knife::RoleRunListAdd.new
@knife.config = {
- :after => nil,
+ after: nil,
}
@knife.name_args = [ "will", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
@@ -74,14 +74,14 @@ describe Chef::Knife::RoleRunListAdd do
end
it "should add to the run list after the specified entries in the default run list" do
- #Setup
+ # Setup
@role.run_list_for("_default") << "role[acorns]"
@role.run_list_for("_default") << "role[barn]"
- #Configuration we are testing
+ # Configuration we are testing
@knife.config[:after] = "role[acorns]"
@knife.name_args = [ "will", "role[pad]", "role[whackadoo]" ]
@knife.run
- #The actual tests
+ # The actual tests
expect(@role.run_list[0]).to eq("role[acorns]")
expect(@role.run_list[1]).to eq("role[pad]")
expect(@role.run_list[2]).to eq("role[whackadoo]")
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index 4ed1f312b0..8bbc816d6f 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListClear do
@knife = Chef::Knife::RoleRunListClear.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb
index 087bc2c6ee..c18416feca 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListRemove do
@knife = Chef::Knife::RoleRunListRemove.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb
index 2bc060ae2d..9b212de0ae 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListReplace do
@knife = Chef::Knife::RoleRunListReplace.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "role[dude]", "role[person]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb
index 27b4d9fea1..f8e440f524 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::RoleRunListSet do
@knife = Chef::Knife::RoleRunListSet.new
@knife.config = {
- :print_after => nil,
+ print_after: nil,
}
@knife.name_args = [ "will", "role[owen]", "role[mauntel]" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb
index 9d7fcb6f9e..9cefcba84f 100644
--- a/spec/unit/knife/ssh_spec.rb
+++ b/spec/unit/knife/ssh_spec.rb
@@ -224,7 +224,7 @@ describe Chef::Knife::Ssh do
describe "#session_from_list" do
before :each do
@knife.instance_variable_set(:@longest, 0)
- ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 }
+ ssh_config = { timeout: 50, user: "locutus", port: 23, keepalive: true, keepalive_interval: 60 }
allow(Net::SSH).to receive(:configuration_for).with("the.b.org", true).and_return(ssh_config)
end
@@ -279,39 +279,39 @@ describe Chef::Knife::Ssh do
end
describe "#ssh_command" do
- let(:execution_channel) { double(:execution_channel, :on_data => nil) }
- let(:session_channel) { double(:session_channel, :request_pty => nil) }
+ let(:execution_channel) { double(:execution_channel, on_data: nil) }
+ let(:session_channel) { double(:session_channel, request_pty: nil) }
- let(:execution_channel2) { double(:execution_channel, :on_data => nil) }
- let(:session_channel2) { double(:session_channel, :request_pty => nil) }
+ let(:execution_channel2) { double(:execution_channel, on_data: nil) }
+ let(:session_channel2) { double(:session_channel, request_pty: nil) }
- let(:session) { double(:session, :loop => nil) }
+ let(:session) { double(:session, loop: nil) }
let(:command) { "false" }
before do
- expect(execution_channel).
- to receive(:on_request).
- and_yield(nil, double(:data_stream, :read_long => exit_status))
+ expect(execution_channel)
+ .to receive(:on_request)
+ .and_yield(nil, double(:data_stream, read_long: exit_status))
- expect(session_channel).
- to receive(:exec).
- with(command).
- and_yield(execution_channel, true)
+ expect(session_channel)
+ .to receive(:exec)
+ .with(command)
+ .and_yield(execution_channel, true)
- expect(execution_channel2).
- to receive(:on_request).
- and_yield(nil, double(:data_stream, :read_long => exit_status2))
+ expect(execution_channel2)
+ .to receive(:on_request)
+ .and_yield(nil, double(:data_stream, read_long: exit_status2))
- expect(session_channel2).
- to receive(:exec).
- with(command).
- and_yield(execution_channel2, true)
+ expect(session_channel2)
+ .to receive(:exec)
+ .with(command)
+ .and_yield(execution_channel2, true)
- expect(session).
- to receive(:open_channel).
- and_yield(session_channel).
- and_yield(session_channel2)
+ expect(session)
+ .to receive(:open_channel)
+ .and_yield(session_channel)
+ .and_yield(session_channel2)
end
context "both connections return 0" do
@@ -344,7 +344,7 @@ describe Chef::Knife::Ssh do
describe "#tmux" do
before do
- ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 }
+ ssh_config = { timeout: 50, user: "locutus", port: 23, keepalive: true, keepalive_interval: 60 }
allow(Net::SSH).to receive(:configuration_for).with("foo.example.org", true).and_return(ssh_config)
@query = Chef::Search::Query.new
expect(@query).to receive(:search).and_yield(@node_foo)
diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb
index 8aa18c3abc..9092110b95 100644
--- a/spec/unit/knife/ssl_check_spec.rb
+++ b/spec/unit/knife/ssl_check_spec.rb
@@ -67,11 +67,11 @@ describe Chef::Knife::SslCheck do
it "prints an error and exits" do
expect { ssl_check.run }.to raise_error(SystemExit)
- expected_stdout = <<-E
-USAGE: knife ssl check [URL] (options)
+ expected_stdout = <<~E
+ USAGE: knife ssl check [URL] (options)
E
- expected_stderr = <<-E
-ERROR: Given URI: `foo.test' is invalid
+ expected_stderr = <<~E
+ ERROR: Given URI: `foo.test' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
expect(stderr_io.string).to eq(expected_stderr)
@@ -83,11 +83,11 @@ E
it "prints an error and exits" do
expect { ssl_check.run }.to raise_error(SystemExit)
- expected_stdout = <<-E
-USAGE: knife ssl check [URL] (options)
+ expected_stdout = <<~E
+ USAGE: knife ssl check [URL] (options)
E
- expected_stderr = <<-E
-ERROR: Given URI: `#{name_args[0]}' is invalid
+ expected_stderr = <<~E
+ ERROR: Given URI: `#{name_args[0]}' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
expect(stderr_io.string).to eq(expected_stderr)
@@ -168,8 +168,8 @@ E
def run
ssl_check.run
rescue Exception
- #puts "OUT: #{stdout_io.string}"
- #puts "ERR: #{stderr_io.string}"
+ # puts "OUT: #{stdout_io.string}"
+ # puts "ERR: #{stderr_io.string}"
raise
end
@@ -199,12 +199,12 @@ E
before do
@old_signal = trap(:INT, "DEFAULT")
- expect(ssl_check).to receive(:proxified_socket).
- with("foo.example.com", 8443).
- and_return(tcp_socket_for_debug)
- expect(OpenSSL::SSL::SSLSocket).to receive(:new).
- with(tcp_socket_for_debug, ssl_check.noverify_peer_ssl_context).
- and_return(ssl_socket_for_debug)
+ expect(ssl_check).to receive(:proxified_socket)
+ .with("foo.example.com", 8443)
+ .and_return(tcp_socket_for_debug)
+ expect(OpenSSL::SSL::SSLSocket).to receive(:new)
+ .with(tcp_socket_for_debug, ssl_check.noverify_peer_ssl_context)
+ .and_return(ssl_socket_for_debug)
end
after do
@@ -215,9 +215,9 @@ E
before do
expect(ssl_check).to receive(:verify_X509).and_return(true) # X509 valid certs
expect(ssl_socket).to receive(:connect) # no error
- expect(ssl_socket).to receive(:post_connection_check).
- with("foo.example.com").
- and_raise(OpenSSL::SSL::SSLError)
+ expect(ssl_socket).to receive(:post_connection_check)
+ .with("foo.example.com")
+ .and_raise(OpenSSL::SSL::SSLError)
expect(ssl_socket).to receive(:hostname=).with("foo.example.com") # no error
expect(ssl_socket_for_debug).to receive(:connect)
expect(ssl_socket_for_debug).to receive(:peer_cert).and_return(self_signed_crt)
@@ -235,10 +235,10 @@ E
context "when the cert is not signed by any trusted authority" do
before do
expect(ssl_check).to receive(:verify_X509).and_return(true) # X509 valid certs
- expect(ssl_socket).to receive(:connect).
- and_raise(OpenSSL::SSL::SSLError)
- expect(ssl_socket).to receive(:hostname=).
- with("foo.example.com") # no error
+ expect(ssl_socket).to receive(:connect)
+ .and_raise(OpenSSL::SSL::SSLError)
+ expect(ssl_socket).to receive(:hostname=)
+ .with("foo.example.com") # no error
expect(ssl_socket_for_debug).to receive(:connect)
expect(ssl_socket_for_debug).to receive(:peer_cert).and_return(self_signed_crt)
end
diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb
index bc49c40241..45dd27ceec 100644
--- a/spec/unit/knife/ssl_fetch_spec.rb
+++ b/spec/unit/knife/ssl_fetch_spec.rb
@@ -68,11 +68,11 @@ describe Chef::Knife::SslFetch do
it "prints an error and exits" do
expect { ssl_fetch.run }.to raise_error(SystemExit)
- expected_stdout = <<-E
-USAGE: knife ssl fetch [URL] (options)
+ expected_stdout = <<~E
+ USAGE: knife ssl fetch [URL] (options)
E
- expected_stderr = <<-E
-ERROR: Given URI: `foo.test' is invalid
+ expected_stderr = <<~E
+ ERROR: Given URI: `foo.test' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
expect(stderr_io.string).to eq(expected_stderr)
@@ -84,11 +84,11 @@ E
it "prints an error and exits" do
expect { ssl_fetch.run }.to raise_error(SystemExit)
- expected_stdout = <<-E
-USAGE: knife ssl fetch [URL] (options)
+ expected_stdout = <<~E
+ USAGE: knife ssl fetch [URL] (options)
E
- expected_stderr = <<-E
-ERROR: Given URI: `#{name_args[0]}' is invalid
+ expected_stderr = <<~E
+ ERROR: Given URI: `#{name_args[0]}' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
expect(stderr_io.string).to eq(expected_stderr)
@@ -187,9 +187,9 @@ E
end
it "tells the user their URL is for a non-ssl service" do
- expected_error_text = <<-ERROR_TEXT
-ERROR: The service at the given URI (http://foo.example.com) does not accept SSL connections
-ERROR: Perhaps you meant to connect to 'https://foo.example.com'?
+ expected_error_text = <<~ERROR_TEXT
+ ERROR: The service at the given URI (http://foo.example.com) does not accept SSL connections
+ ERROR: Perhaps you meant to connect to 'https://foo.example.com'?
ERROR_TEXT
run
diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb
index 0f71b39a41..68749fe727 100644
--- a/spec/unit/knife/user_delete_spec.rb
+++ b/spec/unit/knife/user_delete_spec.rb
@@ -51,7 +51,7 @@ describe Chef::Knife::UserDelete do
end
it "deletes the user" do
- #expect(knife).to receive(:delete_object).with(Chef::UserV1, 'my_user')
+ # expect(knife).to receive(:delete_object).with(Chef::UserV1, 'my_user')
expect(knife).to receive(:delete_object).with("my_user")
knife.run
end
diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb
index d650ff9fb8..8501347087 100644
--- a/spec/unit/knife/user_reregister_spec.rb
+++ b/spec/unit/knife/user_reregister_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::UserReregister do
let(:knife) { Chef::Knife::UserReregister.new }
- let(:user_mock) { double("user_mock", :private_key => "private_key") }
+ let(:user_mock) { double("user_mock", private_key: "private_key") }
let(:stdout) { StringIO.new }
before do
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index adaab11d55..c091286077 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Knife do
instance_double("WorkstationConfigLoader",
load: nil, no_config_found?: false,
config_location: config_location,
- :chef_config_dir => "/etc/chef")
+ chef_config_dir: "/etc/chef")
end
before(:each) do
@@ -225,10 +225,10 @@ describe Chef::Knife do
it "merges the global knife CLI options" do
extra_opts = {}
- extra_opts[:editor] = { :long => "--editor EDITOR",
- :description => "Set the editor to use for interactive commands",
- :short => "-e EDITOR",
- :default => "/usr/bin/vim" }
+ extra_opts[:editor] = { long: "--editor EDITOR",
+ description: "Set the editor to use for interactive commands",
+ short: "-e EDITOR",
+ default: "/usr/bin/vim" }
# there is special hackery to return the subcommand instance going on here.
command = Chef::Knife.run(%w{test yourself}, extra_opts)
@@ -283,8 +283,8 @@ describe Chef::Knife do
describe "merging configuration options" do
before do
KnifeSpecs::TestYourself.option(:opt_with_default,
- :short => "-D VALUE",
- :default => "default-value")
+ short: "-D VALUE",
+ default: "default-value")
end
it "sets the default log_location to STDERR for Chef::Log warnings" do
@@ -300,14 +300,14 @@ describe Chef::Knife do
end
it "prefers the default value if no config or command line value is present" do
- knife_command = KnifeSpecs::TestYourself.new([]) #empty argv
+ knife_command = KnifeSpecs::TestYourself.new([]) # empty argv
knife_command.configure_chef
expect(knife_command.config[:opt_with_default]).to eq("default-value")
end
it "prefers a value in Chef::Config[:knife] to the default" do
Chef::Config[:knife][:opt_with_default] = "from-knife-config"
- knife_command = KnifeSpecs::TestYourself.new([]) #empty argv
+ knife_command = KnifeSpecs::TestYourself.new([]) # empty argv
knife_command.configure_chef
expect(knife_command.config[:opt_with_default]).to eq("from-knife-config")
end
@@ -330,7 +330,7 @@ describe Chef::Knife do
before do
knife.config[:verbosity] = 1
knife.config[:config_file] = fake_config
- config_loader = double("Chef::WorkstationConfigLoader", :load => true, :no_config_found? => false, :chef_config_dir => "/etc/chef", :config_location => fake_config)
+ config_loader = double("Chef::WorkstationConfigLoader", load: true, no_config_found?: false, chef_config_dir: "/etc/chef", config_location: fake_config)
allow(config_loader).to receive(:explicit_config_file=).with(fake_config).and_return(fake_config)
allow(config_loader).to receive(:profile=)
allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
@@ -423,7 +423,7 @@ describe Chef::Knife do
it "formats 401s nicely" do
response = Net::HTTPUnauthorized.new("1.1", "401", "Unauthorized")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no syncronize your clock?"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no syncronize your clock?"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("401 Unauthorized", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(/ERROR: Failed to authenticate to/)
@@ -433,7 +433,7 @@ describe Chef::Knife do
it "formats 403s nicely" do
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no administrator"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
@@ -453,7 +453,7 @@ describe Chef::Knife do
it "formats proxy errors nicely" do
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
response.instance_variable_set(:@read, true)
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u no administrator"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
@@ -466,7 +466,7 @@ describe Chef::Knife do
it "formats 400s nicely" do
response = Net::HTTPBadRequest.new("1.1", "400", "Bad Request")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "y u search wrong"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("400 Bad Request", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: The data in your request was invalid})
@@ -476,7 +476,7 @@ describe Chef::Knife do
it "formats 404s nicely" do
response = Net::HTTPNotFound.new("1.1", "404", "Not Found")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "nothing to see here"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("404 Not Found", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: The object you are looking for could not be found})
@@ -488,9 +488,9 @@ describe Chef::Knife do
response.instance_variable_set(:@read, true) # I hate you, net/http.
# set the header
- response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(:min_version => "0", :max_version => "1", :request_version => "10000000")
+ response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(min_version: "0", max_version: "1", request_version: "10000000")
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("406 Not Acceptable", response))
knife.run_with_pretty_exceptions
@@ -502,7 +502,7 @@ describe Chef::Knife do
it "formats 500s nicely" do
response = Net::HTTPInternalServerError.new("1.1", "500", "Internal Server Error")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone"))
allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("500 Internal Server Error", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: internal server error})
@@ -512,7 +512,7 @@ describe Chef::Knife do
it "formats 502s nicely" do
response = Net::HTTPBadGateway.new("1.1", "502", "Bad Gateway")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sadder trombone"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sadder trombone"))
allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("502 Bad Gateway", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: bad gateway})
@@ -522,7 +522,7 @@ describe Chef::Knife do
it "formats 503s nicely" do
response = Net::HTTPServiceUnavailable.new("1.1", "503", "Service Unavailable")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "saddest trombone"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "saddest trombone"))
allow(knife).to receive(:run).and_raise(Net::HTTPFatalError.new("503 Service Unavailable", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: Service temporarily unavailable})
@@ -532,7 +532,7 @@ describe Chef::Knife do
it "formats other HTTP errors nicely" do
response = Net::HTTPPaymentRequired.new("1.1", "402", "Payment Required")
response.instance_variable_set(:@read, true) # I hate you, net/http.
- allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "nobugfixtillyoubuy"))
+ allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy"))
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("402 Payment Required", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: Payment Required})
@@ -571,11 +571,11 @@ describe Chef::Knife do
knife.run_with_pretty_exceptions
- expected_message = <<-MSG
-ERROR: Could not establish a secure connection to the server.
-Use `knife ssl check` to troubleshoot your SSL configuration.
-If your Chef Server uses a self-signed certificate, you can use
-`knife ssl fetch` to make knife trust the server's certificates.
+ expected_message = <<~MSG
+ ERROR: Could not establish a secure connection to the server.
+ Use `knife ssl check` to troubleshoot your SSL configuration.
+ If your Chef Server uses a self-signed certificate, you can use
+ `knife ssl fetch` to make knife trust the server's certificates.
MSG
expect(stderr.string).to include(expected_message)
end
diff --git a/spec/unit/log/syslog_spec.rb b/spec/unit/log/syslog_spec.rb
index 6d56b96575..4586503e88 100644
--- a/spec/unit/log/syslog_spec.rb
+++ b/spec/unit/log/syslog_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-describe "Chef::Log::Syslog", :unix_only => true do
+describe "Chef::Log::Syslog", unix_only: true do
let(:syslog) { Chef::Log::Syslog.new }
before do
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index b42ac3af1e..a7f95f8bfd 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -243,8 +243,8 @@ describe "LWRP" do
let(:klass) do
Class.new(Chef::Resource::LWRPBase) do
self.resource_name = :sample_resource
- attribute :food, :default => lazy { "BACON!" * 3 }
- attribute :drink, :default => lazy { |r| "Drink after #{r.food}!" }
+ attribute :food, default: lazy { "BACON!" * 3 }
+ attribute :drink, default: lazy { |r| "Drink after #{r.food}!" }
end
end
@@ -520,7 +520,7 @@ describe "LWRP" do
resource.provider(get_dynamic_lwrp_provider(:lwrp_embedded_resource_accesses_providers_scope))
provider = resource.provider_for_action(:twiddle_thumbs)
- #provider = @runner.build_provider(resource)
+ # provider = @runner.build_provider(resource)
provider.action_twiddle_thumbs
expect(provider.enclosed_resource.monkey).to eq("bob, the monkey")
diff --git a/spec/unit/mash_spec.rb b/spec/unit/mash_spec.rb
index e58f6b85a1..0797e80f2c 100644
--- a/spec/unit/mash_spec.rb
+++ b/spec/unit/mash_spec.rb
@@ -21,7 +21,7 @@ require "chef/mash"
describe Mash do
it "should duplicate a simple key/value mash to a new mash" do
- data = { :x => "one", :y => "two", :z => "three" }
+ data = { x: "one", y: "two", z: "three" }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
@@ -30,7 +30,7 @@ describe Mash do
end
it "should duplicate a mash with an array to a new mash" do
- data = { :x => "one", :y => "two", :z => [1, 2, 3] }
+ data = { x: "one", y: "two", z: [1, 2, 3] }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
@@ -39,7 +39,7 @@ describe Mash do
end
it "should duplicate a nested mash to a new mash" do
- data = { :x => "one", :y => "two", :z => Mash.new({ :a => [1, 2, 3] }) }
+ data = { x: "one", y: "two", z: Mash.new({ a: [1, 2, 3] }) }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index 191dee643b..cabc85439c 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -26,24 +26,24 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:default_supported_client_versions) { [0, 1, 2] }
context "when the response code is not 406" do
- let(:response) { OpenStruct.new(:code => "405") }
+ let(:response) { OpenStruct.new(code: "405") }
let(:exception) { Net::HTTPServerException.new("405 Something Else", response) }
it "returns nil" do
- expect(object.server_client_api_version_intersection(exception, default_supported_client_versions)).
- to be_nil
+ expect(object.server_client_api_version_intersection(exception, default_supported_client_versions))
+ .to be_nil
end
end # when the response code is not 406
context "when the response code is 406" do
- let(:response) { OpenStruct.new(:code => "406") }
+ let(:response) { OpenStruct.new(code: "406") }
let(:exception) { Net::HTTPServerException.new("406 Not Acceptable", response) }
context "when x-ops-server-api-version header does not exist" do
it "returns nil" do
- expect(object.server_client_api_version_intersection(exception, default_supported_client_versions)).
- to be_nil
+ expect(object.server_client_api_version_intersection(exception, default_supported_client_versions))
+ .to be_nil
end
end # when x-ops-server-api-version header does not exist
@@ -64,13 +64,13 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when there is no intersection between client and server versions" do
shared_examples_for "no intersection between client and server versions" do
it "return an array" do
- expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to be_a_kind_of(Array)
+ expect(object.server_client_api_version_intersection(exception, supported_client_versions))
+ .to be_a_kind_of(Array)
end
it "returns an empty array" do
- expect(object.server_client_api_version_intersection(exception, supported_client_versions).length).
- to eq(0)
+ expect(object.server_client_api_version_intersection(exception, supported_client_versions).length)
+ .to eq(0)
end
end
@@ -94,8 +94,8 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:supported_client_versions) { [1, 2, 3, 4, 5] }
it "includes all of the intersection" do
- expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to eq([2, 3, 4])
+ expect(object.server_client_api_version_intersection(exception, supported_client_versions))
+ .to eq([2, 3, 4])
end
end # when multiple versions intersect
@@ -103,8 +103,8 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:supported_client_versions) { [0, 1, 2] }
it "includes the intersection" do
- expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to eq([2])
+ expect(object.server_client_api_version_intersection(exception, supported_client_versions))
+ .to eq([2])
end
end # when only the min client version intersects
@@ -112,8 +112,8 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:supported_client_versions) { [4, 5, 6] }
it "includes the intersection" do
- expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to eq([4])
+ expect(object.server_client_api_version_intersection(exception, supported_client_versions))
+ .to eq([4])
end
end # when only the max client version intersects
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index 801c8820d2..873d2a2fc0 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Mixin::Checksum do
@checksum_user = Chef::CMCCheck.new
@cache = Chef::Digester.instance
@file = CHEF_SPEC_DATA + "/checksum/random.txt"
- @stat = double("File::Stat", { :mtime => Time.at(0) })
+ @stat = double("File::Stat", { mtime: Time.at(0) })
allow(File).to receive(:stat).and_return(@stat)
end
diff --git a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
index 248de0ba95..701de06167 100644
--- a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
+++ b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
@@ -51,11 +51,11 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do
allow_any_instance_of(Chef::FileAccessControl).to receive(:define_resource_requirements)
allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes)
- passwd_struct = OpenStruct.new(:name => "root", :passwd => "x",
- :uid => 0, :gid => 0, :dir => "/root",
- :shell => "/bin/bash")
+ passwd_struct = OpenStruct.new(name: "root", passwd: "x",
+ uid: 0, gid: 0, dir: "/root",
+ shell: "/bin/bash")
- group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
+ group_struct = OpenStruct.new(name: "root", passwd: "x", gid: 0)
allow(Etc).to receive(:getpwuid).and_return(passwd_struct)
allow(Etc).to receive(:getgrgid).and_return(group_struct)
end
@@ -75,11 +75,11 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do
allow_any_instance_of(Chef::FileAccessControl).to receive(:uid_from_resource).and_return(0)
allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes)
- passwd_struct = OpenStruct.new(:name => "root", :passwd => "x",
- :uid => 0, :gid => 0, :dir => "/root",
- :shell => "/bin/bash")
+ passwd_struct = OpenStruct.new(name: "root", passwd: "x",
+ uid: 0, gid: 0, dir: "/root",
+ shell: "/bin/bash")
- group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
+ group_struct = OpenStruct.new(name: "root", passwd: "x", gid: 0)
allow(Etc).to receive(:getpwuid).and_return(passwd_struct)
allow(Etc).to receive(:getgrgid).and_return(group_struct)
end
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb
index 67d79719aa..df89962cce 100644
--- a/spec/unit/mixin/homebrew_user_spec.rb
+++ b/spec/unit/mixin/homebrew_user_spec.rb
@@ -56,7 +56,7 @@ describe Chef::Mixin::HomebrewUser do
context "debug statement prints owner name" do
before do
- expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name"))
+ expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(name: "name"))
end
it "returns the owner of the brew executable when it is at a default location" do
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index 7bc8a27398..62d6b3e117 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should allow a hash and a hash as arguments to validate" do
- expect { @vo.validate({ :one => "two" }, {}) }.not_to raise_error
+ expect { @vo.validate({ one: "two" }, {}) }.not_to raise_error
end
it "should raise an argument error if validate is called incorrectly" do
@@ -42,26 +42,26 @@ describe Chef::Mixin::ParamsValidate do
end
it "should require validation map keys to be symbols or strings" do
- expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
- expect { @vo.validate({ :one => "two" }, { "one" => true }) }.not_to raise_error
- expect { @vo.validate({ :one => "two" }, { Hash.new => true }) }.to raise_error(ArgumentError)
+ expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error
+ expect { @vo.validate({ one: "two" }, { "one" => true }) }.not_to raise_error
+ expect { @vo.validate({ one: "two" }, { Hash.new => true }) }.to raise_error(ArgumentError)
end
it "should allow options to be required with true" do
- expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
+ expect { @vo.validate({ one: "two" }, { one: true }) }.not_to raise_error
end
it "should allow options to be optional with false" do
- expect { @vo.validate({}, { :one => false }) }.not_to raise_error
+ expect { @vo.validate({}, { one: false }) }.not_to raise_error
end
it "should allow you to check what kind_of? thing an argument is with kind_of" do
expect do
@vo.validate(
- { :one => "string" },
+ { one: "string" },
{
- :one => {
- :kind_of => String,
+ one: {
+ kind_of: String,
},
}
)
@@ -69,10 +69,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :one => "string" },
+ { one: "string" },
{
- :one => {
- :kind_of => Array,
+ one: {
+ kind_of: Array,
},
}
)
@@ -82,10 +82,10 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify an argument is required with required" do
expect do
@vo.validate(
- { :one => "string" },
+ { one: "string" },
{
- :one => {
- :required => true,
+ one: {
+ required: true,
},
}
)
@@ -93,10 +93,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :two => "string" },
+ { two: "string" },
{
- :one => {
- :required => true,
+ one: {
+ required: true,
},
}
)
@@ -104,10 +104,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :two => "string" },
+ { two: "string" },
{
- :one => {
- :required => false,
+ one: {
+ required: false,
},
}
)
@@ -117,10 +117,10 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has a method with respond_to" do
expect do
@vo.validate(
- { :one => @vo },
+ { one: @vo },
{
- :one => {
- :respond_to => "validate",
+ one: {
+ respond_to: "validate",
},
}
)
@@ -128,10 +128,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :one => @vo },
+ { one: @vo },
{
- :one => {
- :respond_to => "monkey",
+ one: {
+ respond_to: "monkey",
},
}
)
@@ -141,10 +141,10 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has all the given methods with respond_to and an array" do
expect do
@vo.validate(
- { :one => @vo },
+ { one: @vo },
{
- :one => {
- :respond_to => %w{validate music},
+ one: {
+ respond_to: %w{validate music},
},
}
)
@@ -152,10 +152,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :one => @vo },
+ { one: @vo },
{
- :one => {
- :respond_to => %w{monkey validate},
+ one: {
+ respond_to: %w{monkey validate},
},
}
)
@@ -165,8 +165,8 @@ describe Chef::Mixin::ParamsValidate do
it "should let you set a default value with default => value" do
arguments = Hash.new
@vo.validate(arguments, {
- :one => {
- :default => "is the loneliest number",
+ one: {
+ default: "is the loneliest number",
},
})
expect(arguments[:one]).to eq("is the loneliest number")
@@ -175,10 +175,10 @@ describe Chef::Mixin::ParamsValidate do
it "should let you check regular expressions" do
expect do
@vo.validate(
- { :one => "is good" },
+ { one: "is good" },
{
- :one => {
- :regex => /^is good$/,
+ one: {
+ regex: /^is good$/,
},
}
)
@@ -186,10 +186,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :one => "is good" },
+ { one: "is good" },
{
- :one => {
- :regex => /^is bad$/,
+ one: {
+ regex: /^is bad$/,
},
}
)
@@ -199,10 +199,10 @@ describe Chef::Mixin::ParamsValidate do
it "should let you specify your own callbacks" do
expect do
@vo.validate(
- { :one => "is good" },
+ { one: "is good" },
{
- :one => {
- :callbacks => {
+ one: {
+ callbacks: {
"should be equal to is good" => lambda do |a|
a == "is good"
end,
@@ -214,10 +214,10 @@ describe Chef::Mixin::ParamsValidate do
expect do
@vo.validate(
- { :one => "is bad" },
+ { one: "is bad" },
{
- :one => {
- :callbacks => {
+ one: {
+ callbacks: {
"should be equal to 'is good'" => lambda do |a|
a == "is good"
end,
@@ -229,27 +229,27 @@ describe Chef::Mixin::ParamsValidate do
end
it "should let you combine checks" do
- args = { :one => "is good", :two => "is bad" }
+ args = { one: "is good", two: "is bad" }
expect do
@vo.validate(
args,
{
- :one => {
- :kind_of => String,
- :respond_to => [ :to_s, :upcase ],
- :regex => /^is good/,
- :callbacks => {
+ one: {
+ kind_of: String,
+ respond_to: [ :to_s, :upcase ],
+ regex: /^is good/,
+ callbacks: {
"should be your friend" => lambda do |a|
a == "is good"
end,
},
- :required => true,
+ required: true,
},
- :two => {
- :kind_of => String,
- :required => false,
+ two: {
+ kind_of: String,
+ required: false,
},
- :three => { :default => "neato mosquito" },
+ three: { default: "neato mosquito" },
}
)
end.not_to raise_error
@@ -258,22 +258,22 @@ describe Chef::Mixin::ParamsValidate do
@vo.validate(
args,
{
- :one => {
- :kind_of => String,
- :respond_to => [ :to_s, :upcase ],
- :regex => /^is good/,
- :callbacks => {
+ one: {
+ kind_of: String,
+ respond_to: [ :to_s, :upcase ],
+ regex: /^is good/,
+ callbacks: {
"should be your friend" => lambda do |a|
a == "is good"
end,
},
- :required => true,
+ required: true,
},
- :two => {
- :kind_of => Hash,
- :required => false,
+ two: {
+ kind_of: Hash,
+ required: false,
},
- :three => { :default => "neato mosquito" },
+ three: { default: "neato mosquito" },
}
)
end.to raise_error(ArgumentError)
@@ -282,10 +282,10 @@ describe Chef::Mixin::ParamsValidate do
it "should raise an ArgumentError if the validation map has an unknown check" do
expect do
@vo.validate(
- { :one => "two" },
+ { one: "two" },
{
- :one => {
- :busted => "check",
+ one: {
+ busted: "check",
},
}
)
@@ -294,37 +294,37 @@ describe Chef::Mixin::ParamsValidate do
it "should accept keys that are strings in the options" do
expect do
- @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } })
+ @vo.validate({ "one" => "two" }, { one: { regex: /^two$/ } })
end.not_to raise_error
end
it "should allow an array to kind_of" do
expect do
@vo.validate(
- { :one => "string" },
+ { one: "string" },
{
- :one => {
- :kind_of => [ String, Array ],
+ one: {
+ kind_of: [ String, Array ],
},
}
)
end.not_to raise_error
expect do
@vo.validate(
- { :one => ["string"] },
+ { one: ["string"] },
{
- :one => {
- :kind_of => [ String, Array ],
+ one: {
+ kind_of: [ String, Array ],
},
}
)
end.not_to raise_error
expect do
@vo.validate(
- { :one => Hash.new },
+ { one: Hash.new },
{
- :one => {
- :kind_of => [ String, Array ],
+ one: {
+ kind_of: [ String, Array ],
},
}
)
@@ -333,23 +333,23 @@ describe Chef::Mixin::ParamsValidate do
it "asserts that a value returns false from a predicate method" do
expect do
- @vo.validate({ :not_blank => "should pass" },
- { :not_blank => { :cannot_be => [ :nil, :empty ] } })
+ @vo.validate({ not_blank: "should pass" },
+ { not_blank: { cannot_be: [ :nil, :empty ] } })
end.not_to raise_error
expect do
- @vo.validate({ :not_blank => "" },
- { :not_blank => { :cannot_be => [ :nil, :empty ] } })
+ @vo.validate({ not_blank: "" },
+ { not_blank: { cannot_be: [ :nil, :empty ] } })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "allows a custom validation message" do
expect do
- @vo.validate({ :not_blank => "should pass" },
- { :not_blank => { :cannot_be => [ :nil, :empty ], validation_message: "my validation message" } })
+ @vo.validate({ not_blank: "should pass" },
+ { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } })
end.not_to raise_error
expect do
- @vo.validate({ :not_blank => "" },
- { :not_blank => { :cannot_be => [ :nil, :empty ], validation_message: "my validation message" } })
+ @vo.validate({ not_blank: "" },
+ { not_blank: { cannot_be: [ :nil, :empty ], validation_message: "my validation message" } })
end.to raise_error(Chef::Exceptions::ValidationFailed, "my validation message")
end
@@ -361,38 +361,38 @@ describe Chef::Mixin::ParamsValidate do
it "should set and return a default value when the argument is nil, then return the same value" do
value = "meow"
- expect(@vo.set_or_return(:test, nil, { :default => value }).object_id).to eq(value.object_id)
+ expect(@vo.set_or_return(:test, nil, { default: value }).object_id).to eq(value.object_id)
expect(@vo.set_or_return(:test, nil, {}).object_id).to eq(value.object_id)
end
it "should raise an ArgumentError when argument is nil and required is true" do
expect do
- @vo.set_or_return(:test, nil, { :required => true })
+ @vo.set_or_return(:test, nil, { required: true })
end.to raise_error(ArgumentError)
end
it "should not raise an error when argument is nil and required is false" do
expect do
- @vo.set_or_return(:test, nil, { :required => false })
+ @vo.set_or_return(:test, nil, { required: false })
end.not_to raise_error
end
it "should set and return @name, then return @name for foo when argument is nil" do
value = "meow"
expect(@vo.set_or_return(:name, value, {}).object_id).to eq(value.object_id)
- expect(@vo.set_or_return(:foo, nil, { :name_attribute => true }).object_id).to eq(value.object_id)
+ expect(@vo.set_or_return(:foo, nil, { name_attribute: true }).object_id).to eq(value.object_id)
end
it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do
value = Chef::DelayedEvaluator.new { "test" }
- @vo.set_or_return(:test, value, { :kind_of => Numeric })
+ @vo.set_or_return(:test, value, { kind_of: Numeric })
end
it "should raise an error when delayed evaluated attribute is not valid" do
value = Chef::DelayedEvaluator.new { "test" }
- @vo.set_or_return(:test, value, { :kind_of => Numeric })
+ @vo.set_or_return(:test, value, { kind_of: Numeric })
expect do
- @vo.set_or_return(:test, nil, { :kind_of => Numeric })
+ @vo.set_or_return(:test, nil, { kind_of: Numeric })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index 159a0a8d1d..210267ba19 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Mixin::PowershellTypeCoercions do
["'", '"', "#", "`"].each do |c|
it "base64 encodes a string that contains #{c}" do
- expect(test_class.translate_type("#{c}")).to match(Base64.strict_encode64(c))
+ expect(test_class.translate_type(c.to_s)).to match(Base64.strict_encode64(c))
end
end
diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb
index 6f50ce853f..de95aa2614 100644
--- a/spec/unit/mixin/securable_spec.rb
+++ b/spec/unit/mixin/securable_spec.rb
@@ -117,10 +117,10 @@ describe Chef::Mixin::Securable do
it "should not accept group/owner names containing embedded carriage returns" do
skip "XXX: params_validate needs to be extended to support multi-line regex"
- #lambda { @securable.group "\ntest" }.should raise_error(ArgumentError)
- #lambda { @securable.group "te\nst" }.should raise_error(ArgumentError)
- #lambda { @securable.owner "\ntest" }.should raise_error(ArgumentError)
- #lambda { @securable.owner "te\nst" }.should raise_error(ArgumentError)
+ # lambda { @securable.group "\ntest" }.should raise_error(ArgumentError)
+ # lambda { @securable.group "te\nst" }.should raise_error(ArgumentError)
+ # lambda { @securable.owner "\ntest" }.should raise_error(ArgumentError)
+ # lambda { @securable.owner "te\nst" }.should raise_error(ArgumentError)
end
it "should accept group/owner names in UTF-8" do
@@ -258,23 +258,23 @@ describe Chef::Mixin::Securable do
end
it "should allow you to specify whether the permissions applies_to_children with true/false/:containers_only/:objects_only" do
- expect { @securable.rights :read, "The Dude", :applies_to_children => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => :containers_only }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => :objects_only }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => "poop" }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", applies_to_children: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: :containers_only }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: :objects_only }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: "poop" }.to raise_error(ArgumentError)
end
it "should allow you to specify whether the permissions applies_to_self with true/false" do
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_self => "poop" }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_self: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_self: "poop" }.to raise_error(ArgumentError)
end
it "should allow you to specify whether the permissions applies one_level_deep with true/false" do
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => "poop" }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: "poop" }.to raise_error(ArgumentError)
end
it "should allow multiple rights and deny_rights declarations" do
@@ -288,21 +288,21 @@ describe Chef::Mixin::Securable do
end
it "should allow you to specify whether the permission applies_to_self only if you specified applies_to_children" do
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => false, :applies_to_self => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => false, :applies_to_self => false }.to raise_error(ArgumentError)
- expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_self => false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, applies_to_self: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: false, applies_to_self: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: false, applies_to_self: false }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", applies_to_self: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_self: false }.not_to raise_error
end
it "should allow you to specify whether the permission applies one_level_deep only if you specified applies_to_children" do
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => false, :one_level_deep => true }.to raise_error(ArgumentError)
- expect { @securable.rights :read, "The Dude", :applies_to_children => false, :one_level_deep => false }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :one_level_deep => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :one_level_deep => false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: true, one_level_deep: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", applies_to_children: false, one_level_deep: true }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", applies_to_children: false, one_level_deep: false }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", one_level_deep: true }.not_to raise_error
+ expect { @securable.rights :read, "The Dude", one_level_deep: false }.not_to raise_error
end
it "should allow you to specify whether the permissions inherit with true/false" do
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 2fef051b29..6b0cd659ef 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -60,21 +60,21 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is a Hash" do
describe "and environment is an option" do
it "should not change environment language settings when they are set to nil" do
- options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } }
+ options = { environment: { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
shell_out_obj.send(method, cmd, options)
end
it "should not change environment language settings when they are set to non-nil" do
- options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } }
+ options = { environment: { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
shell_out_obj.send(method, cmd, options)
end
it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :environment => { "HOME" => "/Users/morty" } }
+ options = { environment: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :environment => {
+ environment: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
@@ -86,9 +86,9 @@ describe Chef::Mixin::ShellOut do
end
it "should not mutate the options hash when it adds language settings" do
- options = { :environment => { "HOME" => "/Users/morty" } }
+ options = { environment: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :environment => {
+ environment: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
@@ -103,21 +103,21 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when langauge options are set to nil" do
- options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } }
+ options = { env: { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
shell_out_obj.send(method, cmd, options)
end
it "should not change env when language options are set to non-nil" do
- options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } }
+ options = { env: { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
shell_out_obj.send(method, cmd, options)
end
it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :env => { "HOME" => "/Users/morty" } }
+ options = { env: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :env => {
+ env: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
@@ -129,9 +129,9 @@ describe Chef::Mixin::ShellOut do
end
it "should not mutate the options hash when it adds language settings" do
- options = { :env => { "HOME" => "/Users/morty" } }
+ options = { env: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :env => {
+ env: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
@@ -146,10 +146,10 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should set environment language settings to the configured internal locale" do
- options = { :user => "morty" }
+ options = { user: "morty" }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :user => "morty",
- :environment => {
+ user: "morty",
+ environment: {
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
@@ -164,7 +164,7 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is not a Hash" do
it "should set environment language settings to the configured internal locale" do
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
- :environment => {
+ environment: {
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
@@ -185,19 +185,19 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is a Hash" do
describe "and environment is an option" do
it "should not change environment['LC_ALL'] when set to nil" do
- options = { :environment => { "LC_ALL" => nil } }
+ options = { environment: { "LC_ALL" => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should not change environment['LC_ALL'] when set to non-nil" do
- options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
+ options = { environment: { "LC_ALL" => "en_US.UTF-8" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :environment => { "HOME" => "/Users/morty" } }
+ options = { environment: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
@@ -205,19 +205,19 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when set to nil" do
- options = { :env => { "LC_ALL" => nil } }
+ options = { env: { "LC_ALL" => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should not change env when set to non-nil" do
- options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
+ options = { env: { "LC_ALL" => "en_US.UTF-8" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :env => { "HOME" => "/Users/morty" } }
+ options = { env: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
@@ -225,7 +225,7 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
- options = { :user => "morty" }
+ options = { user: "morty" }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
@@ -245,19 +245,19 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is a Hash" do
describe "and environment is an option" do
it "should not change environment['LC_ALL'] when set to nil" do
- options = { :environment => { "LC_ALL" => nil } }
+ options = { environment: { "LC_ALL" => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should not change environment['LC_ALL'] when set to non-nil" do
- options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
+ options = { environment: { "LC_ALL" => "en_US.UTF-8" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :environment => { "HOME" => "/Users/morty" } }
+ options = { environment: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
@@ -265,19 +265,19 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when set to nil" do
- options = { :env => { "LC_ALL" => nil } }
+ options = { env: { "LC_ALL" => nil } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should not change env when set to non-nil" do
- options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
+ options = { env: { "LC_ALL" => "en_US.UTF-8" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :env => { "HOME" => "/Users/morty" } }
+ options = { env: { "HOME" => "/Users/morty" } }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
@@ -285,7 +285,7 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
- options = { :user => "morty" }
+ options = { user: "morty" }
expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, **options, default_env: false)
end
diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb
index 3dadf6a2c3..896241f173 100644
--- a/spec/unit/mixin/user_context_spec.rb
+++ b/spec/unit/mixin/user_context_spec.rb
@@ -43,7 +43,7 @@ describe "a class that mixes in user_context" do
allow(::Chef::Util::Windows::LogonSession).to receive(:new).and_return(logon_session)
end
- let(:logon_session) { instance_double("::Chef::Util::Windows::LogonSession", :set_user_context => nil, :open => nil, :close => nil) }
+ let(:logon_session) { instance_double("::Chef::Util::Windows::LogonSession", set_user_context: nil, open: nil, close: nil) }
it "does not raise an exception when the user and all parameters are nil" do
expect { instance_with_user_context.with_context(nil, nil, nil) {} }.not_to raise_error
diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb
index 495ad0662c..761cab60c8 100644
--- a/spec/unit/mixin/xml_escape_spec.rb
+++ b/spec/unit/mixin/xml_escape_spec.rb
@@ -49,6 +49,6 @@ describe Chef::Mixin::XMLEscape do
end
it "converts win 1252 characters correctly" do
- expect(@escaper.xml_escape("#{0x80.chr}")).to eq("&#8364;")
+ expect(@escaper.xml_escape((0x80.chr).to_s)).to eq("&#8364;")
end
end
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 557c469216..618a9bbe0e 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -22,8 +22,8 @@ require "chef/node/attribute"
describe Chef::Node::Attribute do
let(:events) { instance_double(Chef::EventDispatch::Dispatcher) }
- let(:run_context) { instance_double(Chef::RunContext, :events => events) }
- let(:node) { instance_double(Chef::Node, :run_context => run_context) }
+ let(:run_context) { instance_double(Chef::RunContext, events: events) }
+ let(:node) { instance_double(Chef::Node, run_context: run_context) }
before(:each) do
allow(events).to receive(:attribute_changed)
@attribute_hash =
@@ -184,7 +184,7 @@ describe Chef::Node::Attribute do
[ :normal, :default, :override, :automatic ].each do |accessor|
it "should set #{accessor}" do
- na = Chef::Node::Attribute.new({ :normal => true }, { :default => true }, { :override => true }, { :automatic => true })
+ na = Chef::Node::Attribute.new({ normal: true }, { default: true }, { override: true }, { automatic: true })
expect(na.send(accessor)).to eq({ accessor.to_s => true })
end
end
diff --git a/spec/unit/node/vivid_mash_spec.rb b/spec/unit/node/vivid_mash_spec.rb
index 4898c22380..e1021ba0c0 100644
--- a/spec/unit/node/vivid_mash_spec.rb
+++ b/spec/unit/node/vivid_mash_spec.rb
@@ -61,7 +61,7 @@ describe Chef::Node::VividMash do
it "deep converts values through arrays" do
expect(root).to receive(:reset_cache).with("foo")
- vivid["foo"] = [ { :bar => true } ]
+ vivid["foo"] = [ { bar: true } ]
expect(vivid["foo"].class).to eql(Chef::Node::AttrArray)
expect(vivid["foo"][0].class).to eql(Chef::Node::VividMash)
expect(vivid["foo"][0]["bar"]).to be true
@@ -69,7 +69,7 @@ describe Chef::Node::VividMash do
it "deep converts values through nested arrays" do
expect(root).to receive(:reset_cache).with("foo")
- vivid["foo"] = [ [ { :bar => true } ] ]
+ vivid["foo"] = [ [ { bar: true } ] ]
expect(vivid["foo"].class).to eql(Chef::Node::AttrArray)
expect(vivid["foo"][0].class).to eql(Chef::Node::AttrArray)
expect(vivid["foo"][0][0].class).to eql(Chef::Node::VividMash)
@@ -78,7 +78,7 @@ describe Chef::Node::VividMash do
it "deep converts values through hashes" do
expect(root).to receive(:reset_cache).with("foo")
- vivid["foo"] = { baz: { :bar => true } }
+ vivid["foo"] = { baz: { bar: true } }
expect(vivid["foo"]).to be_an_instance_of(Chef::Node::VividMash)
expect(vivid["foo"]["baz"]).to be_an_instance_of(Chef::Node::VividMash)
expect(vivid["foo"]["baz"]["bar"]).to be true
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 253486438b..df70ad380a 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -145,14 +145,14 @@ describe Chef::NodeMap do
describe "deleting classes" do
it "deletes a class and removes the mapping completely" do
node_map.set(:thing, Bar)
- expect( node_map.delete_class(Bar) ).to include({ :thing => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] })
+ expect( node_map.delete_class(Bar) ).to include({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] })
expect( node_map.get(node, :thing) ).to eql(nil)
end
it "deletes a class and leaves the mapping that still has an entry" do
node_map.set(:thing, Bar)
node_map.set(:thing, Foo)
- expect( node_map.delete_class(Bar) ).to eql({ :thing => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] })
+ expect( node_map.delete_class(Bar) ).to eql({ thing: [{ klass: Bar, cookbook_override: false, core_override: false }] })
expect( node_map.get(node, :thing) ).to eql(Foo)
end
@@ -160,7 +160,7 @@ describe Chef::NodeMap do
node_map.set(:thing1, Bar)
node_map.set(:thing2, Bar)
node_map.set(:thing2, Foo)
- expect( node_map.delete_class(Bar) ).to eql({ :thing1 => [{ :klass => Bar, :cookbook_override => false, :core_override => false }], :thing2 => [{ :klass => Bar, :cookbook_override => false, :core_override => false }] })
+ expect( node_map.delete_class(Bar) ).to eql({ thing1: [{ klass: Bar, cookbook_override: false, core_override: false }], thing2: [{ klass: Bar, cookbook_override: false, core_override: false }] })
expect( node_map.get(node, :thing1) ).to eql(nil)
expect( node_map.get(node, :thing2) ).to eql(Foo)
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 3a43a155d5..0ca5f83adc 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Node do
describe "when the node does not exist on the server" do
before do
- response = OpenStruct.new(:code => "404")
+ response = OpenStruct.new(code: "404")
exception = Net::HTTPServerException.new("404 not found", response)
allow(Chef::Node).to receive(:load).and_raise(exception)
node.name("created-node")
@@ -852,7 +852,7 @@ describe Chef::Node do
describe "consuming json" do
before do
- @ohai_data = { :platform => "foo", :platform_version => "bar" }
+ @ohai_data = { platform: "foo", platform_version: "bar" }
end
it "consumes the run list portion of a collection of attributes and returns the remainder" do
@@ -944,7 +944,7 @@ describe Chef::Node do
describe "preparing for a chef client run" do
before do
- @ohai_data = { :platform => "foobuntu", :platform_version => "23.42" }
+ @ohai_data = { platform: "foobuntu", platform_version: "23.42" }
end
it "sets its platform according to platform detection" do
@@ -1096,12 +1096,12 @@ describe Chef::Node do
before do
node.chef_environment = "rspec"
@expansion = Chef::RunList::RunListExpansion.new("rspec", [])
- @expansion.default_attrs.replace({ :default => "from role", :d_role => "role only" })
- @expansion.override_attrs.replace({ :override => "from role", :o_role => "role only" })
+ @expansion.default_attrs.replace({ default: "from role", d_role: "role only" })
+ @expansion.override_attrs.replace({ override: "from role", o_role: "role only" })
@environment = Chef::Environment.new
- @environment.default_attributes = { :default => "from env", :d_env => "env only" }
- @environment.override_attributes = { :override => "from env", :o_env => "env only" }
+ @environment.default_attributes = { default: "from env", d_env: "env only" }
+ @environment.override_attributes = { override: "from env", o_env: "env only" }
allow(Chef::Environment).to receive(:load).and_return(@environment)
node.apply_expansion_attributes(@expansion)
end
@@ -1269,7 +1269,7 @@ describe Chef::Node do
end
describe "converting to or from json" do
- it "should serialize itself as json", :json => true do
+ it "should serialize itself as json", json: true do
node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
json = Chef::JSONCompat.to_json(node)
expect(json).to match(/json_class/)
@@ -1281,16 +1281,16 @@ describe Chef::Node do
expect(json).to match(/run_list/)
end
- it "should serialize valid json with a run list", :json => true do
- #This test came about because activesupport mucks with Chef json serialization
- #Test should pass with and without Activesupport
+ it "should serialize valid json with a run list", json: true do
+ # This test came about because activesupport mucks with Chef json serialization
+ # Test should pass with and without Activesupport
node.run_list << { "type" => "role", "name" => "Cthulu" }
node.run_list << { "type" => "role", "name" => "Hastur" }
json = Chef::JSONCompat.to_json(node)
expect(json).to match(/\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/)
end
- it "should serialize the correct run list", :json => true do
+ it "should serialize the correct run list", json: true do
node.run_list << "role[marxist]"
node.run_list << "role[leninist]"
node.override_runlist << "role[stalinist]"
@@ -1315,7 +1315,7 @@ describe Chef::Node do
expect(node_for_json["default"]["env default"]).to eq("env default")
end
- it "should deserialize itself from json", :json => true do
+ it "should deserialize itself from json", json: true do
node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
json = Chef::JSONCompat.to_json(node)
serialized_node = Chef::Node.from_hash(Chef::JSONCompat.parse(json))
@@ -1392,7 +1392,7 @@ describe Chef::Node do
describe "list" do
describe "inflated" do
it "should return a hash of node names and objects" do
- n1 = double("Chef::Node", :name => "one")
+ n1 = double("Chef::Node", name: "one")
allow(n1).to receive(:kind_of?).with(Chef::Node) { true }
expect(@query).to receive(:search).with(:node).and_yield(n1)
r = Chef::Node.list(true)
@@ -1446,7 +1446,7 @@ describe Chef::Node do
it "should create if it cannot update" do
node.name("monkey")
allow(node).to receive(:data_for_save).and_return({})
- exception = double("404 error", :code => "404")
+ exception = double("404 error", code: "404")
expect(@rest).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception))
expect(@rest).to receive(:post).with("nodes", {})
node.save
diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb
index 49557417a5..79a29b1fff 100644
--- a/spec/unit/org_spec.rb
+++ b/spec/unit/org_spec.rb
@@ -164,7 +164,7 @@ describe Chef::Org do
describe "create" do
it "creates a new org via the API" do
- expect(rest).to receive(:post).with("organizations", { :name => "foobar", :full_name => "foo bar bat" }).and_return({})
+ expect(rest).to receive(:post).with("organizations", { name: "foobar", full_name: "foo bar bat" }).and_return({})
org.create
end
end
@@ -181,7 +181,7 @@ describe Chef::Org do
describe "update" do
it "updates an existing org on via the API" do
- expect(rest).to receive(:put).with("organizations/foobar", { :name => "foobar", :full_name => "foo bar bat" }).and_return({})
+ expect(rest).to receive(:put).with("organizations/foobar", { name: "foobar", full_name: "foo bar bat" }).and_return({})
org.update
end
end
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index ac5158e913..82ed4de9c6 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -51,9 +51,9 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns true when the registry value is 1" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_yield(registry)
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_yield(registry)
expect(registry).to receive(:[]).with("NanoServer").and_return(1)
expect(Chef::Platform.windows_nano_server?).to be true
end
@@ -61,9 +61,9 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns false when the registry value is not 1" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_yield(registry)
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_yield(registry)
expect(registry).to receive(:[]).with("NanoServer").and_return(0)
expect(Chef::Platform.windows_nano_server?).to be false
end
@@ -71,20 +71,20 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns false when the registry value does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_yield(registry)
- expect(registry).to receive(:[]).with("NanoServer").
- and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_yield(registry)
+ expect(registry).to receive(:[]).with("NanoServer")
+ .and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
expect(Chef::Platform.windows_nano_server?).to be false
end
it "returns false when the registry key does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
expect(Chef::Platform.windows_nano_server?).to be false
end
end
@@ -122,18 +122,18 @@ describe "Chef::Platform#supports_msi?" do
it "returns true when the registry key exists" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_yield(registry)
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_yield(registry)
expect(Chef::Platform.supports_msi?).to be true
end
it "returns false when the registry key does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
- expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
- with(key, access).
- and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
+ expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
+ .with(key, access)
+ .and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
expect(Chef::Platform.supports_msi?).to be false
end
end
@@ -188,18 +188,18 @@ describe "Chef::Platform#dsc_refresh_mode_disabled?" do
let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult") }
it "returns true when RefreshMode is Disabled" do
- expect(Chef::Util::Powershell::Cmdlet).to receive(:new).
- with(node, "Get-DscLocalConfigurationManager", :object).
- and_return(cmdlet)
+ expect(Chef::Util::Powershell::Cmdlet).to receive(:new)
+ .with(node, "Get-DscLocalConfigurationManager", :object)
+ .and_return(cmdlet)
expect(cmdlet).to receive(:run!).and_return(cmdlet_result)
expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "Disabled" })
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true
end
it "returns false when RefreshMode is not Disabled" do
- expect(Chef::Util::Powershell::Cmdlet).to receive(:new).
- with(node, "Get-DscLocalConfigurationManager", :object).
- and_return(cmdlet)
+ expect(Chef::Util::Powershell::Cmdlet).to receive(:new)
+ .with(node, "Get-DscLocalConfigurationManager", :object)
+ .and_return(cmdlet)
expect(cmdlet).to receive(:run!).and_return(cmdlet_result)
expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "LaLaLa" })
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb
index a7f4f1fa43..122c960c11 100644
--- a/spec/unit/policy_builder/expand_node_object_spec.rb
+++ b/spec/unit/policy_builder/expand_node_object_spec.rb
@@ -48,7 +48,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
it "implements a setup_run_context method that accepts a list of recipe files to run" do
expect(policy_builder).to respond_to(:setup_run_context)
- expect(policy_builder.method(:setup_run_context).arity).to eq(-1) #optional argument
+ expect(policy_builder.method(:setup_run_context).arity).to eq(-1) # optional argument
end
it "implements a run_context method" do
@@ -176,7 +176,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
let(:expansion) do
recipe_list = Chef::RunList::VersionedRecipeList.new
recipe_list.add_recipe("recipe[from_role::default", "1.0.2")
- double("RunListExpansion", :recipes => recipe_list)
+ double("RunListExpansion", recipes: recipe_list)
end
let(:node) do
@@ -268,13 +268,13 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
let(:chef_http) { double("Chef::ServerAPI") }
let(:cookbook_resolve_url) { "environments/#{node.chef_environment}/cookbook_versions" }
- let(:cookbook_resolve_post_data) { { :run_list => ["first::default", "second::default"] } }
+ let(:cookbook_resolve_post_data) { { run_list: ["first::default", "second::default"] } }
# cookbook_hash is just a hash, but since we're passing it between mock
# objects, we get a little better test strictness by using a double (which
# will have object equality rather than semantic equality #== semantics).
let(:cookbook_hash) { double("cookbook hash") }
- let(:expanded_cookbook_hash) { double("expanded cookbook hash", :each => nil) }
+ let(:expanded_cookbook_hash) { double("expanded cookbook hash", each: nil) }
let(:cookbook_synchronizer) { double("CookbookSynchronizer") }
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 5663cb8b19..ab2fdecfe7 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -221,9 +221,9 @@ describe Chef::PolicyBuilder::Policyfile do
let(:error404) { Net::HTTPServerException.new("404 message", :body) }
before do
- expect(api_service).to receive(:get).
- with("data/policyfiles/example-policy-stage").
- and_raise(error404)
+ expect(api_service).to receive(:get)
+ .with("data/policyfiles/example-policy-stage")
+ .and_raise(error404)
end
it "raises an error" do
@@ -393,10 +393,10 @@ describe Chef::PolicyBuilder::Policyfile do
let(:run_list_for_data_collector) do
{
- :id => "_policy_node",
- :run_list => [
- { :type => "recipe", :name => "test::default", :skipped => false, :version => nil },
- { :type => "recipe", :name => "test::other", :skipped => false, :version => nil },
+ id: "_policy_node",
+ run_list: [
+ { type: "recipe", name: "test::default", skipped: false, version: nil },
+ { type: "recipe", name: "test::other", skipped: false, version: nil },
],
}
end
@@ -744,8 +744,8 @@ describe Chef::PolicyBuilder::Policyfile do
policy_builder.finish_load_node(node)
policy_builder.build_node
- expect(api_service).to receive(:get).with(cookbook1_url).
- and_raise(error404)
+ expect(api_service).to receive(:get).with(cookbook1_url)
+ .and_raise(error404)
end
it "raises an error indicating which cookbook is missing" do
@@ -763,9 +763,9 @@ describe Chef::PolicyBuilder::Policyfile do
policy_builder.finish_load_node(node)
policy_builder.build_node
- allow(Chef::CookbookSynchronizer).to receive(:new).
- with(expected_cookbook_hash, events).
- and_return(cookbook_synchronizer)
+ allow(Chef::CookbookSynchronizer).to receive(:new)
+ .with(expected_cookbook_hash, events)
+ .and_return(cookbook_synchronizer)
end
after do
@@ -814,15 +814,15 @@ describe Chef::PolicyBuilder::Policyfile do
context "when the cookbooks exist on the server" do
before do
- expect(api_service).to receive(:get).with(cookbook1_url).
- and_return(example1_cookbook_data)
- expect(api_service).to receive(:get).with(cookbook2_url).
- and_return(example2_cookbook_data)
+ expect(api_service).to receive(:get).with(cookbook1_url)
+ .and_return(example1_cookbook_data)
+ expect(api_service).to receive(:get).with(cookbook2_url)
+ .and_return(example2_cookbook_data)
- expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data).
- and_return(example1_cookbook_object)
- expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example2_cookbook_data).
- and_return(example2_cookbook_object)
+ expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data)
+ .and_return(example1_cookbook_object)
+ expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example2_cookbook_data)
+ .and_return(example2_cookbook_object)
end
include_examples "fetching cookbooks when they exist"
@@ -847,15 +847,15 @@ describe Chef::PolicyBuilder::Policyfile do
context "when the cookbooks exist on the server" do
before do
- expect(api_service).to receive(:get).with(cookbook1_url).
- and_return(example1_cookbook_data)
- expect(api_service).to receive(:get).with(cookbook2_url).
- and_return(example2_cookbook_data)
-
- expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data).
- and_return(example1_cookbook_object)
- expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example2_cookbook_data).
- and_return(example2_cookbook_object)
+ expect(api_service).to receive(:get).with(cookbook1_url)
+ .and_return(example1_cookbook_data)
+ expect(api_service).to receive(:get).with(cookbook2_url)
+ .and_return(example2_cookbook_data)
+
+ expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example1_cookbook_data)
+ .and_return(example1_cookbook_object)
+ expect(Chef::CookbookVersion).to receive(:from_cb_artifact_data).with(example2_cookbook_data)
+ .and_return(example2_cookbook_object)
end
include_examples "fetching cookbooks when they exist"
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 79c4baa89f..793bb3248f 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -64,7 +64,7 @@ describe "Chef::Resource.property" do
if properties.size == 1
description = "With property #{properties.first}"
else
- description = "With properties #{english_join(properties.map { |property| "#{property.inspect}" })}"
+ description = "With properties #{english_join(properties.map { |property| (property.inspect).to_s })}"
end
context description, *tags do
before do
@@ -1070,13 +1070,13 @@ describe "Chef::Resource.property" do
end
it "raises an error if both name_property and name_attribute are specified" do
- expect { resource_class.property :x, :name_property => false, :name_attribute => 1 }.to raise_error ArgumentError,
+ expect { resource_class.property :x, name_property: false, name_attribute: 1 }.to raise_error ArgumentError,
/name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
- expect { resource_class.property :x, :name_property => false, :name_attribute => nil }.to raise_error ArgumentError,
+ expect { resource_class.property :x, name_property: false, name_attribute: nil }.to raise_error ArgumentError,
/name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
- expect { resource_class.property :x, :name_property => false, :name_attribute => false }.to raise_error ArgumentError,
+ expect { resource_class.property :x, name_property: false, name_attribute: false }.to raise_error ArgumentError,
/name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
- expect { resource_class.property :x, :name_property => true, :name_attribute => true }.to raise_error ArgumentError,
+ expect { resource_class.property :x, name_property: true, name_attribute: true }.to raise_error ArgumentError,
/name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
end
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index d881d01124..8ea2b9b823 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -23,25 +23,25 @@ require "spec_helper"
#
# Output of the command:
# => apt-key adv --list-public-keys --with-fingerprint --with-colons
-APT_KEY_FINGER = <<-EOF
-tru:t:1:1488924856:0:3:1:5
-pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC:
-fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:
-sub:-:2048:16:251BEFF479164387:2004-09-12::::::e:
-pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC:
-fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451:
-pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC:
-fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32:
-pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC:
-fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092:
+APT_KEY_FINGER = <<~EOF
+ tru:t:1:1488924856:0:3:1:5
+ pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC:
+ fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:
+ sub:-:2048:16:251BEFF479164387:2004-09-12::::::e:
+ pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC:
+ fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451:
+ pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC:
+ fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32:
+ pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC:
+ fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092:
EOF
# Output of the command:
# => gpg --with-fingerprint --with-colons [FILE]
-GPG_FINGER = <<-EOF
-pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository:
-fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD:
-sub:-:2048:16:84080586D1CA74A1:2009-04-22::::
+GPG_FINGER = <<~EOF
+ pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository:
+ fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD:
+ sub:-:2048:16:84080586D1CA74A1:2009-04-22::::
EOF
describe Chef::Provider::AptRepository do
@@ -67,14 +67,14 @@ describe Chef::Provider::AptRepository do
end
let(:gpg_shell_out_success) do
- double("shell_out", :stdout => "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>",
- :exitstatus => 0, :error? => false)
+ double("shell_out", stdout: "pub 2048R/7BD9BF62 2011-08-19 nginx signing key <signing-key@nginx.com>",
+ exitstatus: 0, error?: false)
end
let(:gpg_shell_out_failure) do
- double("shell_out", :stderr => "gpg: no valid OpenPGP data found.\n
+ double("shell_out", stderr: "gpg: no valid OpenPGP data found.\n
gpg: processing message failed: eof",
- :exitstatus => 1, :error? => true)
+ exitstatus: 1, error?: true)
end
let(:apt_fingerprints) do
diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb
index 096ac85b64..4e07915a95 100644
--- a/spec/unit/provider/cookbook_file/content_spec.rb
+++ b/spec/unit/provider/cookbook_file/content_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::CookbookFile::Content do
- let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") }
+ let(:new_resource) { double("Chef::Resource::CookbookFile (new)", cookbook_name: "apache2", cookbook: "apache2") }
let(:content) do
@run_context = double("Chef::RunContext")
@current_resource = double("Chef::Resource::CookbookFile (current)")
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index f27392de5d..e1ef3c63d8 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::CookbookFile do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index 62b941c4aa..c77b0e0528 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do
end
end
- let(:status) { double("Process::Status", :exitstatus => exitstatus) }
+ let(:status) { double("Process::Status", exitstatus: exitstatus) }
let(:exitstatus) { 0 }
- let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) }
+ let(:shell_out) { double("Mixlib::ShellOut", status: status, stdout: stdout, stderr: stderr) }
let(:logger) { double("Mixlib::Log::Child").as_null_object }
@@ -53,25 +53,25 @@ describe Chef::Provider::Cron::Unix do
describe "read_crontab" do
let(:stderr) { "" }
let(:stdout) do
- String.new(<<-CRONTAB)
-0 2 * * * /some/other/command
+ String.new(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-* 5 * * * /bin/true
+ # Chef Name: something else
+ * 5 * * * /bin/true
-# Another comment
+ # Another comment
CRONTAB
end
before do
allow(logger).to receive(:trace)
allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
- allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out)
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", user: username).and_return(shell_out)
end
it "should call crontab -l with the user" do
provider.send(:read_crontab)
- expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username)
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", user: username)
end
it "should return the contents of the crontab" do
@@ -111,7 +111,7 @@ describe Chef::Provider::Cron::Unix do
describe "write_crontab" do
let(:stdout) { "" }
let(:stderr) { "" }
- let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) }
+ let(:tempfile) { double("foo", path: "/tmp/foo", close: true) }
before do
expect(Tempfile).to receive(:new).and_return(tempfile)
@@ -119,12 +119,12 @@ describe Chef::Provider::Cron::Unix do
expect(tempfile).to receive(:chmod).with(420)
expect(tempfile).to receive(:close!)
allow(tempfile).to receive(:<<)
- allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out)
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username).and_return(shell_out)
end
it "should call crontab for the user" do
provider.send(:write_crontab, "Foo")
- expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username)
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", user: username)
end
it "should call crontab with a file containing the crontab" do
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 5673ecc317..67d578e2ea 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -42,15 +42,15 @@ describe Chef::Provider::Cron do
context "with a matching entry in the user's crontab" do
before :each do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-@reboot /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ @reboot /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
@@ -67,19 +67,19 @@ CRONTAB
end
it "should pull env vars out" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
-
-# Chef Name: cronhole some stuff
-MAILTO=foo@example.com
-SHELL=/bin/foosh
-PATH=/bin:/foo
-HOME=/home/foo
-@reboot /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
-
-# Another comment
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
+
+ # Chef Name: cronhole some stuff
+ MAILTO=foo@example.com
+ SHELL=/bin/foosh
+ PATH=/bin:/foo
+ HOME=/home/foo
+ @reboot /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
+
+ # Another comment
CRONTAB
cron = @provider.load_current_resource
expect(cron.mailto).to eq("foo@example.com")
@@ -91,12 +91,12 @@ CRONTAB
end
it "should parse and load generic and standard environment variables from cron entry" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-# Chef Name: cronhole some stuff
-MAILTO=warn@example.com
-TEST=lol
-FLAG=1
-@reboot /bin/true
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ # Chef Name: cronhole some stuff
+ MAILTO=warn@example.com
+ TEST=lol
+ FLAG=1
+ @reboot /bin/true
CRONTAB
cron = @provider.load_current_resource
@@ -105,13 +105,13 @@ CRONTAB
end
it "should not break with variables that match the cron resource internals" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-# Chef Name: cronhole some stuff
-MINUTE=40
-REBOOT=midnight
-TEST=lol
-ENVIRONMENT=production
-@reboot /bin/true
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ # Chef Name: cronhole some stuff
+ MINUTE=40
+ REBOOT=midnight
+ TEST=lol
+ ENVIRONMENT=production
+ @reboot /bin/true
CRONTAB
cron = @provider.load_current_resource
@@ -137,9 +137,9 @@ CRONTAB
end
it "should create a crontab with the entry" do
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-# Chef Name: cronhole some stuff
-@reboot /bin/true
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ # Chef Name: cronhole some stuff
+ @reboot /bin/true
ENDCRON
@provider.run_action(:create)
end
@@ -168,13 +168,13 @@ CRONTAB
context "with no matching entry in the user's crontab" do
before :each do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-* 5 * * * /bin/true
+ # Chef Name: something else
+ * 5 * * * /bin/true
-# Another comment
+ # Another comment
CRONTAB
end
@@ -190,9 +190,9 @@ CRONTAB
end
it "should not fail if there's an existing cron with a numerical argument" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-# Chef Name: foo[bar] (baz)
-21 */4 * * * some_prog 1234567
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ # Chef Name: foo[bar] (baz)
+ 21 */4 * * * some_prog 1234567
CRONTAB
expect do
@provider.load_current_resource
@@ -202,15 +202,15 @@ CRONTAB
context "with a matching entry in the user's crontab" do
before :each do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-* 5 * 1 * /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ * 5 * 1 * /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
@@ -232,19 +232,19 @@ CRONTAB
end
it "should pull env vars out" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
-
-# Chef Name: cronhole some stuff
-MAILTO=foo@example.com
-SHELL=/bin/foosh
-PATH=/bin:/foo
-HOME=/home/foo
-* 5 * 1 * /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
-
-# Another comment
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
+
+ # Chef Name: cronhole some stuff
+ MAILTO=foo@example.com
+ SHELL=/bin/foosh
+ PATH=/bin:/foo
+ HOME=/home/foo
+ * 5 * 1 * /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
+
+ # Another comment
CRONTAB
cron = @provider.load_current_resource
expect(cron.mailto).to eq("foo@example.com")
@@ -261,12 +261,12 @@ CRONTAB
end
it "should parse and load generic and standard environment variables from cron entry" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-# Chef Name: cronhole some stuff
-MAILTO=warn@example.com
-TEST=lol
-FLAG=1
-* 5 * * * /bin/true
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ # Chef Name: cronhole some stuff
+ MAILTO=warn@example.com
+ TEST=lol
+ FLAG=1
+ * 5 * * * /bin/true
CRONTAB
cron = @provider.load_current_resource
@@ -275,13 +275,13 @@ CRONTAB
end
it "should not break with variabels that match the cron resource internals" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-# Chef Name: cronhole some stuff
-MINUTE=40
-HOUR=midnight
-TEST=lol
-ENVIRONMENT=production
-* 5 * * * /bin/true
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ # Chef Name: cronhole some stuff
+ MINUTE=40
+ HOUR=midnight
+ TEST=lol
+ ENVIRONMENT=production
+ * 5 * * * /bin/true
CRONTAB
cron = @provider.load_current_resource
@@ -298,15 +298,15 @@ CRONTAB
context "with a matching entry in the user's crontab using month names and weekday names (#CHEF-3178)" do
before :each do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-* 5 * Jan Mon /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ * 5 * Jan Mon /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
@@ -334,10 +334,10 @@ CRONTAB
context "with a matching entry without a crontab line" do
it "should set cron_exists and leave current_resource values at defaults" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
+ # Chef Name: cronhole some stuff
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
@@ -351,11 +351,11 @@ CRONTAB
end
it "should not pick up a commented out crontab line" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-#* 5 * 1 * /bin/true param1 param2
+ # Chef Name: cronhole some stuff
+ #* 5 * 1 * /bin/true param1 param2
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
@@ -369,15 +369,15 @@ CRONTAB
end
it "should not pick up a later crontab entry" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-#* 5 * 1 * /bin/true param1 param2
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ #* 5 * 1 * /bin/true param1 param2
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
@@ -442,9 +442,9 @@ CRONTAB
end
it "should create a crontab with the entry" do
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-# Chef Name: cronhole some stuff
-30 * * * * /bin/true
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ # Chef Name: cronhole some stuff
+ 30 * * * * /bin/true
ENDCRON
@provider.run_action(:create)
end
@@ -455,14 +455,14 @@ CRONTAB
@new_resource.shell "/bin/foosh"
@new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-# Chef Name: cronhole some stuff
-MAILTO="foo@example.com"
-PATH="/usr/bin:/my/custom/path"
-SHELL="/bin/foosh"
-HOME="/home/foo"
-TEST=LOL
-30 * * * * /bin/true
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ # Chef Name: cronhole some stuff
+ MAILTO="foo@example.com"
+ PATH="/usr/bin:/my/custom/path"
+ SHELL="/bin/foosh"
+ HOME="/home/foo"
+ TEST=LOL
+ 30 * * * * /bin/true
ENDCRON
@provider.run_action(:create)
end
@@ -481,26 +481,26 @@ TEST=LOL
context "when there is a crontab with no matching section" do
before :each do
@provider.cron_exists = false
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
it "should add the entry to the crontab" do
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
-# Chef Name: cronhole some stuff
-30 * * * * /bin/true
+ # Another comment
+ # Chef Name: cronhole some stuff
+ 30 * * * * /bin/true
ENDCRON
@provider.run_action(:create)
end
@@ -511,20 +511,20 @@ TEST=LOL
@new_resource.shell "/bin/foosh"
@new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
-
-# Chef Name: something else
-2 * 1 * * /bin/false
-
-# Another comment
-# Chef Name: cronhole some stuff
-MAILTO="foo@example.com"
-PATH="/usr/bin:/my/custom/path"
-SHELL="/bin/foosh"
-HOME="/home/foo"
-TEST=LOL
-30 * * * * /bin/true
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
+
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
+
+ # Another comment
+ # Chef Name: cronhole some stuff
+ MAILTO="foo@example.com"
+ PATH="/usr/bin:/my/custom/path"
+ SHELL="/bin/foosh"
+ HOME="/home/foo"
+ TEST=LOL
+ 30 * * * * /bin/true
ENDCRON
@provider.run_action(:create)
end
@@ -544,28 +544,28 @@ TEST=LOL
before :each do
@provider.cron_exists = true
allow(@provider).to receive(:cron_different?).and_return(true)
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ 30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
it "should update the crontab entry" do
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-30 * * * * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ 30 * * * * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:create)
end
@@ -576,20 +576,20 @@ TEST=LOL
@new_resource.shell "/bin/foosh"
@new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
-
-# Chef Name: cronhole some stuff
-MAILTO="foo@example.com"
-PATH="/usr/bin:/my/custom/path"
-SHELL="/bin/foosh"
-HOME="/home/foo"
-TEST=LOL
-30 * * * * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
-
-# Another comment
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
+
+ # Chef Name: cronhole some stuff
+ MAILTO="foo@example.com"
+ PATH="/usr/bin:/my/custom/path"
+ SHELL="/bin/foosh"
+ HOME="/home/foo"
+ TEST=LOL
+ 30 * * * * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
+
+ # Another comment
ENDCRON
@provider.run_action(:create)
end
@@ -612,78 +612,78 @@ TEST=LOL
end
it "should add the crontab to the entry" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
+ # Chef Name: cronhole some stuff
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-30 * * * * /bin/true
+ # Chef Name: cronhole some stuff
+ 30 * * * * /bin/true
ENDCRON
@provider.run_action(:create)
end
it "should not blat any following entries" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-#30 * * * * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ #30 * * * * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-30 * * * * /bin/true
-#30 * * * * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ 30 * * * * /bin/true
+ #30 * * * * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:create)
end
it "should handle env vars with no crontab" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-MAILTO=bar@example.com
-PATH=/usr/bin:/my/custom/path
-SHELL=/bin/barsh
-HOME=/home/foo
+ # Chef Name: cronhole some stuff
+ MAILTO=bar@example.com
+ PATH=/usr/bin:/my/custom/path
+ SHELL=/bin/barsh
+ HOME=/home/foo
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
@new_resource.mailto "foo@example.com"
@new_resource.path "/usr/bin:/my/custom/path"
@new_resource.shell "/bin/foosh"
@new_resource.home "/home/foo"
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-MAILTO="foo@example.com"
-PATH="/usr/bin:/my/custom/path"
-SHELL="/bin/foosh"
-HOME="/home/foo"
-30 * * * * /bin/true
+ # Chef Name: cronhole some stuff
+ MAILTO="foo@example.com"
+ PATH="/usr/bin:/my/custom/path"
+ SHELL="/bin/foosh"
+ HOME="/home/foo"
+ 30 * * * * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:create)
end
@@ -693,13 +693,13 @@ HOME="/home/foo"
before :each do
@provider.cron_exists = true
allow(@provider).to receive(:cron_different?).and_return(false)
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-* 5 * * * /bin/true
+ # Chef Name: cronhole some stuff
+ * 5 * * * /bin/true
-# Another comment
+ # Another comment
CRONTAB
end
@@ -747,50 +747,50 @@ CRONTAB
context "when the user has a crontab with a matching section" do
before :each do
@provider.cron_exists = true
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ 30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
end
it "should remove the entry" do
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:delete)
end
it "should remove any env vars with the entry" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-MAILTO=foo@example.com
-FOO=test
-30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ MAILTO=foo@example.com
+ FOO=test
+ 30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:delete)
end
@@ -812,61 +812,61 @@ FOO=test
end
it "should remove the section" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
+ # Chef Name: cronhole some stuff
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
ENDCRON
@provider.run_action(:delete)
end
it "should not blat following sections" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-#30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ #30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-#30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ #30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:delete)
end
it "should remove any envvars with the section" do
- allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
-0 2 * * * /some/other/command
+ allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
+ 0 2 * * * /some/other/command
-# Chef Name: cronhole some stuff
-MAILTO=foo@example.com
-#30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ # Chef Name: cronhole some stuff
+ MAILTO=foo@example.com
+ #30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
CRONTAB
- expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
-0 2 * * * /some/other/command
+ expect(@provider).to receive(:write_crontab).with(<<~ENDCRON)
+ 0 2 * * * /some/other/command
-#30 * * 3 * /bin/true
-# Chef Name: something else
-2 * 1 * * /bin/false
+ #30 * * 3 * /bin/true
+ # Chef Name: something else
+ 2 * 1 * * /bin/false
-# Another comment
+ # Another comment
ENDCRON
@provider.run_action(:delete)
end
@@ -875,13 +875,13 @@ MAILTO=foo@example.com
describe "read_crontab" do
before :each do
- @stdout = <<-CRONTAB
-0 2 * * * /some/other/command
+ @stdout = <<~CRONTAB
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-* 5 * * * /bin/true
+ # Chef Name: something else
+ * 5 * * * /bin/true
-# Another comment
+ # Another comment
CRONTAB
@status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
@@ -894,13 +894,13 @@ MAILTO=foo@example.com
it "should return the contents of the crontab" do
crontab = @provider.send(:read_crontab)
- expect(crontab).to eq <<-CRONTAB
-0 2 * * * /some/other/command
+ expect(crontab).to eq <<~CRONTAB
+ 0 2 * * * /some/other/command
-# Chef Name: something else
-* 5 * * * /bin/true
+ # Chef Name: something else
+ * 5 * * * /bin/true
-# Another comment
+ # Another comment
CRONTAB
end
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 747e37f308..411dc50cc9 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -103,8 +103,8 @@ describe Chef::Provider::DscResource do
it "flags the resource as reboot required when required" do
expect(provider).to receive(:test_resource).and_return(false)
- expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value => nil))
+ expect(provider).to receive(:invoke_resource)
+ .and_return(double(stdout: "", return_value: nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
expect(provider).to receive(:create_reboot_resource)
@@ -113,8 +113,8 @@ describe Chef::Provider::DscResource do
it "does not flag the resource as reboot required when not required" do
expect(provider).to receive(:test_resource).and_return(false)
- expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value => nil))
+ expect(provider).to receive(:invoke_resource)
+ .and_return(double(stdout: "", return_value: nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
expect(provider).to_not receive(:create_reboot_resource)
@@ -293,12 +293,12 @@ describe Chef::Provider::DscResource do
set_node_object
end
- let(:cmdlet) { double(:run! => nil) }
+ let(:cmdlet) { double(run!: nil) }
before(:each) do
allow(provider).to receive(:translate_type).and_return("my_properties")
provider.instance_variable_set(:@new_resource, double(
- :properties => "my_properties", :resource => "my_resource", :timeout => 123
+ properties: "my_properties", resource: "my_resource", timeout: 123
))
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 78534bfb57..48cee78462 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Execute do
let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) }
let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) }
# You will be the same object, I promise.
- @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute)
+ @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute)
let(:opts) do
{
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index f840d92dbb..e65d094327 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Provider::File::Content do
end
let(:new_resource) do
- double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path)
+ double("Chef::Provider::File::Resource (new)", name: "seattle.txt", path: resource_path)
end
let(:run_context) do
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index fed9cd5ece..311ef4c55a 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Provider::File do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index a20c7a838c..4a6266b58a 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -58,7 +58,7 @@ describe Chef::Provider::Git do
it "determines the current revision when there is one" do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n"
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13")
end
@@ -66,7 +66,7 @@ describe Chef::Provider::Git do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stderr = "fatal: Not a git repository (or any of the parent directories): .git"
@stdout = ""
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128], :log_tag => "git[web2.0 app]" ).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", cwd: "/my/deploy/dir", returns: [0, 128], log_tag: "git[web2.0 app]" ).and_return(double("ShellOut result", stdout: "", stderr: @stderr))
expect(@provider.find_current_revision).to be_nil
end
end
@@ -152,7 +152,7 @@ describe Chef::Provider::Git do
@resource.revision "v1.0"
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -161,7 +161,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -170,7 +170,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -179,7 +179,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -188,7 +188,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -198,7 +198,7 @@ describe Chef::Provider::Git do
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -207,7 +207,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -222,21 +222,21 @@ describe Chef::Provider::Git do
it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do
@resource.revision "FAIL, that's the revision I want"
@provider.action = :checkout
- expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n"))
+ expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n"))
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::UnresolvableGitReference)
end
it "does not raise an error if the revision can't be resolved when assertions are not run" do
@resource.revision "FAIL, that's the revision I want"
- expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n"))
+ expect(@provider).to receive(:shell_out!).and_return(double("ShellOut result", stdout: "\n"))
expect(@provider.target_revision).to eq(nil)
end
it "does not raise an error when the revision is valid and assertions are run." do
@resource.revision "0.8-alpha"
@stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
@provider.action = :checkout
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
@provider.define_resource_requirements
@@ -244,24 +244,24 @@ describe Chef::Provider::Git do
end
it "gives the latest HEAD revision SHA if nothing is specified" do
- @stdout = <<-SHAS
-28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD
-503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha
-28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master
-c44fe79bb5e36941ce799cee6b9de3a2ef89afee\trefs/tags/0.5.2
-14534f0e0bf133dc9ff6dbe74f8a0c863ff3ac6d\trefs/tags/0.5.4
-d36fddb4291341a1ff2ecc3c560494e398881354\trefs/tags/0.5.6
-9e5ce9031cbee81015de680d010b603bce2dd15f\trefs/tags/0.6.0
-9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\trefs/tags/0.6.2
-014a69af1cdce619de82afaf6cdb4e6ac658fede\trefs/tags/0.7.0
-fa8097ff666af3ce64761d8e1f1c2aa292a11378\trefs/tags/0.7.2
-44f9be0b33ba5c10027ddb030a5b2f0faa3eeb8d\trefs/tags/0.7.4
-d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8
-b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
-ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
+ @stdout = <<~SHAS
+ 28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD
+ 503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha
+ 28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master
+ c44fe79bb5e36941ce799cee6b9de3a2ef89afee\trefs/tags/0.5.2
+ 14534f0e0bf133dc9ff6dbe74f8a0c863ff3ac6d\trefs/tags/0.5.4
+ d36fddb4291341a1ff2ecc3c560494e398881354\trefs/tags/0.5.6
+ 9e5ce9031cbee81015de680d010b603bce2dd15f\trefs/tags/0.6.0
+ 9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\trefs/tags/0.6.2
+ 014a69af1cdce619de82afaf6cdb4e6ac658fede\trefs/tags/0.7.0
+ fa8097ff666af3ce64761d8e1f1c2aa292a11378\trefs/tags/0.7.2
+ 44f9be0b33ba5c10027ddb030a5b2f0faa3eeb8d\trefs/tags/0.7.4
+ d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8
+ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
+ ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
SHAS
@resource.revision ""
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { log_tag: "git[web2.0 app]" }).and_return(double("ShellOut result", stdout: @stdout))
expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
end
end
@@ -276,15 +276,15 @@ SHAS
let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' }
let(:default_options) do
{
- :user => deploy_user,
- :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" },
- :log_tag => "git[web2.0 app]",
+ user: deploy_user,
+ environment: { "GIT_SSH" => wrapper, "HOME" => "/home/deployNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@resource.user deploy_user
@resource.ssh_wrapper wrapper
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
end
context "without a timeout set" do
it "clones a repo with default git options" do
@@ -296,7 +296,7 @@ SHAS
let (:seconds) { 10 }
before { @resource.timeout(seconds) }
it "clones a repo with amended git options" do
- expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(:timeout => seconds))
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds))
@provider.clone
end
end
@@ -306,9 +306,9 @@ SHAS
end
let(:overrided_options) do
{
- :user => deploy_user,
- :environment => { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" },
- :log_tag => "git[web2.0 app]",
+ user: deploy_user,
+ environment: { "GIT_SSH" => wrapper, "HOME" => "/home/masterNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@@ -327,14 +327,14 @@ SHAS
let(:expected_cmd) { 'git clone "git://github.com/opscode/chef.git" "/my/deploy/dir"' }
let(:default_options) do
{
- :user => 123,
- :environment => { "HOME" => "/home/deployNinja" },
- :log_tag => "git[web2.0 app]",
+ user: 123,
+ environment: { "HOME" => "/home/deployNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@resource.user deploy_user
- allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
end
context "with a specific home" do
let (:override_home) do
@@ -342,9 +342,9 @@ SHAS
end
let(:overrided_options) do
{
- :user => 123,
- :environment => { "HOME" => "/home/masterNinja" },
- :log_tag => "git[web2.0 app]",
+ user: 123,
+ environment: { "HOME" => "/home/masterNinja" },
+ log_tag: "git[web2.0 app]",
}
end
before do
@@ -360,14 +360,14 @@ SHAS
it "runs a clone command with escaped destination" do
@resource.user "deployNinja"
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/deployNinja"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
@resource.destination "/Application Support/with/space"
@resource.ssh_wrapper "do_it_this_way.sh"
expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\""
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/deployNinja",
- "GIT_SSH" => "do_it_this_way.sh" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, user: "deployNinja",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/deployNinja",
+ "GIT_SSH" => "do_it_this_way.sh" })
@provider.clone
end
@@ -377,8 +377,8 @@ SHAS
version_response = double("shell_out")
allow(version_response).to receive(:stdout) { "git version 1.7.9" }
expect(@provider).to receive(:shell_out!).with("git --version",
- :log_tag => "git[web2.0 app]").and_return(version_response)
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ log_tag: "git[web2.0 app]").and_return(version_response)
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
@@ -388,33 +388,33 @@ SHAS
version_response = double("shell_out")
allow(version_response).to receive(:stdout) { "git version 1.7.10" }
expect(@provider).to receive(:shell_out!).with("git --version",
- :log_tag => "git[web2.0 app]").and_return(version_response)
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ log_tag: "git[web2.0 app]").and_return(version_response)
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
it "compiles a clone command with a remote other than ``origin''" do
@resource.remote "opscode"
expected_cmd = "git clone -o opscode \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, log_tag: "git[web2.0 app]")
@provider.clone
end
it "runs a checkout command with default options" do
- expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
- expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
+ expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]").ordered
+ expect(@provider).to receive(:shell_out!).with("git checkout deploy", cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]").ordered
@provider.checkout
end
it "runs an enable_submodule command" do
@resource.enable_submodules true
expected_cmd = "git submodule sync"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
expected_cmd = "git submodule update --init --recursive"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.enable_submodules
end
@@ -426,35 +426,35 @@ SHAS
it "runs a sync command with default options" do
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
expected_cmd2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
it "runs a sync command with the user and group specified in the resource" do
@resource.user("whois")
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois"))
@resource.group("thisis")
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(expected_cmd1, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd1, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
expected_cmd2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(expected_cmd2, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd2, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
expected_cmd3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(expected_cmd3, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment => { "HOME" => "/home/whois" })
+ expect(@provider).to receive(:shell_out!).with(expected_cmd3, cwd: "/my/deploy/dir",
+ user: "whois", group: "thisis",
+ log_tag: "git[web2.0 app]",
+ environment: { "HOME" => "/home/whois" })
@provider.fetch_updates
end
@@ -462,11 +462,11 @@ SHAS
@resource.remote "origin"
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
fetch_command1 = "git fetch --prune origin"
- expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command2 = "git fetch origin --tags"
- expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
@@ -474,11 +474,11 @@ SHAS
@resource.remote "opscode"
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
fetch_command1 = "git fetch --prune opscode"
- expect(@provider).to receive(:shell_out!).with(fetch_command1, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command1, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command2 = "git fetch opscode --tags"
- expect(@provider).to receive(:shell_out!).with(fetch_command2, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command2, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
fetch_command3 = "git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(fetch_command3, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(fetch_command3, cwd: "/my/deploy/dir", log_tag: "git[web2.0 app]")
@provider.fetch_updates
end
@@ -489,37 +489,37 @@ SHAS
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
it "runs the config with the user and group specified in the resource" do
@resource.user("whois")
@resource.group("thisis")
- allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
+ allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/whois"))
command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :user => "whois",
- :group => "thisis",
- :environment => { "HOME" => "/home/whois" },
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ user: "whois",
+ group: "thisis",
+ environment: { "HOME" => "/home/whois" },
+ returns: [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :user => "whois",
- :group => "thisis",
- :environment => { "HOME" => "/home/whois" })
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ user: "whois",
+ group: "thisis",
+ environment: { "HOME" => "/home/whois" })
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -529,13 +529,13 @@ SHAS
allow(command_response).to receive(:exitstatus) { 1 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
end
@@ -547,13 +547,13 @@ SHAS
allow(command_response).to receive(:stdout) { "some_other_url" }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -563,13 +563,13 @@ SHAS
allow(command_response).to receive(:stdout) { @resource.repository }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
unexpected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).not_to receive(:shell_out!).with(unexpected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -578,13 +578,13 @@ SHAS
allow(command_response).to receive(:exitstatus) { 2 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]",
- :returns => [0, 1, 2]).and_return(command_response)
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]",
+ returns: [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url \"#{@resource.repository}\""
expect(@provider).to receive(:shell_out!).with(expected_command,
- :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ cwd: "/my/deploy/dir",
+ log_tag: "git[web2.0 app]")
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
end
@@ -705,9 +705,9 @@ SHAS
allow(::File).to receive(:directory?).with("/my/deploy/dir").and_return(true)
allow(@provider).to receive(:sync_command).and_return("huzzah!")
expect(@provider).to receive(:action_checkout)
- expect(@provider).not_to receive(:shell_out!).with("huzzah!", :cwd => "/my/deploy/dir")
+ expect(@provider).not_to receive(:shell_out!).with("huzzah!", cwd: "/my/deploy/dir")
@provider.run_action(:sync)
- #@resource.should be_updated
+ # @resource.should be_updated
end
it "does an export by cloning the repo then removing the .git directory" do
@@ -719,8 +719,8 @@ SHAS
describe "calling add_remotes" do
it "adds a new remote for each entry in additional remotes hash" do
- @resource.additional_remotes({ :opscode => "opscode_repo_url",
- :another_repo => "some_other_repo_url" })
+ @resource.additional_remotes({ opscode: "opscode_repo_url",
+ another_repo: "some_other_repo_url" })
allow(STDOUT).to receive(:tty?).and_return(false)
command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index b6748fd5f8..4d18a8c2b0 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -309,19 +309,19 @@ describe "Test DSCL loading" do
@new_resource = Chef::Resource::Group.new("group name aj")
@new_resource.group_name("aj")
@provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context)
- @output = <<-EOF
-AppleMetaNodeLocation: /Local/Default
-Comment:
- Test Group
-GeneratedUID: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA
-NestedGroups: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAB
-Password: *
-PrimaryGroupID: 999
-RealName:
- TestGroup
-RecordName: com.apple.aj
-RecordType: dsRecTypeStandard:Groups
-GroupMembership: waka bar
+ @output = <<~EOF
+ AppleMetaNodeLocation: /Local/Default
+ Comment:
+ Test Group
+ GeneratedUID: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA
+ NestedGroups: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAB
+ Password: *
+ PrimaryGroupID: 999
+ RealName:
+ TestGroup
+ RecordName: com.apple.aj
+ RecordType: dsRecTypeStandard:Groups
+ GroupMembership: waka bar
EOF
allow(@provider).to receive(:safe_dscl).with(*"read /Groups/aj".split(" ")).and_return(@output)
@current_resource = @provider.load_current_resource
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index c3e0d4b345..437b8c45ea 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -37,9 +37,9 @@ describe Chef::Provider::User do
@provider.current_resource = @current_resource
@pw_group = double("Struct::Group",
- :name => "wheel",
- :gid => 20,
- :mem => %w{root aj}
+ name: "wheel",
+ gid: 20,
+ mem: %w{root aj}
)
allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group)
end
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 3eb4228c51..654b08b2c9 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -22,16 +22,16 @@ require "chef/exceptions"
describe Chef::Provider::Ifconfig::Aix do
before(:all) do
- @ifconfig_output = <<-IFCONFIG
-en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN>
- inet 10.153.11.59 netmask 0xffff0000 broadcast 10.153.255.255
- tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
-en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> metric 1
- inet 172.29.174.58 netmask 0xffffc000 broadcast 172.29.191.255
- tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
-lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
- inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
- inet6 ::1%1/0
+ @ifconfig_output = <<~IFCONFIG
+ en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN>
+ inet 10.153.11.59 netmask 0xffff0000 broadcast 10.153.255.255
+ tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
+ en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> metric 1
+ inet 172.29.174.58 netmask 0xffffc000 broadcast 172.29.191.255
+ tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
+ lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
+ inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
+ inet6 ::1%1/0
IFCONFIG
end
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index 9a90dc1e0a..93b0008e8b 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -119,10 +119,10 @@ describe Chef::Provider::Ifconfig::Debian do
context "when the /etc/network/interfaces file has the source line" do
let(:expected_string) do
- <<-EOF
-a line
-source #{tempdir_path}/*
-another line
+ <<~EOF
+ a line
+ source #{tempdir_path}/*
+ another line
EOF
end
@@ -142,10 +142,10 @@ EOF
context "when the /etc/network/interfaces file does not have the source line" do
let(:expected_string) do
- <<-EOF
-a line
-another line
-source #{tempdir_path}/*
+ <<~EOF
+ a line
+ another line
+ source #{tempdir_path}/*
EOF
end
@@ -246,10 +246,10 @@ EOF
context "when the /etc/network/interfaces file has the source line" do
let(:expected_string) do
- <<-EOF
-a line
-source #{tempdir_path}/*
-another line
+ <<~EOF
+ a line
+ source #{tempdir_path}/*
+ another line
EOF
end
@@ -267,10 +267,10 @@ another line
context "when the /etc/network/interfaces file does not have the source line" do
let(:expected_string) do
- <<-EOF
-a line
-another line
-source #{tempdir_path}/*
+ <<~EOF
+ a line
+ another line
+ source #{tempdir_path}/*
EOF
end
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index 748b4d897e..0b8db90428 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -41,9 +41,9 @@ describe Chef::Provider::Ifconfig do
end
describe Chef::Provider::Ifconfig, "load_current_resource" do
- let(:net_tools_version) { StringIO.new <<-EOS }
-net-tools 1.60
-ifconfig 1.42 (2001-04-13)
+ let(:net_tools_version) { StringIO.new <<~EOS }
+ net-tools 1.60
+ ifconfig 1.42 (2001-04-13)
EOS
before do
diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb
index 693801f99b..3031ea36c3 100644
--- a/spec/unit/provider/launchd_spec.rb
+++ b/spec/unit/provider/launchd_spec.rb
@@ -29,55 +29,55 @@ describe Chef::Provider::Launchd do
let(:label) { "call.mom.weekly" }
let(:new_resource) { Chef::Resource::Launchd.new(label) }
let!(:current_resource) { Chef::Resource::Launchd.new(label) }
- let(:test_plist) { String.new <<-XML }
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-\t<key>Label</key>
-\t<string>call.mom.weekly</string>
-\t<key>Program</key>
-\t<string>/Library/scripts/call_mom.sh</string>
-\t<key>StartCalendarInterval</key>
-\t<dict>
-\t\t<key>Hour</key>
-\t\t<integer>10</integer>
-\t\t<key>Weekday</key>
-\t\t<integer>7</integer>
-\t</dict>
-\t<key>TimeOut</key>
-\t<integer>300</integer>
-</dict>
-</plist>
+ let(:test_plist) { String.new <<~XML }
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ \t<key>Label</key>
+ \t<string>call.mom.weekly</string>
+ \t<key>Program</key>
+ \t<string>/Library/scripts/call_mom.sh</string>
+ \t<key>StartCalendarInterval</key>
+ \t<dict>
+ \t\t<key>Hour</key>
+ \t\t<integer>10</integer>
+ \t\t<key>Weekday</key>
+ \t\t<integer>7</integer>
+ \t</dict>
+ \t<key>TimeOut</key>
+ \t<integer>300</integer>
+ </dict>
+ </plist>
XML
- let(:test_plist_multiple_intervals) { String.new <<-XML }
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-\t<key>Label</key>
-\t<string>call.mom.weekly</string>
-\t<key>Program</key>
-\t<string>/Library/scripts/call_mom.sh</string>
-\t<key>StartCalendarInterval</key>
-\t<array>
-\t\t<dict>
-\t\t\t<key>Hour</key>
-\t\t\t<integer>11</integer>
-\t\t\t<key>Weekday</key>
-\t\t\t<integer>1</integer>
-\t\t</dict>
-\t\t<dict>
-\t\t\t<key>Hour</key>
-\t\t\t<integer>12</integer>
-\t\t\t<key>Weekday</key>
-\t\t\t<integer>2</integer>
-\t\t</dict>
-\t</array>
-\t<key>TimeOut</key>
-\t<integer>300</integer>
-</dict>
-</plist>
+ let(:test_plist_multiple_intervals) { String.new <<~XML }
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ \t<key>Label</key>
+ \t<string>call.mom.weekly</string>
+ \t<key>Program</key>
+ \t<string>/Library/scripts/call_mom.sh</string>
+ \t<key>StartCalendarInterval</key>
+ \t<array>
+ \t\t<dict>
+ \t\t\t<key>Hour</key>
+ \t\t\t<integer>11</integer>
+ \t\t\t<key>Weekday</key>
+ \t\t\t<integer>1</integer>
+ \t\t</dict>
+ \t\t<dict>
+ \t\t\t<key>Hour</key>
+ \t\t\t<integer>12</integer>
+ \t\t\t<key>Weekday</key>
+ \t\t\t<integer>2</integer>
+ \t\t</dict>
+ \t</array>
+ \t<key>TimeOut</key>
+ \t<integer>300</integer>
+ </dict>
+ </plist>
XML
let(:test_hash) do
@@ -112,14 +112,14 @@ XML
describe "agent" do
it "path should be /Library/LaunchAgents/call.mom.weekly.plist" do
new_resource.type "agent"
- expect(provider.gen_path_from_type).
- to eq("/Library/LaunchAgents/call.mom.weekly.plist")
+ expect(provider.gen_path_from_type)
+ .to eq("/Library/LaunchAgents/call.mom.weekly.plist")
end
end
describe "daemon" do
it "path should be /Library/LaunchDaemons/call.mom.weekly.plist" do
- expect(provider.gen_path_from_type).
- to eq("/Library/LaunchDaemons/call.mom.weekly.plist")
+ expect(provider.gen_path_from_type)
+ .to eq("/Library/LaunchDaemons/call.mom.weekly.plist")
end
end
end
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 10dbdc1766..027b318c7e 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -22,7 +22,7 @@ require "ostruct"
require "spec_helper"
if Chef::Platform.windows?
- require "chef/win32/file" #probably need this in spec_helper
+ require "chef/win32/file" # probably need this in spec_helper
end
describe Chef::Resource::Link do
@@ -46,7 +46,7 @@ describe Chef::Resource::Link do
describe "when the target is a symlink" do
before(:each) do
- lstat = double("stats", :ino => 5)
+ lstat = double("stats", ino: 5)
allow(lstat).to receive(:uid).and_return(501)
allow(lstat).to receive(:gid).and_return(501)
allow(lstat).to receive(:mode).and_return(0777)
@@ -146,7 +146,7 @@ describe Chef::Resource::Link do
describe "when the target is a regular old file" do
before do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(501)
allow(stat).to receive(:gid).and_return(501)
allow(stat).to receive(:mode).and_return(0755)
@@ -178,7 +178,7 @@ describe Chef::Resource::Link do
describe "and the source exists" do
before do
- stat = double("stats", :ino => 6)
+ stat = double("stats", ino: 6)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
@@ -205,7 +205,7 @@ describe Chef::Resource::Link do
describe "and is hardlinked to the source" do
before do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
@@ -254,7 +254,7 @@ describe Chef::Resource::Link do
describe "action_delete" do
before(:each) do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(501)
allow(stat).to receive(:gid).and_return(501)
allow(stat).to receive(:mode).and_return(0755)
@@ -321,7 +321,7 @@ describe Chef::Resource::Link do
end
before(:each) do
- stat = double("stats", :ino => 5)
+ stat = double("stats", ino: 5)
allow(stat).to receive(:uid).and_return(502)
allow(stat).to receive(:gid).and_return(502)
allow(stat).to receive(:mode).and_return(0644)
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 8ef884e131..17824c4fb8 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -32,20 +32,20 @@ describe Chef::Provider::Mdadm do
describe "when determining the current metadevice status" do
it "should set the current resources mount point to the new resources mount point" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(status: 0))
@provider.load_current_resource
expect(@provider.current_resource.name).to eq("/dev/md1")
expect(@provider.current_resource.raid_device).to eq("/dev/md1")
end
it "determines that the metadevice exists when mdadm exit code is zero" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 0))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_truthy
end
it "determines that the metadevice does not exist when mdadm exit code is 4" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", returns: [0, 4]).and_return(OpenStruct.new(status: 4))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_falsey
end
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index 615f3c3304..80a83130e9 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -22,32 +22,32 @@ require "ostruct"
describe Chef::Provider::Mount::Aix do
before(:all) do
- @mounted_output = <<-MOUNT
- node mounted mounted over vfs date options
--------- --------------- --------------- ------ ------------ ---------------
- /dev/sdz1 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8
+ @mounted_output = <<~MOUNT
+ node mounted mounted over vfs date options
+ -------- --------------- --------------- ------ ------------ ---------------
+ /dev/sdz1 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8
MOUNT
- @unmounted_output = <<-UNMOUNTED
- node mounted mounted over vfs date options
--------- --------------- --------------- ------ ------------ ---------------
- /dev/sdz2 / jfs2 Jul 17 13:22 rw,log=/dev/hd8
+ @unmounted_output = <<~UNMOUNTED
+ node mounted mounted over vfs date options
+ -------- --------------- --------------- ------ ------------ ---------------
+ /dev/sdz2 / jfs2 Jul 17 13:22 rw,log=/dev/hd8
UNMOUNTED
- @conflict_mounted_output = <<-MOUNT
- node mounted mounted over vfs date options
--------- --------------- --------------- ------ ------------ ---------------
- /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8
+ @conflict_mounted_output = <<~MOUNT
+ node mounted mounted over vfs date options
+ -------- --------------- --------------- ------ ------------ ---------------
+ /dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8
MOUNT
- @enabled_output = <<-ENABLED
-#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
-/tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no
+ @enabled_output = <<~ENABLED
+ #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
+ /tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no
ENABLED
- @test_wrong_output = <<-WRONG
-#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
-/tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no
+ @test_wrong_output = <<~WRONG
+ #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
+ /tmp/foo::/dev/sdz1:jfs2:bootfs:10485760:rw:yes:no
WRONG
end
@@ -61,7 +61,7 @@ WRONG
@new_resource.device_type :device
@new_resource.fstype "jfs2"
- @new_resource.supports :remount => false
+ @new_resource.supports remount: false
@provider = Chef::Provider::Mount::Aix.new(@new_resource, @run_context)
@@ -70,12 +70,12 @@ WRONG
end
def stub_mounted(provider, mounted_output)
- response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => mounted_output, :stderr => "")
+ response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: mounted_output, stderr: "")
expect(provider).to receive(:shell_out!).with("mount").and_return(response)
end
def stub_enabled(provider, enabled_output)
- response = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => enabled_output, :stderr => "")
+ response = double("Mixlib::ShellOut command", exitstatus: 0, stdout: enabled_output, stderr: "")
expect(provider).to receive(:shell_out).with("lsfs -c #{@new_resource.mount_point}").and_return(response)
end
@@ -179,7 +179,7 @@ WRONG
describe "remount_fs" do
it "should remount resource if it is already mounted and it supports remounting" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
stub_mounted_enabled(@provider, @mounted_output, "")
expect(@provider).to receive(:shell_out!).with("mount -o remount #{@new_resource.device} #{@new_resource.mount_point}")
@@ -188,7 +188,7 @@ WRONG
end
it "should remount with new mount options if it is already mounted and it supports remounting" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
@new_resource.options("nodev,rw")
stub_mounted_enabled(@provider, @mounted_output, "")
@@ -232,22 +232,22 @@ WRONG
it "should disable mount if it is mounted and enabled" do
stub_mounted_enabled(@provider, @mounted_output, @enabled_output)
- allow(::File).to receive(:open).with("/etc/filesystems", "r").and_return(<<-ETCFILESYSTEMS)
-/tmp/foo:
- dev = /dev/sdz1
- vfs = jfs2
- log = /dev/hd8
- mount = true
- check = true
- vol = /opt
- free = false
- quota = no
-
-/tmp/abc:
- dev = /dev/sdz2
- vfs = jfs2
- mount = true
- options = rw
+ allow(::File).to receive(:open).with("/etc/filesystems", "r").and_return(<<~ETCFILESYSTEMS)
+ /tmp/foo:
+ dev = /dev/sdz1
+ vfs = jfs2
+ log = /dev/hd8
+ mount = true
+ check = true
+ vol = /opt
+ free = false
+ quota = no
+
+ /tmp/abc:
+ dev = /dev/sdz2
+ vfs = jfs2
+ mount = true
+ options = rw
ETCFILESYSTEMS
filesystems = StringIO.new
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index af7916e5bd..562dbcdc5d 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device_type :device
@new_resource.fstype "ext3"
- @new_resource.supports :remount => false
+ @new_resource.supports remount: false
@provider = Chef::Provider::Mount::Mount.new(@new_resource, @run_context)
@@ -42,7 +42,7 @@ describe Chef::Provider::Mount::Mount do
describe "when discovering the current fs state" do
before do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => ""))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: ""))
allow(::File).to receive(:foreach).with("/etc/fstab")
end
@@ -54,10 +54,10 @@ describe Chef::Provider::Mount::Mount do
end
it "should accept device_type :uuid", :not_supported_on_solaris do
- @status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ @status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
@new_resource.device_type :uuid
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
- @stdout_findfs = double("STDOUT", :first => "/dev/sdz1")
+ @stdout_findfs = double("STDOUT", first: "/dev/sdz1")
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(@status)
@provider.load_current_resource
@provider.mountable?
@@ -73,7 +73,7 @@ describe Chef::Provider::Mount::Mount do
it "should ignore trailing slash and set mounted to true for network mount (#{type})" do
@new_resource.device fs_spec
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{fs_spec}/ on /tmp/foo type #{type} (rw)\n"))
@provider.load_current_resource
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -94,7 +94,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should raise an error if the mount device (uuid) does not exist", :not_supported_on_solaris do
- status = double(:stdout => "", :exitstatus => 1)
+ status = double(stdout: "", exitstatus: 1)
@new_resource.device_type :uuid
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
@@ -121,13 +121,13 @@ describe Chef::Provider::Mount::Mount do
end
it "should set mounted true if the mount point is found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
it "should set mounted false if another mount point beginning with the same path is found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdz1 on /tmp/foobar type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -136,10 +136,10 @@ describe Chef::Provider::Mount::Mount do
# expand the target path to correct specs on Windows
target = ::File.expand_path("/dev/mapper/target")
- allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
- allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
+ allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true)
+ allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target)
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{target} on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{target} on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -150,10 +150,10 @@ describe Chef::Provider::Mount::Mount do
# expand the target path to correct specs on Windows
absolute_target = ::File.expand_path("/dev/xsdz1")
- allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
- allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
+ allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true)
+ allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target)
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "#{absolute_target} on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "#{absolute_target} on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Mount::Mount do
mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -171,13 +171,13 @@ describe Chef::Provider::Mount::Mount do
mount = "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => mount))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
it "mounted should be false if the mount point is not found in the mounts list" do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "/dev/sdy1 on /tmp/foo type ext3 (rw)\n"))
@provider.load_current_resource()
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -205,8 +205,8 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to true if the symlink target is in fstab" do
target = "/dev/mapper/target"
- allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
- allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
+ allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true)
+ allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target)
fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
@@ -219,8 +219,8 @@ describe Chef::Provider::Mount::Mount do
it "should set enabled to true if the symlink target is relative and is in fstab - CHEF-4957" do
target = "xsdz1"
- allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
- allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
+ allow(::File).to receive(:symlink?).with((@new_resource.device).to_s).and_return(true)
+ allow(::File).to receive(:readlink).with((@new_resource.device).to_s).and_return(target)
fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
@@ -307,7 +307,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should mount the filesystem specified by uuid", :not_supported_on_solaris do
- status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@new_resource.device_type :uuid
allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
@@ -341,14 +341,14 @@ describe Chef::Provider::Mount::Mount do
describe "remount_fs" do
it "should use mount -o remount if remount is supported" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
@current_resource.mounted(true)
expect(@provider).to receive(:shell_out!).with("mount -o remount,defaults #{@new_resource.mount_point}")
@provider.remount_fs
end
it "should use mount -o remount with new mount options if remount is supported" do
- @new_resource.supports({ :remount => true })
+ @new_resource.supports({ remount: true })
options = "rw,noexec,noauto"
@new_resource.options(%w{rw noexec noauto})
@current_resource.mounted(true)
@@ -357,7 +357,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should umount and mount if remount is not supported" do
- @new_resource.supports({ :remount => false })
+ @new_resource.supports({ remount: false })
@current_resource.mounted(true)
expect(@provider).to receive(:umount_fs)
expect(@provider).to receive(:sleep).with(1)
@@ -499,7 +499,7 @@ describe Chef::Provider::Mount::Mount do
context "when the device is described differently", :not_supported_on_solaris do
it "should update the existing line" do
@current_resource.enabled(true)
- status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ status = double(stdout: "/dev/sdz1\n", exitstatus: 1)
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2},
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 2ec9feaf3b..e489b9001a 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
new_resource.fsck_device fsck_device
new_resource.fstype fstype
new_resource.options options
- new_resource.supports :remount => false
+ new_resource.supports remount: false
new_resource
end
@@ -92,7 +92,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
before do
stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path )
- allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(:stdout => mount_output))
+ allow(provider).to receive(:shell_out!).with("mount -v").and_return(OpenStruct.new(stdout: mount_output))
allow(File).to receive(:symlink?).with(device).and_return(false)
allow(File).to receive(:exist?).and_call_original # Tempfile.open on ruby 1.8.7 calls File.exist?
allow(File).to receive(:exist?).with(device).and_return(true)
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index fdb44836b5..6d55fb958c 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -99,10 +99,10 @@ describe Chef::Provider::Mount::Windows do
end
it "should mount the filesystem if it is not mounted" do
- expect(@vol).to receive(:add).with(:remote => @new_resource.device,
- :username => @new_resource.username,
- :domainname => @new_resource.domain,
- :password => @new_resource.password)
+ expect(@vol).to receive(:add).with(remote: @new_resource.device,
+ username: @new_resource.username,
+ domainname: @new_resource.domain,
+ password: @new_resource.password)
@provider.mount_fs
end
diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb
index fad08ba589..518523dca2 100644
--- a/spec/unit/provider/ohai_spec.rb
+++ b/spec/unit/provider/ohai_spec.rb
@@ -29,16 +29,16 @@ describe Chef::Provider::Ohai do
@platform_version = "example-platform"
Chef::Config[:node_name] = @fqdn
mock_ohai = {
- :fqdn => @fqdn,
- :hostname => @hostname,
- :platform => @platform,
- :platform_version => @platform_version,
- :data => {
- :origdata => "somevalue",
+ fqdn: @fqdn,
+ hostname: @hostname,
+ platform: @platform,
+ platform_version: @platform_version,
+ data: {
+ origdata: "somevalue",
},
- :data2 => {
- :origdata => "somevalue",
- :newdata => "somevalue",
+ data2: {
+ origdata: "somevalue",
+ newdata: "somevalue",
},
}
allow(mock_ohai).to receive(:all_plugins).and_return(true)
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index a1dcf3ecd6..dce52fd598 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::OsxProfile do
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
describe "action_create" do
let(:node) { Chef::Node.new }
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index f15929880d..05be08f332 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -31,19 +31,19 @@ describe Chef::Provider::Package::Apt do
allow(@run_context).to receive(:logger).and_return(logger)
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
- @status = double("Status", :exitstatus => 0)
+ @status = double("Status", exitstatus: 0)
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
@stdin = StringIO.new
- @stdout = <<-PKG_STATUS
-irssi:
- Installed: (none)
- Candidate: 0.8.14-1ubuntu4
- Version table:
- 0.8.14-1ubuntu4 0
- 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
+ @stdout = <<~PKG_STATUS
+ irssi:
+ Installed: (none)
+ Candidate: 0.8.14-1ubuntu4
+ Version table:
+ 0.8.14-1ubuntu4 0
+ 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
PKG_STATUS
@stderr = ""
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
@timeout = 900
end
@@ -52,8 +52,8 @@ irssi:
it "should create a current resource with the name of the new_resource" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(@shell_out)
@provider.load_current_resource
@@ -65,17 +65,17 @@ irssi:
end
it "should set the installed version if package has one" do
- @stdout.replace(<<-INSTALLED)
-sudo:
- Installed: 1.7.2p1-1ubuntu5.3
- Candidate: 1.7.2p1-1ubuntu5.3
- Version table:
- *** 1.7.2p1-1ubuntu5.3 0
- 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
- 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
- 100 /var/lib/dpkg/status
- 1.7.2p1-1ubuntu5 0
- 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
+ @stdout.replace(<<~INSTALLED)
+ sudo:
+ Installed: 1.7.2p1-1ubuntu5.3
+ Candidate: 1.7.2p1-1ubuntu5.3
+ Version table:
+ *** 1.7.2p1-1ubuntu5.3 0
+ 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
+ 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
+ 100 /var/lib/dpkg/status
+ 1.7.2p1-1ubuntu5 0
+ 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
INSTALLED
expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
@@ -86,23 +86,23 @@ sudo:
# it is the superclasses responsibility to throw most exceptions
it "if the package does not exist in the cache sets installed + candidate version to nil" do
@new_resource.package_name("conic-smarms")
- policy_out = <<-POLICY_STDOUT
-N: Unable to locate package conic-smarms
+ policy_out = <<~POLICY_STDOUT
+ N: Unable to locate package conic-smarms
POLICY_STDOUT
- policy = double(:stdout => policy_out, :exitstatus => 0)
+ policy = double(stdout: policy_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "conic-smarms",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(policy)
- showpkg_out = <<-SHOWPKG_STDOUT
-N: Unable to locate package conic-smarms
+ showpkg_out = <<~SHOWPKG_STDOUT
+ N: Unable to locate package conic-smarms
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "conic-smarms",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
@provider.load_current_resource
end
@@ -111,104 +111,104 @@ N: Unable to locate package conic-smarms
# list of virtual packages: http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt
it "should not install the virtual package there is a single provider package and it is installed" do
@new_resource.package_name("libmysqlclient15-dev")
- virtual_package_out = <<-VPKG_STDOUT
-libmysqlclient15-dev:
- Installed: (none)
- Candidate: (none)
- Version table:
+ virtual_package_out = <<~VPKG_STDOUT
+ libmysqlclient15-dev:
+ Installed: (none)
+ Candidate: (none)
+ Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
+ virtual_package = double(stdout: virtual_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(virtual_package)
- showpkg_out = <<-SHOWPKG_STDOUT
-Package: libmysqlclient15-dev
-Versions:
-
-Reverse Depends:
- libmysqlclient-dev,libmysqlclient15-dev
- libmysqlclient-dev,libmysqlclient15-dev
- libmysqlclient-dev,libmysqlclient15-dev
- libmysqlclient-dev,libmysqlclient15-dev
- libmysqlclient-dev,libmysqlclient15-dev
- libmysqlclient-dev,libmysqlclient15-dev
-Dependencies:
-Provides:
-Reverse Provides:
-libmysqlclient-dev 5.1.41-3ubuntu12.7
-libmysqlclient-dev 5.1.41-3ubuntu12.10
-libmysqlclient-dev 5.1.41-3ubuntu12
+ showpkg_out = <<~SHOWPKG_STDOUT
+ Package: libmysqlclient15-dev
+ Versions:
+
+ Reverse Depends:
+ libmysqlclient-dev,libmysqlclient15-dev
+ libmysqlclient-dev,libmysqlclient15-dev
+ libmysqlclient-dev,libmysqlclient15-dev
+ libmysqlclient-dev,libmysqlclient15-dev
+ libmysqlclient-dev,libmysqlclient15-dev
+ libmysqlclient-dev,libmysqlclient15-dev
+ Dependencies:
+ Provides:
+ Reverse Provides:
+ libmysqlclient-dev 5.1.41-3ubuntu12.7
+ libmysqlclient-dev 5.1.41-3ubuntu12.10
+ libmysqlclient-dev 5.1.41-3ubuntu12
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
- real_package_out = <<-RPKG_STDOUT
-libmysqlclient-dev:
- Installed: 5.1.41-3ubuntu12.10
- Candidate: 5.1.41-3ubuntu12.10
- Version table:
- *** 5.1.41-3ubuntu12.10 0
- 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
- 100 /var/lib/dpkg/status
- 5.1.41-3ubuntu12.7 0
- 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
- 5.1.41-3ubuntu12 0
- 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
+ real_package_out = <<~RPKG_STDOUT
+ libmysqlclient-dev:
+ Installed: 5.1.41-3ubuntu12.10
+ Candidate: 5.1.41-3ubuntu12.10
+ Version table:
+ *** 5.1.41-3ubuntu12.10 0
+ 500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
+ 100 /var/lib/dpkg/status
+ 5.1.41-3ubuntu12.7 0
+ 500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
+ 5.1.41-3ubuntu12 0
+ 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
RPKG_STDOUT
- real_package = double(:stdout => real_package_out, :exitstatus => 0)
+ real_package = double(stdout: real_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(real_package)
@provider.load_current_resource
end
it "should raise an exception if you specify a virtual package with multiple provider packages" do
@new_resource.package_name("mp3-decoder")
- virtual_package_out = <<-VPKG_STDOUT
-mp3-decoder:
- Installed: (none)
- Candidate: (none)
- Version table:
+ virtual_package_out = <<~VPKG_STDOUT
+ mp3-decoder:
+ Installed: (none)
+ Candidate: (none)
+ Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
+ virtual_package = double(stdout: virtual_package_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", "mp3-decoder",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(virtual_package)
- showpkg_out = <<-SHOWPKG_STDOUT
-Package: mp3-decoder
-Versions:
-
-Reverse Depends:
- nautilus,mp3-decoder
- vux,mp3-decoder
- plait,mp3-decoder
- ecasound,mp3-decoder
- nautilus,mp3-decoder
-Dependencies:
-Provides:
-Reverse Provides:
-vlc-nox 1.0.6-1ubuntu1.8
-vlc 1.0.6-1ubuntu1.8
-vlc-nox 1.0.6-1ubuntu1
-vlc 1.0.6-1ubuntu1
-opencubicplayer 1:0.1.17-2
-mpg321 0.2.10.6
-mpg123 1.12.1-0ubuntu1
+ showpkg_out = <<~SHOWPKG_STDOUT
+ Package: mp3-decoder
+ Versions:
+
+ Reverse Depends:
+ nautilus,mp3-decoder
+ vux,mp3-decoder
+ plait,mp3-decoder
+ ecasound,mp3-decoder
+ nautilus,mp3-decoder
+ Dependencies:
+ Provides:
+ Reverse Provides:
+ vlc-nox 1.0.6-1ubuntu1.8
+ vlc 1.0.6-1ubuntu1.8
+ vlc-nox 1.0.6-1ubuntu1
+ vlc 1.0.6-1ubuntu1
+ opencubicplayer 1:0.1.17-2
+ mpg321 0.2.10.6
+ mpg123 1.12.1-0ubuntu1
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
+ showpkg = double(stdout: showpkg_out, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "showpkg", "mp3-decoder",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(showpkg)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -221,8 +221,8 @@ mpg123 1.12.1-0ubuntu1
@new_resource.provider(nil)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "-o", "APT::Default-Release=lenny-backports", "policy", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
).and_return(@shell_out)
@provider.load_current_resource
end
@@ -231,8 +231,8 @@ mpg123 1.12.1-0ubuntu1
@new_resource.source "pluto"
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-cache", "policy", @new_resource.package_name,
- :env => { "DEBIAN_FRONTEND" => "noninteractive" } ,
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" } ,
+ timeout: @timeout
).and_return(@shell_out)
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
@@ -260,8 +260,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version" do
expect(@provider).to receive(:shell_out_compacted!). with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["irssi"], ["0.8.12-7"])
end
@@ -269,8 +269,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "--force-yes", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -285,8 +285,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "-o", "APT::Default-Release=lenny-backports", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -295,8 +295,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and quotes options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confnew", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options('--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"')
@provider.install_package(["irssi"], ["0.8.12-7"])
@@ -316,8 +316,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get remove with the package name" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.remove_package(["irssi"], ["0.8.12-7"])
end
@@ -325,8 +325,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get remove with the package name and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "remove", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@@ -339,8 +339,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get purge with the package name" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.purge_package(["irssi"], ["0.8.12-7"])
end
@@ -348,8 +348,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get purge with the package name and options if specified" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "--force-yes", "purge", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@new_resource.options("--force-yes")
@@ -367,8 +367,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.preseed_package(file)
@@ -377,8 +377,8 @@ mpg123 1.12.1-0ubuntu1
it "should run debconf-set-selections on the preseed file if it has changed" do
expect(@provider).to receive(:shell_out_compacted!).with(
"debconf-set-selections", "/tmp/irssi-0.8.12-7.seed",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
file = @provider.get_preseed_file("irssi", "0.8.12-7")
@provider.preseed_package(file)
@@ -398,8 +398,8 @@ mpg123 1.12.1-0ubuntu1
it "should run dpkg-reconfigure package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"dpkg-reconfigure", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.reconfig_package("irssi", "0.8.12-7")
end
@@ -409,8 +409,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-mark hold package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "hold", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.lock_package("irssi", "0.8.12-7")
end
@@ -430,8 +430,8 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-mark unhold package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "unhold", "irssi",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.unlock_package("irssi", "0.8.12-7")
end
@@ -452,8 +452,8 @@ mpg123 1.12.1-0ubuntu1
@provider.package_data["libmysqlclient15-dev"][:virtual] = true
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -464,8 +464,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "remove", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.remove_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -476,8 +476,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:resolve_virtual_package_name).with("libmysqlclient15-dev").and_return("libmysqlclient-dev")
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "purge", "libmysqlclient-dev",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.purge_package(["libmysqlclient15-dev"], ["not_a_real_version"])
end
@@ -488,8 +488,8 @@ mpg123 1.12.1-0ubuntu1
# https://github.com/chef/chef/issues/2914
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "libmysqlclient15-dev", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.install_package(["libmysqlclient15-dev", "irssi"], ["not_a_real_version", "0.8.12-7"])
end
@@ -511,8 +511,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:version_compare).and_return(-1)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.run_action(:upgrade)
end
@@ -523,8 +523,8 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).not_to receive(:version_compare)
expect(@provider).to receive(:shell_out_compacted!).with(
"apt-get", "-q", "-y", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive" },
- :timeout => @timeout
+ env: { "DEBIAN_FRONTEND" => "noninteractive" },
+ timeout: @timeout
)
@provider.run_action(:upgrade)
end
diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb
index df407914d3..7606092762 100644
--- a/spec/unit/provider/package/bff_spec.rb
+++ b/spec/unit/provider/package/bff_spec.rb
@@ -38,11 +38,11 @@ describe Chef::Provider::Package::Bff do
@bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:
/etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
- @empty_status = double("Status", :stdout => "", :exitstatus => 0)
+ @empty_status = double("Status", stdout: "", exitstatus: 0)
end
it "should create a current resource with the name of new_resource" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -50,7 +50,7 @@ describe Chef::Provider::Package::Bff do
end
it "should set the current resource bff package name to the new resource bff package name" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -66,7 +66,7 @@ describe Chef::Provider::Package::Bff do
end
it "should get the source package version from lslpp if provided" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -78,7 +78,7 @@ describe Chef::Provider::Package::Bff do
it "should warn if the package is not a fileset" do
info = "samba.base:samba.base.samples:3.3.12.0::COMMITTED:I:Samba for AIX:
/etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
- status = double("Status", :stdout => info, :exitstatus => 0)
+ status = double("Status", stdout: info, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
expect(logger).to receive(:warn).once.with(%r{bff package by product name})
@@ -89,7 +89,7 @@ describe Chef::Provider::Package::Bff do
end
it "should return the current version installed if found by lslpp" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
@stdout = StringIO.new(@bffinfo)
@stdin, @stderr = StringIO.new, StringIO.new
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
@@ -99,7 +99,7 @@ describe Chef::Provider::Package::Bff do
end
it "should raise an exception if the source is not set but we are installing" do
- status = double("Status", :stdout => "", :exitstatus => 1, :format_for_exception => "")
+ status = double("Status", stdout: "", exitstatus: 1, format_for_exception: "")
@new_resource = Chef::Resource::Package.new("samba.base")
@provider = Chef::Provider::Package::Bff.new(@new_resource, @run_context)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@@ -107,13 +107,13 @@ describe Chef::Provider::Package::Bff do
end
it "should raise an exception if installp/lslpp fails to run" do
- status = double(:stdout => "", :exitstatus => -1, :format_for_exception => "")
+ status = double(stdout: "", exitstatus: -1, format_for_exception: "")
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
it "should return a current resource with a nil version if the package is not found" do
- status = double("Status", :stdout => @bffinfo, :exitstatus => 0)
+ status = double("Status", stdout: @bffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("lslpp", "-lcq", "samba.base", timeout: 900).and_return(@empty_status)
@provider.load_current_resource
@@ -123,7 +123,7 @@ describe Chef::Provider::Package::Bff do
it "should raise an exception if the source doesn't provide the requested package" do
wrongbffinfo = "/usr/lib/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:
/etc/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:"
- status = double("Status", :stdout => wrongbffinfo, :exitstatus => 0)
+ status = double("Status", stdout: wrongbffinfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("installp", "-L", "-d", "/tmp/samba.base", timeout: 900).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -137,13 +137,13 @@ describe Chef::Provider::Package::Bff do
end
it "should lookup the candidate_version if the variable is not already set" do
- status = double(:stdout => "", :exitstatus => 0)
+ status = double(stdout: "", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.candidate_version
end
it "should throw and exception if the exitstatus is not 0" do
- @status = double(:stdout => "", :exitstatus => 1, :format_for_exception => "")
+ @status = double(stdout: "", exitstatus: 1, format_for_exception: "")
allow(@provider).to receive(:shell_out_compacted).and_return(@status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
diff --git a/spec/unit/provider/package/cab_spec.rb b/spec/unit/provider/package/cab_spec.rb
index 5c86f781f3..2ed40566f4 100644
--- a/spec/unit/provider/package/cab_spec.rb
+++ b/spec/unit/provider/package/cab_spec.rb
@@ -31,25 +31,25 @@ describe Chef::Provider::Package::Cab do
end
let(:installed_package_list_stdout) do
- <<-EOF
-Packages listing:
-Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
-Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
+ <<~EOF
+ Packages listing:
+ Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
+ Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
EOF
end
let(:package_version_stdout) do
- <<-EOF
-Package information:
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-State : Installed
-Dependency : Language Pack
-The operation completed successfully
+ <<~EOF
+ Package information:
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ State : Installed
+ Dependency : Language Pack
+ The operation completed successfully
EOF
end
before do
- new_resource.source = File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab")
+ new_resource.source = File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab")
installed_package_list_obj = double(stdout: installed_package_list_stdout)
allow(provider).to receive(:dism_command).with("/Get-Packages").and_return(installed_package_list_obj)
package_version_obj = double(stdout: package_version_stdout)
@@ -57,20 +57,20 @@ The operation completed successfully
end
def allow_package_info(package_path = nil, package_name = nil)
- get_package_info_stdout = <<-EOF
-Deployment Image Servicing and Management tool
-Version: 6.1.7600.16385
-
-Image Version: 6.1.7600.16385
-
-Package information:
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-Applicable : Yes
-Copyright : Microsoft Corporation
-Company : Microsoft Corporation
-State : Installed
-Dependency : Language Pack
-The operation completed successfully
+ get_package_info_stdout = <<~EOF
+ Deployment Image Servicing and Management tool
+ Version: 6.1.7600.16385
+
+ Image Version: 6.1.7600.16385
+
+ Package information:
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ Applicable : Yes
+ Copyright : Microsoft Corporation
+ Company : Microsoft Corporation
+ State : Installed
+ Dependency : Language Pack
+ The operation completed successfully
EOF
get_package_info_obj = double(stdout: get_package_info_stdout)
if package_path
@@ -81,30 +81,30 @@ The operation completed successfully
end
def allow_get_packages
- get_packages_stdout = <<-EOF
-Deployment Image Servicing and Management tool
-Version: 6.1.7600.16385
+ get_packages_stdout = <<~EOF
+ Deployment Image Servicing and Management tool
+ Version: 6.1.7600.16385
-Image Version: 6.1.7600.16385
+ Image Version: 6.1.7600.16385
-Packages listing:
+ Packages listing:
-Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
-State : Installed
-Release Type : Language Pack
-Install Time : 2/11/2015 11:33 PM
+ Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
+ State : Installed
+ Release Type : Language Pack
+ Install Time : 2/11/2015 11:33 PM
-Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
-State : Installed
-Release Type : Language Pack
-Install Time : 2/11/2015 11:33 PM
+ Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
+ State : Installed
+ Release Type : Language Pack
+ Install Time : 2/11/2015 11:33 PM
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-State : Installed
-Release Type : Feature Pack
-Install Time : 11/21/2010 3:40 AM
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ State : Installed
+ Release Type : Feature Pack
+ Install Time : 11/21/2010 3:40 AM
-The operation completed successfully.
+ The operation completed successfully.
EOF
get_packages_obj = double(stdout: get_packages_stdout)
allow(provider).to receive(:dism_command).with("/Get-Packages").and_return(get_packages_obj)
@@ -151,9 +151,9 @@ The operation completed successfully.
allow(Chef::FileCache).to receive(:create_cache_path).and_return(ENV["TEMP"])
path = provider.default_download_cache_path
if windows?
- expect(path).to be == File.join("#{ENV['TEMP']}", "\\", "Test6.1-KB2664825-v3-x64.cab")
+ expect(path).to be == File.join((ENV["TEMP"]).to_s, "\\", "Test6.1-KB2664825-v3-x64.cab")
else
- expect(path).to be == File.join("#{ENV['TEMP']}", "Test6.1-KB2664825-v3-x64.cab")
+ expect(path).to be == File.join((ENV["TEMP"]).to_s, "Test6.1-KB2664825-v3-x64.cab")
end
end
end
@@ -161,12 +161,12 @@ The operation completed successfully.
describe "#cab_file_source" do
context "when local file path is set" do
it "returns local cab file source path" do
- new_resource.source = File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab")
+ new_resource.source = File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab")
path = provider.cab_file_source
if windows?
- expect(path).to be == File.join("#{ENV['TEMP'].downcase}", "\\", "test6.1-kb2664825-v3-x64.cab")
+ expect(path).to be == File.join((ENV["TEMP"].downcase).to_s, "\\", "test6.1-kb2664825-v3-x64.cab")
else
- expect(path).to be == File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab")
+ expect(path).to be == File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab")
end
end
end
@@ -174,9 +174,9 @@ The operation completed successfully.
it "calls download_source_file method" do
new_resource.source = "https://www.something.com/test6.1-kb2664825-v3-x64.cab"
if windows?
- expect(provider).to receive(:download_source_file).and_return(File.join("#{ENV['TEMP'].downcase}", "\\", "test6.1-kb2664825-v3-x64.cab"))
+ expect(provider).to receive(:download_source_file).and_return(File.join((ENV["TEMP"].downcase).to_s, "\\", "test6.1-kb2664825-v3-x64.cab"))
else
- expect(provider).to receive(:download_source_file).and_return(File.join("#{ENV['TEMP']}", "test6.1-kb2664825-v3-x64.cab"))
+ expect(provider).to receive(:download_source_file).and_return(File.join((ENV["TEMP"]).to_s, "test6.1-kb2664825-v3-x64.cab"))
end
provider.cab_file_source
end
@@ -248,14 +248,14 @@ The operation completed successfully.
context "Invalid package source" do
def package_version_stdout
- package_version_stdout = <<-EOF
-Deployment Image Servicing and Management tool
-Version: 6.1.7600.16385
-Image Version: 6.1.7600.16385
-An error occurred trying to open - c:\\temp\\test6.1-KB2664825-v3-x64.cab Error: 0x80070003
-Error: 3
-The system cannot find the path specified.
-The DISM log file can be found at C:\\Windows\\Logs\\DISM\\dism.log.
+ package_version_stdout = <<~EOF
+ Deployment Image Servicing and Management tool
+ Version: 6.1.7600.16385
+ Image Version: 6.1.7600.16385
+ An error occurred trying to open - c:\\temp\\test6.1-KB2664825-v3-x64.cab Error: 0x80070003
+ Error: 3
+ The system cannot find the path specified.
+ The DISM log file can be found at C:\\Windows\\Logs\\DISM\\dism.log.
EOF
end
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index a0a73c445a..48f8a562de 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -35,32 +35,32 @@ describe Chef::Provider::Package::Chocolatey do
# installed packages (ConEmu is upgradable)
let(:local_list_stdout) do
- <<-EOF
-Chocolatey v0.9.9.11
-chocolatey|0.9.9.11
-ConEmu|15.10.25.0
+ <<~EOF
+ Chocolatey v0.9.9.11
+ chocolatey|0.9.9.11
+ ConEmu|15.10.25.0
EOF
end
before do
allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
allow(provider).to receive(:choco_exe).and_return(choco_exe)
- local_list_obj = double(:stdout => local_list_stdout)
- allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj)
+ local_list_obj = double(stdout: local_list_stdout)
+ allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -l -r", { returns: [0], timeout: timeout }).and_return(local_list_obj)
end
def allow_remote_list(package_names, args = nil)
- remote_list_stdout = <<-EOF
-Chocolatey v0.9.9.11
-chocolatey|0.9.9.11
-ConEmu|15.10.25.1
-Git|2.6.1
-Git|2.6.2
-munin-node|1.6.1.20130823
+ remote_list_stdout = <<~EOF
+ Chocolatey v0.9.9.11
+ chocolatey|0.9.9.11
+ ConEmu|15.10.25.1
+ Git|2.6.1
+ Git|2.6.2
+ munin-node|1.6.1.20130823
EOF
remote_list_obj = double(stdout: remote_list_stdout)
package_names.each do |pkg|
- allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { :returns => [0], timeout: timeout }).and_return(remote_list_obj)
+ allow(provider).to receive(:shell_out_compacted!).with("#{choco_exe} list -r #{pkg}#{args}", { returns: [0], timeout: timeout }).and_return(remote_list_obj)
end
end
@@ -182,7 +182,7 @@ munin-node|1.6.1.20130823
it "should install a single package" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -193,7 +193,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.timeout(timeout)
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -222,7 +222,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("ConEmu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -235,7 +235,7 @@ munin-node|1.6.1.20130823
new_resource.package_name(%w{chocolatey ConEmu})
new_resource.version([nil, "15.10.25.1"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -245,7 +245,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("conemu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -255,8 +255,8 @@ munin-node|1.6.1.20130823
new_resource.package_name(%w{ConEmu git})
new_resource.version(["15.10.25.1", nil])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { returns: [0], timeout: timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -265,7 +265,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git", "munin-node"])
new_resource.package_name(["git", "munin-node"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y git munin-node", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -275,7 +275,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"], " -source localpackages")
new_resource.source("localpackages")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -source localpackages git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -285,7 +285,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.options("-force")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} install -y -force git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -319,7 +319,7 @@ munin-node|1.6.1.20130823
it "should install a package that is not installed" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -328,7 +328,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -337,7 +337,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -346,7 +346,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["chocolatey"])
new_resource.package_name("chocolatey")
provider.load_current_resource
- expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { :returns => [0], :timeout => timeout })
+ expect(provider).not_to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y chocolatey", { returns: [0], timeout: timeout })
provider.run_action(:upgrade)
expect(new_resource).not_to be_updated_by_last_action
end
@@ -355,7 +355,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.version("2.6.2")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :returns => [0], :timeout => timeout })
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { returns: [0], timeout: timeout })
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -363,7 +363,7 @@ munin-node|1.6.1.20130823
it "upgrading multiple packages uses a single command" do
allow_remote_list(%w{conemu git})
new_resource.package_name(%w{conemu git})
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} upgrade -y conemu git", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -415,7 +415,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y ConEmu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -424,7 +424,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -434,7 +434,7 @@ munin-node|1.6.1.20130823
allow_remote_list(%w{git conemu})
new_resource.package_name(%w{git conemu})
provider.load_current_resource
- expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out_compacted!).with("#{choco_exe} uninstall -y conemu", { returns: [0], timeout: timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -457,7 +457,7 @@ describe "behavior when Chocolatey is not installed" do
provider.instance_variable_set("@choco_install_path", nil)
# we don't care what this returns, but we have to let it be called.
- allow(provider).to receive(:shell_out_compacted!).and_return(double(:stdout => ""))
+ allow(provider).to receive(:shell_out_compacted!).and_return(double(stdout: ""))
end
let(:error_regex) do
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index c99e91dd46..9df19f0f1b 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -31,23 +31,23 @@ describe Chef::Provider::Package::Dpkg do
let(:provider) { Chef::Provider::Package::Dpkg.new(new_resource, run_context) }
let(:dpkg_deb_version) { "1.11.4" }
- let(:dpkg_deb_status) { status = double(:stdout => "#{package}\t#{dpkg_deb_version}", :exitstatus => 0) }
+ let(:dpkg_deb_status) { status = double(stdout: "#{package}\t#{dpkg_deb_version}", exitstatus: 0) }
let(:dpkg_s_version) { "1.11.4-1ubuntu1" }
let(:dpkg_s_status) do
- stdout = <<-DPKG_S
-Package: #{package}
-Status: install ok installed
-Priority: important
-Section: web
-Installed-Size: 1944
-Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com>
-Architecture: amd64
-Version: #{dpkg_s_version}
-Config-Version: #{dpkg_s_version}
-Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
-Conflicts: wget-ssl
+ stdout = <<~DPKG_S
+ Package: #{package}
+ Status: install ok installed
+ Priority: important
+ Section: web
+ Installed-Size: 1944
+ Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com>
+ Architecture: amd64
+ Version: #{dpkg_s_version}
+ Config-Version: #{dpkg_s_version}
+ Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
+ Conflicts: wget-ssl
DPKG_S
- status = double(:stdout => stdout, :exitstatus => 1)
+ status = double(stdout: stdout, exitstatus: 1)
end
before(:each) do
@@ -112,7 +112,7 @@ Conflicts: wget-ssl
describe "gets the source package version from dpkg-deb" do
def check_version(version)
- status = double(:stdout => "wget\t#{version}", :exitstatus => 0)
+ status = double(stdout: "wget\t#{version}", exitstatus: 0)
expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", source, timeout: 900).and_return(status)
provider.load_current_resource
expect(provider.current_resource.package_name).to eq(["wget"])
@@ -172,10 +172,10 @@ Conflicts: wget-ssl
it "on new debian/ubuntu we get an exit(1) and no stdout from dpkg -s for uninstalled" do
dpkg_s_status = double(
- exitstatus: 1, stdout: "", stderr: <<-EOF
-dpkg-query: package '#{package}' is not installed and no information is available
-Use dpkg --info (= dpkg-deb --info) to examine archive files,
-and dpkg --contents (= dpkg-deb --contents) to list their contents.
+ exitstatus: 1, stdout: "", stderr: <<~EOF
+ dpkg-query: package '#{package}' is not installed and no information is available
+ Use dpkg --info (= dpkg-deb --info) to examine archive files,
+ and dpkg --contents (= dpkg-deb --contents) to list their contents.
EOF
)
expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
@@ -185,11 +185,11 @@ and dpkg --contents (= dpkg-deb --contents) to list their contents.
it "on old debian/ubuntu we get an exit(0) and we get info on stdout from dpkg -s for uninstalled" do
dpkg_s_status = double(
- exitstatus: 0, stderr: "", stdout: <<-EOF
-Package: #{package}
-Status: unknown ok not-installed
-Priority: extra
-Section: ruby
+ exitstatus: 0, stderr: "", stdout: <<~EOF
+ Package: #{package}
+ Status: unknown ok not-installed
+ Priority: extra
+ Section: ruby
EOF
)
expect(provider).to receive(:shell_out_compacted!).with("dpkg", "-s", package, returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
@@ -206,7 +206,7 @@ Section: ruby
end
it "should raise an exception if dpkg-deb -W fails to run" do
- status = double(:stdout => "", :exitstatus => -1)
+ status = double(stdout: "", exitstatus: -1)
expect(provider).to receive(:shell_out_compacted!).with("dpkg-deb", "-W", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb
index 259bd7a4c4..8c3e25a0f9 100644
--- a/spec/unit/provider/package/freebsd/pkg_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkg_spec.rb
@@ -66,33 +66,33 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
describe "when querying for package state and attributes" do
before do
- #@new_resource = Chef::Resource::Package.new("zsh")
+ # @new_resource = Chef::Resource::Package.new("zsh")
- #@provider = Chef::Provider::Package::Freebsd::Pkg.new(@node, @new_resource)
+ # @provider = Chef::Provider::Package::Freebsd::Pkg.new(@node, @new_resource)
- #@status = double("Status", :exitstatus => 0)
- #@stdin = double("STDIN", :null_object => true)
- #@stdout = double("STDOUT", :null_object => true)
- #@stderr = double("STDERR", :null_object => true)
- #@pid = double("PID", :null_object => true)
+ # @status = double("Status", :exitstatus => 0)
+ # @stdin = double("STDIN", :null_object => true)
+ # @stdout = double("STDOUT", :null_object => true)
+ # @stderr = double("STDERR", :null_object => true)
+ # @pid = double("PID", :null_object => true)
end
it "should return the version number when it is installed" do
- pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7")
+ pkg_info = OpenStruct.new(stdout: "zsh-4.3.6_7")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to eq("4.3.6_7")
end
it "does not set the current version number when the package is not installed" do
- pkg_info = OpenStruct.new(:stdout => "")
+ pkg_info = OpenStruct.new(stdout: "")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to be_nil
end
it "should return the port path for a valid port name" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
allow(@provider).to receive(:port_name).and_return("zsh")
expect(@provider.port_path).to eq("/usr/ports/shells/zsh")
@@ -101,7 +101,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
# Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile.
it "should return the ports candidate version when given a valid port path" do
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
- make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0)
+ make_v = OpenStruct.new(stdout: "4.3.6\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v)
expect(@provider.ports_candidate_version).to eq("4.3.6")
end
@@ -109,16 +109,16 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should figure out the package name when we have ports" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
- make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0)
+ make_v = OpenStruct.new(stdout: "zsh-4.3.6_7\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v)
- #@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7")
+ # @provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7")
expect(@provider.package_name).to eq("zsh")
end
end
describe Chef::Provider::Package::Freebsd::Pkg, "install_package" do
before(:each) do
- @cmd_result = OpenStruct.new(:status => true)
+ @cmd_result = OpenStruct.new(status: true)
@provider.current_resource = @current_resource
allow(@provider).to receive(:package_name).and_return("zsh")
@@ -134,14 +134,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
describe Chef::Provider::Package::Freebsd::Pkg, "port path" do
before do
- #@node = Chef::Node.new
+ # @node = Chef::Node.new
@new_resource = Chef::Resource::Package.new("zsh")
@new_resource.cookbook_name = "adventureclub"
@provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context)
end
it "should figure out the port path from the package_name using whereis" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect(@provider.port_path).to eq("/usr/ports/shells/zsh")
end
@@ -174,7 +174,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("ruby18-iconv")
allow(@provider).to receive(:latest_link_name).and_return("ruby18-iconv")
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run pkg_add -r with the package name" do
@@ -185,7 +185,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
describe Chef::Provider::Package::Freebsd::Pkg, "remove_package" do
before(:each) do
- @pkg_delete = OpenStruct.new(:status => true)
+ @pkg_delete = OpenStruct.new(status: true)
@new_resource.version "4.3.6_7"
@current_resource.version "4.3.6_7"
@provider.current_resource = @current_resource
@@ -212,14 +212,14 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should return the port path for a valid port name" do
- whereis = OpenStruct.new(:stdout => "bonnie++: /usr/ports/benchmarks/bonnie++")
+ whereis = OpenStruct.new(stdout: "bonnie++: /usr/ports/benchmarks/bonnie++")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis)
allow(@provider).to receive(:port_name).and_return("bonnie++")
expect(@provider.port_path).to eq("/usr/ports/benchmarks/bonnie++")
end
it "should return the version number when it is installed" do
- pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96")
+ pkg_info = OpenStruct.new(stdout: "bonnie++-1.96")
expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("bonnie++")
expect(@provider.current_installed_version).to eq("1.96")
@@ -252,7 +252,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("perl")
allow(@provider).to receive(:latest_link_name).and_return("perl")
- cmd = OpenStruct.new(:status => true)
+ cmd = OpenStruct.new(status: true)
expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd)
@provider.install_package("perl5.8", "5.8.8_1")
end
@@ -266,7 +266,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(@provider).to receive(:package_name).and_return("mysql-server")
allow(@provider).to receive(:latest_link_name).and_return("mysql50-server")
- cmd = OpenStruct.new(:status => true)
+ cmd = OpenStruct.new(status: true)
expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd)
@provider.install_package("mysql50-server", "5.0.45_1")
end
diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb
index 2fdcb87758..13e5dd17fd 100644
--- a/spec/unit/provider/package/freebsd/pkgng_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining current installed version" do
before(:each) do
allow(@provider).to receive(:supports_pkgng?)
- @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\nVersion : 3.1.7\n")
+ @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\nVersion : 3.1.7\n")
end
it "should query pkg database" do
@@ -74,14 +74,14 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining candidate version" do
it "should query repository" do
- pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0)
+ pkg_query = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
expect(@provider.candidate_version).to eq("5.0.5")
end
it "should query specified repository when given option" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0)
+ pkg_query = OpenStruct.new(stdout: "5.0.3\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "rquery", "-r", "LocalMirror", "%v", "zsh", env: nil, timeout: 900).and_return(pkg_query)
expect(@provider.candidate_version).to eq("5.0.3")
end
@@ -94,54 +94,54 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "installing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should handle package source from file" do
@provider.new_resource.source("/nas/pkg/repo/zsh-5.0.1.txz")
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "add", "/nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
- and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "add", "/nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900)
+ .and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle package source over ftp or http" do
@provider.new_resource.source("http://repo.example.com/zsh-5.0.1.txz")
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "add", "http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
- and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "add", "http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900)
+ .and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name" do
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "install", "-y", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "install", "-y", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name with a specified repo" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "install", "-y", "-r", "LocalMirror", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "install", "-y", "-r", "LocalMirror", "zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
end
describe "removing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should call pkg delete" do
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
@provider.remove_package("zsh", "5.0.1")
end
it "should not include repo option in pkg delete" do
@provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
- expect(@provider).to receive(:shell_out_compacted!).
- with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("pkg", "delete", "-y", "zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
@provider.remove_package("zsh", "5.0.1")
end
end
diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb
index 26a960dedc..af5216dc04 100644
--- a/spec/unit/provider/package/freebsd/port_spec.rb
+++ b/spec/unit/provider/package/freebsd/port_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining current installed version" do
before(:each) do
- @pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n")
+ @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\n")
end
it "should check 'pkg_info' if system uses pkg_* tools" do
@@ -73,7 +73,7 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do
- pkg_enabled = OpenStruct.new(:stdout => "yes\n")
+ pkg_enabled = OpenStruct.new(stdout: "yes\n")
[1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version|
@node.automatic_attrs[:os_version] = freebsd_version
expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
@@ -92,14 +92,14 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "determining candidate version" do
before(:each) do
- @port_version = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0)
+ @port_version = OpenStruct.new(stdout: "5.0.5\n", exitstatus: 0)
end
it "should return candidate version if port exists" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
- and_return(@port_version)
+ expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900)
+ .and_return(@port_version)
expect(@provider.candidate_version).to eq("5.0.5")
end
@@ -121,13 +121,13 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should query system for path given just a name" do
- whereis = OpenStruct.new(:stdout => "zsh: /usr/ports/shells/zsh\n")
+ whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh\n")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect(@provider.port_dir).to eq("/usr/ports/shells/zsh")
end
it "should raise exception if not found" do
- whereis = OpenStruct.new(:stdout => "zsh:\n")
+ whereis = OpenStruct.new(stdout: "zsh:\n")
expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis)
expect { @provider.port_dir }.to raise_error(Chef::Exceptions::Package, "Could not find port with the name zsh")
end
@@ -135,28 +135,28 @@ describe Chef::Provider::Package::Freebsd::Port do
describe "building a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run make install in port directory" do
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out_compacted!).
- with("make", "-DBATCH", "install", "clean", :timeout => 1800, :cwd => "/usr/ports/shells/zsh", :env => nil).
- and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("make", "-DBATCH", "install", "clean", timeout: 1800, cwd: "/usr/ports/shells/zsh", env: nil)
+ .and_return(@install_result)
@provider.install_package("zsh", "5.0.5")
end
end
describe "removing a binary package" do
before(:each) do
- @install_result = OpenStruct.new(:status => true)
+ @install_result = OpenStruct.new(status: true)
end
it "should run make deinstall in port directory" do
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out_compacted!).
- with("make", "deinstall", :timeout => 300, :cwd => "/usr/ports/shells/zsh", :env => nil).
- and_return(@install_result)
+ expect(@provider).to receive(:shell_out_compacted!)
+ .with("make", "deinstall", timeout: 300, cwd: "/usr/ports/shells/zsh", env: nil)
+ .and_return(@install_result)
@provider.remove_package("zsh", "5.0.5")
end
end
diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb
index 833fa7bd3e..903aebc93e 100644
--- a/spec/unit/provider/package/homebrew_spec.rb
+++ b/spec/unit/provider/package/homebrew_spec.rb
@@ -173,16 +173,16 @@ describe Chef::Provider::Package::Homebrew do
describe "brew" do
before do
expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid)
- expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/"))
+ expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(name: "name", dir: "/"))
end
it "passes a single to the brew command and return stdout" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo"))
expect(provider.brew).to eql("zombo")
end
it "takes multiple arguments as an array" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "homestarrunner"))
expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner")
end
@@ -190,7 +190,7 @@ describe Chef::Provider::Package::Homebrew do
let(:new_resource) { Chef::Resource::Package.new("emacs") }
it "does not try to read homebrew_user from Package, which does not have it" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: "zombo"))
expect(provider.brew).to eql("zombo")
end
end
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index eac0fd90f3..70e1c3fe32 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -35,31 +35,31 @@ describe Chef::Provider::Package::Ips do
def local_output
stdin = StringIO.new
stdout = ""
- stderr = <<-PKG_STATUS
-pkg: info: no packages matching the following patterns you specified are
-installed on the system. Try specifying -r to query remotely:
+ stderr = <<~PKG_STATUS
+ pkg: info: no packages matching the following patterns you specified are
+ installed on the system. Try specifying -r to query remotely:
- crypto/gnupg
+ crypto/gnupg
PKG_STATUS
- OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
+ OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 1)
end
def remote_output
- stdout = <<-PKG_STATUS
- Name: security/sudo
- Summary: sudo - authority delegation tool
- State: Not Installed
- Publisher: omnios
- Version: 1.8.4.1 (1.8.4p1)
- Build Release: 5.11
- Branch: 0.151002
-Packaging Date: April 1, 2012 05:55:52 PM
- Size: 2.57 MB
- FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
+ stdout = <<~PKG_STATUS
+ Name: security/sudo
+ Summary: sudo - authority delegation tool
+ State: Not Installed
+ Publisher: omnios
+ Version: 1.8.4.1 (1.8.4p1)
+ Build Release: 5.11
+ Branch: 0.151002
+ Packaging Date: April 1, 2012 05:55:52 PM
+ Size: 2.57 MB
+ FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
stdin = StringIO.new
stderr = ""
- OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
+ OpenStruct.new(stdout: stdout, stdin: stdin, stderr: stderr, status: @status, exitstatus: 0)
end
context "when loading current resource" do
@@ -92,20 +92,20 @@ PKG_STATUS
it "should set the installed version if package has one" do
local = local_output
- local.stdout = <<-INSTALLED
- Name: crypto/gnupg
- Summary: GNU Privacy Guard
- Description: A complete and free implementation of the OpenPGP Standard as
- defined by RFC4880.
- Category: Applications/System Utilities
- State: Installed
- Publisher: solaris
- Version: 2.0.17
- Build Release: 5.11
- Branch: 0.175.0.0.0.2.537
-Packaging Date: October 19, 2011 09:14:50 AM
- Size: 8.07 MB
- FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
+ local.stdout = <<~INSTALLED
+ Name: crypto/gnupg
+ Summary: GNU Privacy Guard
+ Description: A complete and free implementation of the OpenPGP Standard as
+ defined by RFC4880.
+ Category: Applications/System Utilities
+ State: Installed
+ Publisher: solaris
+ Version: 2.0.17
+ Build Release: 5.11
+ Branch: 0.175.0.0.0.2.537
+ Packaging Date: October 19, 2011 09:14:50 AM
+ Size: 8.07 MB
+ FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
INSTALLED
expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote_output)
@@ -140,17 +140,17 @@ INSTALLED
it "should not include the human-readable version in the candidate_version" do
remote = remote_output
- remote.stdout = <<-PKG_STATUS
- Name: security/sudo
- Summary: sudo - authority delegation tool
- State: Not Installed
- Publisher: omnios
- Version: 1.8.4.1 (1.8.4p1)
- Build Release: 5.11
- Branch: 0.151002
-Packaging Date: April 1, 2012 05:55:52 PM
- Size: 2.57 MB
- FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
+ remote.stdout = <<~PKG_STATUS
+ Name: security/sudo
+ Summary: sudo - authority delegation tool
+ State: Not Installed
+ Publisher: omnios
+ Version: 1.8.4.1 (1.8.4p1)
+ Build Release: 5.11
+ Branch: 0.151002
+ Packaging Date: April 1, 2012 05:55:52 PM
+ Size: 2.57 MB
+ FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local_output)
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "-r", @new_resource.package_name, timeout: 900).and_return(remote)
@@ -161,36 +161,36 @@ PKG_STATUS
it "should not upgrade the package if it is already installed" do
local = local_output
- local.stdout = <<-INSTALLED
- Name: crypto/gnupg
- Summary: GNU Privacy Guard
- Description: A complete and free implementation of the OpenPGP Standard as
- defined by RFC4880.
- Category: Applications/System Utilities
- State: Installed
- Publisher: solaris
- Version: 2.0.17
- Build Release: 5.11
- Branch: 0.175.0.0.0.2.537
-Packaging Date: October 19, 2011 09:14:50 AM
- Size: 8.07 MB
- FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
+ local.stdout = <<~INSTALLED
+ Name: crypto/gnupg
+ Summary: GNU Privacy Guard
+ Description: A complete and free implementation of the OpenPGP Standard as
+ defined by RFC4880.
+ Category: Applications/System Utilities
+ State: Installed
+ Publisher: solaris
+ Version: 2.0.17
+ Build Release: 5.11
+ Branch: 0.175.0.0.0.2.537
+ Packaging Date: October 19, 2011 09:14:50 AM
+ Size: 8.07 MB
+ FMRI: pkg://solaris/crypto/gnupg@2.0.17,5.11-0.175.0.0.0.2.537:20111019T091450Z
INSTALLED
remote = remote_output
- remote.stdout = <<-REMOTE
- Name: crypto/gnupg
- Summary: GNU Privacy Guard
- Description: A complete and free implementation of the OpenPGP Standard as
- defined by RFC4880.
- Category: Applications/System Utilities
- State: Not Installed
- Publisher: solaris
- Version: 2.0.18
- Build Release: 5.11
- Branch: 0.175.0.0.0.2.537
-Packaging Date: October 19, 2011 09:14:50 AM
- Size: 8.07 MB
- FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z
+ remote.stdout = <<~REMOTE
+ Name: crypto/gnupg
+ Summary: GNU Privacy Guard
+ Description: A complete and free implementation of the OpenPGP Standard as
+ defined by RFC4880.
+ Category: Applications/System Utilities
+ State: Not Installed
+ Publisher: solaris
+ Version: 2.0.18
+ Build Release: 5.11
+ Branch: 0.175.0.0.0.2.537
+ Packaging Date: October 19, 2011 09:14:50 AM
+ Size: 8.07 MB
+ FMRI: pkg://solaris/crypto/gnupg@2.0.18,5.11-0.175.0.0.0.2.537:20111019T091450Z
REMOTE
expect(@provider).to receive(:shell_out_compacted).with("pkg", "info", @new_resource.package_name, timeout: 900).and_return(local)
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index 04e0a9177e..8b75e40d72 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -70,18 +70,18 @@ describe Chef::Provider::Package::Macports do
describe "current_installed_version" do
it "should return the current version if the package is installed" do
- stdout = <<EOF
-The following ports are currently installed:
- openssl @0.9.8k_0 (active)
+ stdout = <<~EOF
+ The following ports are currently installed:
+ openssl @0.9.8k_0 (active)
EOF
- status = double(:stdout => stdout, :exitstatus => 0)
+ status = double(stdout: stdout, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.current_installed_version).to eq("0.9.8k_0")
end
it "should return nil if a package is not currently installed" do
- status = double(:stdout => " \n", :exitstatus => 0)
+ status = double(stdout: " \n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.current_installed_version).to be_nil
end
@@ -89,13 +89,13 @@ EOF
describe "macports_candidate_version" do
it "should return the latest available version of a given package" do
- status = double(:stdout => "version: 4.2.7\n", :exitstatus => 0)
+ status = double(stdout: "version: 4.2.7\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.macports_candidate_version).to eq("4.2.7")
end
it "should return nil if there is no version for a given package" do
- status = double(:stdout => "Error: port fadsfadsfads not found\n", :exitstatus => 0)
+ status = double(stdout: "Error: port fadsfadsfads not found\n", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.macports_candidate_version).to be_nil
end
diff --git a/spec/unit/provider/package/msu_spec.rb b/spec/unit/provider/package/msu_spec.rb
index de805fcb39..b2f0b22963 100644
--- a/spec/unit/provider/package/msu_spec.rb
+++ b/spec/unit/provider/package/msu_spec.rb
@@ -31,66 +31,66 @@ describe Chef::Provider::Package::Msu, :windows_only do
end
let(:installed_package_list_stdout) do
- <<-EOF
-Packages listing:
-Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
-Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
+ <<~EOF
+ Packages listing:
+ Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
+ Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
EOF
end
let(:package_version_stdout) do
- <<-EOF
-Package information:
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-State : Installed
-Dependency : Language Pack
-The operation completed successfully
+ <<~EOF
+ Package information:
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ State : Installed
+ Dependency : Language Pack
+ The operation completed successfully
EOF
end
let(:get_package_info_stdout) do
- <<-EOF
-Deployment Image Servicing and Management tool
-Version: 6.1.7600.16385
-
-Image Version: 6.1.7600.16385
-
-Package information:
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-Applicable : Yes
-Copyright : Microsoft Corporation
-Company : Microsoft Corporation
-State : Installed
-Dependency : Language Pack
-The operation completed successfully
+ <<~EOF
+ Deployment Image Servicing and Management tool
+ Version: 6.1.7600.16385
+
+ Image Version: 6.1.7600.16385
+
+ Package information:
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ Applicable : Yes
+ Copyright : Microsoft Corporation
+ Company : Microsoft Corporation
+ State : Installed
+ Dependency : Language Pack
+ The operation completed successfully
EOF
end
def allow_get_packages
- get_packages_stdout = <<-EOF
-Deployment Image Servicing and Management tool
-Version: 6.1.7600.16385
+ get_packages_stdout = <<~EOF
+ Deployment Image Servicing and Management tool
+ Version: 6.1.7600.16385
-Image Version: 6.1.7600.16385
+ Image Version: 6.1.7600.16385
-Packages listing:
+ Packages listing:
-Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
-State : Installed
-Release Type : Language Pack
-Install Time : 2/11/2015 11:33 PM
+ Package Identity : Package_for_KB2999486~31bf3856ad364e35~amd64~~6.1.9768.0
+ State : Installed
+ Release Type : Language Pack
+ Install Time : 2/11/2015 11:33 PM
-Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
-State : Installed
-Release Type : Language Pack
-Install Time : 2/11/2015 11:33 PM
+ Package Identity : Package_for_KB2994825~31bf3856ad364e35~amd64~~6.1.7601.0
+ State : Installed
+ Release Type : Language Pack
+ Install Time : 2/11/2015 11:33 PM
-Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
-State : Installed
-Release Type : Feature Pack
-Install Time : 11/21/2010 3:40 AM
+ Package Identity : Package_for_KB2664825~31bf3856ad364e35~amd64~~6.1.3.0
+ State : Installed
+ Release Type : Feature Pack
+ Install Time : 11/21/2010 3:40 AM
-The operation completed successfully.
+ The operation completed successfully.
EOF
get_packages_obj = double(stdout: get_packages_stdout)
allow_any_instance_of(Chef::Provider::Package::Cab).to receive(:dism_command).with("/Get-Packages").and_return(get_packages_obj)
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 07950acf6e..01d6571f65 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Provider::Package::Openbsd do
context "when not already installed" do
before do
- allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
+ allow(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{name}->0", anything()).and_return(instance_double("shellout", stdout: ""))
end
context "when there is a single candidate" do
@@ -53,11 +53,11 @@ describe Chef::Provider::Package::Openbsd do
context "when source is not provided" do
it "should run the installation command" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}\n"))
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}",
- { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -70,7 +70,7 @@ describe Chef::Provider::Package::Openbsd do
context "if no version is specified" do
it "should raise an exception" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
end
end
@@ -83,13 +83,13 @@ describe Chef::Provider::Package::Openbsd do
context "if no version is specified" do
it "should run the installation command" do
- expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", :stdout => ""))
+ expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-e", "#{package_name}->0", anything()).and_return(instance_double("shellout", stdout: ""))
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n"))
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}-#{flavor}",
{ env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -99,13 +99,13 @@ describe Chef::Provider::Package::Openbsd do
context "if a version is specified" do
it "should use the flavor from the version" do
expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", "#{name}-#{version}-#{flavor_b}", anything()).and_return(
- instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n"))
+ instance_double("shellout", stdout: "#{name}-#{version}-#{flavor_a}\n"))
new_resource.version("#{version}-#{flavor_b}")
expect(provider).to receive(:shell_out_compacted!).with(
"pkg_add", "-r", "#{name}-#{version}-#{flavor_b}",
{ env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
provider.run_action(:install)
end
end
@@ -124,7 +124,7 @@ describe Chef::Provider::Package::Openbsd do
it "should run the command to delete the installed package" do
expect(@provider).to receive(:shell_out_compacted!).with(
"pkg_delete", @name, env: nil, timeout: 900
- ) { OpenStruct.new :status => true }
+ ) { OpenStruct.new status: true }
@provider.remove_package(@name, nil)
end
end
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index d41df8c24b..10bb3492b2 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -26,14 +26,14 @@ describe Chef::Provider::Package::Pacman do
@new_resource = Chef::Resource::Package.new("nano")
@current_resource = Chef::Resource::Package.new("nano")
- @status = double(:stdout => "", :exitstatus => 0)
+ @status = double(stdout: "", exitstatus: 0)
@provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
allow(@provider).to receive(:shell_out_compacted).and_return(@status)
@stdin = StringIO.new
- @stdout = StringIO.new(<<-ERR)
-error: package "nano" not found
+ @stdout = StringIO.new(<<~ERR)
+ error: package "nano" not found
ERR
@stderr = StringIO.new
@pid = 2342
@@ -66,61 +66,61 @@ ERR
end
it "should set the installed version if pacman has one" do
- stdout = <<-PACMAN
-Name : nano
-Version : 2.2.2-1
-URL : http://www.nano-editor.org
-Licenses : GPL
-Groups : base
-Provides : None
-Depends On : glibc ncurses
-Optional Deps : None
-Required By : None
-Conflicts With : None
-Replaces : None
-Installed Size : 1496.00 K
-Packager : Andreas Radke <andyrtr@archlinux.org>
-Architecture : i686
-Build Date : Mon 18 Jan 2010 06:16:16 PM CET
-Install Date : Mon 01 Feb 2010 10:06:30 PM CET
-Install Reason : Explicitly installed
-Install Script : Yes
-Description : Pico editor clone with enhancements
+ stdout = <<~PACMAN
+ Name : nano
+ Version : 2.2.2-1
+ URL : http://www.nano-editor.org
+ Licenses : GPL
+ Groups : base
+ Provides : None
+ Depends On : glibc ncurses
+ Optional Deps : None
+ Required By : None
+ Conflicts With : None
+ Replaces : None
+ Installed Size : 1496.00 K
+ Packager : Andreas Radke <andyrtr@archlinux.org>
+ Architecture : i686
+ Build Date : Mon 18 Jan 2010 06:16:16 PM CET
+ Install Date : Mon 01 Feb 2010 10:06:30 PM CET
+ Install Reason : Explicitly installed
+ Install Script : Yes
+ Description : Pico editor clone with enhancements
PACMAN
- status = double(:stdout => stdout, :exitstatus => 0)
+ status = double(stdout: stdout, exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@current_resource.version).to eq("2.2.2-1")
end
it "should set the candidate version if pacman has one" do
- status = double(:stdout => "core nano 2.2.3-1", :exitstatus => 0)
+ status = double(stdout: "core nano 2.2.3-1", exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
@provider.load_current_resource
expect(@provider.candidate_version).to eql("2.2.3-1")
end
it "should use pacman.conf to determine valid repo names for package versions" do
- @pacman_conf = <<-PACMAN_CONF
-[options]
-HoldPkg = pacman glibc
-Architecture = auto
+ @pacman_conf = <<~PACMAN_CONF
+ [options]
+ HoldPkg = pacman glibc
+ Architecture = auto
-[customrepo]
-Server = https://my.custom.repo
+ [customrepo]
+ Server = https://my.custom.repo
-[core]
-Include = /etc/pacman.d/mirrorlist
+ [core]
+ Include = /etc/pacman.d/mirrorlist
-[extra]
-Include = /etc/pacman.d/mirrorlist
+ [extra]
+ Include = /etc/pacman.d/mirrorlist
-[community]
-Include = /etc/pacman.d/mirrorlist
+ [community]
+ Include = /etc/pacman.d/mirrorlist
PACMAN_CONF
- status = double(:stdout => "customrepo nano 1.2.3-4", :exitstatus => 0)
+ status = double(stdout: "customrepo nano 1.2.3-4", exitstatus: 0)
allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true)
allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb
index 5481a33c0d..10c0d0f7e8 100644
--- a/spec/unit/provider/package/paludis_spec.rb
+++ b/spec/unit/provider/package/paludis_spec.rb
@@ -33,16 +33,16 @@ describe Chef::Provider::Package::Paludis do
@stdin = StringIO.new
@stderr = StringIO.new
- @stdout = <<-PKG_STATUS
-group/ntp 0 accounts
-group/ntp 0 installed-accounts
-net/ntp 4.2.6_p5-r2 arbor
-user/ntp 0 accounts
-user/ntp 0 installed-accounts
-net/ntp 4.2.6_p5-r1 installed
+ @stdout = <<~PKG_STATUS
+ group/ntp 0 accounts
+ group/ntp 0 installed-accounts
+ net/ntp 4.2.6_p5-r2 arbor
+ user/ntp 0 accounts
+ user/ntp 0 installed-accounts
+ net/ntp 4.2.6_p5-r1 installed
PKG_STATUS
@pid = 12345
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
end
context "when loading current resource" do
@@ -64,13 +64,13 @@ PKG_STATUS
end
it "should return new version if package is installed" do
- @stdout.replace(<<-INSTALLED)
-group/ntp 0 accounts
-group/ntp 0 installed-accounts
-net/ntp 4.2.6_p5-r2 arbor
-user/ntp 0 accounts
-user/ntp 0 installed-accounts
-net/ntp 4.2.6_p5-r1 installed
+ @stdout.replace(<<~INSTALLED)
+ group/ntp 0 accounts
+ group/ntp 0 installed-accounts
+ net/ntp 4.2.6_p5-r2 arbor
+ user/ntp 0 accounts
+ user/ntp 0 installed-accounts
+ net/ntp 4.2.6_p5-r1 installed
INSTALLED
expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
@@ -86,29 +86,29 @@ INSTALLED
context "when installing a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
it "should run pkg install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "--preserve-world", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@new_resource.options "--preserve-world"
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
it "should not contain invalid characters for the version string" do
- @stdout.replace(<<-PKG_STATUS)
-sys-process/lsof 4.87 arbor
-sys-process/lsof 4.87 x86_64
+ @stdout.replace(<<~PKG_STATUS)
+ sys-process/lsof 4.87 arbor
+ sys-process/lsof 4.87 x86_64
PKG_STATUS
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=sys-process/lsof-4.87", { timeout: @new_resource.timeout || 900 })
@provider.install_package("sys-process/lsof", "4.87")
end
it "should not include the human-readable version in the candidate_version" do
- @stdout.replace(<<-PKG_STATUS)
-sys-process/lsof 4.87 arbor
-sys-process/lsof 4.87 x86_64
+ @stdout.replace(<<~PKG_STATUS)
+ sys-process/lsof 4.87 arbor
+ sys-process/lsof 4.87 x86_64
PKG_STATUS
expect(@provider).to receive(:shell_out_compacted!).and_return(@shell_out)
@provider.load_current_resource
@@ -119,7 +119,7 @@ PKG_STATUS
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { :timeout => @new_resource.timeout || 900 })
+ expect(@provider).to receive(:shell_out_compacted!).with("cave", "-L", "warning", "resolve", "-x", "=net/ntp-4.2.6_p5-r2", { timeout: @new_resource.timeout || 900 })
@provider.upgrade_package("net/ntp", "4.2.6_p5-r2")
end
end
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index 7bf8e7f2e8..e1036bea74 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -113,33 +113,33 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
end
it "should throw an exception if the exitstatus is not 0" do
- status = double(:stdout => "", :stderr => "", :exitstatus => 1)
+ status = double(stdout: "", stderr: "", exitstatus: 1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
it "should find the candidate_version if a category is specifed and there are no duplicates" do
- status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0)
+ status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.candidate_version).to eq("2.16.2")
end
it "should find the candidate_version if a category is not specifed and there are no duplicates" do
- status = double(:stdout => "dev-vcs/git-2.16.2", :exitstatus => 0)
+ status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider.candidate_version).to eq("2.16.2")
end
it "should throw an exception if a category is not specified and there are duplicates" do
- stderr_output = <<EOF
-You specified an unqualified atom that matched multiple packages:
-* app-misc/sphinx
-* dev-python/sphinx
+ stderr_output = <<~EOF
+ You specified an unqualified atom that matched multiple packages:
+ * app-misc/sphinx
+ * dev-python/sphinx
-Please use a more specific atom.
+ Please use a more specific atom.
EOF
- status = double(:stdout => "", :stderr => stderr_output, :exitstatus => 1)
+ status = double(stdout: "", stderr: stderr_output, exitstatus: 1)
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
expect(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb
index 63f611ac23..c7a16acaa2 100644
--- a/spec/unit/provider/package/powershell_spec.rb
+++ b/spec/unit/provider/package/powershell_spec.rb
@@ -34,63 +34,63 @@ describe Chef::Provider::Package::Powershell do
end
let(:package_xcertificate_installed) do
- double("powershell_out", :stdout => "2.1.0.0\r\n")
+ double("powershell_out", stdout: "2.1.0.0\r\n")
end
let(:package_xcertificate_installed_2_0_0_0) do
- double("powershell_out", :stdout => "2.0.0.0\r\n")
+ double("powershell_out", stdout: "2.0.0.0\r\n")
end
let(:package_xcertificate_available) do
- double("powershell_out", :stdout => "2.1.0.0\r\n")
+ double("powershell_out", stdout: "2.1.0.0\r\n")
end
let(:package_xcertificate_available_2_0_0_0) do
- double("powershell_out", :stdout => "2.0.0.0\r\n")
+ double("powershell_out", stdout: "2.0.0.0\r\n")
end
let(:package_xcertificate_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xcertificate_not_available) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xnetworking_installed) do
- double("powershell_out", :stdout => "2.12.0.0\r\n")
+ double("powershell_out", stdout: "2.12.0.0\r\n")
end
let(:package_xnetworking_installed_2_11_0_0) do
- double("powershell_out", :stdout => "2.11.0.0\r\n")
+ double("powershell_out", stdout: "2.11.0.0\r\n")
end
let(:package_xnetworking_available) do
- double("powershell_out", :stdout => "2.12.0.0\r\n")
+ double("powershell_out", stdout: "2.12.0.0\r\n")
end
let(:package_xnetworking_available_2_11_0_0) do
- double("powershell_out", :stdout => "2.11.0.0\r\n")
+ double("powershell_out", stdout: "2.11.0.0\r\n")
end
let(:package_xnetworking_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_xnetworking_not_available) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:package_7zip_available) do
- double("powershell_out", :stdout => "16.02\r\n")
+ double("powershell_out", stdout: "16.02\r\n")
end
let(:package_7zip_not_installed) do
- double("powershell_out", :stdout => "")
+ double("powershell_out", stdout: "")
end
let(:powershell_installed_version) do
- double("powershell_out", :stdout => "5")
+ double("powershell_out", stdout: "5")
end
let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" }
@@ -116,14 +116,14 @@ describe Chef::Provider::Package::Powershell do
describe "#candidate_version" do
it "should set the candidate_version to the latest version when not pinning" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(["xNetworking"])
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.12.0.0"])
end
it "should use the candidate_version from the correct source" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(["xNetworking"])
new_resource.version(nil)
new_resource.source("MyGallery")
@@ -131,60 +131,60 @@ describe Chef::Provider::Package::Powershell do
end
it "should set the candidate_version to the latest version when not pinning and package name is space seperated" do
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
new_resource.package_name(["7-Zip 16.02 (x64)"])
new_resource.version(nil)
expect(provider.candidate_version).to eql(["16.02"])
end
it "should set the candidate_version to pinned version if available" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
new_resource.package_name(["xCertificate"])
new_resource.version(["2.0.0.0"])
expect(provider.candidate_version).to eql(["2.0.0.0"])
end
it "should set the candidate_version to nil if there is no candidate" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
new_resource.package_name(["xCertificate"])
expect(provider.candidate_version).to eql([nil])
end
it "should set the candidate_version correctly when there are two packages to install" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
end
it "should set the candidate_version correctly when only the first is installable" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql(["2.1.0.0", nil])
end
it "should set the candidate_version correctly when only the last is installable" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
end
it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xNetworking xCertificate})
new_resource.version([nil, nil])
expect(provider.candidate_version).to eql([nil, nil])
end
it "should set the candidate_version correctly when neither are is installable and version is not passed" do
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
new_resource.package_name(%w{xNetworking xCertificate})
new_resource.version(nil)
expect(provider.candidate_version).to eql([nil, nil])
@@ -283,10 +283,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -296,10 +296,10 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -309,10 +309,10 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
new_resource.skip_publisher_check(true)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -321,10 +321,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["7-Zip 16.02 (x64)"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_7zip_not_installed)
+ allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -336,10 +336,10 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -348,8 +348,8 @@ describe Chef::Provider::Package::Powershell do
it "should not install packages that are up-to-date" do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:install_package)
@@ -360,8 +360,8 @@ describe Chef::Provider::Package::Powershell do
it "should not install packages that are up-to-date" do
new_resource.package_name(["xNetworking"])
new_resource.version(["2.11.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:install_package)
@@ -374,13 +374,13 @@ describe Chef::Provider::Package::Powershell do
# new_version.resource[0]
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version([nil, "2.11.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -389,13 +389,13 @@ describe Chef::Provider::Package::Powershell do
it "should split up commands when given two packages, one with a version pin" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(["2.1.0.0", nil])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
@@ -405,13 +405,13 @@ describe Chef::Provider::Package::Powershell do
it "should do multipackage installs when given two packages without constraints" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -421,13 +421,13 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
- expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
provider.load_current_resource
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -439,8 +439,8 @@ describe Chef::Provider::Package::Powershell do
provider.load_current_resource
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
expect(provider).not_to receive(:remove_package)
provider.run_action(:remove)
@@ -451,11 +451,11 @@ describe Chef::Provider::Package::Powershell do
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
new_resource.source("MyGallery")
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -463,10 +463,10 @@ describe Chef::Provider::Package::Powershell do
it "does nothing when all the packages are already removed" do
new_resource.package_name(%w{xCertificate xNetworking})
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xnetworking_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
expect(provider).not_to receive(:remove_package)
@@ -477,11 +477,11 @@ describe Chef::Provider::Package::Powershell do
it "removes a package when version is specified" do
new_resource.package_name(["xCertificate"])
new_resource.version(["2.1.0.0"])
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { :timeout => new_resource.timeout })
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -489,11 +489,11 @@ describe Chef::Provider::Package::Powershell do
it "removes a package when version is not specified" do
new_resource.package_name(["xCertificate"])
new_resource.version(nil)
- allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
- allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
+ allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
provider.load_current_resource
- expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available)
+ expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index 91d4ca69b4..3682043dcd 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -85,13 +85,13 @@ describe Chef::Provider::Package::Rpm do
describe "when the package source is valid" do
before do
- expect(provider).to receive(:shell_out_compacted!).
- with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900).
- and_return(rpm_qp_status)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_source, timeout: 900)
+ .and_return(rpm_qp_status)
- expect(provider).to receive(:shell_out_compacted).
- with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900).
- and_return(rpm_q_status)
+ expect(provider).to receive(:shell_out_compacted)
+ .with("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", package_name, timeout: 900)
+ .and_return(rpm_q_status)
end
context "when rpm fails when querying package installed state" do
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 3b1a13e49c..6b33ab97f9 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -253,32 +253,32 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
end
it "detects when the target gem environment is the jruby platform" do
- gem_env_out = <<-JRUBY_GEM_ENV
-RubyGems Environment:
- - RUBYGEMS VERSION: 1.3.6
- - RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java]
- - INSTALLATION DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0
- - RUBY EXECUTABLE: /Users/you/.rvm/rubies/jruby-1.5.0/bin/jruby
- - EXECUTABLE DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0/bin
- - RUBYGEMS PLATFORMS:
- - ruby
- - universal-java-1.6
- - GEM PATHS:
- - /Users/you/.rvm/gems/jruby-1.5.0
- - /Users/you/.rvm/gems/jruby-1.5.0@global
- - GEM CONFIGURATION:
- - :update_sources => true
- - :verbose => true
- - :benchmark => false
- - :backtrace => false
- - :bulk_threshold => 1000
- - "install" => "--env-shebang"
- - "update" => "--env-shebang"
- - "gem" => "--no-rdoc --no-ri"
- - :sources => ["https://rubygems.org/", "http://gems.github.com/"]
- - REMOTE SOURCES:
- - https://rubygems.org/
- - http://gems.github.com/
+ gem_env_out = <<~JRUBY_GEM_ENV
+ RubyGems Environment:
+ - RUBYGEMS VERSION: 1.3.6
+ - RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java]
+ - INSTALLATION DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0
+ - RUBY EXECUTABLE: /Users/you/.rvm/rubies/jruby-1.5.0/bin/jruby
+ - EXECUTABLE DIRECTORY: /Users/you/.rvm/gems/jruby-1.5.0/bin
+ - RUBYGEMS PLATFORMS:
+ - ruby
+ - universal-java-1.6
+ - GEM PATHS:
+ - /Users/you/.rvm/gems/jruby-1.5.0
+ - /Users/you/.rvm/gems/jruby-1.5.0@global
+ - GEM CONFIGURATION:
+ - :update_sources => true
+ - :verbose => true
+ - :benchmark => false
+ - :backtrace => false
+ - :bulk_threshold => 1000
+ - "install" => "--env-shebang"
+ - "update" => "--env-shebang"
+ - "gem" => "--no-rdoc --no-ri"
+ - :sources => ["https://rubygems.org/", "http://gems.github.com/"]
+ - REMOTE SOURCES:
+ - https://rubygems.org/
+ - http://gems.github.com/
JRUBY_GEM_ENV
expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", stdout: gem_env_out))
expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
@@ -295,32 +295,32 @@ RubyGems Environment:
end
it "uses the current gem platforms when the target env is not jruby" do
- gem_env_out = <<-RBX_GEM_ENV
-RubyGems Environment:
- - RUBYGEMS VERSION: 1.3.6
- - RUBY VERSION: 1.8.7 (2010-05-14 patchlevel 174) [x86_64-apple-darwin10.3.0]
- - INSTALLATION DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514
- - RUBYGEMS PREFIX: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514
- - RUBY EXECUTABLE: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514/bin/rbx
- - EXECUTABLE DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514/bin
- - RUBYGEMS PLATFORMS:
- - ruby
- - x86_64-darwin-10
- - x86_64-rubinius-1.0
- - GEM PATHS:
- - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514
- - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514@global
- - GEM CONFIGURATION:
- - :update_sources => true
- - :verbose => true
- - :benchmark => false
- - :backtrace => false
- - :bulk_threshold => 1000
- - :sources => ["https://rubygems.org/", "http://gems.github.com/"]
- - "gem" => "--no-rdoc --no-ri"
- - REMOTE SOURCES:
- - https://rubygems.org/
- - http://gems.github.com/
+ gem_env_out = <<~RBX_GEM_ENV
+ RubyGems Environment:
+ - RUBYGEMS VERSION: 1.3.6
+ - RUBY VERSION: 1.8.7 (2010-05-14 patchlevel 174) [x86_64-apple-darwin10.3.0]
+ - INSTALLATION DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514
+ - RUBYGEMS PREFIX: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514
+ - RUBY EXECUTABLE: /Users/ddeleo/.rvm/rubies/rbx-1.0.0-20100514/bin/rbx
+ - EXECUTABLE DIRECTORY: /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514/bin
+ - RUBYGEMS PLATFORMS:
+ - ruby
+ - x86_64-darwin-10
+ - x86_64-rubinius-1.0
+ - GEM PATHS:
+ - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514
+ - /Users/ddeleo/.rvm/gems/rbx-1.0.0-20100514@global
+ - GEM CONFIGURATION:
+ - :update_sources => true
+ - :verbose => true
+ - :benchmark => false
+ - :backtrace => false
+ - :bulk_threshold => 1000
+ - :sources => ["https://rubygems.org/", "http://gems.github.com/"]
+ - "gem" => "--no-rdoc --no-ri"
+ - REMOTE SOURCES:
+ - https://rubygems.org/
+ - http://gems.github.com/
RBX_GEM_ENV
expect(@gem_env).to receive(:shell_out_compacted!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", stdout: gem_env_out))
expect(@gem_env.gem_platforms).to eq(Gem.platforms)
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index cb5e987a85..cd85e1b3d9 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -28,14 +28,14 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
@new_resource = Chef::Resource::Package.new("varnish")
@current_resource = Chef::Resource::Package.new("varnish")
- @status = double("Status", :exitstatus => 0)
+ @status = double("Status", exitstatus: 0)
@provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@stdin = StringIO.new
@stdout = "varnish-2.1.5nb2\n"
@stderr = StringIO.new
@pid = 10
- @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
+ @shell_out = OpenStruct.new(stdout: @stdout, stdin: @stdin, stderr: @stderr, status: @status, exitstatus: 0)
end
describe "when loading current resource" do
@@ -59,7 +59,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
end
it "should set the installed version to nil if it's not installed" do
- out = OpenStruct.new(:stdout => nil)
+ out = OpenStruct.new(stdout: nil)
expect(@provider).to receive(:shell_out_compacted!).and_return(out)
@provider.load_current_resource
expect(@current_resource.version).to eq(nil)
@@ -76,21 +76,21 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
it "should lookup the candidate_version if the variable is not already set (pkgin separated by spaces)" do
search = double()
- expect(search).to receive(:each_line).
- and_yield("something-varnish-1.1.1 something varnish like\n").
- and_yield("varnish-2.3.4 actual varnish\n")
- @shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ expect(search).to receive(:each_line)
+ .and_yield("something-varnish-1.1.1 something varnish like\n")
+ .and_yield("varnish-2.3.4 actual varnish\n")
+ @shell_out = double("shell_out!", stdout: search)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
it "should lookup the candidate_version if the variable is not already set (pkgin separated by semicolons)" do
search = double()
- expect(search).to receive(:each_line).
- and_yield("something-varnish-1.1.1;;something varnish like\n").
- and_yield("varnish-2.3.4;;actual varnish\n")
- @shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
+ expect(search).to receive(:each_line)
+ .and_yield("something-varnish-1.1.1;;something varnish like\n")
+ .and_yield("varnish-2.3.4;;actual varnish\n")
+ @shell_out = double("shell_out!", stdout: search)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "se", "varnish", env: nil, returns: [0, 1], timeout: 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
end
@@ -98,9 +98,9 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
describe "when manipulating a resource" do
it "run pkgin and install the package" do
- out = OpenStruct.new(:stdout => nil)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out)
- expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out)
+ out = OpenStruct.new(stdout: nil)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { env: nil, returns: [0, 1], timeout: 900 }).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out_compacted!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { env: nil, timeout: 900 }).and_return(out)
@provider.load_current_resource
@provider.install_package("varnish", "2.1.5nb2")
end
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index 57a0288f58..2aa37fe8b3 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -32,21 +32,21 @@ describe Chef::Provider::Package::Solaris do
describe "assessing the current package status" do
before do
- @pkginfo = <<-PKGINFO
-PKGINST: SUNWbash
-NAME: GNU Bourne-Again shell (bash)
-CATEGORY: system
-ARCH: sparc
-VERSION: 11.10.0,REV=2005.01.08.05.16
-BASEDIR: /
-VENDOR: Sun Microsystems, Inc.
-DESC: GNU Bourne-Again shell (bash) version 3.0
-PSTAMP: sfw10-patch20070430084444
-INSTDATE: Nov 04 2009 01:02
-HOTLINE: Please contact your local service provider
+ @pkginfo = <<~PKGINFO
+ PKGINST: SUNWbash
+ NAME: GNU Bourne-Again shell (bash)
+ CATEGORY: system
+ ARCH: sparc
+ VERSION: 11.10.0,REV=2005.01.08.05.16
+ BASEDIR: /
+ VENDOR: Sun Microsystems, Inc.
+ DESC: GNU Bourne-Again shell (bash) version 3.0
+ PSTAMP: sfw10-patch20070430084444
+ INSTDATE: Nov 04 2009 01:02
+ HOTLINE: Please contact your local service provider
PKGINFO
- @status = double("Status", :stdout => "", :exitstatus => 0)
+ @status = double("Status", stdout: "", exitstatus: 0)
end
it "should create a current resource with the name of new_resource" do
@@ -70,7 +70,7 @@ PKGINFO
end
it "should get the source package version from pkginfo if provided" do
- status = double(:stdout => @pkginfo, :exitstatus => 0)
+ status = double(stdout: @pkginfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(status)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(@status)
@provider.load_current_resource
@@ -80,7 +80,7 @@ PKGINFO
end
it "should return the current version installed if found by pkginfo" do
- status = double(:stdout => @pkginfo, :exitstatus => 0)
+ status = double(stdout: @pkginfo, exitstatus: 0)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "-d", "/tmp/bash.pkg", "SUNWbash", { timeout: 900 }).and_return(@status)
expect(@provider).to receive(:shell_out_compacted).with("pkginfo", "-l", "SUNWbash", { timeout: 900 }).and_return(status)
@provider.load_current_resource
@@ -95,7 +95,7 @@ PKGINFO
end
it "should raise an exception if pkginfo fails to run" do
- status = double(:stdout => "", :exitstatus => -1)
+ status = double(stdout: "", exitstatus: -1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
end
@@ -116,14 +116,14 @@ PKGINFO
end
it "should lookup the candidate_version if the variable is not already set" do
- status = double(:stdout => "", :exitstatus => 0)
+ status = double(stdout: "", exitstatus: 0)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect(@provider).to receive(:shell_out_compacted)
@provider.candidate_version
end
it "should throw and exception if the exitstatus is not 0" do
- status = double(:stdout => "", :exitstatus => 1)
+ status = double(stdout: "", exitstatus: 1)
allow(@provider).to receive(:shell_out_compacted).and_return(status)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
end
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index f18cbf3dca..f8c4e83fc5 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do
it "removes installed package and quotes uninstall string" do
new_resource.timeout = 300
allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true)
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, :timeout => 300, :returns => [0])
+ expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, timeout: 300, returns: [0])
provider.remove_package
end
end
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index aa528ab90e..0e939610db 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows::MSI do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events) }
let(:package_name) { "calculator" }
let(:resource_source) { "calculator.msi" }
let(:resource_version) { nil }
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index aed0ca88be..3030b7f04a 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
before(:each) do
allow(Chef::Util::PathHelper).to receive(:validate_path)
allow(provider).to receive(:package_provider).and_return(double("package_provider",
- :installed_version => "1.0", :package_version => "2.0"))
+ installed_version: "1.0", package_version: "2.0"))
end
it "creates a current resource with the name of the new resource" do
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 4ba8ac36ac..6795f9e051 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Package::Zypper do
Chef::Provider::Package::Zypper.new(new_resource, run_context)
end
- let(:status) { double(:stdout => "\n", :exitstatus => 0) }
+ let(:status) { double(stdout: "\n", exitstatus: 0) }
before(:each) do
allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
@@ -73,7 +73,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version < 1.13.0)" do
- status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0)
+ status = double(stdout: "Version: 1.0\nInstalled: Yes\n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -81,7 +81,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version >= 1.13.0)" do
- status = double(:stdout => "Version : 1.0 \nInstalled : Yes \n", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0 \nInstalled : Yes \n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -89,7 +89,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the installed version if zypper info has one (zypper version >= 1.13.17)" do
- status = double(:stdout => "Version : 1.0\nInstalled : Yes (automatically)\n", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0\nInstalled : Yes (automatically)\n", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
@@ -97,7 +97,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do
- status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0)
+ status = double(stdout: "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
@@ -105,7 +105,7 @@ describe Chef::Provider::Package::Zypper do
end
it "should set the candidate version if zypper info has one (zypper version >= 1.13.0)" do
- status = double(:stdout => "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", :exitstatus => 0)
+ status = double(stdout: "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", exitstatus: 0)
allow(provider).to receive(:shell_out_compacted!).and_return(status)
provider.load_current_resource
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index f4663861c6..79d84e61dc 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
if ! powershell_version.nil?
- node.default[:languages] = { :powershell => { :version => powershell_version } }
+ node.default[:languages] = { powershell: { version: powershell_version } }
end
node
end
diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb
index 096fe9b9ed..3563af4dc4 100644
--- a/spec/unit/provider/registry_key_spec.rb
+++ b/spec/unit/provider/registry_key_spec.rb
@@ -275,20 +275,20 @@ describe Chef::Provider::RegistryKey do
context "when the key data is safe" do
let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' }
- let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
- let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
- let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
- let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
+ let(:testval1) { { name: "one", type: :string, data: "1" } }
+ let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } }
+ let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } }
+ let(:testval2) { { name: "two", type: :string, data: "2" } }
it_should_behave_like "a registry key"
end
context "when the key data is unsafe" do
let(:keyname) { 'HKLM\Software\Opscode\Testing\Unsafe' }
- let(:testval1) { { :name => "one", :type => :binary, :data => 255.chr * 1 } }
- let(:testval1_wrong_type) { { :name => "one", :type => :string, :data => 255.chr * 1 } }
- let(:testval1_wrong_data) { { :name => "one", :type => :binary, :data => 254.chr * 1 } }
- let(:testval2) { { :name => "two", :type => :binary, :data => 0.chr * 1 } }
+ let(:testval1) { { name: "one", type: :binary, data: 255.chr * 1 } }
+ let(:testval1_wrong_type) { { name: "one", type: :string, data: 255.chr * 1 } }
+ let(:testval1_wrong_data) { { name: "one", type: :binary, data: 254.chr * 1 } }
+ let(:testval2) { { name: "two", type: :binary, data: 0.chr * 1 } }
it_should_behave_like "a registry key"
end
@@ -296,8 +296,8 @@ describe Chef::Provider::RegistryKey do
describe "action_create" do
context "when key exists and type matches" do
let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' }
- let(:dword_passed_as_integer) { { :name => "one", :type => :dword, :data => 12345 } }
- let(:testval1) { { :name => "one", :type => :dword, :data => "12345" } }
+ let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } }
+ let(:testval1) { { name: "one", type: :dword, data: "12345" } }
before do
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
end
@@ -321,33 +321,33 @@ describe Chef::Provider::RegistryKey, "key_missing?" do
let(:provider) { Chef::Provider::RegistryKey.new(new_resource, run_context) }
let(:all_keys_present_in_all_hash) do
- [ { :name => "input1_value1", :type => :string, :data => "my_value1" },
- { :name => "input1_value2", :type => :string, :data => "my_value2" },
+ [ { name: "input1_value1", type: :string, data: "my_value1" },
+ { name: "input1_value2", type: :string, data: "my_value2" },
]
end
let(:type_key_not_present_in_any_hash) do
- [ { :name => "input2_value1", :data => "my_value1" },
- { :name => "input2_value2", :data => "my_value2" },
+ [ { name: "input2_value1", data: "my_value1" },
+ { name: "input2_value2", data: "my_value2" },
]
end
let(:type_key_not_present_in_some_hash) do
- [ { :name => "input3_value1", :data => "my_value1" },
- { :name => "input3_value2", :type => :string, :data => "my_value2" },
+ [ { name: "input3_value1", data: "my_value1" },
+ { name: "input3_value2", type: :string, data: "my_value2" },
]
end
let(:data_key_not_present_in_any_hash) do
- [ { :name => "input4_value1", :type => :string },
- { :name => "input4_value2", :type => :string },
+ [ { name: "input4_value1", type: :string },
+ { name: "input4_value2", type: :string },
]
end
let(:data_key_not_present_in_some_hash) do
- [ { :name => "input5_value1", :type => :string, :data => "my_value1" },
- { :name => "input5_value2", :type => :string },
+ [ { name: "input5_value1", type: :string, data: "my_value1" },
+ { name: "input5_value2", type: :string },
]
end
let(:only_name_key_present_in_all_hash) do
- [ { :name => "input6_value1" },
- { :name => "input6_value2" },
+ [ { name: "input6_value1" },
+ { name: "input6_value2" },
]
end
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 307eb98187..1afc95fa48 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -84,7 +84,7 @@ describe Chef::Provider::RemoteFile::Content do
describe "when the fetcher returns nil for the tempfile" do
before do
- http_fetcher = double("Chef::Provider::RemoteFile::HTTP", :fetch => nil)
+ http_fetcher = double("Chef::Provider::RemoteFile::HTTP", fetch: nil)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher)
end
@@ -97,7 +97,7 @@ describe Chef::Provider::RemoteFile::Content do
let(:mtime) { Time.now }
let(:tempfile) { double("Tempfile") }
- let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) }
+ let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", fetch: tempfile) }
before do
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher)
@@ -199,7 +199,7 @@ describe Chef::Provider::RemoteFile::Content do
before do
@tempfile = double("Tempfile")
mtime = Time.now
- http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
+ http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works)
end
@@ -236,7 +236,7 @@ describe Chef::Provider::RemoteFile::Content do
expect(URI).not_to receive(:parse).with(new_resource.source[1])
@tempfile = double("Tempfile")
mtime = Time.now
- http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
+ http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", fetch: @tempfile)
expect(Chef::Provider::RemoteFile::Fetcher).to receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works)
end
diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb
index f5b32800f2..b110e2c03a 100644
--- a/spec/unit/provider/remote_file/fetcher_spec.rb
+++ b/spec/unit/provider/remote_file/fetcher_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an http url" do
- let(:uri) { double("uri", :scheme => "http" ) }
+ let(:uri) { double("uri", scheme: "http" ) }
before do
expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance)
end
@@ -56,7 +56,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an https url" do
- let(:uri) { double("uri", :scheme => "https" ) }
+ let(:uri) { double("uri", scheme: "https" ) }
before do
expect(Chef::Provider::RemoteFile::HTTP).to receive(:new).and_return(fetcher_instance)
end
@@ -66,7 +66,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed an ftp url" do
- let(:uri) { double("uri", :scheme => "ftp" ) }
+ let(:uri) { double("uri", scheme: "ftp" ) }
before do
expect(Chef::Provider::RemoteFile::FTP).to receive(:new).and_return(fetcher_instance)
end
@@ -76,7 +76,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed a file url" do
- let(:uri) { double("uri", :scheme => "file" ) }
+ let(:uri) { double("uri", scheme: "file" ) }
before do
expect(Chef::Provider::RemoteFile::LocalFile).to receive(:new).and_return(fetcher_instance)
end
@@ -86,7 +86,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
end
describe "when passed a url we do not recognize" do
- let(:uri) { double("uri", :scheme => "xyzzy" ) }
+ let(:uri) { double("uri", scheme: "xyzzy" ) }
it "throws an ArgumentError exception" do
expect { described_class.for_resource(uri, new_resource, current_resource) }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index b2fbb7300c..72bb910e66 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Provider::RemoteFile::FTP do
before do
current_resource.checksum(current_resource_checksum)
- #Chef::Provider::RemoteFile::CacheControlData.should_receive(:load_and_validate).with(uri, current_resource_checksum).and_return(cache_control_data)
+ # Chef::Provider::RemoteFile::CacheControlData.should_receive(:load_and_validate).with(uri, current_resource_checksum).and_return(cache_control_data)
end
it "should connect to the host from the uri on the default port 21" do
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index e1f74bd35a..8ece1a854b 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -292,7 +292,7 @@ describe Chef::Provider::RemoteFile::HTTP do
context "and the target file is a tarball [CHEF-3140]" do
let(:uri) { URI.parse("http://opscode.com/tarball.tgz") }
- let(:expected_http_opts) { { :disable_gzip => true } }
+ let(:expected_http_opts) { { disable_gzip: true } }
# CHEF-3140
# Some servers return tarballs as content type tar and encoding gzip, which
diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb
index 6f345cadd1..6dad6a57f2 100644
--- a/spec/unit/provider/remote_file/local_file_spec.rb
+++ b/spec/unit/provider/remote_file/local_file_spec.rb
@@ -84,8 +84,8 @@ describe Chef::Provider::RemoteFile::LocalFile do
describe "when fetching the object" do
- let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) }
- let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) }
+ let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/nyan.png", close: nil) }
+ let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) }
before do
current_resource.source("file:///nyan_cat.png")
diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb
index ecb326fc64..1c2bcc5911 100644
--- a/spec/unit/provider/remote_file/network_file_spec.rb
+++ b/spec/unit/provider/remote_file/network_file_spec.rb
@@ -28,9 +28,9 @@ describe Chef::Provider::RemoteFile::NetworkFile do
describe "when fetching the object" do
- let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/Foo.tar.gz", :close => nil) }
- let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) }
- let(:source_file) { double("::File", :read => nil) }
+ let(:tempfile) { double("Tempfile", path: "/tmp/foo/bar/Foo.tar.gz", close: nil) }
+ let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", tempfile: tempfile) }
+ let(:source_file) { double("::File", read: nil) }
before do
allow(Chef::Platform).to receive(:windows?).and_return(true)
diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb
index ddab1605f0..244440d5c3 100644
--- a/spec/unit/provider/remote_file/sftp_spec.rb
+++ b/spec/unit/provider/remote_file/sftp_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
describe Chef::Provider::RemoteFile::SFTP do
- #built out dependencies
+ # built out dependencies
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
@@ -120,7 +120,7 @@ describe Chef::Provider::RemoteFile::SFTP do
let(:uri) { URI.parse("sftp://conan:cthu1hu@opscode.com:8021/seattle.txt") }
it "should connect on an alternate port when one is provided" do
- expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", :password => "cthu1hu")
+ expect(Net::SFTP).to receive(:start).with("opscode.com:8021", "conan", password: "cthu1hu")
fetcher.fetch
end
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index 3f91377c60..07b854da6b 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::RemoteFile do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 651e5130e0..08b19730a7 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -93,7 +93,7 @@ describe Chef::Provider::Script, "action_run" do
end
context "when an alternate user is specified" do
- let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", :dacl => []) }
+ let(:security_descriptor) { instance_double("Chef::ReservedNames::Win32::Security::SecurityDescriptor", dacl: []) }
let(:securable_object) { instance_double("Chef::ReservedNames::Win32::Security::SecurableObject", :security_descriptor => security_descriptor, :dacl= => nil) }
it "sets the script file's security descriptor" do
new_resource.user("toor")
diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb
index 802ccee2c7..cf6309e82a 100644
--- a/spec/unit/provider/service/aix_service_spec.rb
+++ b/spec/unit/provider/service/aix_service_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::Service::Aix do
describe "load current resource" do
it "should create a current resource with the name of the new resource and determine the status" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@@ -47,7 +47,7 @@ describe Chef::Provider::Service::Aix do
describe "determine current status" do
context "when the service is active" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef chef 12345 active\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef chef 12345 active\n")
end
it "current resource is running" do
@@ -61,7 +61,7 @@ describe Chef::Provider::Service::Aix do
context "when the service is inoperative" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n")
end
it "current resource is not running" do
@@ -75,7 +75,7 @@ describe Chef::Provider::Service::Aix do
context "when there is no such service" do
before do
- @status = double("Status", :exitstatus => 1, :stdout => "0513-085 The chef Subsystem is not on file.\n")
+ @status = double("Status", exitstatus: 1, stdout: "0513-085 The chef Subsystem is not on file.\n")
end
it "current resource is not running" do
expect(@provider).to receive(:shell_out!).with("lssrc -s chef").and_return(@status)
@@ -90,7 +90,7 @@ describe Chef::Provider::Service::Aix do
describe "is resource group" do
context "when there are multiple subsystems associated with group" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative")
+ @status = double("Status", exitstatus: 0, stdout: "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative")
end
it "service is a group" do
@@ -102,7 +102,7 @@ describe Chef::Provider::Service::Aix do
context "when there is a single subsystem in the group" do
before do
- @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef inoperative\n")
+ @status = double("Status", exitstatus: 0, stdout: "chef1 chef inoperative\n")
end
it "service is a group" do
@@ -114,8 +114,8 @@ describe Chef::Provider::Service::Aix do
context "when the service is a subsystem" do
before do
- @group_status = double("Status", :exitstatus => 1, :stdout => "0513-086 The chef Group is not on file.\n")
- @service_status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n")
+ @group_status = double("Status", exitstatus: 1, stdout: "0513-086 The chef Group is not on file.\n")
+ @service_status = double("Status", exitstatus: 0, stdout: "chef chef inoperative\n")
end
it "service is a subsystem" do
diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb
index 09c177903b..6a586a0240 100644
--- a/spec/unit/provider/service/aixinit_service_spec.rb
+++ b/spec/unit/provider/service/aixinit_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::AixInit do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "fuuuu" }
+ @node.automatic_attrs[:command] = { ps: "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -209,7 +209,7 @@ describe Chef::Provider::Service::AixInit do
before do
@files = ["/etc/rc.d/rc2.d/S20apache", "/etc/rc.d/rc2.d/K80apache"]
# FIXME: this is clearly buggy the duplicated keys do not work
- #@priority = {2 => [:start, 20], 2 => [:stop, 80]}
+ # @priority = {2 => [:start, 20], 2 => [:stop, 80]}
@priority = { 2 => [:stop, 80] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]chef"]).and_return(@files)
@@ -256,7 +256,7 @@ describe Chef::Provider::Service::AixInit do
before do
files = ["/etc/rc.d/rc2.d/Sapache", "/etc/rc.d/rc2.d/Kapache"]
# FIXME: this is clearly buggy the duplicated keys do not work
- #@priority = {2 => [:start, ''], 2 => [:stop, '']}
+ # @priority = {2 => [:start, ''], 2 => [:stop, '']}
@priority = { 2 => [:stop, ""] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files)
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index 2139e31818..18db25fef9 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -26,14 +26,14 @@ require "ostruct"
describe Chef::Provider::Service::Arch, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Service.new("chef")
@new_resource.pattern("chef")
- @new_resource.supports({ :status => false })
+ @new_resource.supports({ status: false })
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
@@ -43,7 +43,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when first created" do
it "should set the current resources service name to the new resources service name" do
- allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => ""))
+ allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(exitstatus: 0, stdout: ""))
@provider.load_current_resource
expect(@provider.current_resource.service_name).to eq("chef")
end
@@ -51,22 +51,22 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/etc/rc.d/service_name status'" do
- expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
+ expect(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
end
it "should set running to true if the status command returns 0" do
- allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0))
+ allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
expect(@provider.current_resource.running).to be_truthy
end
it "should set running to false if the status command returns anything except 0" do
- allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 1))
+ allow(@provider).to receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(exitstatus: 1))
@provider.load_current_resource
expect(@provider.current_resource.running).to be_falsey
end
@@ -85,21 +85,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
it "should run the services status command if one has been specified" do
- expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0))
+ expect(@provider).to receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(exitstatus: 0))
@provider.load_current_resource
end
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -117,21 +117,21 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when discovering service status with ps" do
before do
- @stdout = StringIO.new(<<-DEFAULT_PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
-aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
-aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
+ @stdout = StringIO.new(<<~DEFAULT_PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
+ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
+ aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
DEFAULT_PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
end
it "determines the service is running when it appears in ps" do
- @stdout = StringIO.new(<<-RUNNING_PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 chef
-aj 7842 5057 0 21:26 pts/2 00:00:06 poos
+ @stdout = StringIO.new(<<~RUNNING_PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 chef
+ aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
allow(@status).to receive(:stdout).and_return(@stdout)
@provider.load_current_resource
@@ -274,7 +274,7 @@ RUNNING_PS
# end
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -309,7 +309,7 @@ RUNNING_PS
# end
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 25e7c9acc2..626abb10f7 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Debian do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "fuuuu" }
+ @node.automatic_attrs[:command] = { ps: "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -88,7 +88,7 @@ describe Chef::Provider::Service::Debian do
"5" => [:start, "20"],
"0" => [:stop, "20"],
"1" => [:stop, "20"],
- "6" => [:stop, "20"]
+ "6" => [:stop, "20"],
})
end
end
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 511962f432..954ef3d153 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -27,14 +27,14 @@ end
describe Chef::Provider::Service::Freebsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
node
end
let(:new_resource) do
new_resource = Chef::Resource::Service.new("apache22")
new_resource.pattern("httpd")
- new_resource.supports({ :status => false })
+ new_resource.supports({ status: false })
new_resource
end
@@ -99,7 +99,7 @@ describe Chef::Provider::Service::Freebsd do
end
context "when a status command has been specified" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
new_resource.status_command("/bin/chefhasmonkeypants status")
@@ -112,10 +112,10 @@ describe Chef::Provider::Service::Freebsd do
end
context "when the service supports status" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
- new_resource.supports({ :status => true })
+ new_resource.supports({ status: true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -138,16 +138,16 @@ describe Chef::Provider::Service::Freebsd do
context "when we have a 'ps' attribute" do
let(:stdout) do
- StringIO.new(<<-PS_SAMPLE)
-413 ?? Ss 0:02.51 /usr/sbin/syslogd -s
-539 ?? Is 0:00.14 /usr/sbin/sshd
-545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
+ StringIO.new(<<~PS_SAMPLE)
+ 413 ?? Ss 0:02.51 /usr/sbin/syslogd -s
+ 539 ?? Is 0:00.14 /usr/sbin/sshd
+ 545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
PS_SAMPLE
end
- let(:status) { double(:stdout => stdout, :exitstatus => 0) }
+ let(:status) { double(stdout: stdout, exitstatus: 0) }
before do
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
end
it "should shell_out! the node's ps command" do
@@ -163,9 +163,9 @@ PS_SAMPLE
context "when the regex matches the output" do
let(:stdout) do
- StringIO.new(<<-PS_SAMPLE)
-555 ?? Ss 0:05.16 /usr/sbin/cron -s
- 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT
+ StringIO.new(<<~PS_SAMPLE)
+ 555 ?? Ss 0:05.16 /usr/sbin/cron -s
+ 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT
PS_SAMPLE
end
@@ -191,7 +191,7 @@ PS_SAMPLE
context "when ps is empty string" do
before do
- node.automatic_attrs[:command] = { :ps => "" }
+ node.automatic_attrs[:command] = { ps: "" }
end
it "should set running to nil" do
@@ -341,9 +341,9 @@ PS_SAMPLE
context "when the rc script has a 'name' variable" do
let(:rcscript) do
- StringIO.new(<<-EOF)
-name="#{new_resource.service_name}"
-rcvar=`set_rcvar`
+ StringIO.new(<<~EOF)
+ name="#{new_resource.service_name}"
+ rcvar=`set_rcvar`
EOF
end
@@ -363,23 +363,23 @@ EOF
describe "when the rcscript does not have a name variable" do
let(:rcscript) do
- StringIO.new <<-EOF
-rcvar=`set_rcvar`
+ StringIO.new <<~EOF
+ rcvar=`set_rcvar`
EOF
end
before do
- status = double(:stdout => rcvar_stdout, :exitstatus => 0)
+ status = double(stdout: rcvar_stdout, exitstatus: 0)
allow(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} rcvar").and_return(status)
end
describe "when rcvar returns foobar_enable" do
let(:rcvar_stdout) do
- rcvar_stdout = <<-EOF
-# apache22
-#
-# #{new_resource.service_name}_enable="YES"
-# (default: "")
+ rcvar_stdout = <<~EOF
+ # apache22
+ #
+ # #{new_resource.service_name}_enable="YES"
+ # (default: "")
EOF
end
@@ -394,9 +394,9 @@ EOF
describe "when rcvar does not return foobar_enable" do
let(:rcvar_stdout) do
- rcvar_stdout = <<-EOF
-# service_with_noname
-#
+ rcvar_stdout = <<~EOF
+ # service_with_noname
+ #
EOF
end
@@ -469,7 +469,7 @@ EOF
describe Chef::Provider::Service::Freebsd, "restart_service" do
it "should call 'restart' on the service_name if the resource supports it" do
- new_resource.supports({ :restart => true })
+ new_resource.supports({ restart: true })
expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart", default_env: false)
provider.restart_service()
end
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index a00ca7aadd..6a928d849b 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::Service::Gentoo do
@provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out).and_return(@status)
allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true)
allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true)
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index ff7fae767a..7bbe2c6363 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Init, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -32,12 +32,12 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
@provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- @stdout = StringIO.new(<<-PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
-aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
-aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
+ @stdout = StringIO.new(<<~PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
+ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
+ aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -109,7 +109,7 @@ PS
describe "when the node has not specified a ps command" do
it "should raise an error if the node has a nil ps attribute" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -117,7 +117,7 @@ PS
end
it "should raise an error if the node has an empty ps attribute" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -133,9 +133,9 @@ PS
end
it "should set running to true if the regex matches the output" do
- @stdout = StringIO.new(<<-RUNNING_PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 chef
-aj 7842 5057 0 21:26 pts/2 00:00:06 poos
+ @stdout = StringIO.new(<<~RUNNING_PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 chef
+ aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
allow(@status).to receive(:stdout).and_return(@stdout)
@provider.load_current_resource
@@ -189,7 +189,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -210,7 +210,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index 3b2b19c432..f2fe19db59 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -23,13 +23,13 @@ describe Chef::Provider::Service::Insserv do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ @node.automatic_attrs[:command] = { ps: "ps -ax" }
@new_resource = Chef::Resource::Service.new("initgrediant")
@current_resource = Chef::Resource::Service.new("initgrediant")
@provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context)
- @status = double("Process::Status mock", :exitstatus => 0, :stdout => "")
+ @status = double("Process::Status mock", exitstatus: 0, stdout: "")
allow(@provider).to receive(:shell_out!).and_return(@status)
end
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index e70ba7e094..2e30c16da4 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Invokercd, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -32,12 +32,12 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
@provider = Chef::Provider::Service::Invokercd.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- @stdout = StringIO.new(<<-PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
-aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
-aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
+ @stdout = StringIO.new(<<~PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
+ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
+ aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb
PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({ :status => true })
+ @new_resource.supports({ status: true })
end
it "should run '/usr/sbin/invoke-rc.d service_name status'" do
@@ -95,14 +95,14 @@ PS
describe "when the node has not specified a ps command" do
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -112,24 +112,24 @@ PS
describe "when we have a 'ps' attribute" do
it "should shell_out! the node's ps command" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).with(@node[:command][:ps]).and_return(@status)
@provider.load_current_resource
end
it "should set running to true if the regex matches the output" do
- @stdout = StringIO.new(<<-RUNNING_PS)
-aj 7842 5057 0 21:26 pts/2 00:00:06 chef
-aj 7842 5057 0 21:26 pts/2 00:00:06 poos
+ @stdout = StringIO.new(<<~RUNNING_PS)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 chef
+ aj 7842 5057 0 21:26 pts/2 00:00:06 poos
RUNNING_PS
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
end
it "should set running to false if the regex doesn't match" do
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
expect(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_falsey
@@ -176,7 +176,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({ :restart => true })
+ @new_resource.supports({ restart: true })
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart", default_env: false)
@provider.restart_service()
end
@@ -197,7 +197,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({ :reload => true })
+ @new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload", default_env: false)
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 283512108a..9864fb0185 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -48,15 +48,15 @@ describe Chef::Provider::Service::Macosx do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:provider) { described_class.new(new_resource, run_context) }
let(:launchctl_stdout) { StringIO.new }
- let(:plutil_stdout) { String.new <<-XML }
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>Label</key>
- <string>io.redis.redis-server</string>
-</dict>
-</plist>
+ let(:plutil_stdout) { String.new <<~XML }
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ <key>Label</key>
+ <string>io.redis.redis-server</string>
+ </dict>
+ </plist>
XML
%w{Daemon Agent}.each do |service_type|
@@ -76,20 +76,20 @@ XML
before do
allow(run_context).to receive(:logger).and_return(logger)
allow(Dir).to receive(:glob).and_return([plist], [])
- @stat = double("File::Stat", { :uid => 501 })
+ @stat = double("File::Stat", { uid: 501 })
allow(File).to receive(:stat).and_return(@stat)
- @getpwuid = double("Etc::Passwd", { :name => "mikedodge04" })
+ @getpwuid = double("Etc::Passwd", { name: "mikedodge04" })
allow(Etc).to receive(:getpwuid).and_return(@getpwuid)
allow(node).to receive(:[]).with("platform_version").and_return(platform_version)
cmd = "launchctl list #{service_label}"
- allow(provider).to receive(:shell_out).
- with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false).
- and_return(double("Status",
- :stdout => launchctl_stdout, :exitstatus => 0))
+ allow(provider).to receive(:shell_out)
+ .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false)
+ .and_return(double("Status",
+ stdout: launchctl_stdout, exitstatus: 0))
allow(File).to receive(:exists?).and_return([true], [])
- allow(provider).to receive(:shell_out!).
- with(/plutil -convert xml1 -o/, default_env: false).
- and_return(double("Status", :stdout => plutil_stdout))
+ allow(provider).to receive(:shell_out!)
+ .with(/plutil -convert xml1 -o/, default_env: false)
+ .and_return(double("Status", stdout: plutil_stdout))
end
context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do
@@ -113,9 +113,9 @@ XML
before do
allow(Dir).to receive(:glob).and_return([])
allow(File).to receive(:exists?).and_return([true], [])
- allow(provider).to receive(:shell_out!).
- with(/plutil -convert xml1 -o/).
- and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ allow(provider).to receive(:shell_out!)
+ .with(/plutil -convert xml1 -o/)
+ .and_raise(Mixlib::ShellOut::ShellCommandFailed)
end
it "works for action :nothing" do
@@ -136,20 +136,20 @@ XML
end
context "when launchctl returns pid in service list" do
- let(:launchctl_stdout) { StringIO.new <<-SVC_LIST }
-{
- "LimitLoadToSessionType" = "System";
- "Label" = "io.redis.redis-server";
- "TimeOut" = 30;
- "OnDemand" = false;
- "LastExitStatus" = 0;
- "PID" = 62803;
- "Program" = "do_some.sh";
- "ProgramArguments" = (
- "path/to/do_something.sh";
- "-f";
- );
-};
+ let(:launchctl_stdout) { StringIO.new <<~SVC_LIST }
+ {
+ "LimitLoadToSessionType" = "System";
+ "Label" = "io.redis.redis-server";
+ "TimeOut" = 30;
+ "OnDemand" = false;
+ "LastExitStatus" = 0;
+ "PID" = 62803;
+ "Program" = "do_some.sh";
+ "ProgramArguments" = (
+ "path/to/do_something.sh";
+ "-f";
+ );
+ };
SVC_LIST
before do
@@ -167,7 +167,7 @@ SVC_LIST
describe "running unsupported actions" do
before do
- allow(Dir).to receive(:glob).and_return(["#{plist}"], [])
+ allow(Dir).to receive(:glob).and_return([(plist).to_s], [])
allow(File).to receive(:exists?).and_return([true], [])
end
it "should throw an exception when reload action is attempted" do
@@ -175,19 +175,19 @@ SVC_LIST
end
end
context "when launchctl returns empty service pid" do
- let(:launchctl_stdout) { StringIO.new <<-SVC_LIST }
-{
- "LimitLoadToSessionType" = "System";
- "Label" = "io.redis.redis-server";
- "TimeOut" = 30;
- "OnDemand" = false;
- "LastExitStatus" = 0;
- "Program" = "do_some.sh";
- "ProgramArguments" = (
- "path/to/do_something.sh";
- "-f";
- );
-};
+ let(:launchctl_stdout) { StringIO.new <<~SVC_LIST }
+ {
+ "LimitLoadToSessionType" = "System";
+ "Label" = "io.redis.redis-server";
+ "TimeOut" = 30;
+ "OnDemand" = false;
+ "LastExitStatus" = 0;
+ "Program" = "do_some.sh";
+ "ProgramArguments" = (
+ "path/to/do_something.sh";
+ "-f";
+ );
+ };
SVC_LIST
before do
@@ -204,8 +204,8 @@ SVC_LIST
end
context "when launchctl doesn't return service entry at all" do
- let(:launchctl_stdout) { StringIO.new <<-SVC_LIST }
-Could not find service "io.redis.redis-server" in domain for system
+ let(:launchctl_stdout) { StringIO.new <<~SVC_LIST }
+ Could not find service "io.redis.redis-server" in domain for system
SVC_LIST
it "sets service running state to false" do
@@ -226,7 +226,7 @@ SVC_LIST
context "and plist for service is available" do
before do
- allow(Dir).to receive(:glob).and_return(["#{plist}"], [])
+ allow(Dir).to receive(:glob).and_return([(plist).to_s], [])
provider.load_current_resource
end
@@ -237,7 +237,7 @@ SVC_LIST
describe "and several plists match service name" do
it "throws exception" do
- allow(Dir).to receive(:glob).and_return(["#{plist}",
+ allow(Dir).to receive(:glob).and_return([(plist).to_s,
"/Users/wtf/something.plist"])
provider.load_current_resource
provider.define_resource_requirements
@@ -269,9 +269,9 @@ SVC_LIST
it "starts service via launchctl if service found" do
cmd = "launchctl load -w " + session + plist
- expect(provider).to receive(:shell_out).
- with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false).
- and_return(0)
+ expect(provider).to receive(:shell_out)
+ .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
+ .and_return(0)
provider.start_service
end
@@ -301,9 +301,9 @@ SVC_LIST
it "stops the service via launchctl if service found" do
cmd = "launchctl unload -w " + plist
- expect(provider).to receive(:shell_out).
- with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false).
- and_return(0)
+ expect(provider).to receive(:shell_out)
+ .with(/(#{su_cmd} .#{cmd}.|#{cmd})/, default_env: false)
+ .and_return(0)
provider.stop_service
end
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index b990532aaf..913fddc1cf 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -31,11 +31,11 @@ end
describe Chef::Provider::Service::Openbsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ node.automatic_attrs[:command] = { ps: "ps -ax" }
node
end
- let(:supports) { { :status => false } }
+ let(:supports) { { status: false } }
let(:new_resource) do
new_resource = Chef::Resource::Service.new("sndiod")
@@ -93,7 +93,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "when a status command has been specified" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
before do
new_resource.status_command("/bin/chefhasmonkeypants status")
@@ -106,9 +106,9 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the service supports status" do
- let(:status) { double(:stdout => "", :exitstatus => 0) }
+ let(:status) { double(stdout: "", exitstatus: 0) }
- let(:supports) { { :status => true } }
+ let(:supports) { { status: true } }
it "should run '/etc/rc.d/service_name status'" do
expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status)
@@ -189,7 +189,7 @@ describe Chef::Provider::Service::Openbsd do
let(:lines) do
[
%Q{#{provider.builtin_service_enable_variable_name}_thing="YES"},
- %Q{#{provider.builtin_service_enable_variable_name}},
+ (provider.builtin_service_enable_variable_name).to_s,
] end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 40f9bc3a91..b965183d14 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -23,17 +23,17 @@ shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false)
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
- allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_raise(Errno::ENOENT)
+ allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should not raise an error if the service exists but is not added to any runlevels" do
- status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
+ status = double("Status", exitstatus: 0, stdout: "" , stderr: "")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "", stderr: "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
@@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "foo" }
+ @node.automatic_attrs[:command] = { ps: "foo" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -65,13 +65,13 @@ describe "Chef::Provider::Service::Redhat" do
describe "load current resource" do
before do
- status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
+ status = double("Status", exitstatus: 0, stdout: "" , stderr: "")
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
end
it "sets supports[:status] to true by default" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@provider.supports[:status]).to be true
@@ -80,9 +80,9 @@ describe "Chef::Provider::Service::Redhat" do
it "lets the user override supports[:status] in the new_resource" do
@new_resource.supports( { status: false } )
@new_resource.pattern "myservice"
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
- foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "")
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
+ foo_out = double("ps_command", exitstatus: 0, stdout: "a line that matches myservice", stderr: "")
expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out)
expect(@provider.service_missing).to be false
expect(@provider).not_to receive(:shell_out).with("/sbin/service chef status")
@@ -91,16 +91,16 @@ describe "Chef::Provider::Service::Redhat" do
end
it "sets the current enabled status to true if the service is enabled for any run level" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
end
it "sets the current enabled status to false if the regex does not match" do
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
expect(@provider.load_current_resource).to eql(@current_resource)
expect(@current_resource.enabled).to be false
@@ -108,8 +108,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to true if the service is enabled at specified run levels" do
@new_resource.run_levels([1, 2])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
@@ -118,8 +118,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is enabled at a run level it should not" do
@new_resource.run_levels([1, 2])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -128,8 +128,8 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is not enabled at specified run levels" do
@new_resource.run_levels([ 2 ])
- chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", exitstatus: 0, stdout: "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", stderr: "")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -142,10 +142,10 @@ describe "Chef::Provider::Service::Redhat" do
context "when the service does not exist" do
before do
- status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
+ status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
end
@@ -194,10 +194,10 @@ describe "Chef::Provider::Service::Redhat" do
it_should_behave_like "define_resource_requirements_common"
it "should not raise an error if the service does not exist" do
- status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
+ status = double("Status", exitstatus: 1, stdout: "", stderr: "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", existatus: 1, stdout: "", stderr: "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 8a03c0552d..0529462d2f 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Simple, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = { :ps => "ps -ef" }
+ @node.automatic_attrs[:command] = { ps: "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -31,12 +31,12 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
@provider = Chef::Provider::Service::Simple.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
- @stdout = StringIO.new(<<-NOMOCKINGSTRINGSPLZ)
-aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
-aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
-aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb
+ @stdout = StringIO.new(<<~NOMOCKINGSTRINGSPLZ)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb
+ aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash
+ aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb
NOMOCKINGSTRINGSPLZ
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
end
@@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => nil }
+ @node.automatic_attrs[:command] = { ps: nil }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = { :ps => "" }
+ @node.automatic_attrs[:command] = { ps: "" }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
@@ -75,11 +75,11 @@ NOMOCKINGSTRINGSPLZ
end
it "should set running to true if the regex matches the output" do
- @stdout = StringIO.new(<<-NOMOCKINGSTRINGSPLZ)
-aj 7842 5057 0 21:26 pts/2 00:00:06 chef
-aj 7842 5057 0 21:26 pts/2 00:00:06 poos
+ @stdout = StringIO.new(<<~NOMOCKINGSTRINGSPLZ)
+ aj 7842 5057 0 21:26 pts/2 00:00:06 chef
+ aj 7842 5057 0 21:26 pts/2 00:00:06 poos
NOMOCKINGSTRINGSPLZ
- @status = double("Status", :exitstatus => 0, :stdout => @stdout)
+ @status = double("Status", exitstatus: 0, stdout: @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
@@ -106,8 +106,8 @@ NOMOCKINGSTRINGSPLZ
describe "when starting the service" do
it "should call the start command if one is specified" do
- @new_resource.start_command("#{@new_resource.start_command}")
- expect(@provider).to receive(:shell_out!).with("#{@new_resource.start_command}", default_env: false)
+ @new_resource.start_command((@new_resource.start_command).to_s)
+ expect(@provider).to receive(:shell_out!).with((@new_resource.start_command).to_s, default_env: false)
@provider.start_service()
end
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index a5148c236a..7b8bd950d2 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -74,19 +74,19 @@ describe Chef::Provider::Service::Solaris do
].join("\n")
# shell_out! return value for a service that is running
- @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "")
+ @enabled_svc_status = double("Status", exitstatus: 0, stdout: enabled_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that is disabled
- @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "")
+ @disabled_svc_status = double("Status", exitstatus: 0, stdout: disabled_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that is in maintenance mode
- @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "")
+ @maintenance_svc_status = double("Status", exitstatus: 0, stdout: maintenance_svc_stdout, stdin: "", stderr: "")
# shell_out! return value for a service that does not exist
- @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n")
+ @no_svc_status = double("Status", exitstatus: 1, stdout: "", stdin: "", stderr: "svcs: Pattern 'chef' doesn't match any instances\n")
# shell_out! return value for a successful execution
- @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "")
+ @success = double("clear", exitstatus: 0, stdout: "", stdin: "", stderr: "")
end
it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do
@@ -116,19 +116,19 @@ describe Chef::Provider::Service::Solaris do
describe "when discovering the current service state" do
it "should create a current resource with the name of the new resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
expect(@provider.maintenance).to be_falsey
@provider.load_current_resource
end
it "should return the current resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider.load_current_resource).to eql(@current_resource)
end
it "should call '/bin/svcs -l service_name'" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
end
@@ -163,7 +163,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef" do
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -173,7 +173,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef for start_service" do
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -183,7 +183,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm clear chef for start_service when state maintenance" do
# we are in maint mode
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@maintenance_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@@ -192,7 +192,7 @@ describe Chef::Provider::Service::Solaris do
expect(@provider.enable_service).to be_truthy
# now we are enabled
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
expect(@current_resource.enabled).to be_truthy
@@ -206,7 +206,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm enable -s -r chef" do
@new_resource.options("-r")
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -216,7 +216,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm enable -s -r -t chef when passed an array of options" do
@new_resource.options(["-r", "-t"])
- expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -232,7 +232,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -240,7 +240,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef for stop_service" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -249,7 +249,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm disable chef with options" do
@new_resource.options("-t")
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -261,7 +261,7 @@ describe Chef::Provider::Service::Solaris do
describe "when reloading the service" do
before(:each) do
@provider.current_resource = @current_resource
- allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@enabled_svc_status)
end
it "should call svcadm refresh chef" do
@@ -274,7 +274,7 @@ describe Chef::Provider::Service::Solaris do
describe "when the service doesn't exist" do
before(:each) do
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@no_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { returns: [0, 1] }).and_return(@no_svc_status)
end
it "should be marked not running" do
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 1082bdfdc4..15b79922b0 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -36,11 +36,11 @@ describe Chef::Provider::Service::Systemd do
let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
let(:shell_out_failure) do
- double("shell_out", :exitstatus => 1, :error? => true)
+ double("shell_out", exitstatus: 1, error?: true)
end
let(:current_resource) { Chef::Resource::Service.new(service_name) }
@@ -190,14 +190,14 @@ describe Chef::Provider::Service::Systemd do
context "when a user is specified" do
it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do
current_resource.user("joe")
- expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe", default_env: false }).and_return(shell_out_success)
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe", default_env: false }).and_return(shell_out_success)
provider.start_service
end
it "should not call '#{systemctl_path} --user start service_name' if it is already running" do
current_resource.running(true)
current_resource.user("joe")
- expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" })
+ expect(provider).not_to receive(:shell_out!).with("#{systemctl_path} --user start #{service_name_escaped}", { environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, user: "joe" })
provider.start_service
end
end
@@ -264,7 +264,7 @@ describe Chef::Provider::Service::Systemd do
before(:each) do
provider.current_resource = current_resource
current_resource.service_name(service_name)
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
it "should call '#{systemctl_path} --system enable service_name' to enable the service" do
@@ -282,7 +282,7 @@ describe Chef::Provider::Service::Systemd do
before(:each) do
provider.current_resource = current_resource
current_resource.service_name(service_name)
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
it "should call '#{systemctl_path} --system mask service_name' to mask the service" do
@@ -300,7 +300,7 @@ describe Chef::Provider::Service::Systemd do
before(:each) do
provider.current_resource = current_resource
current_resource.service_name(service_name)
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
it "should return true if '#{systemctl_path} --system is-active service_name' returns 0" do
@@ -318,7 +318,7 @@ describe Chef::Provider::Service::Systemd do
before(:each) do
provider.current_resource = current_resource
current_resource.service_name(service_name)
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 0" do
@@ -336,26 +336,26 @@ describe Chef::Provider::Service::Systemd do
before(:each) do
provider.current_resource = current_resource
current_resource.service_name(service_name)
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
it "should return true if '#{systemctl_path} --system is-enabled service_name' returns 'masked' and returns anything except 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be true
end
it "should return true if '#{systemctl_path} --system is-enabled service_name' outputs 'masked-runtime' and returns anything except 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "masked-runtime", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "masked-runtime", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be true
end
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "enabled", :exitstatus => shell_out_success))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "enabled", exitstatus: shell_out_success))
expect(provider.is_masked?).to be false
end
it "should return false if '#{systemctl_path} --system is-enabled service_name' returns anything except 0 and outputs an error'" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(:stdout => "Failed to get unit file state for #{service_name}: No such file or directory", :exitstatus => shell_out_failure))
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} --system is-enabled #{service_name_escaped}", {}).and_return(double(stdout: "Failed to get unit file state for #{service_name}: No such file or directory", exitstatus: shell_out_failure))
expect(provider.is_masked?).to be false
end
end
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index a95f9c494e..365201cb38 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::Service::Upstart do
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
before(:each) do
@@ -43,7 +43,7 @@ describe Chef::Provider::Service::Upstart do
it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do
@node.automatic_attrs[:platform_version] = "9.04"
- #Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
+ # Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/event.d")
expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq("")
@@ -66,7 +66,7 @@ describe Chef::Provider::Service::Upstart do
describe "load_current_resource" do
before(:each) do
- @node.automatic_attrs[:command] = { :ps => "ps -ax" }
+ @node.automatic_attrs[:command] = { ps: "ps -ax" }
@current_resource = Chef::Resource::Service.new("rsyslog")
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@@ -167,14 +167,14 @@ describe Chef::Provider::Service::Upstart do
end
it "should set enabled to true when it finds 'starts on'" do
- @lines = double("start on filesystem", :gets => "start on filesystem")
+ @lines = double("start on filesystem", gets: "start on filesystem")
allow(::File).to receive(:open).and_yield(@lines)
expect(@current_resource).to receive(:running).with(false)
@provider.load_current_resource
end
it "should set enabled to false when it finds '#starts on'" do
- @lines = double("start on filesystem", :gets => "#start on filesystem")
+ @lines = double("start on filesystem", gets: "#start on filesystem")
allow(::File).to receive(:open).and_yield(@lines)
expect(@current_resource).to receive(:running).with(false)
@provider.load_current_resource
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 18ea004795..dd59089418 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -98,7 +98,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
Win32::Service::DISABLED = 0x00000004
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name)
.and_return(chef_service_config_info)
@@ -502,13 +502,13 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "start_service" do
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
end
it "calls the start command if one is specified" do
new_resource.start_command "sc start #{chef_service_name}"
- expect(provider).to receive(:shell_out!).with("#{new_resource.start_command}").and_return("Starting custom service")
+ expect(provider).to receive(:shell_out!).with((new_resource.start_command).to_s).and_return("Starting custom service")
provider.start_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
@@ -528,7 +528,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -537,7 +537,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -546,9 +546,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continues if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -557,7 +557,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"))
+ double("StatusStruct", current_state: "stop pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -597,13 +597,13 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"))
end
it "calls the stop command if one is specified" do
new_resource.stop_command "sc stop #{chef_service_name}"
- expect(provider).to receive(:shell_out!).with("#{new_resource.stop_command}").and_return("Stopping custom service")
+ expect(provider).to receive(:shell_out!).with((new_resource.stop_command).to_s).and_return("Stopping custom service")
provider.stop_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
@@ -623,7 +623,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -632,7 +632,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -641,9 +641,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continue if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -652,7 +652,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"))
+ double("StatusStruct", current_state: "start pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -661,7 +661,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "passes custom timeout to the stop command if provided" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
new_resource.timeout 1
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
Timeout.timeout(2) do
@@ -676,17 +676,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "calls the restart command if one is specified" do
new_resource.restart_command "sc restart"
- expect(provider).to receive(:shell_out!).with("#{new_resource.restart_command}")
+ expect(provider).to receive(:shell_out!).with((new_resource.restart_command).to_s)
provider.restart_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
it "stops then starts the service if it is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
@@ -695,9 +695,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "just starts the service if it is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
expect(new_resource.updated_by_last_action?).to be_truthy
@@ -716,11 +716,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "enable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
end
it "enables service" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.enable_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
@@ -736,14 +736,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_enable" do
it "does nothing if the service is enabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).not_to receive(:enable_service)
provider.action_enable
end
it "enables the service if it is not set to automatic start" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).to receive(:enable_service)
provider.action_enable
end
@@ -752,14 +752,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_disable" do
it "does nothing if the service is disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).not_to receive(:disable_service)
provider.action_disable
end
it "disables the service if it is not set to disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).to receive(:disable_service)
provider.action_disable
end
@@ -768,7 +768,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "disable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
end
it "disables service" do
@@ -810,17 +810,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "set_start_type" do
it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.send(:set_startup_type, :automatic)
end
it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DEMAND_START)
provider.send(:set_startup_type, :manual)
end
it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DISABLED)
provider.send(:set_startup_type, :disabled)
end
diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb
index c788cb223e..f3e725abb6 100644
--- a/spec/unit/provider/service_spec.rb
+++ b/spec/unit/provider/service_spec.rb
@@ -99,7 +99,7 @@ describe Chef::Provider::Service do
describe "action_restart" do
before do
- @current_resource.supports(:restart => true)
+ @current_resource.supports(restart: true)
end
it "should restart the service if it's supported and set the resource as updated" do
@@ -118,11 +118,11 @@ describe Chef::Provider::Service do
describe "action_reload" do
before do
- @new_resource.supports(:reload => true)
+ @new_resource.supports(reload: true)
end
it "should raise an exception if reload isn't supported" do
- @new_resource.supports(:reload => false)
+ @new_resource.supports(reload: false)
@new_resource.reload_command(false)
expect { @provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index 55d6dc5d24..5233ecb229 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::Subversion do
it "converts resource attributes to options for shell_out" do
expect(@provider.run_options).to eq({})
@resource.user "deployninja"
- expect(@provider.run_options).to eq({ :user => "deployninja" })
+ expect(@provider.run_options).to eq({ user: "deployninja" })
end
context "determining the revision of the currently deployed code" do
@@ -73,18 +73,18 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
- expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }]
+ expect(@provider).to receive(:shell_out!).with(*expected_command)
+ .and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.find_current_revision).to eql("11410")
end
it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do
example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n"
expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
- expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ expected_command = ["svn info", { cwd: "/my/deploy/dir", returns: [0, 1] }]
+ expect(@provider).to receive(:shell_out!).with(*expected_command)
+ .and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.find_current_revision).to be_nil
end
@@ -128,18 +128,18 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
- expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }]
+ expect(@provider).to receive(:shell_out!).with(*expected_command)
+ .and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect(@provider.revision_int).to eql("11410")
end
it "returns a helpful message if data from `svn info` can't be parsed" do
example_svn_info = "some random text from an error message\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
- expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { cwd: "/my/deploy/dir", returns: [0, 1] }]
+ expect(@provider).to receive(:shell_out!).with(*expected_command)
+ .and_return(double("ShellOut result", stdout: example_svn_info, stderr: ""))
expect { @provider.revision_int }.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n")
end
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 5e57cbb840..93f624933f 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -50,27 +50,27 @@ describe Chef::Provider::SystemdUnit do
let(:user_cmd_opts) do
{
- :user => "joe",
- :environment => {
+ user: "joe",
+ environment: {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus",
},
}
end
let(:shell_out_success) do
- double("shell_out", :exitstatus => 0, :error? => false)
+ double("shell_out", exitstatus: 0, error?: false)
end
let(:shell_out_failure) do
- double("shell_out", :exitstatus => 1, :error? => true)
+ double("shell_out", exitstatus: 1, error?: true)
end
let(:shell_out_masked) do
- double("shell_out", :exit_status => 0, :error? => false, :stdout => "masked")
+ double("shell_out", exit_status: 0, error?: false, stdout: "masked")
end
let(:shell_out_static) do
- double("shell_out", :exit_status => 0, :error? => false, :stdout => "static")
+ double("shell_out", exit_status: 0, error?: false, stdout: "static")
end
before(:each) do
@@ -803,7 +803,7 @@ describe Chef::Provider::SystemdUnit do
describe "#active?" do
before(:each) do
provider.current_resource = current_resource
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
context "when a user is specified" do
@@ -844,7 +844,7 @@ describe Chef::Provider::SystemdUnit do
describe "#enabled?" do
before(:each) do
provider.current_resource = current_resource
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
context "when a user is specified" do
@@ -885,7 +885,7 @@ describe Chef::Provider::SystemdUnit do
describe "#masked?" do
before(:each) do
provider.current_resource = current_resource
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
context "when a user is specified" do
@@ -926,7 +926,7 @@ describe Chef::Provider::SystemdUnit do
describe "#static?" do
before(:each) do
provider.current_resource = current_resource
- allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
end
context "when a user is specified" do
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 8f30d8f868..67d4eba138 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -30,20 +30,20 @@ describe Chef::Provider::Template::Content do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => "openldap",
- :recipe_name => "default",
- :source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
- :source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
- :source_line_number => "2",
- :source => "openldap_stuff.conf.erb",
- :name => "openldap_stuff.conf",
- :path => resource_path,
- :local => false,
- :cookbook => nil,
- :variables => {},
- :inline_helper_blocks => {},
- :inline_helper_modules => [],
- :helper_modules => [])
+ cookbook_name: "openldap",
+ recipe_name: "default",
+ source_line: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
+ source_line_file: "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
+ source_line_number: "2",
+ source: "openldap_stuff.conf.erb",
+ name: "openldap_stuff.conf",
+ path: resource_path,
+ local: false,
+ cookbook: nil,
+ variables: {},
+ inline_helper_blocks: {},
+ inline_helper_modules: [],
+ helper_modules: [])
end
let(:rendered_file_locations) do
@@ -58,7 +58,7 @@ describe Chef::Provider::Template::Content do
cl.load_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cl)
node = Chef::Node.new
- double("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection)
+ double("Chef::Resource::RunContext", node: node, cookbook_collection: cookbook_collection)
end
let(:content) do
@@ -130,38 +130,38 @@ describe Chef::Provider::Template::Content do
describe "when using location helpers" do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => "openldap",
- :recipe_name => "default",
- :source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
- :source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
- :source_line_number => "2",
- :source => "helpers.erb",
- :name => "helpers.erb",
- :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb",
- :local => false,
- :cookbook => nil,
- :variables => {},
- :inline_helper_blocks => {},
- :inline_helper_modules => [],
- :helper_modules => [])
+ cookbook_name: "openldap",
+ recipe_name: "default",
+ source_line: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
+ source_line_file: CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
+ source_line_number: "2",
+ source: "helpers.erb",
+ name: "helpers.erb",
+ path: CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb",
+ local: false,
+ cookbook: nil,
+ variables: {},
+ inline_helper_blocks: {},
+ inline_helper_modules: [],
+ helper_modules: [])
end
it "creates the template with the rendered content" do
- expect(IO.read(content.tempfile.path)).to eql <<EOF
-openldap
-default
-#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
-#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
-2
-helpers.erb
-#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
-openldap
-default
-#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
-#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
-2
-helpers.erb
-#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
+ expect(IO.read(content.tempfile.path)).to eql <<~EOF
+ openldap
+ default
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
+ 2
+ helpers.erb
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
+ openldap
+ default
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
+ 2
+ helpers.erb
+ #{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
EOF
end
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index 9f69772bc8..a65846ecb2 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Template do
let(:node) { double("Chef::Node") }
let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:logger) { double("Mixlib::Log::Child").as_null_object }
- let(:run_context) { double("Chef::RunContext", :node => node, :events => events, :logger => logger) }
+ let(:run_context) { double("Chef::RunContext", node: node, events: events, logger: logger) }
let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
end
@@ -50,7 +50,7 @@ describe Chef::Provider::Template do
end
let(:content) do
- content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz")
+ content = double("Chef::Provider::File::Content::Template", template_location: "/foo/bar/baz")
allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true)
content
end
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index 8cc69f88af..7c6948bf84 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -202,7 +202,7 @@ describe Chef::Provider::User::Pw do
end
it "should run pw usermod with the username and the option -H 0" do
- expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { :input => "abracadabra" }).and_return(@status)
+ expect(@provider).to receive(:shell_out_compacted!).with( "pw usermod adam -H 0", { input: "abracadabra" }).and_return(@status)
@provider.modify_password
end
diff --git a/spec/unit/provider/windows_env_spec.rb b/spec/unit/provider/windows_env_spec.rb
index a42a0509c5..0e6cb02d48 100644
--- a/spec/unit/provider/windows_env_spec.rb
+++ b/spec/unit/provider/windows_env_spec.rb
@@ -36,8 +36,8 @@ describe Chef::Provider::WindowsEnv, :windows_only do
describe "when loading the current status" do
before do
- #@current_resource = @new_resource.clone
- #Chef::Resource::Env.stub(:new).and_return(@current_resource)
+ # @current_resource = @new_resource.clone
+ # Chef::Resource::Env.stub(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
allow(@provider).to receive(:env_value).with("FOO").and_return("bar")
allow(@provider).to receive(:env_key_exists).and_return(true)
diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb
index 66bd6854b6..3a046ab5de 100644
--- a/spec/unit/provider/windows_task_spec.rb
+++ b/spec/unit/provider/windows_task_spec.rb
@@ -70,20 +70,20 @@ describe Chef::Provider::WindowsTask, :windows_only do
new_resource.frequency_modifier 15
new_resource.random_delay 60
result = {
- :start_year => 2017,
- :start_month => 12,
- :start_day => 2,
- :start_hour => 17,
- :start_minute => 30,
- :end_month => 0,
- :end_day => 0,
- :end_year => 0,
- :trigger_type => 1,
- :type => { :once => nil },
- :random_minutes_interval => 60,
- :minutes_interval => 15,
- :run_on_last_day_of_month => false,
- :run_on_last_week_of_month => false
+ start_year: 2017,
+ start_month: 12,
+ start_day: 2,
+ start_hour: 17,
+ start_minute: 30,
+ end_month: 0,
+ end_day: 0,
+ end_year: 0,
+ trigger_type: 1,
+ type: { once: nil },
+ random_minutes_interval: 60,
+ minutes_interval: 15,
+ run_on_last_day_of_month: false,
+ run_on_last_week_of_month: false,
}
expect(provider.send(:trigger)).to eq(result)
@@ -145,7 +145,7 @@ describe Chef::Provider::WindowsTask, :windows_only do
new_resource.frequency_modifier 2
result = provider.send(:type)
expect(result).to include(:once)
- expect(result).to eq({ :once => nil })
+ expect(result).to eq({ once: nil })
end
it "returns type hash when frequency :daily" do
@@ -286,7 +286,7 @@ describe Chef::Provider::WindowsTask, :windows_only do
end
end
- #Ref : https://msdn.microsoft.com/en-us/library/windows/desktop/aa380729(v=vs.85).aspx
+ # Ref : https://msdn.microsoft.com/en-us/library/windows/desktop/aa380729(v=vs.85).aspx
describe "#days_of_week" do
it "returns the binary value 2 if day is set as 'Mon'" do
new_resource.day "Mon"
diff --git a/spec/unit/provider/zypper_repository_spec.rb b/spec/unit/provider/zypper_repository_spec.rb
index 3a26876f99..fc8ff14afb 100644
--- a/spec/unit/provider/zypper_repository_spec.rb
+++ b/spec/unit/provider/zypper_repository_spec.rb
@@ -20,17 +20,17 @@ require "spec_helper"
# Output of the command:
# => rpm -qa gpg-pubkey*
-RPM_KEYS = <<-EOF
-gpg-pubkey-307e3d54-4be01a65
-gpg-pubkey-3dbdc284-53674dd4
+RPM_KEYS = <<~EOF
+ gpg-pubkey-307e3d54-4be01a65
+ gpg-pubkey-3dbdc284-53674dd4
EOF
# Output of the command:
# => gpg --with-fingerprint [FILE]
-GPG_FINGER = <<-EOF
-pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14]
- Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
-uid nginx signing key <signing-key@nginx.com>
+GPG_FINGER = <<~EOF
+ pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14]
+ Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
+ uid nginx signing key <signing-key@nginx.com>
EOF
describe Chef::Provider::ZypperRepository do
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index 66b53b2f4a..cb03141c76 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -27,7 +27,7 @@ require "fileutils"
include Chef::Mixin::ConvertToClassName
# Open up Provider so we can write things down easier in here
-#module Chef::Provider
+# module Chef::Provider
describe Chef::ProviderResolver do
include IntegrationSupport
@@ -428,7 +428,7 @@ describe Chef::ProviderResolver do
# old debian uses the Debian provider (does not have insserv or upstart, or update-rc.d???)
on_platform "debian", platform_version: "4.0", os: "linux" do
- #it_behaves_like "a debian platform using the debian provider"
+ # it_behaves_like "a debian platform using the debian provider"
end
# Debian replaced the debian provider with insserv in the FIXME:VERSION distro
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 93d03756a7..3b16edaa4a 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -110,7 +110,7 @@ describe Chef::Recipe do
it "locate resource for particular platform" do
ShaunTheSheep = Class.new(Chef::Resource)
ShaunTheSheep.resource_name :shaun_the_sheep
- ShaunTheSheep.provides :laughter, :platform => ["television"]
+ ShaunTheSheep.provides :laughter, platform: ["television"]
node.automatic[:platform] = "television"
node.automatic[:platform_version] = "123"
res = recipe.laughter "timmy"
@@ -183,7 +183,7 @@ describe Chef::Recipe do
it "does not add the resource to the resource collection" do
zm_resource # force let binding evaluation
- expect { run_context.resource_collection.resources(:zen_master => "klopp") }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ expect { run_context.resource_collection.resources(zen_master: "klopp") }.to raise_error(Chef::Exceptions::ResourceNotFound)
end
end
@@ -238,7 +238,7 @@ describe Chef::Recipe do
it "adds the resource to the resource collection" do
zm_resource # force let binding evaluation
- expect(run_context.resource_collection.resources(:zen_master => "klopp")).to eq(zm_resource)
+ expect(run_context.resource_collection.resources(zen_master: "klopp")).to eq(zm_resource)
end
it "will insert another resource if create_if_missing is not set (cloned resource as of Chef-12)" do
@@ -339,7 +339,7 @@ describe Chef::Recipe do
describe "resource definitions" do
it "should execute defined resources" do
crow_define = Chef::ResourceDefinition.new
- crow_define.define :crow, :peace => false, :something => true do
+ crow_define.define :crow, peace: false, something: true do
zen_master "lao tzu" do
peace params[:peace]
something params[:something]
@@ -349,13 +349,13 @@ describe Chef::Recipe do
recipe.crow "mine" do
peace true
end
- expect(run_context.resource_collection.resources(:zen_master => "lao tzu").name).to eql("lao tzu")
- expect(run_context.resource_collection.resources(:zen_master => "lao tzu").something).to eql(true)
+ expect(run_context.resource_collection.resources(zen_master: "lao tzu").name).to eql("lao tzu")
+ expect(run_context.resource_collection.resources(zen_master: "lao tzu").something).to eql(true)
end
it "should set the node on defined resources" do
crow_define = Chef::ResourceDefinition.new
- crow_define.define :crow, :peace => false, :something => true do
+ crow_define.define :crow, peace: false, something: true do
zen_master "lao tzu" do
peace params[:peace]
something params[:something]
@@ -366,12 +366,12 @@ describe Chef::Recipe do
recipe.crow "mine" do
something node[:foo]
end
- expect(recipe.resources(:zen_master => "lao tzu").something).to eql(false)
+ expect(recipe.resources(zen_master: "lao tzu").something).to eql(false)
end
it "should return the last statement in the definition as the retval" do
crow_define = Chef::ResourceDefinition.new
- crow_define.define :crow, :peace => false, :something => true do
+ crow_define.define :crow, peace: false, something: true do
"the return val"
end
run_context.definitions[:crow] = crow_define
@@ -392,7 +392,7 @@ describe Chef::Recipe do
end
CODE
expect { recipe.instance_eval(code) }.not_to raise_error
- expect(recipe.resources(:zen_master => "gnome").name).to eql("gnome")
+ expect(recipe.resources(zen_master: "gnome").name).to eql("gnome")
end
end
@@ -408,7 +408,7 @@ describe Chef::Recipe do
describe "from_file" do
it "should load a resource from a ruby file" do
recipe.from_file(File.join(CHEF_SPEC_DATA, "recipes", "test.rb"))
- res = recipe.resources(:file => "/etc/nsswitch.conf")
+ res = recipe.resources(file: "/etc/nsswitch.conf")
expect(res.name).to eql("/etc/nsswitch.conf")
expect(res.action).to eql([:create])
expect(res.owner).to eql("root")
@@ -426,7 +426,7 @@ describe Chef::Recipe do
expect(node).to receive(:loaded_recipe).with(:openldap, "gigantor")
allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false)
run_context.include_recipe "openldap::gigantor"
- res = run_context.resource_collection.resources(:cat => "blanket")
+ res = run_context.resource_collection.resources(cat: "blanket")
expect(res.name).to eql("blanket")
expect(res.pretty_kitty).to eql(false)
end
@@ -435,7 +435,7 @@ describe Chef::Recipe do
expect(node).to receive(:loaded_recipe).with(:openldap, "default")
allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false)
run_context.include_recipe "openldap"
- res = run_context.resource_collection.resources(:cat => "blanket")
+ res = run_context.resource_collection.resources(cat: "blanket")
expect(res.name).to eql("blanket")
expect(res.pretty_kitty).to eql(true)
end
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index c38ebbdd46..2a2e166e6c 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -22,7 +22,7 @@ require "ostruct"
describe Chef::Resource::Conditional do
before do
allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(nil)
- @status = OpenStruct.new(:success? => true)
+ @status = OpenStruct.new(success?: true)
allow_any_instance_of(Mixlib::ShellOut).to receive(:status).and_return(@status)
@parent_resource = Chef::Resource.new("", Chef::Node.new)
end
diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index 734fc152c1..b35233649d 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -2,7 +2,7 @@
# Author:: Daniel DeLeo (<dan@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
# Copyright:: Copyright 2010-2017, Chef Software Inc.
-#p License:: Apache License, Version 2.0
+# p License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -72,8 +72,8 @@ describe Chef::Resource::CookbookFile do
state = resource.state_for_resource_reporter
if Chef::Platform.windows?
puts state
- expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
- expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }])
+ expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
+ expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
else
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0664")
diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb
index 1b90fd3a0d..f4262a0396 100644
--- a/spec/unit/resource/dnf_package_spec.rb
+++ b/spec/unit/resource/dnf_package_spec.rb
@@ -59,19 +59,19 @@ describe Chef::Resource::DnfPackage, "flush_cache" do
let(:resource) { Chef::Resource::DnfPackage.new("foo") }
it "defaults the flush timing to false" do
- flush_hash = { :before => false, :after => false }
+ flush_hash = { before: false, after: false }
expect(resource.flush_cache).to eq(flush_hash)
end
it "allows you to set the flush timing with an array" do
flush_array = [ :before, :after ]
- flush_hash = { :before => true, :after => true }
+ flush_hash = { before: true, after: true }
resource.flush_cache(flush_array)
expect(resource.flush_cache).to eq(flush_hash)
end
it "allows you to set the flush timing with a hash" do
- flush_hash = { :before => true, :after => true }
+ flush_hash = { before: true, after: true }
resource.flush_cache(flush_hash)
expect(resource.flush_cache).to eq(flush_hash)
end
diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb
index 947f6c608e..9bd434b74a 100644
--- a/spec/unit/resource/execute_spec.rb
+++ b/spec/unit/resource/execute_spec.rb
@@ -109,7 +109,7 @@ describe Chef::Resource::Execute do
shared_examples_for "a consumer of the Execute resource" do
context "when running on Windows" do
before do
- allow(resource).to receive(:node).and_return({ :platform_family => "windows" })
+ allow(resource).to receive(:node).and_return({ platform_family: "windows" })
end
context "when no user, domain, or password is specified" do
@@ -211,7 +211,7 @@ describe Chef::Resource::Execute do
context "when not running on Windows" do
before do
- allow(resource).to receive(:node).and_return({ :platform_family => "ubuntu" })
+ allow(resource).to receive(:node).and_return({ platform_family: "ubuntu" })
end
context "when no user, domain, or password is specified" do
diff --git a/spec/unit/resource/file/verification/systemd_unit_spec.rb b/spec/unit/resource/file/verification/systemd_unit_spec.rb
index 8a3d849582..b1f9239442 100644
--- a/spec/unit/resource/file/verification/systemd_unit_spec.rb
+++ b/spec/unit/resource/file/verification/systemd_unit_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Resource::File::Verification::SystemdUnit do
let(:command) { "#{systemd_analyze_path} verify %{path}" }
- let(:opts) { { :future => true } }
+ let(:opts) { { future: true } }
let(:parent_resource) { Chef::Resource.new("llama") }
let(:systemd_analyze_path) { "/usr/bin/systemd-analyze" }
let(:systemd_dir) { "/etc/systemd/system" }
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index e46040268a..f0ec999019 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Resource::File::Verification do
it "accepts an options hash" do
v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {}
- expect { v.verify("/foo/bar", { :future => true }) }.to_not raise_error
+ expect { v.verify("/foo/bar", { future: true }) }.to_not raise_error
end
context "with a verification block" do
diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb
index 7e9b96616a..5e649da1a9 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_spec.rb
@@ -113,15 +113,15 @@ describe Chef::Resource::File do
end
- describe "when access controls are set on windows", :windows_only => true do
+ describe "when access controls are set on windows", windows_only: true do
before do
resource.rights :read, "Everyone"
resource.rights :full_control, "DOMAIN\User"
end
it "describes its state including windows ACL attributes" do
state = resource.state_for_resource_reporter
- expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" },
- { :permissions => :full_control, :principals => "DOMAIN\User" } ])
+ expect(state[:rights]).to eq([ { permissions: :read, principals: "Everyone" },
+ { permissions: :full_control, principals: "DOMAIN\User" } ])
end
end
end
diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb
index 9747c41a88..154bd09616 100644
--- a/spec/unit/resource/freebsd_package_spec.rb
+++ b/spec/unit/resource/freebsd_package_spec.rb
@@ -79,8 +79,8 @@ describe Chef::Resource::FreebsdPackage do
describe "if pkgng enabled" do
it "is Freebsd::Pkgng" do
- pkg_enabled = OpenStruct.new(:stdout => "yes\n")
- allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled)
+ pkg_enabled = OpenStruct.new(stdout: "yes\n")
+ allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
resource.after_created
expect(resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng)
end
@@ -88,8 +88,8 @@ describe Chef::Resource::FreebsdPackage do
describe "if freebsd_version is less than 1000017 and pkgng not enabled" do
it "is Freebsd::Pkg" do
- pkg_enabled = OpenStruct.new(:stdout => "\n")
- allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", :env => nil).and_return(pkg_enabled)
+ pkg_enabled = OpenStruct.new(stdout: "\n")
+ allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled)
[1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version|
node.automatic_attrs[:os_version] = freebsd_version
diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb
index 638d8718c7..10bef38410 100644
--- a/spec/unit/resource/group_spec.rb
+++ b/spec/unit/resource/group_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Resource::Group, "group_name" do
end
it "does not allow a hash" do
- expect { resource.send(:group_name, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
+ expect { resource.send(:group_name, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
@@ -85,7 +85,7 @@ describe Chef::Resource::Group, "gid" do
end
it "does not allow a hash" do
- expect { resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
+ expect { resource.send(:gid, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
@@ -109,7 +109,7 @@ describe Chef::Resource::Group, "members" do
end
it "(#{method}) does not allow a hash" do
- expect { resource.send(method, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
+ expect { resource.send(method, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
end
@@ -127,7 +127,7 @@ describe Chef::Resource::Group, "append" do
end
it "does not allow a hash" do
- expect { resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
+ expect { resource.send(:gid, { aj: "is freakin awesome" }) }.to raise_error(ArgumentError)
end
describe "when it has members" do
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index 721f30cf09..ec6fb1232a 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -144,19 +144,19 @@ describe Chef::Resource::Mount do
end
it "defaults all feature support to false" do
- support_hash = { :remount => false }
+ support_hash = { remount: false }
expect(resource.supports).to eq(support_hash)
end
it "allows you to set feature support as an array" do
support_array = [ :remount ]
- support_hash = { :remount => true }
+ support_hash = { remount: true }
resource.supports(support_array)
expect(resource.supports).to eq(support_hash)
end
it "allows you to set feature support as a hash" do
- support_hash = { :remount => true }
+ support_hash = { remount: true }
resource.supports(support_hash)
expect(resource.supports).to eq(support_hash)
end
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index 79a714edfc..b0e1304775 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_spec.rb
@@ -56,8 +56,8 @@ describe Chef::Resource::Package do
end
it "accepts a hash for response file template variables" do
- resource.response_file_variables({ :variables => true })
- expect(resource.response_file_variables).to eql({ :variables => true })
+ resource.response_file_variables({ variables: true })
+ expect(resource.response_file_variables).to eql({ variables: true })
end
it "accepts a string for the source" do
diff --git a/spec/unit/resource/powershell_package_source_spec.rb b/spec/unit/resource/powershell_package_source_spec.rb
index d8cb8a09a0..4033f4515f 100644
--- a/spec/unit/resource/powershell_package_source_spec.rb
+++ b/spec/unit/resource/powershell_package_source_spec.rb
@@ -205,13 +205,13 @@ describe Chef::Resource::PowershellPackageSource do
describe "#package_source_exists?" do
it "returns true if it exists" do
- allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => "MyGallery\r\n"))
+ allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: "MyGallery\r\n"))
resource.source_name("MyGallery")
expect(provider.package_source_exists?).to eql(true)
end
it "returns false if it doesn't exist" do
- allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", :stdout => ""))
+ allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: ""))
resource.source_name("MyGallery")
expect(provider.package_source_exists?).to eql(false)
end
diff --git a/spec/unit/resource/powershell_package_spec.rb b/spec/unit/resource/powershell_package_spec.rb
index 33c652f1d7..d82121a97b 100644
--- a/spec/unit/resource/powershell_package_spec.rb
+++ b/spec/unit/resource/powershell_package_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Resource::PowershellPackage do
expect(resource).to be_a_kind_of(Chef::Resource::Package)
end
- #to check the value of resource.resource_name
+ # to check the value of resource.resource_name
it "has a resource name of :powershell_package" do
expect(resource.resource_name).to eql(:powershell_package)
end
diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb
index 9cdb6fdbee..9afd202f91 100644
--- a/spec/unit/resource/powershell_script_spec.rb
+++ b/spec/unit/resource/powershell_script_spec.rb
@@ -87,7 +87,7 @@ describe Chef::Resource::PowershellScript do
it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {})
+ { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {})
resource.only_if("$true")
end
@@ -98,27 +98,27 @@ describe Chef::Resource::PowershellScript do
file_resource.guard_interpreter :powershell_script
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {})
+ { convert_boolean_return: true, code: "$true" }).and_return(Proc.new {})
resource.only_if("$true")
end
it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do
- guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 }
+ guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 }
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {})
+ { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {})
resource.only_if("$true", guard_parameters)
end
it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do
- guard_parameters = { :cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64 }
+ guard_parameters = { cwd: "/etc/chef", convert_boolean_return: true, architecture: :x86_64 }
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {})
+ { convert_boolean_return: true, code: "$true" }.merge(guard_parameters)).and_return(Proc.new {})
resource.only_if("$true", guard_parameters)
end
it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do
- other_guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 }
- parameters_with_boolean_disabled = other_guard_parameters.merge({ :convert_boolean_return => false, :code => "$true" })
+ other_guard_parameters = { cwd: "/etc/chef", architecture: :x86_64 }
+ parameters_with_boolean_disabled = other_guard_parameters.merge({ convert_boolean_return: false, code: "$true" })
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
parameters_with_boolean_disabled).and_return(Proc.new {})
resource.only_if("$true", parameters_with_boolean_disabled)
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index c7e95c37be..147bc8492c 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Resource::RegistryKey, "key" do
end
it "does not allow a hash" do
- expect { resource.send(:key, { :sonic => "screwdriver" }) }.to raise_error(ArgumentError)
+ expect { resource.send(:key, { sonic: "screwdriver" }) }.to raise_error(ArgumentError)
end
end
@@ -80,26 +80,26 @@ describe Chef::Resource::RegistryKey, "values" do
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
it "allows a single proper hash of registry values" do
- resource.values( { :name => "poosh", :type => :string, :data => "carmen" } )
- expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
+ resource.values( { name: "poosh", type: :string, data: "carmen" } )
+ expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ])
end
it "allows an array of proper hashes of registry values" do
- resource.values [ { :name => "poosh", :type => :string, :data => "carmen" } ]
- expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
+ resource.values [ { name: "poosh", type: :string, data: "carmen" } ]
+ expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ])
end
it "returns checksummed data if the type is unsafe" do
- resource.values( { :name => "poosh", :type => :binary, :data => 255.chr * 1 })
- expect(resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ])
+ resource.values( { name: "poosh", type: :binary, data: 255.chr * 1 })
+ expect(resource.values).to eql([ { name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ])
end
it "raises an exception if the name field is missing" do
- expect { resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError)
+ expect { resource.values [ { type: :string, data: "carmen" } ] }.to raise_error(ArgumentError)
end
it "raises an exception if extra fields are present" do
- expect { resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError)
+ expect { resource.values [ { name: "poosh", type: :string, data: "carmen", screwdriver: "sonic" } ] }.to raise_error(ArgumentError)
end
it "does not allow a string" do
@@ -111,26 +111,26 @@ describe Chef::Resource::RegistryKey, "values" do
end
it "raises an exception if type of name is not string" do
- expect { resource.values([ { :name => 123, :type => :string, :data => "carmen" } ]) }.to raise_error(ArgumentError)
+ expect { resource.values([ { name: 123, type: :string, data: "carmen" } ]) }.to raise_error(ArgumentError)
end
it "does not raise an exception if type of name is string" do
- expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
+ expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error
end
context "type key not given" do
it "does not raise an exception" do
- expect { resource.values([ { :name => "123", :data => "carmen" } ]) }.to_not raise_error
+ expect { resource.values([ { name: "123", data: "carmen" } ]) }.to_not raise_error
end
end
context "type key given" do
it "raises an exception if type of type is not symbol" do
- expect { resource.values([ { :name => "123", :type => "string", :data => "carmen" } ]) }.to raise_error(ArgumentError)
+ expect { resource.values([ { name: "123", type: "string", data: "carmen" } ]) }.to raise_error(ArgumentError)
end
it "does not raise an exception if type of type is symbol" do
- expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
+ expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error
end
end
end
@@ -144,7 +144,7 @@ describe Chef::Resource::RegistryKey, "recursive" do
end
it "does not allow a hash" do
- expect { resource.recursive({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
+ expect { resource.recursive({ sonic: :screwdriver }) }.to raise_error(ArgumentError)
end
it "does not allow an array" do
@@ -175,7 +175,7 @@ describe Chef::Resource::RegistryKey, "architecture" do
end
it "does not allow a hash" do
- expect { resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
+ expect { resource.architecture({ sonic: :screwdriver }) }.to raise_error(ArgumentError)
end
it "does not allow an array" do
@@ -195,7 +195,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
it "returns unsafe data as-is" do
- key_values = [ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]
+ key_values = [ { name: "poosh", type: :binary, data: 255.chr * 1 } ]
resource.values(key_values)
expect(resource.unscrubbed_values).to eql(key_values)
end
@@ -205,7 +205,7 @@ describe Chef::Resource::RegistryKey, "state" do
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
it "returns scrubbed values" do
- resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ])
- expect(resource.state_for_resource_reporter[:values]).to eql( [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] )
+ resource.values([ { name: "poosh", type: :binary, data: 255.chr * 1 } ])
+ expect(resource.state_for_resource_reporter[:values]).to eql( [{ name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] )
end
end
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 581b2dbf6e..39d34d9a96 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -199,8 +199,8 @@ describe Chef::Resource::RemoteFile do
state = resource.state_for_resource_reporter
if Chef::Platform.windows?
puts state
- expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
- expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }])
+ expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
+ expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
else
expect(state[:group]).to eq("pokemon")
expect(state[:mode]).to eq("0664")
diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb
index e141e01fcf..07fd63bb2b 100644
--- a/spec/unit/resource/resource_notification_spec.rb
+++ b/spec/unit/resource/resource_notification_spec.rb
@@ -65,7 +65,7 @@ describe Chef::Resource::Notification do
end
it "resolves a lazy reference to a resource" do
- notification.resource = { :cat => "keyboard_cat" }
+ notification.resource = { cat: "keyboard_cat" }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @keyboard_cat
@@ -78,7 +78,7 @@ describe Chef::Resource::Notification do
it "resolves a lazy reference to its notifying resource" do
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
notification.resource = @keyboard_cat
- notification.notifying_resource = { :cat => "long_cat" }
+ notification.notifying_resource = { cat: "long_cat" }
@long_cat = Chef::Resource::Cat.new("long_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @long_cat
@@ -87,11 +87,11 @@ describe Chef::Resource::Notification do
end
it "resolves lazy references to both its resource and its notifying resource" do
- notification.resource = { :cat => "keyboard_cat" }
+ notification.resource = { cat: "keyboard_cat" }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @keyboard_cat
- notification.notifying_resource = { :cat => "long_cat" }
+ notification.notifying_resource = { cat: "long_cat" }
@long_cat = Chef::Resource::Cat.new("long_cat")
@resource_collection << @long_cat
notification.resolve_resource_reference(@resource_collection)
@@ -100,7 +100,7 @@ describe Chef::Resource::Notification do
end
it "raises a RuntimeError if you try to reference multiple resources" do
- notification.resource = { :cat => %w{keyboard_cat cheez_cat} }
+ notification.resource = { cat: %w{keyboard_cat cheez_cat} }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@@ -112,7 +112,7 @@ describe Chef::Resource::Notification do
end
it "raises a RuntimeError if you try to reference multiple notifying resources" do
- notification.notifying_resource = { :cat => %w{long_cat cheez_cat} }
+ notification.notifying_resource = { cat: %w{long_cat cheez_cat} }
@long_cat = Chef::Resource::Cat.new("long_cat")
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@@ -124,7 +124,7 @@ describe Chef::Resource::Notification do
end
it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do
- notification.resource = { :cat => "keyboard_cat" }
+ notification.resource = { cat: "keyboard_cat" }
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @cheez_cat
@@ -134,7 +134,7 @@ describe Chef::Resource::Notification do
end
it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do
- notification.notifying_resource = { :cat => "long_cat" }
+ notification.notifying_resource = { cat: "long_cat" }
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @cheez_cat
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index fc82c19b79..963c2b2d89 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -168,19 +168,19 @@ describe Chef::Resource::Service do
end
it "defaults all the feature support to nil" do
- support_hash = { :status => nil, :restart => nil, :reload => nil }
+ support_hash = { status: nil, restart: nil, reload: nil }
expect(resource.supports).to eq(support_hash)
end
it "allows you to set what features this resource supports as a array" do
support_array = [ :status, :restart ]
- support_hash = { :status => true, :restart => true }
+ support_hash = { status: true, restart: true }
resource.supports(support_array)
expect(resource.supports).to eq(support_hash)
end
it "allows you to set what features this resource supports as a hash" do
- support_hash = { :status => true, :restart => true }
+ support_hash = { status: true, restart: true }
resource.supports(support_hash)
expect(resource.supports).to eq(support_hash)
end
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 06469f2f9c..56af50517c 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -64,8 +64,8 @@ describe Chef::Resource::Template do
describe "variables" do
it "accepts a hash for the variable list" do
- resource.variables({ :reluctance => :awkward })
- expect(resource.variables).to eq({ :reluctance => :awkward })
+ resource.variables({ reluctance: :awkward })
+ expect(resource.variables).to eq({ reluctance: :awkward })
end
end
diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb
index 1c583afc44..2a96c5328d 100644
--- a/spec/unit/resource/user_spec.rb
+++ b/spec/unit/resource/user_spec.rb
@@ -75,7 +75,7 @@ end
end
it "does not allow a hash" do
- expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
+ expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(ArgumentError)
end
end
end
@@ -95,7 +95,7 @@ end
end
it "does not allow a hash" do
- expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
+ expect { resource.send(attrib, { woot: "i found it" }) }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb
index ce289ce45a..d1dc1a3cce 100644
--- a/spec/unit/resource/yum_package_spec.rb
+++ b/spec/unit/resource/yum_package_spec.rb
@@ -90,19 +90,19 @@ describe Chef::Resource::YumPackage, "flush_cache" do
end
it "should default the flush timing to false" do
- flush_hash = { :before => false, :after => false }
+ flush_hash = { before: false, after: false }
expect(@resource.flush_cache).to eq(flush_hash)
end
it "should allow you to set the flush timing with an array" do
flush_array = [ :before, :after ]
- flush_hash = { :before => true, :after => true }
+ flush_hash = { before: true, after: true }
@resource.flush_cache(flush_array)
expect(@resource.flush_cache).to eq(flush_hash)
end
it "should allow you to set the flush timing with a hash" do
- flush_hash = { :before => true, :after => true }
+ flush_hash = { before: true, after: true }
@resource.flush_cache(flush_hash)
expect(@resource.flush_cache).to eq(flush_hash)
end
diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb
index 9955bc2bea..403be4c566 100644
--- a/spec/unit/resource_collection/resource_set_spec.rb
+++ b/spec/unit/resource_collection/resource_set_spec.rb
@@ -73,25 +73,25 @@ describe Chef::ResourceCollection::ResourceSet do
it "should find a resource by type symbol and name" do
collection.insert_as(zen_master)
- expect(collection.find(:zen_master => zen_master_name)).to equal(zen_master)
+ expect(collection.find(zen_master: zen_master_name)).to equal(zen_master)
end
it "should find a resource by type symbol and array of names" do
collection.insert_as(zen_master)
collection.insert_as(zen_master2)
- check_by_names(collection.find(:zen_master => [zen_master_name, zen_master2_name]), zen_master_name, zen_master2_name)
+ check_by_names(collection.find(zen_master: [zen_master_name, zen_master2_name]), zen_master_name, zen_master2_name)
end
it "should find a resource by type symbol and array of names with custom names" do
collection.insert_as(zen_master, :zzz, "name1")
collection.insert_as(zen_master2, :zzz, "name2")
- check_by_names(collection.find( :zzz => %w{name1 name2}), zen_master_name, zen_master2_name)
+ check_by_names(collection.find( zzz: %w{name1 name2}), zen_master_name, zen_master2_name)
end
it "should find resources of multiple kinds (:zen_master => a, :zen_follower => b)" do
collection.insert_as(zen_master)
collection.insert_as(zen_follower)
- check_by_names(collection.find(:zen_master => [zen_master_name], :zen_follower => [zen_follower_name]),
+ check_by_names(collection.find(zen_master: [zen_master_name], zen_follower: [zen_follower_name]),
zen_master_name, zen_follower_name)
end
@@ -99,7 +99,7 @@ describe Chef::ResourceCollection::ResourceSet do
collection.insert_as(zen_master, :zzz, "name1")
collection.insert_as(zen_master2, :zzz, "name2")
collection.insert_as(zen_follower, :yyy, "name3")
- check_by_names(collection.find(:zzz => %w{name1 name2}, :yyy => ["name3"]),
+ check_by_names(collection.find(zzz: %w{name1 name2}, yyy: ["name3"]),
zen_master_name, zen_follower_name, zen_master2_name)
end
@@ -215,7 +215,7 @@ describe Chef::ResourceCollection::ResourceSet do
end
it "accepts a single-element :resource_type => 'resource_name' Hash" do
- expect(collection.validate_lookup_spec!(:service => "apache2")).to be_truthy
+ expect(collection.validate_lookup_spec!(service: "apache2")).to be_truthy
end
it "accepts a chef resource object" do
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index c696572b13..8dd367b0ec 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -65,7 +65,7 @@ describe Chef::ResourceCollection do
end
it "should accept named arguments in any order" do
- rc.insert(resource, :instance_name => "foo", :resource_type => "bar")
+ rc.insert(resource, instance_name: "foo", resource_type: "bar")
expect(rc[0]).to eq(resource)
end
@@ -196,19 +196,19 @@ describe Chef::ResourceCollection do
it "should find a resource by symbol and name (:zen_master => monkey)" do
load_up_resources
- expect(rc.resources(:zen_master => "monkey").name).to eql("monkey")
+ expect(rc.resources(zen_master: "monkey").name).to eql("monkey")
end
it "should find a resource by symbol and array of names (:zen_master => [a,b])" do
load_up_resources
- results = rc.resources(:zen_master => %w{monkey dog})
+ results = rc.resources(zen_master: %w{monkey dog})
expect(results.length).to eql(2)
check_by_names(results, "monkey", "dog")
end
it "should find resources of multiple kinds (:zen_master => a, :file => b)" do
load_up_resources
- results = rc.resources(:zen_master => "monkey", :file => "something")
+ results = rc.resources(zen_master: "monkey", file: "something")
expect(results.length).to eql(2)
check_by_names(results, "monkey", "something")
end
@@ -253,7 +253,7 @@ describe Chef::ResourceCollection do
end
it "accepts a single-element :resource_type => 'resource_name' Hash" do
- expect(rc.validate_lookup_spec!(:service => "apache2")).to be_truthy
+ expect(rc.validate_lookup_spec!(service: "apache2")).to be_truthy
end
it "accepts a chef resource object" do
diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb
index cc19cc7a01..5be3e59009 100644
--- a/spec/unit/resource_definition_spec.rb
+++ b/spec/unit/resource_definition_spec.rb
@@ -66,13 +66,13 @@ describe Chef::ResourceDefinition do
it "should accept a new definition with a hash" do
expect do
- defn.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do
+ defn.define :smoke, cigar: "cuban", cigarette: "marlboro" do
end
end.not_to raise_error
end
it "should expose the prototype hash params in the params hash" do
- defn.define(:smoke, :cigar => "cuban", :cigarette => "marlboro") {}
+ defn.define(:smoke, cigar: "cuban", cigarette: "marlboro") {}
expect(defn.params[:cigar]).to eql("cuban")
expect(defn.params[:cigarette]).to eql("marlboro")
end
diff --git a/spec/unit/resource_inspector_spec.rb b/spec/unit/resource_inspector_spec.rb
index 2cb9c0bb65..aef92732b3 100644
--- a/spec/unit/resource_inspector_spec.rb
+++ b/spec/unit/resource_inspector_spec.rb
@@ -21,9 +21,9 @@ class DummyResource < Chef::Resource
resource_name :dummy
description "A dummy resource"
examples <<~EOH
- dummy "foo" do
- first "yes"
- end
+ dummy "foo" do
+ first "yes"
+ end
EOH
introduced "14.0"
property :first, String, description: "My First Property", introduced: "14.0"
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 97a4fe4b30..fe8b129a73 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -42,7 +42,7 @@ describe Chef::ResourceReporter do
@new_resource = Chef::Resource::File.new("/tmp/a-file.txt")
@cookbook_name = "monkey"
@new_resource.cookbook_name = @cookbook_name
- @cookbook_version = double("Cookbook::Version", :version => "1.2.3")
+ @cookbook_version = double("Cookbook::Version", version: "1.2.3")
allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version)
@current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
@start_time = Time.new
@@ -285,7 +285,7 @@ describe Chef::ResourceReporter do
end
it "resource_command in prepared_run_data should be blank" do
- expect(@first_update_report["after"]).to eq({ :command => "sensitive-resource" })
+ expect(@first_update_report["after"]).to eq({ command: "sensitive-resource" })
end
end
@@ -317,9 +317,9 @@ describe Chef::ResourceReporter do
context "the new_resource name and id are hashes" do
before do
@bad_resource = Chef::Resource::File.new("/tmp/filename_as_hash.txt")
- allow(@bad_resource).to receive(:name).and_return({ :foo => :bar })
- allow(@bad_resource).to receive(:identity).and_return({ :foo => :bar })
- allow(@bad_resource).to receive(:path).and_return({ :foo => :bar })
+ allow(@bad_resource).to receive(:name).and_return({ foo: :bar })
+ allow(@bad_resource).to receive(:identity).and_return({ foo: :bar })
+ allow(@bad_resource).to receive(:path).and_return({ foo: :bar })
@resource_reporter.resource_action_start(@bad_resource, :create)
@resource_reporter.resource_current_state_loaded(@bad_resource, :create, @current_resource)
@resource_reporter.resource_updated(@bad_resource, :create)
@@ -472,7 +472,7 @@ describe Chef::ResourceReporter do
context "when the resource is a RegistryKey with binary data" do
let(:new_resource) do
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
- resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ])
+ resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ])
allow(resource).to receive(:cookbook_name).and_return(@cookbook_name)
allow(resource).to receive(:cookbook_version).and_return(@cookbook_version)
resource
@@ -480,7 +480,7 @@ describe Chef::ResourceReporter do
let(:current_resource) do
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
- resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ])
+ resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ])
resource
end
@@ -616,11 +616,11 @@ describe Chef::ResourceReporter do
# 404 getting the run_id
@response = Net::HTTPNotFound.new("a response body", "404", "Not Found")
@error = Net::HTTPServerException.new("404 message", @response)
- expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id,
- :start_time => @start_time.to_s },
- { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
- and_raise(@error)
+ expect(@rest_client).to receive(:post)
+ .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id,
+ start_time: @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
+ .and_raise(@error)
end
it "assumes the feature is not enabled" do
@@ -646,10 +646,10 @@ describe Chef::ResourceReporter do
# 500 getting the run_id
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
@error = Net::HTTPServerException.new("500 message", @response)
- expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
- { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
- and_raise(@error)
+ expect(@rest_client).to receive(:post)
+ .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
+ .and_raise(@error)
end
it "assumes the feature is not enabled" do
@@ -676,10 +676,10 @@ describe Chef::ResourceReporter do
# 500 getting the run_id
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
@error = Net::HTTPServerException.new("500 message", @response)
- expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
- { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
- and_raise(@error)
+ expect(@rest_client).to receive(:post)
+ .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
+ .and_raise(@error)
end
after do
@@ -697,10 +697,10 @@ describe Chef::ResourceReporter do
context "after creating the run history document" do
before do
response = { "uri" => "https://example.com/reports/nodes/spitfire/runs/@run_id" }
- expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
- { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
- and_return(response)
+ expect(@rest_client).to receive(:post)
+ .with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
+ .and_return(response)
@resource_reporter.run_started(@run_status)
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 26660c9415..a4f64e11e1 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -230,54 +230,54 @@ describe Chef::Resource do
describe "notifies" do
it "should make notified resources appear in the actions hash" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee")
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee")
expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
end
it "should make notified resources be capable of acting immediately" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :immediate
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee"), :immediate
expect(resource.immediate_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
end
it "should raise an exception if told to act in other than :delay or :immediate(ly)" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
expect do
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :someday
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee"), :someday
end.to raise_error(ArgumentError)
end
it "should allow multiple notified resources appear in the actions hash" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee")
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee")
expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
run_context.resource_collection << Chef::Resource::ZenMaster.new("beans")
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "beans")
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "beans")
expect(resource.delayed_notifications.detect { |e| e.resource.name == "beans" && e.action == :reload }).not_to be_nil
end
it "creates a notification for a resource that is not yet in the resource collection" do
- resource.notifies(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
+ resource.notifies(:restart, service: "apache")
+ expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource)
expect(resource.delayed_notifications).to include(expected_notification)
end
it "notifies another resource immediately" do
- resource.notifies_immediately(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
+ resource.notifies_immediately(:restart, service: "apache")
+ expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource)
expect(resource.immediate_notifications).to include(expected_notification)
end
it "notifies a resource to take action at the end of the chef run" do
- resource.notifies_delayed(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
+ resource.notifies_delayed(:restart, service: "apache")
+ expected_notification = Chef::Resource::Notification.new({ service: "apache" }, :restart, resource)
expect(resource.delayed_notifications).to include(expected_notification)
end
it "notifies a resource with an array for its name via its prettified string name" do
run_context.resource_collection << Chef::Resource::ZenMaster.new(%w{coffee tea})
- resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee, tea")
+ resource.notifies :reload, run_context.resource_collection.find(zen_master: "coffee, tea")
expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee, tea" && e.action == :reload }).not_to be_nil
end
@@ -302,26 +302,26 @@ describe Chef::Resource do
describe "subscribes" do
it "should make resources appear in the actions hash of subscribed nodes" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- zr = run_context.resource_collection.find(:zen_master => "coffee")
+ zr = run_context.resource_collection.find(zen_master: "coffee")
resource.subscribes :reload, zr
expect(zr.delayed_notifications.detect { |e| e.resource.name == "funk" && e.action == :reload }).not_to be_nil
end
it "should make resources appear in the actions hash of subscribed nodes" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- zr = run_context.resource_collection.find(:zen_master => "coffee")
+ zr = run_context.resource_collection.find(zen_master: "coffee")
resource.subscribes :reload, zr
expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
run_context.resource_collection << Chef::Resource::ZenMaster.new("bean")
- zrb = run_context.resource_collection.find(:zen_master => "bean")
+ zrb = run_context.resource_collection.find(zen_master: "bean")
zrb.subscribes :reload, zr
expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
end
it "should make subscribed resources be capable of acting immediately" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- zr = run_context.resource_collection.find(:zen_master => "coffee")
+ zr = run_context.resource_collection.find(zen_master: "coffee")
resource.subscribes :reload, zr, :immediately
expect(zr.immediate_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
end
@@ -400,16 +400,16 @@ describe Chef::Resource do
it "can have some examples" do
c = Class.new(Chef::Resource) do
- examples <<-EOH
-resource "foo" do
- foo foo
-end
+ examples <<~EOH
+ resource "foo" do
+ foo foo
+ end
EOH
end
- expect(c.examples).to eq <<-EOH
-resource "foo" do
- foo foo
-end
+ expect(c.examples).to eq <<~EOH
+ resource "foo" do
+ foo foo
+ end
EOH
end
end
@@ -675,7 +675,7 @@ end
snitch_variable = nil
resource.only_if { snitch_variable = true }
expect(resource.only_if.first.positivity).to eq(:only_if)
- #Chef::Mixin::Command.should_receive(:only_if).with(true, {}).and_return(false)
+ # Chef::Mixin::Command.should_receive(:only_if).with(true, {}).and_return(false)
resource.run_action(:purr)
expect(snitch_variable).to be_truthy
end
@@ -691,8 +691,8 @@ end
it "accepts command options for only_if conditionals" do
expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_command).at_least(1).times
- resource.only_if("true", :cwd => "/tmp")
- expect(resource.only_if.first.command_opts).to eq({ :cwd => "/tmp" })
+ resource.only_if("true", cwd: "/tmp")
+ expect(resource.only_if.first.command_opts).to eq({ cwd: "/tmp" })
resource.run_action(:purr)
end
@@ -715,8 +715,8 @@ end
end
it "accepts command options for not_if conditionals" do
- resource.not_if("pwd" , :cwd => "/tmp")
- expect(resource.not_if.first.command_opts).to eq({ :cwd => "/tmp" })
+ resource.not_if("pwd" , cwd: "/tmp")
+ expect(resource.not_if.first.command_opts).to eq({ cwd: "/tmp" })
end
it "accepts multiple not_if conditionals" do
@@ -951,7 +951,7 @@ end
node.name("bumblebee")
node.automatic[:platform] = "autobots"
node.automatic[:platform_version] = "6.1"
- klz2.provides :dinobot, :platform => ["autobots"]
+ klz2.provides :dinobot, platform: ["autobots"]
Object.const_set("Grimlock", klz2)
klz2.provides :grimlock
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 1bbbc4c7b0..8e73ad347d 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -104,12 +104,12 @@ describe Chef::Role do
describe "default_attributes" do
it "should let you set the default attributes hash explicitly" do
- expect(@role.default_attributes({ :one => "two" })).to eq({ :one => "two" })
+ expect(@role.default_attributes({ one: "two" })).to eq({ one: "two" })
end
it "should let you return the default attributes hash" do
- @role.default_attributes({ :one => "two" })
- expect(@role.default_attributes).to eq({ :one => "two" })
+ @role.default_attributes({ one: "two" })
+ expect(@role.default_attributes).to eq({ one: "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -119,12 +119,12 @@ describe Chef::Role do
describe "override_attributes" do
it "should let you set the override attributes hash explicitly" do
- expect(@role.override_attributes({ :one => "two" })).to eq({ :one => "two" })
+ expect(@role.override_attributes({ one: "two" })).to eq({ one: "two" })
end
it "should let you return the override attributes hash" do
- @role.override_attributes({ :one => "two" })
- expect(@role.override_attributes).to eq({ :one => "two" })
+ @role.override_attributes({ one: "two" })
+ expect(@role.override_attributes).to eq({ one: "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -137,15 +137,15 @@ describe Chef::Role do
@role.name("mars_volta")
@role.description("Great band!")
@role.run_list("one", "two", "role[a]")
- @role.default_attributes({ :el_groupo => "nuevo" })
- @role.override_attributes({ :deloused => "in the comatorium" })
+ @role.default_attributes({ el_groupo: "nuevo" })
+ @role.override_attributes({ deloused: "in the comatorium" })
@example = Chef::Role.new
@example.name("newname")
@example.description("Really Great band!")
@example.run_list("alpha", "bravo", "role[alpha]")
- @example.default_attributes({ :el_groupo => "nuevo dos" })
- @example.override_attributes({ :deloused => "in the comatorium XOXO" })
+ @example.default_attributes({ el_groupo: "nuevo dos" })
+ @example.override_attributes({ deloused: "in the comatorium XOXO" })
end
it "should update all fields except for name" do
@@ -158,13 +158,13 @@ describe Chef::Role do
end
end
- describe "when serialized as JSON", :json => true do
+ describe "when serialized as JSON", json: true do
before(:each) do
@role.name("mars_volta")
@role.description("Great band!")
@role.run_list("one", "two", "role[a]")
- @role.default_attributes({ :el_groupo => "nuevo" })
- @role.override_attributes({ :deloused => "in the comatorium" })
+ @role.default_attributes({ el_groupo: "nuevo" })
+ @role.override_attributes({ deloused: "in the comatorium" })
@serialized_role = Chef::JSONCompat.to_json(@role)
end
@@ -189,20 +189,20 @@ describe Chef::Role do
end
it "should include 'run_list'" do
- #Activesupport messes with Chef json formatting
- #This test should pass with and without activesupport
+ # Activesupport messes with Chef json formatting
+ # This test should pass with and without activesupport
expect(@serialized_role).to match(/"run_list":\["recipe\[one\]","recipe\[two\]","role\[a\]"\]/)
end
describe "and it has per-environment run lists" do
before do
@role.env_run_lists("_default" => ["one", "two", "role[a]"], "production" => ["role[monitoring]", "role[auditing]", "role[apache]"], "dev" => ["role[nginx]"])
- @serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), :create_additions => false)
+ @serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), create_additions: false)
end
it "includes the per-environment run lists" do
- #Activesupport messes with Chef json formatting
- #This test should pass with and without activesupport
+ # Activesupport messes with Chef json formatting
+ # This test should pass with and without activesupport
expect(@serialized_role["env_run_lists"]["production"]).to eq(["role[monitoring]", "role[auditing]", "role[apache]"])
expect(@serialized_role["env_run_lists"]["dev"]).to eq(["role[nginx]"])
end
@@ -218,7 +218,7 @@ describe Chef::Role do
end
end
- describe "when created from JSON", :json => true do
+ describe "when created from JSON", json: true do
before(:each) do
@role.name("mars_volta")
@role.description("Great band!")
@@ -245,9 +245,9 @@ describe Chef::Role do
end
end
- ROLE_DSL = <<-EOR
-name "ceiling_cat"
-description "like Aliens, but furry"
+ ROLE_DSL = <<~EOR
+ name "ceiling_cat"
+ description "like Aliens, but furry"
EOR
describe "when loading from disk" do
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index f1c3072b8e..bfef3f8836 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -184,7 +184,7 @@ describe Chef::RunContext do
describe "handling reboot requests" do
let(:expected) do
- { :reason => "spec tests require a reboot" }
+ { reason: "spec tests require a reboot" }
end
it "stores and deletes the reboot request" do
diff --git a/spec/unit/run_list/run_list_item_spec.rb b/spec/unit/run_list/run_list_item_spec.rb
index 3f8fd2ab3b..b57a7dcd53 100644
--- a/spec/unit/run_list/run_list_item_spec.rb
+++ b/spec/unit/run_list/run_list_item_spec.rb
@@ -22,15 +22,15 @@ describe Chef::RunList::RunListItem do
describe "when creating from a Hash" do
it "raises an exception when the hash doesn't have a :type key" do
- expect { Chef::RunList::RunListItem.new(:name => "tatft") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new(name: "tatft") }.to raise_error(ArgumentError)
end
it "raises an exception when the hash doesn't have an :name key" do
- expect { Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new(type: "R") }.to raise_error(ArgumentError)
end
it "sets the name and type as given in the hash" do
- item = Chef::RunList::RunListItem.new(:type => "fuuu", :name => "uuuu")
+ item = Chef::RunList::RunListItem.new(type: "fuuu", name: "uuuu")
expect(item.to_s).to eq("fuuu[uuuu]")
end
diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb
index 859fee75ec..e116ffc130 100644
--- a/spec/unit/run_list/versioned_recipe_list_spec.rb
+++ b/spec/unit/run_list/versioned_recipe_list_spec.rb
@@ -54,25 +54,25 @@ describe Chef::RunList::VersionedRecipeList do
it "should allow you to specify a version" do
list.add_recipe "rails", "1.0.0"
expect(list).to eq(%w{apt god apache2 rails})
- expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
+ expect(list.with_versions).to include({ name: "rails", version: "1.0.0" })
end
it "should allow you to specify a version for a recipe that already exists" do
list.add_recipe "apt", "1.2.3"
expect(list).to eq(%w{apt god apache2})
- expect(list.with_versions).to include({ :name => "apt", :version => "1.2.3" })
+ expect(list.with_versions).to include({ name: "apt", version: "1.2.3" })
end
it "should allow you to specify the same version of a recipe twice" do
list.add_recipe "rails", "1.0.0"
list.add_recipe "rails", "1.0.0"
- expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
+ expect(list.with_versions).to include({ name: "rails", version: "1.0.0" })
end
it "should allow you to spcify no version, even when a version already exists" do
list.add_recipe "rails", "1.0.0"
list.add_recipe "rails"
- expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
+ expect(list.with_versions).to include({ name: "rails", version: "1.0.0" })
end
it "should not allow multiple versions of the same recipe" do
@@ -85,9 +85,9 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- { :name => "apt", :version => "1.0.0" },
- { :name => "god", :version => nil },
- { :name => "apache2", :version => "0.0.1" },
+ { name: "apt", version: "1.0.0" },
+ { name: "god", version: nil },
+ { name: "apache2", version: "0.0.1" },
]
end
it "should return an array of hashes with :name and :version" do
@@ -106,9 +106,9 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- { :name => "apt", :version => "~> 1.2.0" },
- { :name => "god", :version => nil },
- { :name => "apache2", :version => "0.0.1" },
+ { name: "apt", version: "~> 1.2.0" },
+ { name: "god", version: nil },
+ { name: "apache2", version: "0.0.1" },
]
end
@@ -151,7 +151,7 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- { :name => "apt", :version => "~> 1.2.0" },
+ { name: "apt", version: "~> 1.2.0" },
]
end
@@ -170,7 +170,7 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- { :name => "apt::cacher", :version => "~> 1.2.0" },
+ { name: "apt::cacher", version: "~> 1.2.0" },
]
end
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index 0dcd349ced..ac062c665d 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -170,12 +170,12 @@ describe Chef::RunList do
@role = Chef::Role.new
@role.name "stubby"
@role.run_list "one", "two"
- @role.default_attributes :one => :two
- @role.override_attributes :three => :four
+ @role.default_attributes one: :two
+ @role.override_attributes three: :four
@role.env_run_list["production"] = Chef::RunList.new( "one", "two", "five")
allow(Chef::Role).to receive(:load).and_return(@role)
- @rest = double("Chef::ServerAPI", { :get => @role.to_hash, :url => "/" })
+ @rest = double("Chef::ServerAPI", { get: @role.to_hash, url: "/" })
allow(Chef::ServerAPI).to receive(:new).and_return(@rest)
@run_list << "role[stubby]"
@@ -197,7 +197,7 @@ describe Chef::RunList do
describe "from the chef server" do
it "should load the role from the chef server" do
- #@rest.should_receive(:get).with("roles/stubby")
+ # @rest.should_receive(:get).with("roles/stubby")
expansion = @run_list.expand("_default", "server")
expect(expansion.recipes).to eq(%w{one two kitty})
end
@@ -263,7 +263,7 @@ describe Chef::RunList do
it "should recurse into a child role" do
dog = Chef::Role.new
dog.name "dog"
- dog.default_attributes :seven => :nine
+ dog.default_attributes seven: :nine
dog.run_list "three"
@role.run_list << "role[dog]"
allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
@@ -277,7 +277,7 @@ describe Chef::RunList do
it "should not recurse infinitely" do
dog = Chef::Role.new
dog.name "dog"
- dog.default_attributes :seven => :nine
+ dog.default_attributes seven: :nine
dog.run_list "role[dog]", "three"
@role.run_list << "role[dog]"
allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index db52862a9c..1effe3157c 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -258,10 +258,10 @@ describe Chef::Runner do
end
expect(exception).to be_a(Chef::Exceptions::MultipleFailures)
- expected_message = <<-E
-Multiple failures occurred:
-* FailureProvider::ChefClientFail occurred in delayed notification: [explode] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
-* FailureProvider::ChefClientFail occurred in delayed notification: [explode again] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
+ expected_message = <<~E
+ Multiple failures occurred:
+ * FailureProvider::ChefClientFail occurred in delayed notification: [explode] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
+ * FailureProvider::ChefClientFail occurred in delayed notification: [explode again] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
E
expect(exception.message).to eq(expected_message)
diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb
index c747f6cc4a..ec3c088b48 100644
--- a/spec/unit/scan_access_control_spec.rb
+++ b/spec/unit/scan_access_control_spec.rb
@@ -49,7 +49,7 @@ describe Chef::ScanAccessControl do
describe "when the fs entity exists" do
before do
- @stat = double("File::Stat for #{@new_resource.path}", :uid => 0, :gid => 0, :mode => 00100644)
+ @stat = double("File::Stat for #{@new_resource.path}", uid: 0, gid: 0, mode: 00100644)
expect(File).to receive(:realpath).with(@new_resource.path).and_return(@real_file)
expect(File).to receive(:stat).with(@real_file).and_return(@stat)
expect(File).to receive(:exist?).with(@new_resource.path).and_return(true)
@@ -128,7 +128,7 @@ describe Chef::ScanAccessControl do
end
it "sets the owner of current_resource to the username of the current owner" do
- @root_passwd = double("Struct::Passwd for uid 0", :name => "root")
+ @root_passwd = double("Struct::Passwd for uid 0", name: "root")
expect(Etc).to receive(:getpwuid).with(0).and_return(@root_passwd)
@scanner.set_all!
@@ -163,7 +163,7 @@ describe Chef::ScanAccessControl do
end
it "sets the group of the current resource to the group name" do
- @group_entry = double("Struct::Group for wheel", :name => "wheel")
+ @group_entry = double("Struct::Group for wheel", name: "wheel")
expect(Etc).to receive(:getgrgid).with(0).and_return(@group_entry)
@scanner.set_all!
diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb
index 00425f2a01..bcce7c1a08 100644
--- a/spec/unit/shell/model_wrapper_spec.rb
+++ b/spec/unit/shell/model_wrapper_spec.rb
@@ -21,13 +21,13 @@ require "ostruct"
describe Shell::ModelWrapper do
before do
- @model = OpenStruct.new(:name => "Chef::Node")
+ @model = OpenStruct.new(name: "Chef::Node")
@wrapper = Shell::ModelWrapper.new(@model)
end
describe "when created with an explicit model_symbol" do
before do
- @model = OpenStruct.new(:name => "Chef::ApiClient")
+ @model = OpenStruct.new(name: "Chef::ApiClient")
@wrapper = Shell::ModelWrapper.new(@model, :client)
end
@@ -46,7 +46,7 @@ describe Shell::ModelWrapper do
@node_1.name("sammich")
@node_2 = Chef::Node.new
@node_2.name("yummy")
- @server_response = { :node_1 => @node_1, :node_2 => @node_2 }
+ @server_response = { node_1: @node_1, node_2: @node_2 }
@wrapper = Shell::ModelWrapper.new(Chef::Node)
allow(Chef::Node).to receive(:list).and_return(@server_response)
end
@@ -67,7 +67,7 @@ describe Shell::ModelWrapper do
@node_1.name("sammich")
@node_2 = Chef::Node.new
@node_2.name("yummy")
- @server_response = { :node_1 => @node_1, :node_2 => @node_2 }
+ @server_response = { node_1: @node_1, node_2: @node_2 }
@wrapper = Shell::ModelWrapper.new(Chef::Node)
# Creating a Chef::Search::Query object tries to read the private key...
diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb
index 0afa1f6390..7ddacf8476 100644
--- a/spec/unit/shell/shell_ext_spec.rb
+++ b/spec/unit/shell/shell_ext_spec.rb
@@ -34,8 +34,8 @@ describe Shell::Extensions do
it "finds a subsession in irb for an object" do
target_context_obj = Chef::Node.new
- irb_context = double("context", :main => target_context_obj)
- irb_session = double("irb session", :context => irb_context)
+ irb_context = double("context", main: target_context_obj)
+ irb_session = double("irb session", context: irb_context)
@job_manager.jobs = [[:thread, irb_session]]
allow(@root_context).to receive(:jobs).and_return(@job_manager)
@root_context.ensure_session_select_defined
@@ -92,9 +92,9 @@ describe Shell::Extensions do
end
it "prints node attributes" do
- node = double("node", :attribute => { :foo => :bar })
+ node = double("node", attribute: { foo: :bar })
@shell_client.node = node
- expect(@root_context).to receive(:pp).with({ :foo => :bar })
+ expect(@root_context).to receive(:pp).with({ foo: :bar })
@root_context.ohai
expect(@root_context).to receive(:pp).with(:bar)
@root_context.ohai(:foo)
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index c96453eeae..ce66676196 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -53,16 +53,16 @@ describe Shell::ClientSession do
let(:session) { Shell::ClientSession.instance }
let(:client) do
double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {}
+ run_ohai: true,
+ load_node: true,
+ build_node: true,
+ register: true,
+ sync_cookbooks: {}
)
end
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] }
session.node = node
session.json_configuration = json_attribs
end
@@ -90,16 +90,16 @@ describe Shell::SoloSession do
let(:session) { Shell::SoloSession.instance }
let(:client) do
double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {}
+ run_ohai: true,
+ load_node: true,
+ build_node: true,
+ register: true,
+ sync_cookbooks: {}
)
end
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] }
session.node = node
session.json_configuration = json_attribs
end
@@ -128,18 +128,18 @@ describe Shell::StandAloneSession do
let(:session) { Shell::StandAloneSession.instance }
let(:client) do
double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {}
+ run_ohai: true,
+ load_node: true,
+ build_node: true,
+ register: true,
+ sync_cookbooks: {}
)
end
let(:recipe) { Chef::Recipe.new(nil, nil, run_context) }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] }
session.node = node
session.json_configuration = json_attribs
session.run_context = run_context
@@ -166,7 +166,7 @@ describe Shell::StandAloneSession do
it "runs chef with the standalone recipe" do
allow(session).to receive(:node_built?).and_return(true)
allow(Chef::Log).to receive(:level)
- chef_runner = double("Chef::Runner.new", :converge => :converged)
+ chef_runner = double("Chef::Runner.new", converge: :converged)
# pre-heat resource collection cache
session.resource_collection
@@ -185,7 +185,7 @@ describe Shell::SoloLegacySession do
let(:json_attribs) { { "a" => "b" } }
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ Chef::Config[:shell_config] = { override_runlist: [Chef::RunList::RunListItem.new("shell::override")] }
Chef::Config[:shell_solo] = true
@session = Shell::SoloLegacySession.instance
@node = Chef::Node.new
@@ -214,7 +214,7 @@ describe Shell::SoloLegacySession do
it "keeps json attribs and passes them to the node for consumption" do
@session.node_attributes = { "besnard_lakes" => "are_the_dark_horse" }
expect(@session.node["besnard_lakes"]).to eq("are_the_dark_horse")
- #pending "1) keep attribs in an ivar 2) pass them to the node 3) feed them to the node on reset"
+ # pending "1) keep attribs in an ivar 2) pass them to the node 3) feed them to the node on reset"
end
it "generates its resource collection from the compiled cookbooks and the ad hoc recipe" do
@@ -223,13 +223,13 @@ describe Shell::SoloLegacySession do
@run_context.resource_collection << kitteh_cat
keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@recipe.run_context.resource_collection << keyboard_cat
- #@session.rebuild_collection
+ # @session.rebuild_collection
expect(@session.resource_collection).to include(kitteh_cat, keyboard_cat)
end
it "runs chef with a resource collection from the compiled cookbooks" do
allow(@session).to receive(:node_built?).and_return(true)
- chef_runner = double("Chef::Runner.new", :converge => :converged)
+ chef_runner = double("Chef::Runner.new", converge: :converged)
expect(Chef::Runner).to receive(:new).with(an_instance_of(Chef::RunContext)).and_return(chef_runner)
expect(@recipe.run_chef).to eq(:converged)
@@ -237,11 +237,11 @@ describe Shell::SoloLegacySession do
it "passes the shell CLI args to the client" do
@client = double("Chef::Client.new",
- :run_ohai => true,
- :load_node => true,
- :build_node => true,
- :register => true,
- :sync_cookbooks => {})
+ run_ohai: true,
+ load_node: true,
+ build_node: true,
+ register: true,
+ sync_cookbooks: {})
expect(Chef::Client).to receive(:new).with(json_attribs, Chef::Config[:shell_config]).and_return(@client)
@session.json_configuration = json_attribs
@session.send(:rebuild_node)
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index 10a79f6c8a..48dbf010e9 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -243,7 +243,7 @@ describe Chef::User do
describe "create" do
it "creates a new user via the API" do
@user.password "password"
- expect(@http_client).to receive(:post).with("users", { :name => "foobar", :admin => false, :password => "password" }).and_return({})
+ expect(@http_client).to receive(:post).with("users", { name: "foobar", admin: false, password: "password" }).and_return({})
@user.create
end
end
@@ -260,7 +260,7 @@ describe Chef::User do
describe "update" do
it "updates an existing user on via the API" do
- expect(@http_client).to receive(:put).with("users/foobar", { :name => "foobar", :admin => false }).and_return({})
+ expect(@http_client).to receive(:put).with("users/foobar", { name: "foobar", admin: false }).and_return({})
@user.update
end
end
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index 16f0d0158b..074a68840e 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -311,7 +311,7 @@ describe Chef::UserV1 do
end
describe "Versioned API Interactions" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
before (:each) do
@@ -334,13 +334,13 @@ describe Chef::UserV1 do
let(:payload) do
{
- :username => "some_username",
- :display_name => "some_display_name",
- :first_name => "some_first_name",
- :middle_name => "some_middle_name",
- :last_name => "some_last_name",
- :email => "some_email",
- :password => "some_password",
+ username: "some_username",
+ display_name: "some_display_name",
+ first_name: "some_first_name",
+ middle_name: "some_middle_name",
+ last_name: "some_last_name",
+ email: "some_email",
+ password: "some_password",
}
end
@@ -356,14 +356,14 @@ describe Chef::UserV1 do
context "when server API V1 is not valid on the Chef Server receiving the request" do
let(:payload) do
{
- :username => "some_username",
- :display_name => "some_display_name",
- :first_name => "some_first_name",
- :middle_name => "some_middle_name",
- :last_name => "some_last_name",
- :email => "some_email",
- :password => "some_password",
- :public_key => "some_public_key",
+ username: "some_username",
+ display_name: "some_display_name",
+ first_name: "some_first_name",
+ middle_name: "some_middle_name",
+ last_name: "some_last_name",
+ email: "some_email",
+ password: "some_password",
+ public_key: "some_public_key",
}
end
@@ -373,7 +373,7 @@ describe Chef::UserV1 do
end
context "when the server returns a 400" do
- let(:response_400) { OpenStruct.new(:code => "400") }
+ let(:response_400) { OpenStruct.new(code: "400") }
let(:exception_400) { Net::HTTPServerException.new("400 Bad Request", response_400) }
context "when the 400 was due to public / private key fields no longer being supported" do
@@ -444,12 +444,12 @@ describe Chef::UserV1 do
describe "create" do
let(:payload) do
{
- :username => "some_username",
- :display_name => "some_display_name",
- :first_name => "some_first_name",
- :last_name => "some_last_name",
- :email => "some_email",
- :password => "some_password",
+ username: "some_username",
+ display_name: "some_display_name",
+ first_name: "some_first_name",
+ last_name: "some_last_name",
+ email: "some_email",
+ password: "some_password",
}
end
before do
@@ -473,7 +473,7 @@ describe Chef::UserV1 do
context "when handling API V1" do
it "creates a new user via the API with a middle_name when it exists" do
@user.middle_name "some_middle_name"
- expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({})
+ expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({ middle_name: "some_middle_name" })).and_return({})
@user.create
end
end # when server API V1 is valid on the Chef Server receiving the request
@@ -496,7 +496,7 @@ describe Chef::UserV1 do
it "creates a new user via the API with a middle_name when it exists" do
@user.middle_name "some_middle_name"
- expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({})
+ expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({ middle_name: "some_middle_name" })).and_return({})
@user.create
end
end # when server API V1 is not valid on the Chef Server receiving the request
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index 4bb0abd087..70376bcdb1 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -546,7 +546,7 @@ shared_examples_for "a diff util" do
end
-describe Chef::Util::Diff, :uses_diff => true do
+describe Chef::Util::Diff, uses_diff: true do
let!(:old_file) { old_tempfile.path }
let!(:new_file) { new_tempfile.path }
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index cfa7a4e264..faf554326d 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -76,7 +76,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
context "when symbols are used as switches" do
it "should merge the hash if there are no restricted switches" do
- merged = conf_man.send(:get_merged_configuration_flags!, { :flag => "a" }, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { flag: "a" }, "hello")
expect(merged).to include(:flag)
expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
@@ -84,18 +84,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do
it "should raise an ArgumentError if you try to override outputpath" do
expect do
- conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { outputpath: "a" }, "hello")
end.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
expect do
- conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { OutputPath: "a" }, "hello")
end.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
- merged = conf_man.send(:get_merged_configuration_flags!, { :FLAG => "a" }, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { FLAG: "a" }, "hello")
expect(merged).to include(:flag)
end
end
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 65eaafe19c..32e5c0e07f 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -47,11 +47,11 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser do
context "correctly formatted output from lcm for WhatIfParser" do
it "returns a single resource when only 1 logged with the correct name" do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources.length).to eq(1)
@@ -59,51 +59,51 @@ EOF
end
it "identifies when a resource changes the state of the system" do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Set ] [name]
-logtype: [machinename]: LCM: [ End Set ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Start Set ] [name]
+ logtype: [machinename]: LCM: [ End Set ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources[0].changes_state?).to be_truthy
end
it "preserves the log provided for how the system changed the state" do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Set ] [name]
-logtype: [machinename]: [message]
-logtype: [machinename]: LCM: [ End Set ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Start Set ] [name]
+ logtype: [machinename]: [message]
+ logtype: [machinename]: LCM: [ End Set ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"])
end
it "returns false for changes_state?" do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Skip Set ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Skip Set ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources[0].changes_state?).to be_falsey
end
it "returns an empty array for change_log if changes_state? is false" do
- str = <<EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Skip Set ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Skip Set ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources[0].change_log).to be_empty
@@ -112,12 +112,12 @@ EOF
context "correctly formatted output from lcm for TestDSCParser" do
it "returns a single resource when only 1 logged with the correct name" do
- str = <<EOF
-InDesiredState : False
-ResourcesInDesiredState :
-ResourcesNotInDesiredState: [name]
-ReturnValue : 0
-PSComputerName : .
+ str = <<~EOF
+ InDesiredState : False
+ ResourcesInDesiredState :
+ ResourcesNotInDesiredState: [name]
+ ReturnValue : 0
+ PSComputerName : .
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
expect(resources.length).to eq(1)
@@ -125,36 +125,36 @@ EOF
end
it "identifies when a resource changes the state of the system" do
- str = <<EOF
-InDesiredState : False
-ResourcesInDesiredState :
-ResourcesNotInDesiredState: [name]
-ReturnValue : 0
-PSComputerName : .
+ str = <<~EOF
+ InDesiredState : False
+ ResourcesInDesiredState :
+ ResourcesNotInDesiredState: [name]
+ ReturnValue : 0
+ PSComputerName : .
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
expect(resources[0].changes_state?).to be_truthy
end
it "returns false for changes_state?" do
- str = <<EOF
-InDesiredState : True
-ResourcesInDesiredState : [name]
-ResourcesNotInDesiredState:
-ReturnValue : 0
-PSComputerName : .
+ str = <<~EOF
+ InDesiredState : True
+ ResourcesInDesiredState : [name]
+ ResourcesNotInDesiredState:
+ ReturnValue : 0
+ PSComputerName : .
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
expect(resources[0].changes_state?).to be_falsey
end
it "returns an empty array for change_log if changes_state? is false" do
- str = <<EOF
-InDesiredState : True
-ResourcesInDesiredState : [name]
-ResourcesNotInDesiredState:
-ReturnValue : 0
-PSComputerName : .
+ str = <<~EOF
+ InDesiredState : True
+ ResourcesInDesiredState : [name]
+ ResourcesNotInDesiredState:
+ ReturnValue : 0
+ PSComputerName : .
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
expect(resources[0].change_log).to be_empty
@@ -163,19 +163,19 @@ EOF
context "Incorrectly formatted output from LCM for WhatIfParser" do
it "allows missing [End Resource] when its the last one and still find all the resource" do
- str = <<-EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Skip Set ]
-logtype: [machinename]: LCM: [ End Resource ]
-logtype: [machinename]: LCM: [ Start Resource ] [name2]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ End Set ]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Skip Set ]
+ logtype: [machinename]: LCM: [ End Resource ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name2]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ End Set ]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
@@ -184,19 +184,19 @@ EOF
end
it "allow missing [End Resource] when its the first one and still find all the resource" do
- str = <<-EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Skip Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name2]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ End Set ]
-logtype: [machinename]: LCM: [ End Resource ]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Skip Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name2]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ End Set ]
+ logtype: [machinename]: LCM: [ End Resource ]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
@@ -205,18 +205,18 @@ EOF
end
it "allows missing set and end resource and assume an unconverged resource in this case" do
- str = <<-EOF
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Start Resource ] [name2]
-logtype: [machinename]: LCM: [ Start Test ]
-logtype: [machinename]: LCM: [ End Test ]
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ End Set ]
-logtype: [machinename]: LCM: [ End Resource ]
-logtype: [machinename]: LCM: [ End Set ]
+ str = <<~EOF
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name2]
+ logtype: [machinename]: LCM: [ Start Test ]
+ logtype: [machinename]: LCM: [ End Test ]
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ End Set ]
+ logtype: [machinename]: LCM: [ End Resource ]
+ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, false)
expect(resources[0].changes_state?).to be_truthy
@@ -228,17 +228,17 @@ EOF
context "Incorrectly formatted output from LCM for TestDSCParser" do
it "allows missing [End Resource] when its the last one and still find all the resource" do
- str = <<EOF
-InDesiredState : True
-ResourcesInDesiredState :
-ResourcesNotInDesiredState: [name]
-ReturnValue : 0
-PSComputerName : .
-InDesiredState : True
-ResourcesInDesiredState :
-ResourcesNotInDesiredState: [name2]
-ReturnValue : 0
-PSComputerName : .
+ str = <<~EOF
+ InDesiredState : True
+ ResourcesInDesiredState :
+ ResourcesNotInDesiredState: [name]
+ ReturnValue : 0
+ PSComputerName : .
+ InDesiredState : True
+ ResourcesInDesiredState :
+ ResourcesNotInDesiredState: [name2]
+ ReturnValue : 0
+ PSComputerName : .
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str, true)
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 4c33fc8616..cce5a39537 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -24,33 +24,33 @@ describe Chef::Util::DSC::LocalConfigurationManager do
let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, "tmp") }
let(:normal_lcm_output) do
- <<-EOH
-logtype: [machinename]: LCM: [ Start Set ]
-logtype: [machinename]: LCM: [ Start Resource ] [name]
-logtype: [machinename]: LCM: [ End Resource ] [name]
-logtype: [machinename]: LCM: [ End Set ]
+ <<~EOH
+ logtype: [machinename]: LCM: [ Start Set ]
+ logtype: [machinename]: LCM: [ Start Resource ] [name]
+ logtype: [machinename]: LCM: [ End Resource ] [name]
+ logtype: [machinename]: LCM: [ End Set ]
EOH
end
let(:no_whatif_lcm_output) do
- <<-EOH
-Start-DscConfiguration : A parameter cannot be found\r\n that matches parameter name 'whatif'.
-At line:1 char:123
-+ run-somecommand -whatif
-+ ~~~~~~~~
- + CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException
- + FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand
+ <<~EOH
+ Start-DscConfiguration : A parameter cannot be found\r\n that matches parameter name 'whatif'.
+ At line:1 char:123
+ + run-somecommand -whatif
+ + ~~~~~~~~
+ + CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException
+ + FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand
EOH
end
let(:dsc_resource_import_failure_output) do
- <<-EOH
-PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : .
+ <<~EOH
+ PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : .
EOH
end
let(:lcm_status) do
- double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success)
+ double("LCM cmdlet status", stderr: lcm_standard_error, return_value: lcm_standard_output, succeeded?: lcm_cmdlet_success)
end
describe "test_configuration method invocation" do
@@ -192,7 +192,7 @@ EOH
context "when invalid dsc script is given" do
it "raises exception" do
configuration_document = "invalid-config"
- shellout_flags = { :cwd => nil, :environment => nil, :timeout => nil }
+ shellout_flags = { cwd: nil, environment: nil, timeout: nil }
expect { lcm.send(:run_configuration_cmdlet, configuration_document, true, shellout_flags) }.to raise_error(Chef::Exceptions::PowershellCmdletException)
end
end
diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb
index 1a71d1d856..5c5b04d8a5 100644
--- a/spec/unit/util/file_edit_spec.rb
+++ b/spec/unit/util/file_edit_spec.rb
@@ -22,29 +22,29 @@ require "tempfile"
describe Chef::Util::FileEdit do
let(:starting_content) do
- <<-EOF
-127.0.0.1 localhost
-255.255.255.255 broadcasthost
-::1 localhost
-fe80::1%lo0 localhost
+ <<~EOF
+ 127.0.0.1 localhost
+ 255.255.255.255 broadcasthost
+ ::1 localhost
+ fe80::1%lo0 localhost
EOF
end
let(:localhost_replaced) do
- <<-EOF
-127.0.0.1 replacement
-255.255.255.255 broadcasthost
-::1 replacement
-fe80::1%lo0 replacement
+ <<~EOF
+ 127.0.0.1 replacement
+ 255.255.255.255 broadcasthost
+ ::1 replacement
+ fe80::1%lo0 replacement
EOF
end
let(:localhost_line_replaced) do
- <<-EOF
-replacement line
-255.255.255.255 broadcasthost
-replacement line
-replacement line
+ <<~EOF
+ replacement line
+ 255.255.255.255 broadcasthost
+ replacement line
+ replacement line
EOF
end
@@ -54,41 +54,41 @@ replacement line
end
let(:localhost_line_deleted) do
- <<-EOF
-255.255.255.255 broadcasthost
+ <<~EOF
+ 255.255.255.255 broadcasthost
EOF
end
let(:append_after_all_localhost) do
- <<-EOF
-127.0.0.1 localhost
-new line inserted
-255.255.255.255 broadcasthost
-::1 localhost
-new line inserted
-fe80::1%lo0 localhost
-new line inserted
+ <<~EOF
+ 127.0.0.1 localhost
+ new line inserted
+ 255.255.255.255 broadcasthost
+ ::1 localhost
+ new line inserted
+ fe80::1%lo0 localhost
+ new line inserted
EOF
end
let(:append_after_content) do
- <<-EOF
-127.0.0.1 localhost
-255.255.255.255 broadcasthost
-::1 localhost
-fe80::1%lo0 localhost
-new line inserted
+ <<~EOF
+ 127.0.0.1 localhost
+ 255.255.255.255 broadcasthost
+ ::1 localhost
+ fe80::1%lo0 localhost
+ new line inserted
EOF
end
let(:append_twice) do
- <<-EOF
-127.0.0.1 localhost
-255.255.255.255 broadcasthost
-::1 localhost
-fe80::1%lo0 localhost
-once
-twice
+ <<~EOF
+ 127.0.0.1 localhost
+ 255.255.255.255 broadcasthost
+ ::1 localhost
+ fe80::1%lo0 localhost
+ once
+ twice
EOF
end
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index 800e4cc9c0..144e363979 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -75,7 +75,7 @@ describe Chef::Util::Powershell::Cmdlet do
it "does not allow invalid switch names" do
expect do
- @cmdlet.send(:command_switches_string, { :foo! => "bar" })
+ @cmdlet.send(:command_switches_string, { foo!: "bar" })
end.to raise_error(ArgumentError)
end
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 8da6492fae..0d2d1aeb3f 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -60,8 +60,8 @@ describe Chef::Util::Selinux do
describe "when selinux is enabled" do
before do
- cmd_result = double("Cmd Result", :exitstatus => 0)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
+ cmd_result = double("Cmd Result", exitstatus: 0)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result)
end
it "should report selinux is enabled" do
@@ -73,8 +73,8 @@ describe Chef::Util::Selinux do
describe "when selinux is disabled" do
before do
- cmd_result = double("Cmd Result", :exitstatus => 1)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
+ cmd_result = double("Cmd Result", exitstatus: 1)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result)
end
it "should report selinux is disabled" do
@@ -86,8 +86,8 @@ describe Chef::Util::Selinux do
describe "when selinux gives an unexpected status" do
before do
- cmd_result = double("Cmd Result", :exitstatus => 101)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
+ cmd_result = double("Cmd Result", exitstatus: 101)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { returns: [0, 1] }).and_return(cmd_result)
end
it "should throw an error" do
diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb
index 1523ac1919..574f38d8e2 100644
--- a/spec/unit/win32/registry_spec.rb
+++ b/spec/unit/win32/registry_spec.rb
@@ -21,8 +21,8 @@ require "spec_helper"
describe Chef::Win32::Registry do
include_context "Win32"
- let(:value1) { { :name => "one", :type => :string, :data => "1" } }
- let(:value1_upcase_name) { { :name => "ONE", :type => :string, :data => "1" } }
+ let(:value1) { { name: "one", type: :string, data: "1" } }
+ let(:value1_upcase_name) { { name: "ONE", type: :string, data: "1" } }
let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
let(:key) { 'Software\OpscodeNumbers' }
let(:key_parent) { "Software" }
@@ -41,7 +41,7 @@ describe Chef::Win32::Registry do
before(:each) do
allow_any_instance_of(Chef::Win32::Registry).to receive(:machine_architecture).and_return(:x86_64)
- #Making the values for registry constants available on unix
+ # Making the values for registry constants available on unix
Win32::Registry::KEY_SET_VALUE = 0x0002
Win32::Registry::KEY_QUERY_VALUE = 0x0001
Win32::Registry::KEY_WRITE = 0x00020000 | 0x0002 | 0x0004
diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb
index 71e01a0b6b..45af0f9d9f 100644
--- a/spec/unit/windows_service_spec.rb
+++ b/spec/unit/windows_service_spec.rb
@@ -32,8 +32,8 @@ describe "Chef::Application::WindowsService", :windows_only do
let(:timeout) { 7200 }
let(:shellout_options) do
{
- :timeout => timeout,
- :logger => Chef::Log,
+ timeout: timeout,
+ logger: Chef::Log,
}
end
diff --git a/tasks/cbgb.rb b/tasks/cbgb.rb
index 09363b42d2..801739a6af 100644
--- a/tasks/cbgb.rb
+++ b/tasks/cbgb.rb
@@ -25,7 +25,7 @@ CBGB_TARGET = File.join(File.dirname(__FILE__), "..", "CBGB.md")
begin
require "tomlrb"
- task :default => :generate
+ task default: :generate
namespace :cbgb do
desc "Generate MarkDown version of CBGB file"
diff --git a/tasks/dependencies.rb b/tasks/dependencies.rb
index 93b357af82..562ec50b81 100644
--- a/tasks/dependencies.rb
+++ b/tasks/dependencies.rb
@@ -25,19 +25,19 @@ namespace :dependencies do
desc "Update all dependencies. dependencies:update to update as little as possible."
task :update do |t, rake_args|
# FIXME: probably broken, and needs less indirection
- system("#{File.join(Dir.pwd, "ci", "dependency_update.sh")}")
+ system((File.join(Dir.pwd, "ci", "dependency_update.sh")).to_s)
end
desc "Force update (when adding new gems to Gemfiles)"
task :force_update do |t, rake_args|
# FIXME: probably broken, and needs less indirection
FileUtils.rm_f(File.join(Dir.pwd, ".bundle", "config"))
- system("#{File.join(Dir.pwd, "ci", "dependency_update.sh")}")
+ system((File.join(Dir.pwd, "ci", "dependency_update.sh")).to_s)
end
# Update all dependencies to the latest constraint-matching version
desc "Update all dependencies. dependencies:update to update as little as possible (CI-only)."
- task :update_ci => %w{
+ task update_ci: %w{
dependencies:update_gemfile_lock
dependencies:update_omnibus_gemfile_lock
dependencies:update_audit_tests_berksfile_lock
@@ -87,6 +87,6 @@ namespace :dependencies do
end
desc "Update all dependencies and check for outdated gems."
-task :dependencies_ci => [ "dependencies:update_ci" ]
-task :dependencies => [ "dependencies:update" ]
-task :update => [ "dependencies:update" ]
+task dependencies_ci: [ "dependencies:update_ci" ]
+task dependencies: [ "dependencies:update" ]
+task update: [ "dependencies:update" ]
diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb
index d2fc482a28..1adac47ecc 100644
--- a/tasks/maintainers.rb
+++ b/tasks/maintainers.rb
@@ -33,7 +33,7 @@ begin
require "pp"
namespace :maintainers do
- task :default => :generate
+ task default: :generate
desc "Generate MarkDown version of MAINTAINERS file"
task :generate do
@@ -63,7 +63,7 @@ begin
end
def github
- @github ||= Octokit::Client.new(:netrc => true)
+ @github ||= Octokit::Client.new(netrc: true)
end
def source
diff --git a/tasks/rspec.rb b/tasks/rspec.rb
index 848c50eb40..afd7d12705 100644
--- a/tasks/rspec.rb
+++ b/tasks/rspec.rb
@@ -35,9 +35,9 @@ begin
end
end
- task :default => :spec
+ task default: :spec
- task :spec => :component_specs
+ task spec: :component_specs
desc "Run standard specs (minus long running specs)"
RSpec::Core::RakeTask.new(:spec) do |t|