summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-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.rb15
-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.rb7
-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_exec_spec.rb2
-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/chocolatey_config_spec.rb98
-rw-r--r--spec/unit/resource/chocolatey_source_spec.rb102
-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
270 files changed, 3995 insertions, 3789 deletions
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 19f3160d0c..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
@@ -59,13 +59,18 @@ describe Chef::CookbookLoader do
cookbook_loader.load_cookbooks
end
- it "should be possible to reload all the cookbooks without triggering deprecation warnings on all of them" do
+ it "should be possible to reload all the cookbooks without triggering deprecation warnings on all of them", chef: "< 15" do
start_merged_cookbooks = cookbook_loader.merged_cookbooks
expect(Chef::Log).to receive(:deprecation).with(/The cookbook\(s\): openldap exist in multiple places in your cookbook_path./)
cookbook_loader.load_cookbooks
expect(cookbook_loader.merged_cookbooks).to eql(start_merged_cookbooks)
end
+ it "should not support multiple merged cookbooks in the cookbook path", chef: ">= 15" do
+ start_merged_cookbooks = cookbook_loader.merged_cookbooks
+ expect { cookbook_loader.load_cookbooks }.to raise_error("FIXME WITH THE CLASS YOU DECIDE TO USE HERE")
+ end
+
describe "[]" do
it "should return cookbook objects with []" do
expect(cookbook_loader[:openldap]).to be_a_kind_of(Chef::CookbookVersion)
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 a469808e63..87729d8652 100644
--- a/spec/unit/data_collector_spec.rb
+++ b/spec/unit/data_collector_spec.rb
@@ -2,7 +2,7 @@
# Author:: Adam Leff (<adamleff@chef.io)
# Author:: Ryan Cragun (<ryan@chef.io>)
#
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -804,14 +804,15 @@ describe Chef::DataCollector::Reporter do
context "when valid output_locations are provided" do
it "does not raise an exception" do
- Chef::Config[:data_collector][:output_locations] = { :urls => ["http://data_collector"], :files => ["data_collection.json"] }
+ expect(reporter).to receive(:open).with("data_collection.json", "a")
+ 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_exec_spec.rb b/spec/unit/mixin/powershell_exec_spec.rb
index 72619bdc8a..7241e67934 100644
--- a/spec/unit/mixin/powershell_exec_spec.rb
+++ b/spec/unit/mixin/powershell_exec_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
execution = object.powershell_exec("this-should-error")
expect(execution.errors).to be_a_kind_of(Array)
expect(execution.errors[0]).to be_a_kind_of(String)
- expect(execution.errors[0]).to include("CommandNotFoundException")
+ expect(execution.errors[0]).to include("Runtime exception: this-should-error")
end
end
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/chocolatey_config_spec.rb b/spec/unit/resource/chocolatey_config_spec.rb
new file mode 100644
index 0000000000..3c50642487
--- /dev/null
+++ b/spec/unit/resource/chocolatey_config_spec.rb
@@ -0,0 +1,98 @@
+#
+# Copyright:: Copyright 2018, 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.
+#
+
+require "spec_helper"
+
+describe Chef::Resource::ChocolateyConfig do
+
+ let(:resource) { Chef::Resource::ChocolateyConfig.new("fakey_fakerton") }
+ let(:config) do
+ <<-CONFIG
+ <?xml version="1.0" encoding="utf-8"?>
+ <chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <config>
+ <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
+ </config>
+ <sources>
+ <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" bypassProxy="false" selfService="false" adminOnly="false" priority="0" />
+ </sources>
+ <features>
+ <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
+ </features>
+ <apiKeys />
+ </chocolatey>
+CONFIG
+ end
+
+ # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs
+ before(:each) do
+ @original_env = ENV.to_hash
+ ENV["ALLUSERSPROFILE"] = 'C:\ProgramData'
+ end
+
+ after(:each) do
+ ENV.clear
+ ENV.update(@original_env)
+ end
+
+ it "has a resource name of :chocolatey_config" do
+ expect(resource.resource_name).to eql(:chocolatey_config)
+ end
+
+ it "is not a preview resource in Chef 15" do
+ pending("Chef 15") unless Chef::VERSION.start_with?("15")
+ expect(resource.class.preview_resource).to be_falsey
+ end
+
+ it "has a name property of config_key" do
+ expect(resource.config_key).to eql("fakey_fakerton")
+ end
+
+ it "sets the default action as :set" do
+ expect(resource.action).to eql([:set])
+ end
+
+ it "supports :set and :unset actions" do
+ expect { resource.action :set }.not_to raise_error
+ expect { resource.action :unset }.not_to raise_error
+ end
+
+ it "bypass_proxy property defaults to false" do
+ expect { resource.bypass_proxy.to be_false }
+ end
+
+ describe "#fetch_config_element" do
+ it "raises and error if the config file cannot be found" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(false)
+ expect { resource.fetch_config_element("foo") }.to raise_error(RuntimeError)
+ end
+
+ it "returns the value if present in the config file" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(true)
+ allow(::File).to receive(:read).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(config)
+ expect(resource.fetch_config_element("containsLegacyPackageInstalls")).to eq("true")
+ expect { resource.fetch_config_element("foo") }.not_to raise_error
+ end
+
+ it "returns nil if the element is not present in the config file" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(true)
+ allow(::File).to receive(:read).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(config)
+ expect(resource.fetch_config_element("foo")).to be_nil
+ expect { resource.fetch_config_element("foo") }.not_to raise_error
+ end
+ end
+end
diff --git a/spec/unit/resource/chocolatey_source_spec.rb b/spec/unit/resource/chocolatey_source_spec.rb
new file mode 100644
index 0000000000..237eb5b787
--- /dev/null
+++ b/spec/unit/resource/chocolatey_source_spec.rb
@@ -0,0 +1,102 @@
+#
+# Copyright:: Copyright 2018, 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.
+#
+
+require "spec_helper"
+
+describe Chef::Resource::ChocolateySource do
+
+ let(:resource) { Chef::Resource::ChocolateySource.new("fakey_fakerton") }
+ let(:config) do
+ <<-CONFIG
+ <?xml version="1.0" encoding="utf-8"?>
+ <chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <config>
+ <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
+ </config>
+ <sources>
+ <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" bypassProxy="false" selfService="false" adminOnly="false" priority="0" />
+ </sources>
+ <features>
+ <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
+ </features>
+ <apiKeys />
+ </chocolatey>
+CONFIG
+ end
+
+ # we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs
+ before(:each) do
+ @original_env = ENV.to_hash
+ ENV["ALLUSERSPROFILE"] = 'C:\ProgramData'
+ end
+
+ after(:each) do
+ ENV.clear
+ ENV.update(@original_env)
+ end
+
+ it "has a resource name of :chocolatey_source" do
+ expect(resource.resource_name).to eql(:chocolatey_source)
+ end
+
+ it "is not a preview resource in Chef 15" do
+ pending("Chef 15") unless Chef::VERSION.start_with?("15")
+ expect(resource.class.preview_resource).to be_falsey
+ end
+
+ it "has a name property of source_name" do
+ expect(resource.source_name).to eql("fakey_fakerton")
+ end
+
+ it "sets the default action as :add" do
+ expect(resource.action).to eql([:add])
+ end
+
+ it "supports :add and :remove actions" do
+ expect { resource.action :add }.not_to raise_error
+ expect { resource.action :remove }.not_to raise_error
+ end
+
+ it "bypass_proxy property defaults to false" do
+ expect { resource.bypass_proxy.to be_false }
+ end
+
+ it "priority property defaults to 0" do
+ expect { resource.priority.to eq(0) }
+ end
+
+ describe "#fetch_source_element" do
+ it "raises and error if the config file cannot be found" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(false)
+ expect { resource.fetch_source_element("foo") }.to raise_error(RuntimeError)
+ end
+
+ it "returns the value if present in the config file" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(true)
+ allow(::File).to receive(:read).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(config)
+ expect(resource.fetch_source_element("chocolatey")["value"]).to eq("https://chocolatey.org/api/v2/")
+ expect { resource.fetch_source_element("foo") }.not_to raise_error
+ end
+
+ it "returns nil if the element is not present in the config file" do
+ allow(::File).to receive(:exist?).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(true)
+ allow(::File).to receive(:read).with('C:\ProgramData\chocolatey\config\chocolatey.config').and_return(config)
+ expect(resource.fetch_source_element("foo")).to be_nil
+ expect { resource.fetch_source_element("foo") }.not_to raise_error
+ end
+ end
+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