summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/dsl/reboot_pending_spec.rb2
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb10
-rw-r--r--spec/functional/file_content_management/deploy_strategies_spec.rb42
-rw-r--r--spec/functional/knife/exec_spec.rb2
-rw-r--r--spec/functional/knife/ssh_spec.rb6
-rw-r--r--spec/functional/mixin/user_context_spec.rb4
-rw-r--r--spec/functional/rebooter_spec.rb2
-rwxr-xr-xspec/functional/resource/aix_service_spec.rb2
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb2
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb2
-rw-r--r--spec/functional/resource/cookbook_file_spec.rb4
-rw-r--r--spec/functional/resource/cron_spec.rb1
-rw-r--r--spec/functional/resource/dsc_resource_spec.rb3
-rw-r--r--spec/functional/resource/dsc_script_spec.rb14
-rw-r--r--spec/functional/resource/group_spec.rb28
-rw-r--r--spec/functional/resource/link_spec.rb4
-rw-r--r--spec/functional/resource/locale_spec.rb8
-rw-r--r--spec/functional/resource/mount_spec.rb2
-rw-r--r--spec/functional/resource/powershell_script_spec.rb17
-rw-r--r--spec/functional/resource/reboot_spec.rb2
-rw-r--r--spec/functional/resource/remote_file_spec.rb4
-rw-r--r--spec/functional/resource/template_spec.rb2
-rw-r--r--spec/functional/resource/user/windows_spec.rb4
-rw-r--r--spec/functional/resource/windows_certificate_spec.rb6
-rw-r--r--spec/functional/resource/windows_service_spec.rb6
-rw-r--r--spec/functional/run_lock_spec.rb5
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb17
-rw-r--r--spec/functional/win32/service_manager_spec.rb2
-rw-r--r--spec/integration/client/client_spec.rb160
-rw-r--r--spec/integration/client/exit_code_spec.rb4
-rw-r--r--spec/integration/client/ipv6_spec.rb4
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb50
-rw-r--r--spec/integration/knife/chef_repo_path_spec.rb8
-rw-r--r--spec/integration/knife/config_get_spec.rb2
-rw-r--r--spec/integration/knife/config_list_profiles_spec.rb3
-rw-r--r--spec/integration/knife/cookbook_api_ipv6_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_download_spec.rb2
-rw-r--r--spec/integration/knife/diff_spec.rb4
-rw-r--r--spec/integration/knife/download_spec.rb2
-rw-r--r--spec/integration/knife/redirection_spec.rb2
-rw-r--r--spec/integration/knife/upload_spec.rb4
-rw-r--r--spec/integration/recipes/accumulator_spec.rb8
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb10
-rw-r--r--spec/integration/recipes/lwrp_spec.rb4
-rw-r--r--spec/integration/recipes/notifies_spec.rb40
-rw-r--r--spec/integration/recipes/notifying_block_spec.rb8
-rw-r--r--spec/integration/recipes/provider_choice.rb3
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb18
-rw-r--r--spec/integration/recipes/remote_directory.rb4
-rw-r--r--spec/integration/solo/solo_spec.rb40
-rw-r--r--spec/spec_helper.rb17
-rw-r--r--spec/stress/win32/security_spec.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb2
-rw-r--r--spec/support/mock/platform.rb4
-rw-r--r--spec/support/platform_helpers.rb6
-rw-r--r--spec/support/platforms/win32/spec_service.rb16
-rw-r--r--spec/support/shared/functional/execute_resource.rb8
-rw-r--r--spec/support/shared/functional/file_resource.rb4
-rw-r--r--spec/support/shared/functional/http.rb54
-rw-r--r--spec/support/shared/functional/securable_resource.rb12
-rw-r--r--spec/support/shared/functional/win32_service.rb2
-rw-r--r--spec/support/shared/functional/windows_script.rb3
-rw-r--r--spec/support/shared/integration/app_server_support.rb7
-rw-r--r--spec/support/shared/integration/integration_helper.rb1
-rw-r--r--spec/support/shared/integration/knife_support.rb10
-rw-r--r--spec/support/shared/unit/application_dot_d.rb14
-rw-r--r--spec/support/shared/unit/file_system_support.rb5
-rw-r--r--spec/support/shared/unit/platform_introspector.rb24
-rw-r--r--spec/support/shared/unit/provider/file.rb2
-rw-r--r--spec/support/shared/unit/script_resource.rb2
-rw-r--r--spec/support/shared/unit/windows_script_resource.rb2
-rw-r--r--spec/tiny_server.rb2
-rw-r--r--spec/unit/api_client/registration_spec.rb2
-rw-r--r--spec/unit/api_client_spec.rb10
-rw-r--r--spec/unit/api_client_v1_spec.rb12
-rw-r--r--spec/unit/application/exit_code_spec.rb5
-rw-r--r--spec/unit/application/knife_spec.rb3
-rw-r--r--spec/unit/chef_fs/config_spec.rb6
-rw-r--r--spec/unit/chef_fs/file_system/repository/directory_spec.rb2
-rw-r--r--spec/unit/chef_fs/parallelizer.rb2
-rw-r--r--spec/unit/client_spec.rb2
-rw-r--r--spec/unit/config_fetcher_spec.rb2
-rw-r--r--spec/unit/cookbook/metadata_spec.rb8
-rw-r--r--spec/unit/cookbook_loader_spec.rb20
-rw-r--r--spec/unit/cookbook_site_streaming_uploader_spec.rb3
-rw-r--r--spec/unit/data_bag_item_spec.rb16
-rw-r--r--spec/unit/data_bag_spec.rb2
-rw-r--r--spec/unit/decorator_spec.rb4
-rw-r--r--spec/unit/deprecated_spec.rb4
-rw-r--r--spec/unit/dsl/data_query_spec.rb5
-rw-r--r--spec/unit/dsl/declare_resource_spec.rb2
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb4
-rw-r--r--spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb3
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb3
-rw-r--r--spec/unit/environment_spec.rb16
-rw-r--r--spec/unit/event_dispatch/dsl_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb6
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb2
-rw-r--r--spec/unit/http/authenticator_spec.rb5
-rw-r--r--spec/unit/http/json_input_spec.rb2
-rw-r--r--spec/unit/key_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap_spec.rb34
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb8
-rw-r--r--spec/unit/knife/configure_client_spec.rb2
-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.rb2
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb6
-rw-r--r--spec/unit/knife/core/gem_glob_loader_spec.rb8
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb4
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb16
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb3
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb3
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb3
-rw-r--r--spec/unit/knife/key_create_spec.rb2
-rw-r--r--spec/unit/knife/key_edit_spec.rb2
-rw-r--r--spec/unit/knife/key_list_spec.rb2
-rw-r--r--spec/unit/knife/node_bulk_delete_spec.rb6
-rw-r--r--spec/unit/knife/node_delete_spec.rb4
-rw-r--r--spec/unit/knife/node_edit_spec.rb2
-rw-r--r--spec/unit/knife/node_environment_set_spec.rb2
-rw-r--r--spec/unit/knife/node_from_file_spec.rb2
-rw-r--r--spec/unit/knife/node_policy_set_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/node_show_spec.rb2
-rw-r--r--spec/unit/knife/role_bulk_delete_spec.rb4
-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_edit_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb2
-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.rb2
-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/status_spec.rb3
-rw-r--r--spec/unit/knife/supermarket_install_spec.rb5
-rw-r--r--spec/unit/knife/supermarket_share_spec.rb2
-rw-r--r--spec/unit/knife_spec.rb55
-rw-r--r--spec/unit/lwrp_spec.rb38
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb2
-rw-r--r--spec/unit/mixin/params_validate_spec.rb20
-rw-r--r--spec/unit/mixin/properties_spec.rb8
-rw-r--r--spec/unit/mixin/shell_out_spec.rb6
-rw-r--r--spec/unit/mixin/template_spec.rb12
-rw-r--r--spec/unit/mixin/unformatter_spec.rb3
-rw-r--r--spec/unit/mixin/user_context_spec.rb3
-rw-r--r--spec/unit/mixin/which.rb2
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb6
-rw-r--r--spec/unit/node/attribute_spec.rb18
-rw-r--r--spec/unit/node/immutable_collections_spec.rb100
-rw-r--r--spec/unit/node_spec.rb22
-rw-r--r--spec/unit/org_spec.rb6
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb4
-rw-r--r--spec/unit/property/state_spec.rb47
-rw-r--r--spec/unit/property/validation_spec.rb27
-rw-r--r--spec/unit/property_spec.rb21
-rw-r--r--spec/unit/provider/apt_update_spec.rb12
-rw-r--r--spec/unit/provider/cron_spec.rb2
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb9
-rw-r--r--spec/unit/provider/dsc_script_spec.rb2
-rw-r--r--spec/unit/provider/group/dscl_spec.rb2
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb2
-rw-r--r--spec/unit/provider/group_spec.rb5
-rw-r--r--spec/unit/provider/launchd_spec.rb24
-rw-r--r--spec/unit/provider/link_spec.rb33
-rw-r--r--spec/unit/provider/mount/mount_spec.rb62
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb22
-rw-r--r--spec/unit/provider/osx_profile_spec.rb12
-rw-r--r--spec/unit/provider/package/apt_spec.rb8
-rw-r--r--spec/unit/provider/package/bff_spec.rb2
-rw-r--r--spec/unit/provider/package/cab_spec.rb2
-rw-r--r--spec/unit/provider/package/msu_spec.rb2
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb24
-rw-r--r--spec/unit/provider/package/smartos_spec.rb4
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb18
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb14
-rw-r--r--spec/unit/provider/package/windows_spec.rb3
-rw-r--r--spec/unit/provider/package/yum/yum_cache_spec.rb2
-rw-r--r--spec/unit/provider/powershell_script_spec.rb24
-rw-r--r--spec/unit/provider/registry_key_spec.rb2
-rw-r--r--spec/unit/provider/route_spec.rb22
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb22
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb3
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb42
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb4
-rw-r--r--spec/unit/provider/service/init_service_spec.rb18
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb18
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb26
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb10
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb28
-rw-r--r--spec/unit/provider/service/windows_spec.rb88
-rw-r--r--spec/unit/provider/subversion_spec.rb12
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb292
-rw-r--r--spec/unit/provider/windows_task_spec.rb2
-rw-r--r--spec/unit/provider_resolver_spec.rb4
-rw-r--r--spec/unit/provider_spec.rb6
-rw-r--r--spec/unit/recipe_spec.rb6
-rw-r--r--spec/unit/resource/batch_spec.rb2
-rw-r--r--spec/unit/resource/cab_package_spec.rb2
-rw-r--r--spec/unit/resource/chef_gem_spec.rb2
-rw-r--r--spec/unit/resource/directory_spec.rb2
-rw-r--r--spec/unit/resource/dnf_package_spec.rb2
-rw-r--r--spec/unit/resource/dsc_resource_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb3
-rw-r--r--spec/unit/resource/file_spec.rb2
-rw-r--r--spec/unit/resource/group_spec.rb2
-rw-r--r--spec/unit/resource/link_spec.rb2
-rw-r--r--spec/unit/resource/locale_spec.rb24
-rw-r--r--spec/unit/resource/osx_profile_spec.rb3
-rw-r--r--spec/unit/resource/powershell_script_spec.rb19
-rw-r--r--spec/unit/resource/registry_key_spec.rb6
-rw-r--r--spec/unit/resource/service_spec.rb2
-rw-r--r--spec/unit/resource/template_spec.rb4
-rw-r--r--spec/unit/resource/windows_env_spec.rb2
-rw-r--r--spec/unit/resource/windows_service_spec.rb14
-rw-r--r--spec/unit/resource/windows_task_spec.rb4
-rw-r--r--spec/unit/resource/windows_uac_spec.rb4
-rw-r--r--spec/unit/resource/yum_package_spec.rb2
-rw-r--r--spec/unit/resource_collection/resource_list_spec.rb2
-rw-r--r--spec/unit/resource_collection/resource_set_spec.rb2
-rw-r--r--spec/unit/resource_collection/stepable_iterator_spec.rb4
-rw-r--r--spec/unit/resource_collection_spec.rb8
-rw-r--r--spec/unit/resource_definition_spec.rb4
-rw-r--r--spec/unit/resource_inspector_spec.rb2
-rw-r--r--spec/unit/resource_spec.rb42
-rw-r--r--spec/unit/role_spec.rb4
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb8
-rw-r--r--spec/unit/run_list/run_list_expansion_spec.rb15
-rw-r--r--spec/unit/run_list_spec.rb2
-rw-r--r--spec/unit/runner_spec.rb6
-rw-r--r--spec/unit/search/query_spec.rb5
-rw-r--r--spec/unit/shell/model_wrapper_spec.rb2
-rw-r--r--spec/unit/shell/shell_session_spec.rb9
-rw-r--r--spec/unit/shell_spec.rb3
-rw-r--r--spec/unit/user_spec.rb8
-rw-r--r--spec/unit/user_v1_spec.rb6
-rw-r--r--spec/unit/util/backup_spec.rb2
-rw-r--r--spec/unit/util/editor_spec.rb2
-rw-r--r--spec/unit/util/powershell/ps_credential_spec.rb5
-rw-r--r--spec/unit/util/threaded_job_queue_spec.rb4
-rw-r--r--spec/unit/version_class_spec.rb6
-rw-r--r--spec/unit/win32/registry_spec.rb10
-rw-r--r--spec/unit/win32/security_spec.rb3
255 files changed, 1373 insertions, 1313 deletions
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb
index 855a38b9cf..89701802b3 100644
--- a/spec/functional/dsl/reboot_pending_spec.rb
+++ b/spec/functional/dsl/reboot_pending_spec.rb
@@ -36,7 +36,7 @@ describe Chef::DSL::RebootPending, :windows_only do
let(:reg_key) { nil }
let(:original_set) { false }
- before(:all) { @any_flag = Hash.new }
+ before(:all) { @any_flag = {} }
after { @any_flag[reg_key] = original_set }
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index c1e5150428..ca15d3e38d 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -49,16 +49,18 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
logger.run_start(version, run_status)
expect(event_log.read(flags, offset).any? do |e|
- e.source == Chef::Dist::PRODUCT && e.event_id == 10000 &&
- e.string_inserts[0].include?(version) end).to be_truthy
+ e.source == Chef::Dist::PRODUCT && e.event_id == 10000 &&
+ e.string_inserts[0].include?(version)
+ end ).to be_truthy
end
it "writes run_started event with event_id 10001 and contains the run_id" do
logger.run_started(run_status)
expect(event_log.read(flags, offset).any? do |e|
- e.source == Chef::Dist::PRODUCT && e.event_id == 10001 &&
- e.string_inserts[0].include?(run_id) end).to be_truthy
+ e.source == Chef::Dist::PRODUCT && e.event_id == 10001 &&
+ e.string_inserts[0].include?(run_id)
+ end ).to be_truthy
end
it "writes run_completed event with event_id 10002 and contains the run_id and elapsed time" do
diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb
index 9e2131388f..07991aa8bd 100644
--- a/spec/functional/file_content_management/deploy_strategies_spec.rb
+++ b/spec/functional/file_content_management/deploy_strategies_spec.rb
@@ -175,20 +175,20 @@ end
describe Chef::FileContentManagement::Deploy::Cp do
let(:unix_invariants) do
- [
- :uid,
- :gid,
- :mode,
- :ino,
- ]
+ %i{
+ uid
+ gid
+ mode
+ ino
+ }
end
let(:security_descriptor_invariants) do
- [
- :owner,
- :group,
- :dacl,
- ]
+ %i{
+ owner
+ group
+ dacl
+ }
end
it_should_behave_like "a content deploy strategy"
@@ -198,11 +198,11 @@ end
describe Chef::FileContentManagement::Deploy::MvUnix, :unix_only do
let(:unix_invariants) do
- [
- :uid,
- :gid,
- :mode,
- ]
+ %i{
+ uid
+ gid
+ mode
+ }
end
it_should_behave_like "a content deploy strategy"
@@ -216,11 +216,11 @@ describe Chef::FileContentManagement::Deploy::MvWindows, :windows_only do
context "when a file has no sacl" do
let(:security_descriptor_invariants) do
- [
- :owner,
- :group,
- :dacl,
- ]
+ %i{
+ owner
+ group
+ dacl
+ }
end
it_should_behave_like "a content deploy strategy"
diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb
index 7cdf1c93eb..010b89c4f4 100644
--- a/spec/functional/knife/exec_spec.rb
+++ b/spec/functional/knife/exec_spec.rb
@@ -49,7 +49,7 @@ describe Chef::Knife::Exec do
code = "$output.puts nodes.all"
@knife.config[:exec] = code
@knife.run
- expect($output.string).to match(%r{node\[ohai-world\]})
+ expect($output.string).to match(/node\[ohai-world\]/)
end
end
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index 95e7b6454c..aade00cbf1 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Knife::Ssh do
@server.stop
end
- let(:ssh_config) { Hash.new }
+ let(:ssh_config) { {} }
before do
allow(Net::SSH).to receive(:configuration_for).and_return(ssh_config)
end
@@ -301,7 +301,7 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway_identity file" do
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
@knife.run
expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
end
@@ -315,7 +315,7 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway_identity file" do
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
@knife.run
expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
end
diff --git a/spec/functional/mixin/user_context_spec.rb b/spec/functional/mixin/user_context_spec.rb
index 802b1db9f1..b6b8b057d5 100644
--- a/spec/functional/mixin/user_context_spec.rb
+++ b/spec/functional/mixin/user_context_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Mixin::UserContext, windows_only: true do
let(:get_user_name_a) do
FFI.ffi_lib "advapi32.dll"
- FFI.attach_function :GetUserNameA, [ :pointer, :pointer ], :bool
+ FFI.attach_function :GetUserNameA, %i{pointer pointer}, :bool
end
let(:process_username) do
@@ -36,12 +36,14 @@ describe Chef::Mixin::UserContext, windows_only: true do
if succeeded || last_error != Chef::ReservedNames::Win32::API::Error::ERROR_INSUFFICIENT_BUFFER
raise Chef::Exceptions::Win32APIError, "Expected ERROR_INSUFFICIENT_BUFFER from GetUserNameA but it returned the following error: #{last_error}"
end
+
user_name = FFI::MemoryPointer.new :char, (name_size.read_long)
succeeded = get_user_name_a.call(user_name, name_size)
last_error = FFI::LastError.error
if succeeded == 0 || last_error != 0
raise Chef::Exceptions::Win32APIError, "GetUserNameA failed with #{lasterror}"
end
+
user_name.read_string
end
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 8e5b23f86b..747978cc96 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Platform::Rebooter do
let(:expected) do
{
- windows: "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"",
+ windows: "#{ENV["SYSTEMROOT"]}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"",
linux: 'shutdown -r +5 "rebooter spec test" &',
solaris: 'shutdown -i6 -g5 -y "rebooter spec test" &',
}
diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb
index 5fff3e00d7..9ffe05266d 100755
--- a/spec/functional/resource/aix_service_spec.rb
+++ b/spec/functional/resource/aix_service_spec.rb
@@ -77,7 +77,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
include Chef::Mixin::ShellOut
def get_user_id
- shell_out("id -u #{ENV['USER']}").stdout.chomp
+ shell_out("id -u #{ENV["USER"]}").stdout.chomp
end
describe "When service is a subsystem" do
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index 68ea5ab8b2..fc8a80eb08 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
directory = []
if priority.is_a? Hash
priority.each do |level, o|
- directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? 'S' : 'K')}#{o[1]}#{new_resource.service_name}"
+ directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? "S" : "K")}#{o[1]}#{new_resource.service_name}"
end
directory
else
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index 3c4b08a1f4..c5590b2d88 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
include Chef::Mixin::PowershellOut
let(:package_name) { "test-A" }
- let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(' ')}").stdout.chomp } }
+ let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
subject do
diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb
index d127413c73..6e964a6499 100644
--- a/spec/functional/resource/cookbook_file_spec.rb
+++ b/spec/functional/resource/cookbook_file_spec.rb
@@ -25,9 +25,7 @@ describe Chef::Resource::CookbookFile do
let(:source) { "java.response" }
let(:cookbook_name) { "java" }
let(:expected_content) do
- content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb") do |f|
- f.read
- end
+ content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb", &:read)
content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding)
content
end
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb
index f616b84ce9..16b0d2645c 100644
--- a/spec/functional/resource/cron_spec.rb
+++ b/spec/functional/resource/cron_spec.rb
@@ -118,6 +118,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
def cron_attribute_should_exists(cron_name, attribute, value)
return if %w{aix solaris}.include?(ohai[:platform])
+
# Test if the attribute exists on newly created cron
cron_should_exists(cron_name, "")
expect(shell_out("crontab -l -u #{new_resource.user} | grep '#{attribute.upcase}=\"#{value}\"'").exitstatus).to eq(0)
diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb
index 3491bb6bbe..8f5ba5fd9e 100644
--- a/spec/functional/resource/dsc_resource_spec.rb
+++ b/spec/functional/resource/dsc_resource_spec.rb
@@ -46,7 +46,8 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
it "raises an exception if the resource is not found" do
new_resource.resource "thisdoesnotexist"
expect { new_resource.run_action(:run) }.to raise_error(
- Chef::Exceptions::ResourceNotFound)
+ Chef::Exceptions::ResourceNotFound
+ )
end
end
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index 0808927000..224141c0f8 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -184,8 +184,8 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
end
let(:dsc_environment_env_var_name) { "dsc_test_cwd" }
- let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" }
- let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
+ let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV["systemroot"]}\\system32" }
+ let(:dsc_environment_fail_etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" }
let(:exception_message_signature) { "LL927-LL928" }
let(:dsc_environment_config) do
<<~EOH
@@ -349,9 +349,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:config_param_section) { config_params }
let(:config_flags) { { "#{dsc_user_prefix_param_name}": (dsc_user_prefix).to_s, "#{dsc_user_suffix_param_name}": (dsc_user_suffix).to_s } }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
- file.read
- end
+ configuration_script_content = ::File.open(dsc_test_resource.command, &:read)
expect(configuration_script_content.include?(dsc_user)).to be(false)
end
it_behaves_like "a dsc_script with configuration data"
@@ -361,9 +359,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:dsc_user_code) { dsc_user_env_code }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
- file.read
- end
+ configuration_script_content = ::File.open(dsc_test_resource.command, &:read)
expect(configuration_script_content.include?(dsc_user)).to be(false)
end
it_behaves_like "a dsc_script with configuration data"
@@ -464,7 +460,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
User dsctestusercreate
{
UserName = '#{dsc_user}'
- Password = #{r.ps_credential('jf9a8m49jrajf4#')}
+ Password = #{r.ps_credential("jf9a8m49jrajf4#")}
Ensure = "Present"
}
EOF
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index efa089ca2e..5b34ad92d0 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Chirag Jog (<chirag@clogeny.com>)
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
-# Copyright:: Copyright 2013-2018, Chef Software Inc.
+# Copyright:: Copyright 2013-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -96,7 +96,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
end
def create_user(username, uid = nil)
- if ! windows_domain_user?(username)
+ unless windows_domain_user?(username)
user_to_create = user(username)
user_to_create.uid(uid) if uid
user_to_create.run_action(:create)
@@ -105,7 +105,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
end
def remove_user(username)
- if ! windows_domain_user?(username)
+ unless windows_domain_user?(username)
u = user(username)
u.manage_home false # jekins hosts throw mail spool file not owned by user if we use manage_home true
u.run_action(:remove)
@@ -152,7 +152,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
let(:excluded_members) { [] }
it "should raise an error" do
- expect { group_resource.run_action(tested_action) }.to raise_error()
+ expect { group_resource.run_action(tested_action) }.to raise_error
end
end
@@ -162,7 +162,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
end
it "should raise an error" do
- expect { group_resource.run_action(tested_action) }.to raise_error()
+ expect { group_resource.run_action(tested_action) }.to raise_error
end
end
end
@@ -333,10 +333,11 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
describe "when group name is length 256", :windows_only do
let!(:group_name) do
- "theoldmanwalkingdownthestreetalwayshadagood\
-smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
-theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
-downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end
+ "theoldmanwalkingdownthestreetalwayshadagood"\
+ "smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface"\
+ "theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking"\
+ "downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree"
+ end
it "should create a group" do
group_resource.run_action(:create)
@@ -359,10 +360,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end
# for group name > 256, Windows 2016 returns "The parameter is incorrect"
context "group create action: when group name length is more than 256", :windows_only do
let!(:group_name) do
- "theoldmanwalkingdownthestreetalwayshadagood\
-smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
-theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
-downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end
+ "theoldmanwalkingdownthestreetalwayshadagood"\
+ "smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface"\
+ "theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking"\
+ "downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ"
+ end
it "should not create a group" do
expect { group_resource.run_action(:create) }.to raise_error(ArgumentError)
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index d86a904098..4593dc1971 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -133,9 +133,9 @@ describe Chef::Resource::Link do
end
def get_sid(value)
- if value.kind_of?(String)
+ if value.is_a?(String)
Chef::ReservedNames::Win32::Security::SID.from_account(value)
- elsif value.kind_of?(Chef::ReservedNames::Win32::Security::SID)
+ elsif value.is_a?(Chef::ReservedNames::Win32::Security::SID)
value
else
raise "Must specify username or SID: #{value}"
diff --git a/spec/functional/resource/locale_spec.rb b/spec/functional/resource/locale_spec.rb
index 83dfc2d007..0103df305b 100644
--- a/spec/functional/resource/locale_spec.rb
+++ b/spec/functional/resource/locale_spec.rb
@@ -61,18 +61,18 @@ describe Chef::Resource::Locale, :requires_root do
context "Unsets system variable" do
it "when LC var is not given" do
- resource.lc_env()
+ resource.lc_env
resource.run_action(:update)
unsets_system_locale("LC_MESSAGES=en_US")
end
it "when lang is not given" do
- resource.lang()
+ resource.lang
resource.run_action(:update)
unsets_system_locale("LANG=en_US")
end
it "when both lang & LC vars are not given" do
- resource.lang()
- resource.lc_env()
+ resource.lang
+ resource.lc_env
resource.run_action(:update)
unsets_system_locale("LANG=en_US", "LC_TIME=en_IN")
sets_system_locale("")
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index f6c7f91bcd..6dd9f54412 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -73,7 +73,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, external: include_
def mount_should_exist(mount_point, device, fstype = nil, options = nil)
validation_cmd = "mount | grep #{mount_point} | grep #{device} "
validation_cmd << " | grep #{fstype} " unless fstype.nil?
- validation_cmd << " | grep #{options.join(',')} " unless options.nil? || options.empty?
+ validation_cmd << " | grep #{options.join(",")} " unless options.nil? || options.empty?
expect(shell_out(validation_cmd).exitstatus).to eq(0)
end
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index 850c273a6c..74ece0d33c 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -28,13 +28,13 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it_behaves_like "a Windows script running on Windows"
- let(:successful_executable_script_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe $env:systemroot" }
- let(:failed_executable_script_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe /badargument" }
+ let(:successful_executable_script_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe $env:systemroot" }
+ let(:failed_executable_script_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe /badargument" }
let(:processor_architecture_script_content) { "echo $env:PROCESSOR_ARCHITECTURE" }
let(:native_architecture_script_content) { "echo $env:PROCESSOR_ARCHITECTUREW6432" }
let(:cmdlet_exit_code_not_found_content) { "get-item '.\\thisdoesnotexist'" }
let(:cmdlet_exit_code_success_content) { "get-item ." }
- let(:windows_process_exit_code_success_content) { "#{ENV['SystemRoot']}\\system32\\attrib.exe $env:systemroot" }
+ let(:windows_process_exit_code_success_content) { "#{ENV["SystemRoot"]}\\system32\\attrib.exe $env:systemroot" }
let(:windows_process_exit_code_not_found_content) { "findstr /notavalidswitch" }
let(:arbitrary_nonzero_process_exit_code) { 4193 }
let(:arbitrary_nonzero_process_exit_code_content) { "exit #{arbitrary_nonzero_process_exit_code}" }
@@ -479,26 +479,26 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
end
it "evaluates a not_if block using the cwd guard parameter" do
- custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc"
resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using the cwd guard parameter" do
- custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc"
resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", cwd: custom_cwd
expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for only_if" do
- custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc"
resource.cwd custom_cwd
resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for not_if" do
- custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ custom_cwd = "#{ENV["SystemRoot"]}\\system32\\drivers\\etc"
resource.cwd custom_cwd
resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
expect(resource.should_skip?(:run)).to be_truthy
@@ -590,7 +590,8 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.only_if "$true", architecture: :i386
expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
- /cannot execute script with requested architecture 'i386' on Windows Nano Server/)
+ /cannot execute script with requested architecture 'i386' on Windows Nano Server/
+ )
end
end
end
diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb
index 3b8e3efe8a..5489dc1c72 100644
--- a/spec/functional/resource/reboot_spec.rb
+++ b/spec/functional/resource/reboot_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Resource::Reboot do
shared_context "testing run context modification" do
def test_reboot_action(resource)
reboot_info = resource.run_context.reboot_info
- expect(reboot_info.keys.sort).to eq([:delay_mins, :reason, :requested_by, :timestamp])
+ expect(reboot_info.keys.sort).to eq(%i{delay_mins reason requested_by timestamp})
expect(reboot_info[:delay_mins]).to eq(expected[:delay_mins])
expect(reboot_info[:reason]).to eq(expected[:reason])
expect(reboot_info[:requested_by]).to eq(expected[:requested_by])
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 44a7a46d68..ffa0364d1d 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -134,7 +134,7 @@ describe Chef::Resource::RemoteFile do
let(:smb_file_local_file_name) { "smb_file.txt" }
let(:smb_file_local_path) { File.join( smb_share_root_directory, smb_file_local_file_name ) }
let(:smb_share_name) { "chef_smb_test" }
- let(:smb_remote_path) { File.join("//#{ENV['COMPUTERNAME']}", smb_share_name, smb_file_local_file_name).gsub(/\//, "\\") }
+ let(:smb_remote_path) { File.join("//#{ENV["COMPUTERNAME"]}", smb_share_name, smb_file_local_file_name).gsub(%r{/}, "\\") }
let(:smb_file_content) { "hellofun" }
let(:local_destination_path) { File.join(Dir.tmpdir, make_tmpname("chef_remote_file")) }
let(:windows_current_user) { ENV["USERNAME"] }
@@ -155,7 +155,7 @@ describe Chef::Resource::RemoteFile do
before do
shell_out("net.exe share #{smb_share_name} /delete")
File.write(smb_file_local_path, smb_file_content )
- shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.gsub(/\//, '\\')}\" /grant:\"authenticated users\",read")
+ shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.gsub(%r{/}, '\\')}\" /grant:\"authenticated users\",read")
end
after do
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 679ffe661a..feef97dd27 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Resource::Template do
def binread(file)
- File.open(file, "rb") { |f| f.read }
+ File.open(file, "rb", &:read)
end
include_context Chef::Resource::File
diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb
index 3a5535f194..6bab270f56 100644
--- a/spec/functional/resource/user/windows_spec.rb
+++ b/spec/functional/resource/user/windows_spec.rb
@@ -47,13 +47,13 @@ describe Chef::Provider::User::Windows, :windows_only do
end
def backup_secedit_policy
- backup_command = "secedit /export /cfg #{ENV['TEMP']}\\secedit_restore.inf /areas SECURITYPOLICY"
+ backup_command = "secedit /export /cfg #{ENV["TEMP"]}\\secedit_restore.inf /areas SECURITYPOLICY"
shell_out(backup_command)
end
def restore_secedit_policy
security_database = "C:\\windows\\security\\database\\seceditnew.sdb"
- restore_command = "secedit /configure /db #{security_database} /cfg #{ENV['TEMP']}\\secedit_restore.inf /areas SECURITYPOLICY"
+ restore_command = "secedit /configure /db #{security_database} /cfg #{ENV["TEMP"]}\\secedit_restore.inf /areas SECURITYPOLICY"
shell_out(restore_command)
end
diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb
index 79b3cd890b..9b79de6a77 100644
--- a/spec/functional/resource/windows_certificate_spec.rb
+++ b/spec/functional/resource/windows_certificate_spec.rb
@@ -81,9 +81,9 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do
# Byepassing the validation so that we may create a custom store
allow_any_instance_of(Chef::Mixin::ParamsValidate)
- .to receive(:_pv_equal_to)
- .with(opts, key, to_be)
- .and_return(true)
+ .to receive(:_pv_equal_to)
+ .with(opts, key, to_be)
+ .and_return(true)
# Creating a custom store for the testing
create_store(store)
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index f422ac21d6..999b235df1 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
include_context "using Win32::Service"
let(:username) { "service_spec_user" }
- let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}" }
+ let(:qualified_username) { "#{ENV["COMPUTERNAME"]}\\#{username}" }
let(:password) { "1a2b3c4X!&narf" }
let(:user_resource) do
@@ -36,7 +36,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
end
let(:global_service_file_path) do
- "#{ENV['WINDIR']}\\temp\\#{File.basename(test_service[:service_file_path])}"
+ "#{ENV["WINDIR"]}\\temp\\#{File.basename(test_service[:service_file_path])}"
end
let(:service_params) do
@@ -59,7 +59,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
let(:service_resource) do
r = Chef::Resource::WindowsService.new(service_params[:service_name], run_context)
- [:run_as_user, :run_as_password].each { |prop| r.send(prop, service_params[prop]) }
+ %i{run_as_user run_as_password}.each { |prop| r.send(prop, service_params[prop]) }
r
end
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 49972360ef..d9a8bd2d0e 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -334,6 +334,7 @@ describe Chef::RunLock do
loop do
line = readline_nonblock(read_from_process)
break if line.nil?
+
event, time = line.split("@")
example.log_event("#{name}.last_event got #{event}")
example.log_event("[#{name}] #{event}", time.strip)
@@ -346,7 +347,7 @@ describe Chef::RunLock do
example.log_event("#{name}.run_to(#{to_event.inspect})")
# Start the process if it's not started
- start if !pid
+ start unless pid
# Tell the process what to stop at (also means it can go)
write_to_process.print "#{to_event}\n"
@@ -370,7 +371,7 @@ describe Chef::RunLock do
def run_to_completion
example.log_event("#{name}.run_to_completion")
# Start the process if it's not started
- start if !pid
+ start unless pid
# Tell the process to stop at nothing (no blocking)
@write_to_process.print "nothing\n"
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 4be021a60b..8ec4fa1366 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) }
let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { depth: 2 }) }
let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { depth: 2 }) }
- let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
+ let(:etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" }
let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") }
it "executes a simple process" do
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index 92ce480d25..a72088a079 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -61,7 +61,8 @@ describe "Chef::Win32::Security", :windows_only do
describe "get_file_security" do
it "should return a security descriptor when called with a path that exists" do
security_descriptor = Chef::ReservedNames::Win32::Security.get_file_security(
- "C:\\Program Files")
+ "C:\\Program Files"
+ )
# Make sure the security descriptor works
expect(security_descriptor.dacl_present?).to be true
end
@@ -70,7 +71,8 @@ describe "Chef::Win32::Security", :windows_only do
describe "access_check" do
let(:security_descriptor) do
Chef::ReservedNames::Win32::Security.get_file_security(
- "C:\\Program Files")
+ "C:\\Program Files"
+ )
end
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS }
@@ -78,7 +80,8 @@ describe "Chef::Win32::Security", :windows_only do
let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
- token_rights).duplicate_token(:SecurityImpersonation)
+ token_rights
+ ).duplicate_token(:SecurityImpersonation)
end
let(:mapping) do
@@ -102,7 +105,8 @@ describe "Chef::Win32::Security", :windows_only do
let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
- token_rights)
+ token_rights
+ )
end
context "with all rights" do
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS }
@@ -127,11 +131,12 @@ describe "Chef::Win32::Security", :windows_only do
let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
- token_rights)
+ token_rights
+ )
end
context "when the token is valid" do
- let(:token_elevation_type) { [:TokenElevationTypeDefault, :TokenElevationTypeFull, :TokenElevationTypeLimited] }
+ let(:token_elevation_type) { %i{TokenElevationTypeDefault TokenElevationTypeFull TokenElevationTypeLimited} }
it "returns the token elevation type" do
elevation_type = Chef::ReservedNames::Win32::Security.get_token_information_elevation_type(token)
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index 8fff73396e..abc8118835 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -43,7 +43,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
end
it "throws an error with required missing options" do
- [:service_name, :service_display_name, :service_description, :service_file_path].each do |key|
+ %i{service_name service_display_name service_description service_file_path}.each do |key|
service_def = test_service.dup
service_def.delete(key)
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index c2dc740025..68cfd015ab 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -21,9 +21,7 @@ describe "chef-client" do
# just a normal file
# (expected_content should be uncompressed)
@api.get("/recipes.tgz", 200) do
- File.open(recipes_filename, "rb") do |f|
- f.read
- end
+ File.open(recipes_filename, "rb", &:read)
end
end
@@ -55,19 +53,19 @@ describe "chef-client" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
end
it "should complete successfully with --no-listen" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} --no-listen -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
@@ -108,10 +106,10 @@ describe "chef-client" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
@@ -151,34 +149,34 @@ describe "chef-client" do
it "should complete with success even with a client key" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
result.error!
end
it "should run recipes specified directly on the command line" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
EOM
file "arbitrary.rb", <<~EOM
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content '1'
end
EOM
file "arbitrary2.rb", <<~EOM
- file #{path_to('tempfile2.txt').inspect} do
+ file #{path_to("tempfile2.txt").inspect} do
content '2'
end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" #{path_to("arbitrary.rb")} #{path_to("arbitrary2.rb")}", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -188,17 +186,17 @@ describe "chef-client" do
it "should run recipes specified as relative paths directly on the command line" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
EOM
file "arbitrary.rb", <<~EOM
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content '1'
end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", cwd: path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -207,8 +205,8 @@ describe "chef-client" do
it "should run recipes specified directly on the command line AFTER recipes in the run list" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
EOM
file "cookbooks/x/recipes/constant_definition.rb", <<~EOM
@@ -218,12 +216,12 @@ describe "chef-client" do
EOM
file "arbitrary.rb", <<~EOM
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content ::Blah::THECONSTANT
end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", cwd: path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o x::constant_definition arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -232,8 +230,8 @@ describe "chef-client" do
it "should run recipes specified directly on the command line AFTER recipes in the run list (without an override_runlist this time)" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
EOM
file "config/dna.json", <<~EOM
@@ -249,12 +247,12 @@ describe "chef-client" do
EOM
file "arbitrary.rb", <<~EOM
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content ::Blah::THECONSTANT
end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -j \"#{path_to('config/dna.json')}\" arbitrary.rb", cwd: path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -j \"#{path_to("config/dna.json")}\" arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -263,8 +261,8 @@ describe "chef-client" do
it "an override_runlist of an empty string should allow a recipe specified directly on the command line to be the only one run" do
file "config/client.rb", <<~EOM
local_mode true
- client_key #{path_to('mykey.pem').inspect}
- cookbook_path #{path_to('cookbooks').inspect}
+ client_key #{path_to("mykey.pem").inspect}
+ cookbook_path #{path_to("cookbooks").inspect}
class ::Blah
THECONSTANT = "1"
end
@@ -284,12 +282,12 @@ describe "chef-client" do
file "arbitrary.rb", <<~EOM
raise "this test failed" unless ::Blah::THECONSTANT == "1"
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content ::Blah::THECONSTANT
end
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -j \"#{path_to('config/dna.json')}\" -o \"\" arbitrary.rb", cwd: path_to(""))
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -j \"#{path_to("config/dna.json")}\" -o \"\" arbitrary.rb", cwd: path_to(""))
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("1")
@@ -300,30 +298,30 @@ describe "chef-client" do
it "should complete with success when passed the -z flag" do
file "config/client.rb", <<~EOM
chef_server_url 'http://omg.com/blah'
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
end
it "should complete with success when passed the --local-mode flag" do
file "config/client.rb", <<~EOM
chef_server_url 'http://omg.com/blah'
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --local-mode", cwd: chef_dir)
result.error!
end
it "should not print SSL warnings when running in local-mode" do
file "config/client.rb", <<~EOM
chef_server_url 'http://omg.com/blah'
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --local-mode", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --local-mode", cwd: chef_dir)
expect(result.stdout).not_to include("SSL validation of HTTPS requests is disabled.")
result.error!
end
@@ -331,20 +329,20 @@ describe "chef-client" do
it "should complete with success when passed -z and --chef-zero-port" do
file "config/client.rb", <<~EOM
chef_server_url 'http://omg.com/blah'
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
end
it "should complete with success when setting the run list with -r" do
file "config/client.rb", <<~EOM
chef_server_url 'http://omg.com/blah'
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -r 'x::default' -z -l info", cwd: chef_dir)
expect(result.stdout).not_to include("Overridden Run List")
expect(result.stdout).to include("Run List is [recipe[x::default]]")
result.error!
@@ -353,9 +351,9 @@ describe "chef-client" do
it "should complete with success when using --profile-ruby and output a profile file", :not_supported_on_aix do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z --profile-ruby", cwd: chef_dir)
result.error!
expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true
end
@@ -363,9 +361,9 @@ describe "chef-client" do
it "doesn't produce a profile when --profile-ruby is not present" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", cwd: chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' -z", cwd: chef_dir)
result.error!
expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false
end
@@ -381,11 +379,11 @@ describe "chef-client" do
EOM
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "should fail the chef client run" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
expect(command.exitstatus).to eql(1)
expect(command.stdout).to match(/Chef::Exceptions::CookbookChefVersionMismatch/)
end
@@ -406,12 +404,12 @@ describe "chef-client" do
EOM
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "the cheffish DSL is loaded lazily" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
expect(command.exitstatus).to eql(0)
end
end
@@ -437,7 +435,7 @@ describe "chef-client" do
it "should output each deprecation warning only once, at the end of the run" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
# Mimick what happens when you are on the console
formatters << :doc
log_level :warn
@@ -445,7 +443,7 @@ describe "chef-client" do
ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
- result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
expect(result.error?).to be_falsey
# Search to the end of the client run in the output
@@ -460,7 +458,7 @@ describe "chef-client" do
when_the_repository "has a cookbook that deploys a file" do
before do
file "cookbooks/x/recipes/default.rb", <<~RECIPE
- cookbook_file #{path_to('tempfile.txt').inspect} do
+ cookbook_file #{path_to("tempfile.txt").inspect} do
source "my_file"
end
RECIPE
@@ -476,9 +474,9 @@ describe "chef-client" do
file "config/client.rb", <<~EOM
no_lazy_load #{lazy}
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
- result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ result = shell_out("#{chef_client} -l debug -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt")).strip).to eq("this is my file")
@@ -490,7 +488,7 @@ describe "chef-client" do
when_the_repository "has a cookbook with an ohai plugin" do
before do
file "cookbooks/x/recipes/default.rb", <<~RECIPE
- file #{path_to('tempfile.txt').inspect} do
+ file #{path_to("tempfile.txt").inspect} do
content node["english"]["version"]
end
RECIPE
@@ -508,12 +506,12 @@ describe "chef-client" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "should run the ohai plugin" do
- result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ result = shell_out("#{chef_client} -l debug -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
result.error!
expect(IO.read(path_to("tempfile.txt"))).to eq("2014")
@@ -536,7 +534,7 @@ describe "chef-client" do
file "config/client.rb", <<~EOM
chef_repo_path "#{tmp_dir}"
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", cwd: tmp_dir)
result.error!
end
@@ -569,17 +567,17 @@ describe "chef-client" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "the chef client run should succeed" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
end
it "a chef-solo run should succeed" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
end
end
@@ -593,30 +591,30 @@ describe "chef-client" do
EOM
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "a chef client run should not log to info by default" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef client run to a pipe should not log to info by default" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork | tee #{path_to("chefrun.out")}", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef solo run should not log to info by default" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
it "a chef solo run to a pipe should not log to info by default" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork | tee #{path_to('chefrun.out')}", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork | tee #{path_to("chefrun.out")}", cwd: chef_dir)
command.error!
expect(command.stdout).not_to include("INFO")
end
@@ -629,42 +627,42 @@ EOM
EOM
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
it "chef-client runs by default with no supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo runs by default with no supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-client --no-fork does not fork" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo --no-fork does not fork" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --no-fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-client with --fork uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
it "chef-solo with --fork uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --fork", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default' --fork", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
@@ -677,19 +675,19 @@ EOM
EOM
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
client_fork true
EOM
end
it "chef-client uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
it "chef-solo uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("WITHFORK")
end
@@ -702,19 +700,19 @@ EOM
EOM
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
client_fork false
EOM
end
it "chef-client uses a supervisor" do
- command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
it "chef-solo uses a supervisor" do
- command = shell_out("#{chef_solo} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ command = shell_out("#{chef_solo} -c \"#{path_to("config/client.rb")}\" -o 'x::default'", cwd: chef_dir)
command.error!
expect(command.stdout).to include("NOFORK")
end
diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb
index ff48d69527..37999ab431 100644
--- a/spec/integration/client/exit_code_spec.rb
+++ b/spec/integration/client/exit_code_spec.rb
@@ -30,12 +30,12 @@ describe "chef-client" do
def setup_client_rb
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
end
def run_chef_client_and_expect_exit_code(exit_code)
- shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'",
+ shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'x::default'",
cwd: chef_dir,
returns: [exit_code])
end
diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb
index b97eb4e8b4..2d16786334 100644
--- a/spec/integration/client/ipv6_spec.rb
+++ b/spec/integration/client/ipv6_spec.rb
@@ -63,7 +63,7 @@ describe "chef-client" do
let(:basic_config_file) do
<<~END_CLIENT_RB
chef_server_url "http://[::1]:8900"
- validation_key '#{path_to('config/validator.pem')}'
+ validation_key '#{path_to("config/validator.pem")}'
cache_path '#{cache_path}'
client_key '#{cache_path}/client.pem'
END_CLIENT_RB
@@ -75,7 +75,7 @@ describe "chef-client" do
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
- let(:chef_client_cmd) { %Q{bundle exec chef-client --minimal-ohai -c "#{path_to('config/client.rb')}" -lwarn} }
+ let(:chef_client_cmd) { %Q{bundle exec chef-client --minimal-ohai -c "#{path_to("config/client.rb")}" -lwarn} }
after do
FileUtils.rm_rf(cache_path)
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index abd4f129a1..58ca5121c5 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -185,12 +185,12 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m PUT /clients/x" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /clients/x").should_succeed( /"x"/ )
knife("list --local /clients").should_succeed "/clients/x.json\n"
end
it "knife cookbook upload works" do
- knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed stderr: <<~EOM
+ knife("cookbook upload -z --cookbook-path #{path_to("cookbooks_to_upload")} x").should_succeed stderr: <<~EOM
Uploading x [1.0.0]
Uploaded 1 cookbook.
EOM
@@ -198,28 +198,28 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m PUT /data/x/y" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_succeed( /"y"/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /data/x/y").should_succeed( /"y"/ )
knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/y.json\n"
end
it "knife raw -z -i empty.json -m PUT /environments/x" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /environments/x").should_succeed( /"x"/ )
knife("list --local /environments").should_succeed "/environments/x.json\n"
end
it "knife raw -z -i dummynode.json -m PUT /nodes/x" do
- knife("raw -z -i #{path_to('dummynode.json')} -m PUT /nodes/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("dummynode.json")} -m PUT /nodes/x").should_succeed( /"x"/ )
knife("list --local /nodes").should_succeed "/nodes/x.json\n"
knife("show -z /nodes/x.json --verbose").should_succeed(/"bar"/)
end
it "knife raw -z -i empty.json -m PUT /roles/x" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /roles/x").should_succeed( /"x"/ )
knife("list --local /roles").should_succeed "/roles/x.json\n"
end
it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty" do
- knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("rolestuff.json")} -m PUT /roles/x").should_succeed( /"x"/ )
expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
{
"name": "x",
@@ -242,12 +242,12 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m POST /clients" do
- knife("raw -z -i #{path_to('empty.json')} -m POST /clients").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty.json")} -m POST /clients").should_succeed( /uri/ )
knife("list --local /clients").should_succeed "/clients/z.json\n"
end
it "knife cookbook upload works" do
- knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed stderr: <<~EOM
+ knife("cookbook upload -z --cookbook-path #{path_to("cookbooks_to_upload")} z").should_succeed stderr: <<~EOM
Uploading z [1.0.0]
Uploaded 1 cookbook.
EOM
@@ -255,34 +255,34 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m POST /data" do
- knife("raw -z -i #{path_to('empty.json')} -m POST /data").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty.json")} -m POST /data").should_succeed( /uri/ )
knife("list --local -Rfp /data_bags").should_succeed "/data_bags/z/\n"
end
it "knife raw -z -i empty.json -m POST /data/x" do
- knife("raw -z -i #{path_to('empty_x.json')} -m POST /data").should_succeed( /uri/ )
- knife("raw -z -i #{path_to('empty_id.json')} -m POST /data/x").should_succeed( /"z"/ )
+ knife("raw -z -i #{path_to("empty_x.json")} -m POST /data").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty_id.json")} -m POST /data/x").should_succeed( /"z"/ )
knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/z.json\n"
end
it "knife raw -z -i empty.json -m POST /environments" do
- knife("raw -z -i #{path_to('empty.json')} -m POST /environments").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty.json")} -m POST /environments").should_succeed( /uri/ )
knife("list --local /environments").should_succeed "/environments/z.json\n"
end
it "knife raw -z -i dummynode.json -m POST /nodes" do
- knife("raw -z -i #{path_to('dummynode.json')} -m POST /nodes").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("dummynode.json")} -m POST /nodes").should_succeed( /uri/ )
knife("list --local /nodes").should_succeed "/nodes/z.json\n"
knife("show -z /nodes/z.json").should_succeed(/"bar"/)
end
it "knife raw -z -i empty.json -m POST /roles" do
- knife("raw -z -i #{path_to('empty.json')} -m POST /roles").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty.json")} -m POST /roles").should_succeed( /uri/ )
knife("list --local /roles").should_succeed "/roles/z.json\n"
end
it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty" do
- knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("rolestuff.json")} -m POST /roles").should_succeed( /uri/ )
expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
{
"name": "x",
@@ -388,23 +388,23 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m PUT /clients/x fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /clients/x").should_fail( /404/ )
end
it "knife raw -z -i empty.json -m PUT /data/x/y fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /data/x/y").should_fail( /404/ )
end
it "knife raw -z -i empty.json -m PUT /environments/x fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /environments/x").should_fail( /404/ )
end
it "knife raw -z -i empty.json -m PUT /nodes/x fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /nodes/x").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /nodes/x").should_fail( /404/ )
end
it "knife raw -z -i empty.json -m PUT /roles/x fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /roles/x").should_fail( /404/ )
end
end
@@ -485,12 +485,12 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m PUT /users/x" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /users/x").should_succeed( /"x"/ )
knife("list --local /users").should_succeed "/users/x.json\n"
end
it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty" do
- knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ )
+ knife("raw -z -i #{path_to("rolestuff.json")} -m PUT /roles/x").should_succeed( /"x"/ )
expect(IO.read(path_to("roles/x.json"))).to eq <<~EOM.strip
{
"name": "x",
@@ -513,7 +513,7 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m POST /users" do
- knife("raw -z -i #{path_to('empty.json')} -m POST /users").should_succeed( /uri/ )
+ knife("raw -z -i #{path_to("empty.json")} -m POST /users").should_succeed( /uri/ )
knife("list --local /users").should_succeed "/users/z.json\n"
end
end
@@ -548,7 +548,7 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife raw -z -i empty.json -m PUT /users/x fails with 404" do
- knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_fail( /404/ )
+ knife("raw -z -i #{path_to("empty.json")} -m PUT /users/x").should_fail( /404/ )
end
end
end
diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb
index 4a133b0181..919741f930 100644
--- a/spec/integration/knife/chef_repo_path_spec.rb
+++ b/spec/integration/knife/chef_repo_path_spec.rb
@@ -59,7 +59,7 @@ describe "chef_repo_path tests", :workstation do
it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do
Chef::Config.delete(:chef_repo_path)
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM
+ knife("list --local -Rfp --chef-repo-path #{path_to("chef_repo2")} /").should_succeed <<~EOM
/clients/
/clients/client3.json
/cookbooks/
@@ -81,7 +81,7 @@ describe "chef_repo_path tests", :workstation do
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only do
Chef::Config.delete(:chef_repo_path)
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM
+ knife("list --local -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM
/clients/
/clients/client3.json
/cookbooks/
@@ -103,7 +103,7 @@ describe "chef_repo_path tests", :workstation do
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only do
Chef::Config.delete(:chef_repo_path)
- knife("list -z -Rfp --chef-repo-path #{path_to('chef_r~1')} /").should_succeed <<~EOM
+ knife("list -z -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM
/acls/
/acls/clients/
/acls/clients/client3.json
@@ -157,7 +157,7 @@ describe "chef_repo_path tests", :workstation do
end
it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do
- knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<~EOM
+ knife("list --local -Rfp --chef-repo-path #{path_to("chef_repo2")} /").should_succeed <<~EOM
/clients/
/clients/client3.json
/cookbooks/
diff --git a/spec/integration/knife/config_get_spec.rb b/spec/integration/knife/config_get_spec.rb
index f34d096051..98fefd729f 100644
--- a/spec/integration/knife/config_get_spec.rb
+++ b/spec/integration/knife/config_get_spec.rb
@@ -143,7 +143,7 @@ describe "knife config get", :workstation do
let(:cmd_args) { %w{node_name client_key} }
before { file(".chef/credentials", "[default]\nclient_name = \"three\"\nclient_key = \"three.pem\"") }
- it { is_expected.to match(/^client_key:\s+\S*\/.chef\/three.pem\nnode_name:\s+three\Z/) }
+ it { is_expected.to match(%r{^client_key:\s+\S*/.chef/three.pem\nnode_name:\s+three\Z}) }
end
context "with a dotted argument" do
diff --git a/spec/integration/knife/config_list_profiles_spec.rb b/spec/integration/knife/config_list_profiles_spec.rb
index 32846f9999..044b50b5be 100644
--- a/spec/integration/knife/config_list_profiles_spec.rb
+++ b/spec/integration/knife/config_list_profiles_spec.rb
@@ -183,6 +183,7 @@ describe "knife config list-profiles", :workstation do
{ "profile" => "default", "active" => true, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/testorg" },
{ "profile" => "prod", "active" => false, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/prod" },
{ "profile" => "qa", "active" => false, "client_name" => "qauser", "client_key" => path_to("src/qauser.pem"), "server_url" => "https://example.com/organizations/testorg" },
- ] }
+ ]
+ }
end
end
diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb
index a7e3709276..c615d8de7a 100644
--- a/spec/integration/knife/cookbook_api_ipv6_spec.rb
+++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb
@@ -77,7 +77,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
<<~END_CLIENT_RB
chef_server_url "http://[::1]:8900"
syntax_check_cache_path '#{cache_path}'
- client_key '#{path_to('config/knifeuser.pem')}'
+ client_key '#{path_to("config/knifeuser.pem")}'
node_name 'whoisthisis'
cookbook_path '#{CHEF_SPEC_DATA}/cookbooks'
END_CLIENT_RB
diff --git a/spec/integration/knife/cookbook_download_spec.rb b/spec/integration/knife/cookbook_download_spec.rb
index 3fe801b64c..538c06802b 100644
--- a/spec/integration/knife/cookbook_download_spec.rb
+++ b/spec/integration/knife/cookbook_download_spec.rb
@@ -65,7 +65,7 @@ describe "knife cookbook download", :workstation do
Downloading root_files
Cookbook downloaded to #{tmpdir}/x-1.0.1
EOM
-)
+ )
end
end
end
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb
index cd08ebdcbd..87cbd1559d 100644
--- a/spec/integration/knife/diff_spec.rb
+++ b/spec/integration/knife/diff_spec.rb
@@ -309,7 +309,7 @@ describe "knife diff", :workstation do
when_the_repository "has an environment with bad JSON" do
before { file "environments/x.json", "{" }
it "knife diff reports an error and does a textual diff" do
- error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
+ error_text = "WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF"
error_match = Regexp.new(Regexp.escape(error_text))
knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match)
end
@@ -592,7 +592,7 @@ describe "knife diff", :workstation do
when_the_repository "has an environment with bad JSON" do
before { file "environments/x.json", "{" }
it "knife diff reports an error and does a textual diff" do
- error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF"
+ error_text = "WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF"
error_match = Regexp.new(Regexp.escape(error_text))
knife("diff /environments/x.json").should_succeed(/- "name": "x"/, stderr: error_match)
end
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index 93d804b749..77f6d3890e 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -561,7 +561,7 @@ describe "knife download", :workstation do
end
it "knife download succeeds" do
warning = <<~EOH
- WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF
{
(right here) ------^
diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb
index d387b10e3b..5e5ef27b9a 100644
--- a/spec/integration/knife/redirection_spec.rb
+++ b/spec/integration/knife/redirection_spec.rb
@@ -34,7 +34,7 @@ describe "redirection", :workstation do
real_chef_server_url = Chef::Config.chef_server_url
Chef::Config.chef_server_url = "http://localhost:9018"
app = lambda do |env|
- [302, { "Content-Type" => "text", "Location" => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ["302 found"] ]
+ [302, { "Content-Type" => "text", "Location" => "#{real_chef_server_url}#{env["PATH_INFO"]}" }, ["302 found"] ]
end
@redirector_server_thread = start_app_server(app, 9018)
end
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 766f91ab25..1a6ddceb17 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -636,7 +636,7 @@ EOM
it "knife upload tries and fails" do
error1 = <<~EOH
- WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF
{
(right here) ------^
@@ -646,7 +646,7 @@ EOM
EOH
warn = <<~EOH
- WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF
+ WARN: Parse error reading #{path_to("environments/x.json")} as JSON: parse error: premature EOF
{
(right here) ------^
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index d19d8637bb..98e3581071 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -115,11 +115,11 @@ describe "Accumulators" do
it "should complete with success" do
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
result.error!
# runs only a single template resource (in the outer run context, as a delayed resource)
expect(result.stdout.scan(/template\S+ action create/).size).to eql(1)
@@ -217,11 +217,11 @@ describe "Accumulators" do
it "should complete with success" do
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
result.error!
# runs only a single template resource (in the outer run context, as a delayed resource)
expect(result.stdout.scan(/template\S+ action create/).size).to eql(1)
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index 6bc857df48..b96fa1d67d 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -53,7 +53,7 @@ describe "LWRPs with inline resources" do
action :fiddle do
file PATH do
content new_resource.content
- action [:create, :delete]
+ action %i{create delete}
end
end
end
@@ -147,12 +147,12 @@ describe "LWRPs with inline resources" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- actual = result.stdout.lines.map { |l| l.chomp }.join("\n")
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ actual = result.stdout.lines.map(&:chomp).join("\n")
expected = <<EOM
* x_my_machine[me] action create
* x_do_nothing[a] action create (up to date)
@@ -163,7 +163,7 @@ describe "LWRPs with inline resources" do
* x_do_nothing[b] action create (up to date)
(up to date)
EOM
- expected = expected.lines.map { |l| l.chomp }.join("\n")
+ expected = expected.lines.map(&:chomp).join("\n")
expect(actual).to include(expected)
result.error!
end
diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb
index ce2861d43b..957c1ea66f 100644
--- a/spec/integration/recipes/lwrp_spec.rb
+++ b/spec/integration/recipes/lwrp_spec.rb
@@ -40,11 +40,11 @@ describe "LWRPs" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'l-w-r-p::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* l_w_r_p_foo\[me\] action create \(up to date\)/)
expect(result.stdout).not_to match(/WARN: You are overriding l_w_r_p_foo/)
result.error!
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index 860a109e4d..ae534dcad4 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -28,11 +28,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* apt_update\[\] action nothing \(skipped due to action :nothing\)\s+\* log\[foo\] action write\s+\* log\[bar\] action write\s+\* apt_update\[\] action nothing \(skipped due to action :nothing\)/)
result.error!
@@ -69,11 +69,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
result.error!
@@ -112,11 +112,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# our delayed notification should run at the end of the parent run_context after the baz resource
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
# and only run once
@@ -159,11 +159,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
expect(result.stdout).to match(/\* log\[quux\] action write\s+\* notifying_test\[whatever\] action run\s+\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
# and only run once
@@ -193,11 +193,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
# the delayed notification from the sub-resource is de-duplicated by the notification already in the parent run_context
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[baz\] action write\s+\* log\[foo\] action write/)
# and only run once
@@ -236,11 +236,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
@@ -276,11 +276,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[bar\] action write\s+\* log\[foo\] action write\s+\* log\[baz\] action write/)
result.error!
end
@@ -313,11 +313,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/Chef::Exceptions::ResourceNotFound/)
expect(result.exitstatus).not_to eql(0)
end
@@ -353,11 +353,11 @@ describe "notifications" do
it "should complete with success" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).not_to match(/CHEF-3694/)
result.error!
end
@@ -381,11 +381,11 @@ describe "notifications" do
it "notifying the resource should work" do
file "config/client.rb", <<~EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match /\* log\[a, b\] action write/
result.error!
end
diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb
index 753e81dadb..465eca97ed 100644
--- a/spec/integration/recipes/notifying_block_spec.rb
+++ b/spec/integration/recipes/notifying_block_spec.rb
@@ -45,7 +45,7 @@ describe "notifying_block" do
end
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
end
@@ -55,7 +55,7 @@ describe "notifying_block" do
# 2. delayed notifications are de-dup'd in the subcontext
# 3. delayed notifications (to resources inside the subcontext) are run at the end of the subcontext
it "should run alpha, beta, gamma, and delta in that order" do
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[alpha\] action write\s+\* log\[beta\] action write\s+\* log\[gamma\] action write\s+Converging 1 resources\s+\* log\[delta\] action write/)
result.error!
end
@@ -94,7 +94,7 @@ describe "notifying_block" do
end
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
log_level :warn
EOM
end
@@ -103,7 +103,7 @@ describe "notifying_block" do
# 1. notifying block will correctly update wrapping new_resource updated_by_last_action status
# 2. delayed notifications from a subcontext inside a resource will notify resources in their outer run_context
it "should run foo, quux, bar, and baz in that order" do
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
expect(result.stdout).to match(/\* log\[foo\] action write\s+\* log\[quux\] action write\s+\* log\[bar\] action write\s+\* log\[baz\] action write/)
result.error!
end
diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb
index 1895d93891..dea58230db 100644
--- a/spec/integration/recipes/provider_choice.rb
+++ b/spec/integration/recipes/provider_choice.rb
@@ -16,8 +16,7 @@ describe "Recipe DSL methods" do
context "And class Chef::Provider::ProviderThingy with no provides" do
before :context do
class Chef::Provider::ProviderThingy < Chef::Provider
- def load_current_resource
- end
+ def load_current_resource; end
def action_create
Chef::Log.warn("hello from #{self.class.name}")
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index 0250786f0e..766752ac13 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -28,8 +28,7 @@ describe "Recipe DSL methods" do
Provider
end
class Provider < Chef::Provider
- def load_current_resource
- end
+ def load_current_resource; end
def action_create
BaseThingy.created_name = new_resource.name
@@ -1154,7 +1153,8 @@ describe "Recipe DSL methods" do
def to_s
"MyResource"
end
- end end
+ end
+ end
let(:my_resource) { :"my_resource#{Namer.current_index}" }
let(:blarghle_blarghle_little_star) { :"blarghle_blarghle_little_star#{Namer.current_index}" }
@@ -1340,10 +1340,10 @@ describe "Recipe DSL methods" do
resource_class.new("blah", run_context)
end
it "The actions are part of actions along with :nothing" do
- expect(resource_class.actions).to eq [ :nothing, :create ]
+ expect(resource_class.actions).to eq %i{nothing create}
end
it "The actions are part of allowed_actions along with :nothing" do
- expect(resource.allowed_actions).to eq [ :nothing, :create ]
+ expect(resource.allowed_actions).to eq %i{nothing create}
end
context "and a subclass that declares more actions" do
@@ -1358,14 +1358,14 @@ describe "Recipe DSL methods" do
end
it "The parent class actions are not part of actions" do
- expect(subresource_class.actions).to eq [ :nothing, :delete ]
+ expect(subresource_class.actions).to eq %i{nothing delete}
end
it "The parent class actions are not part of allowed_actions" do
- expect(subresource.allowed_actions).to eq [ :nothing, :delete ]
+ expect(subresource.allowed_actions).to eq %i{nothing delete}
end
it "The parent class actions do not change" do
- expect(resource_class.actions).to eq [ :nothing, :create ]
- expect(resource.allowed_actions).to eq [ :nothing, :create ]
+ expect(resource_class.actions).to eq %i{nothing create}
+ expect(resource.allowed_actions).to eq %i{nothing create}
end
end
end
diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb
index 6f67a38fc8..8332fb1b56 100644
--- a/spec/integration/recipes/remote_directory.rb
+++ b/spec/integration/recipes/remote_directory.rb
@@ -22,7 +22,7 @@ describe Chef::Resource::RemoteDirectory do
before do
file "config/client.rb", <<-EOM
local_mode true
- cookbook_path "#{path_to('cookbooks')}"
+ cookbook_path "#{path_to("cookbooks")}"
EOM
directory "cookbooks/test" do
directory "files/default/source_dir" do
@@ -50,7 +50,7 @@ describe Chef::Resource::RemoteDirectory do
end
EOM
end
- shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", cwd: chef_dir)
+ shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -o 'test::default'", cwd: chef_dir)
end
def mode_of(path)
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 0d24269199..451943e225 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Dist::SOLOEXEC do
file "config/solo.rb", <<~EOM
chef_repo_path "#{@repository_dir}"
EOM
- result = shell_out("bundle exec chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", cwd: chef_dir)
+ result = shell_out("bundle exec chef-solo -c \"#{path_to("config/solo.rb")}\" -l debug", cwd: chef_dir)
result.error!
end
@@ -76,25 +76,25 @@ describe Chef::Dist::SOLOEXEC do
it "should complete with success" do
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir)
result.error!
expect(result.stdout).to include("ITWORKS")
end
it "should evaluate its node.json file" do
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
file "config/node.json", <<~E
{"run_list":["x::default"]}
E
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -j '#{path_to('config/node.json')}' -l debug", cwd: chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -j '#{path_to("config/node.json")}' -l debug", cwd: chef_dir)
result.error!
expect(result.stdout).to include("ITWORKS")
end
@@ -112,10 +112,10 @@ describe Chef::Dist::SOLOEXEC do
it "should exit with an error" do
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(0) # For CHEF-5120 this becomes 1
expect(result.stdout).to include("WARN: MissingCookbookDependency")
end
@@ -126,13 +126,13 @@ describe Chef::Dist::SOLOEXEC do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"'
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
end
it "should exit with an error" do
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(1)
expect(result.stdout).to include("Chef::Exceptions::CookbookChefVersionMismatch")
end
@@ -143,13 +143,13 @@ describe Chef::Dist::SOLOEXEC do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nohai_version '~> 999.0'")
file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"'
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
end
it "should exit with an error" do
- result = shell_out("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", cwd: chef_dir)
+ result = shell_out("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug", cwd: chef_dir)
expect(result.exitstatus).to eq(1)
expect(result.stdout).to include("Chef::Exceptions::CookbookOhaiVersionMismatch")
end
@@ -175,8 +175,8 @@ describe Chef::Dist::SOLOEXEC do
it "while running solo concurrently" do
file "config/solo.rb", <<~EOM
- cookbook_path "#{path_to('cookbooks')}"
- file_cache_path "#{path_to('config/cache')}"
+ cookbook_path "#{path_to("cookbooks")}"
+ file_cache_path "#{path_to("config/cache")}"
EOM
# We have a timeout protection here so that if due to some bug
# run_lock gets stuck we can discover it.
@@ -188,13 +188,13 @@ describe Chef::Dist::SOLOEXEC do
# Instantiate the first chef-solo run
threads << Thread.new do
- s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir)
+ s1 = Process.spawn("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug -L #{path_to("logs/runs.log")}", chdir: chef_dir)
Process.waitpid(s1)
end
# Instantiate the second chef-solo run
threads << Thread.new do
- s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", chdir: chef_dir)
+ s2 = Process.spawn("#{chef_solo} -c \"#{path_to("config/solo.rb")}\" -o 'x::default' -l debug -L #{path_to("logs/runs.log")}", chdir: chef_dir)
Process.waitpid(s2)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index adfb262637..96d02cc5d8 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -52,7 +52,7 @@ require "chef/knife"
Dir["lib/chef/knife/**/*.rb"]
.map { |f| f.gsub("lib/", "") }
- .map { |f| f.gsub(%r{\.rb$}, "") }
+ .map { |f| f.gsub(/\.rb$/, "") }
.each { |f| require f }
require "chef/resource_resolver"
@@ -93,7 +93,7 @@ require "spec/support/shared/unit/mock_shellout"
Dir["spec/support/**/*.rb"]
.reject { |f| f =~ %r{^spec/support/platforms} }
.reject { |f| f =~ %r{^spec/support/pedant} }
- .map { |f| f.gsub(%r{.rb$}, "") }
+ .map { |f| f.gsub(/.rb$/, "") }
.map { |f| f.gsub(%r{spec/}, "") }
.each { |f| require f }
@@ -145,7 +145,7 @@ RSpec.configure do |config|
config.filter_run_excluding windows_only: true unless windows?
config.filter_run_excluding not_supported_on_windows: true if windows?
config.filter_run_excluding not_supported_on_macos: true if mac_osx?
- config.filter_run_excluding macos_only: true if !mac_osx?
+ config.filter_run_excluding macos_only: true unless mac_osx?
config.filter_run_excluding not_supported_on_aix: true if aix?
config.filter_run_excluding not_supported_on_solaris: true if solaris?
config.filter_run_excluding not_supported_on_gce: true if gce?
@@ -159,7 +159,7 @@ RSpec.configure do |config|
config.filter_run_excluding ruby64_only: true unless ruby_64bit?
config.filter_run_excluding ruby32_only: true unless ruby_32bit?
config.filter_run_excluding windows_powershell_dsc_only: true unless windows_powershell_dsc?
- config.filter_run_excluding windows_powershell_no_dsc_only: true unless ! windows_powershell_dsc?
+ config.filter_run_excluding windows_powershell_no_dsc_only: true if windows_powershell_dsc?
config.filter_run_excluding windows_domain_joined_only: true unless windows_domain_joined?
config.filter_run_excluding windows_not_domain_joined_only: true if windows_domain_joined?
# We think this line was causing rspec tests to not run on the Jenkins windows
@@ -311,14 +311,11 @@ require "thread"
module WEBrick
module Utils
class TimeoutHandler
- def initialize
- end
+ def initialize; end
- def register(*args)
- end
+ def register(*args); end
- def cancel(*args)
- end
+ def cancel(*args); end
end
end
end
diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb
index 0280398ad5..8929a2ff74 100644
--- a/spec/stress/win32/security_spec.rb
+++ b/spec/stress/win32/security_spec.rb
@@ -50,7 +50,7 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do
it "should not leak when retrieving and reading the ACE from a file", :volatile do
expect do
- sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid }
+ sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select(&:sid)
GC.start
end.not_to leak_memory(warmup: 50, iterations: 100)
end
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 84fc71cc99..72dd67ca97 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -25,7 +25,7 @@ class Chef
provides :follower, platform: "zen"
def master(arg = nil)
- if !arg.nil?
+ unless arg.nil?
@master = arg
end
@master
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 9d6e5d46f7..710742a285 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -30,7 +30,7 @@ class Chef
end
def something(arg = nil)
- if !arg.nil?
+ unless arg.nil?
@something = arg
end
@something
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index c6670827f9..2cf605c741 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -19,7 +19,7 @@ def platform_mock(platform = :unix)
mock_constants({ "RUBY_PLATFORM" => (platform == :windows ? "i386-mingw32" : "x86_64-darwin11.2.0"),
"File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"),
"File::ALT_SEPARATOR" => (platform == :windows ? "\\" : nil) }) do
- yield
- end
+ yield
+ end
end
end
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 02f8c28345..509ca6e71e 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -46,6 +46,7 @@ require "wmi-lite/wmi" if windows?
def windows_domain_joined?
return false unless windows?
+
wmi = WmiLite::Wmi.new
computer_system = wmi.first_of("Win32_ComputerSystem")
computer_system["partofdomain"]
@@ -53,11 +54,13 @@ end
def windows_2012r2?
return false unless windows?
+
(host_version && host_version.start_with?("6.3"))
end
def windows_gte_10?
return false unless windows?
+
Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(host_version))
end
@@ -71,6 +74,7 @@ end
def windows_powershell_dsc?
return false unless windows?
+
supports_dsc = false
begin
wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration")
@@ -88,6 +92,7 @@ end
def windows_user_right?(right)
return false unless windows?
+
require "chef/win32/security"
Chef::ReservedNames::Win32::Security.get_account_right(ENV["USERNAME"]).include?(right)
end
@@ -217,6 +222,7 @@ end
def root?
return false if windows?
+
Process.euid == 0
end
diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb
index 5548a79afc..2cc4e40298 100644
--- a/spec/support/platforms/win32/spec_service.rb
+++ b/spec/support/platforms/win32/spec_service.rb
@@ -20,12 +20,12 @@ require "win32/daemon"
class SpecService < ::Win32::Daemon
def service_init
- @test_service_file = "#{ENV['TMP']}/spec_service_file"
+ @test_service_file = "#{ENV["TMP"]}/spec_service_file"
end
def service_main(*startup_parameters)
while running?
- if !File.exists?(@test_service_file)
+ unless File.exists?(@test_service_file)
File.open(@test_service_file, "wb") do |f|
f.write("This file is created by SpecService")
end
@@ -39,17 +39,13 @@ class SpecService < ::Win32::Daemon
# Control Signal Callback Methods
################################################################################
- def service_stop
- end
+ def service_stop; end
- def service_pause
- end
+ def service_pause; end
- def service_resume
- end
+ def service_resume; end
- def service_shutdown
- end
+ def service_shutdown; end
end
# To run this file as a service, it must be called as a script from within
diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb
index 1a14bb38c3..f56479bb49 100644
--- a/spec/support/shared/functional/execute_resource.rb
+++ b/spec/support/shared/functional/execute_resource.rb
@@ -21,7 +21,7 @@ shared_context "a non-admin Windows user" do
let(:windows_nonadmin_user_domain) { ENV["COMPUTERNAME"] }
let(:windows_nonadmin_user_qualified) { "#{windows_nonadmin_user_domain}\\#{windows_nonadmin_user}" }
- let(:temp_profile_path) { "#{ENV['USERPROFILE']}\\..\\cheftesttempuser" }
+ let(:temp_profile_path) { "#{ENV["USERPROFILE"]}\\..\\cheftesttempuser" }
before do
shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0, 2])
@@ -40,7 +40,7 @@ end
shared_context "alternate user identity" do
let(:windows_alternate_user) { "chef%02d%02d%02d" % [Time.now.year % 100, Time.now.month, Time.now.day] }
let(:windows_alternate_user_password) { "lj28;fx3T!x,2" }
- let(:windows_alternate_user_qualified) { "#{ENV['COMPUTERNAME']}\\#{windows_alternate_user}" }
+ let(:windows_alternate_user_qualified) { "#{ENV["COMPUTERNAME"]}\\#{windows_alternate_user}" }
let(:windows_nonadmin_user) { windows_alternate_user }
let(:windows_nonadmin_user_password) { windows_alternate_user_password }
@@ -58,7 +58,7 @@ shared_context "a command that can be executed as an alternate user" do
include Chef::Mixin::ShellOut
before do
- shell_out!("icacls \"#{script_output_dir.gsub(/\//, '\\')}\" /grant \"authenticated users:(F)\"")
+ shell_out!("icacls \"#{script_output_dir.gsub(%r{/}, '\\')}\" /grant \"authenticated users:(F)\"")
end
after do
@@ -73,7 +73,7 @@ shared_examples_for "an execute resource that supports alternate user identity"
include_context "a command that can be executed as an alternate user"
let(:windows_current_user) { ENV["USERNAME"] }
- let(:windows_current_user_qualified) { "#{ENV['USERDOMAIN'] || ENV['COMPUTERNAME']}\\#{windows_current_user}" }
+ let(:windows_current_user_qualified) { "#{ENV["USERDOMAIN"] || ENV["COMPUTERNAME"]}\\#{windows_current_user}" }
let(:resource_identity_command) { "powershell.exe -noprofile -command \"import-module microsoft.powershell.utility;([Security.Principal.WindowsPrincipal]([Security.Principal.WindowsIdentity]::GetCurrent())).identity.name | out-file -encoding ASCII '#{script_output_path}'\"" }
let(:execute_resource) do
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index db947614b3..114971641d 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -392,9 +392,7 @@ shared_examples_for "a configured file resource" do
end
def binread(file)
- content = File.open(file, "rb") do |f|
- f.read
- end
+ content = File.open(file, "rb", &:read)
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
content
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 7450f28e35..f006c6a24a 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -30,9 +30,7 @@ module ChefHTTPShared
end
def binread(file)
- content = File.open(file, "rb") do |f|
- f.read
- end
+ content = File.open(file, "rb", &:read)
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
content
end
@@ -53,25 +51,19 @@ module ChefHTTPShared
# just a normal file
# (expected_content should be uncompressed)
@api.get("/nyan_cat.png", 200) do
- File.open(nyan_uncompressed_filename, "rb") do |f|
- f.read
- end
+ File.open(nyan_uncompressed_filename, "rb", &:read)
end
# this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
# (expected_content should be compressed)
@api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
- File.open(nyan_compressed_filename, "rb") do |f|
- f.read
- end
+ File.open(nyan_compressed_filename, "rb", &:read)
end
# this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
# (expected_content should be uncompressed)
@api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
- File.open(nyan_compressed_filename, "rb") do |f|
- f.read
- end
+ File.open(nyan_compressed_filename, "rb", &:read)
end
#
@@ -82,12 +74,9 @@ module ChefHTTPShared
@api.get("/nyan_cat_content_length.png", 200, nil,
{
"Content-Length" => nyan_uncompressed_size.to_s,
- }
- ) do
- File.open(nyan_uncompressed_filename, "rb") do |f|
- f.read
+ }) do
+ File.open(nyan_uncompressed_filename, "rb", &:read)
end
- end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_content_length_compressed.png", 200, nil,
@@ -95,12 +84,9 @@ module ChefHTTPShared
"Content-Length" => nyan_compressed_size.to_s,
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
- }
- ) do
- File.open(nyan_compressed_filename, "rb") do |f|
- f.read
+ }) do
+ File.open(nyan_compressed_filename, "rb", &:read)
end
- end
#
# endpoints that simulate truncated downloads (bad content-length header)
@@ -110,12 +96,9 @@ module ChefHTTPShared
@api.get("/nyan_cat_truncated.png", 200, nil,
{
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
- }
- ) do
- File.open(nyan_uncompressed_filename, "rb") do |f|
- f.read
+ }) do
+ File.open(nyan_uncompressed_filename, "rb", &:read)
end
- end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_truncated_compressed.png", 200, nil,
@@ -123,12 +106,9 @@ module ChefHTTPShared
"Content-Length" => (nyan_compressed_size + 1).to_s,
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
- }
- ) do
- File.open(nyan_compressed_filename, "rb") do |f|
- f.read
+ }) do
+ File.open(nyan_compressed_filename, "rb", &:read)
end
- end
#
# in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
@@ -139,12 +119,9 @@ module ChefHTTPShared
{
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
"Transfer-Encoding" => "anything",
- }
- ) do
- File.open(nyan_uncompressed_filename, "rb") do |f|
- f.read
+ }) do
+ File.open(nyan_uncompressed_filename, "rb", &:read)
end
- end
#
# 403 with a Content-Length
@@ -152,8 +129,7 @@ module ChefHTTPShared
@api.get("/forbidden", 403, "Forbidden",
{
"Content-Length" => "Forbidden".bytesize.to_s,
- }
- )
+ })
@api.post("/posty", 200, "Hi!")
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 18e7243453..010ef27f47 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -89,7 +89,7 @@ shared_context "use Windows permissions", :windows_only do
end
def explicit_aces
- descriptor.dacl.select { |ace| ace.explicit? }
+ descriptor.dacl.select(&:explicit?)
end
def extract_ace_properties(aces)
@@ -314,7 +314,7 @@ shared_examples_for "a securable resource without existing target" do
end
it "sets owner when owner is specified with a \\" do
- resource.owner "#{ENV['COMPUTERNAME']}\\Guest"
+ resource.owner "#{ENV["COMPUTERNAME"]}\\Guest"
resource.run_action(:create)
expect(descriptor.owner).to eq(SID.Guest)
end
@@ -560,16 +560,12 @@ shared_examples_for "a securable resource without existing target" do
# On certain flavors of Windows the default list of ACLs sometimes includes
# non-inherited ACLs. Filter them out here.
- parent_inherited_acls = parent_acls.dacl.collect do |ace|
- ace.inherited?
- end
+ parent_inherited_acls = parent_acls.dacl.collect(&:inherited?)
resource.run_action(:create)
# Similarly filter out the non-inherited ACLs
- resource_inherited_acls = descriptor.dacl.collect do |ace|
- ace.inherited?
- end
+ resource_inherited_acls = descriptor.dacl.collect(&:inherited?)
expect(resource_inherited_acls).to eq(parent_inherited_acls)
end
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index a528db4a53..2d14c6cf86 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -52,6 +52,6 @@ shared_context "using Win32::Service" do
# for the file it creates under SYSTEM temp directory
let(:test_service_file) do
- "#{ENV['SystemDrive']}\\windows\\temp\\spec_service_file"
+ "#{ENV["SystemDrive"]}\\windows\\temp\\spec_service_file"
end
end
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index 5eb68952d7..49fd727055 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -114,7 +114,8 @@ shared_context Chef::Resource::WindowsScript do
resource.only_if resource_guard_command, architecture: guard_architecture
expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
- /cannot execute script with requested architecture 'i386' on Windows Nano Server/)
+ /cannot execute script with requested architecture 'i386' on Windows Nano Server/
+ )
end
end
end
diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb
index 7f05b14689..317a5a2679 100644
--- a/spec/support/shared/integration/app_server_support.rb
+++ b/spec/support/shared/integration/app_server_support.rb
@@ -27,10 +27,9 @@ module AppServerSupport
Rack::Handler::WEBrick.run(app,
Port: 9018,
AccessLog: [],
- Logger: WEBrick::Log.new(StringIO.new, 7)
- ) do |found_server|
- server = found_server
- end
+ Logger: WEBrick::Log.new(StringIO.new, 7)) do |found_server|
+ server = found_server
+ end
end
Timeout.timeout(30) do
sleep(0.01) until server && server.status == :Running
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 5fc9de4de7..6c0eca98be 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -111,6 +111,7 @@ module IntegrationSupport
RSpec.shared_context "with a chef repo" do
before :each do
raise "Can only create one directory per test" if @repository_dir
+
@repository_dir = Dir.mktmpdir("chef_repo")
Chef::Config.chef_repo_path = @repository_dir
%w{client cookbook data_bag environment node role user}.each do |object_name|
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index 87ce1bc0b0..07d95f17cc 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -58,7 +58,7 @@ module KnifeSupport
old_loggers = Chef::Log.loggers
old_log_level = Chef::Log.level
begin
- puts "knife: #{args.join(' ')}" if DEBUG
+ puts "knife: #{args.join(" ")}" if DEBUG
subcommand_class = Chef::Knife.subcommand_class_from(args)
subcommand_class.options = Chef::Application::Knife.options.merge(subcommand_class.options)
subcommand_class.load_deps
@@ -150,7 +150,7 @@ module KnifeSupport
expected[:stderr] = arg
end
end
- expected[:exit_code] = 1 if !expected[:exit_code]
+ expected[:exit_code] = 1 unless expected[:exit_code]
should_result_in(expected)
end
@@ -169,9 +169,9 @@ module KnifeSupport
private
def should_result_in(expected)
- expected[:stdout] = "" if !expected[:stdout]
- expected[:stderr] = "" if !expected[:stderr]
- expected[:exit_code] = 0 if !expected[:exit_code]
+ expected[:stdout] = "" unless expected[:stdout]
+ expected[:stderr] = "" unless expected[:stderr]
+ expected[:exit_code] = 0 unless expected[:exit_code]
# TODO make this go away
stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, "")
diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb
index b94fa7c184..0f2f06eff8 100644
--- a/spec/support/shared/unit/application_dot_d.rb
+++ b/spec/support/shared/unit/application_dot_d.rb
@@ -33,13 +33,15 @@ shared_examples_for "an application that loads a dot d" do
# make sure that we are correctly globbing.
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../../data/client.d_00")) end
+ File.join(File.dirname(__FILE__), "../../../data/client.d_00")
+ )
+ end
it "loads the configuration in order" do
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0")
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("bar 0")
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_return("strings 0")
- allow(app).to receive(:apply_config).with(anything(), Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered
+ allow(app).to receive(:apply_config).with(anything, Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered
expect(app).to receive(:apply_config).with("foo 0", Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered
expect(app).to receive(:apply_config).with("bar 0", Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered
expect(app).to receive(:apply_config).with("strings 0", Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_call_original.ordered
@@ -50,7 +52,9 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory without configuration" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) end
+ File.join(File.dirname(__FILE__), "../../data/client.d_01")
+ )
+ end
# client.d_01 has a nested folder with a rb file that if
# executed, would raise an exception. If it is executed,
@@ -66,7 +70,9 @@ shared_examples_for "an application that loads a dot d" do
# foo.rb as a directory should be ignored
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_02")) end
+ File.join(File.dirname(__FILE__), "../../data/client.d_02")
+ )
+ end
it "does not raise an exception" do
expect { app.reconfigure }.not_to raise_error
diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb
index 32bdb1456e..957479f149 100644
--- a/spec/support/shared/unit/file_system_support.rb
+++ b/spec/support/shared/unit/file_system_support.rb
@@ -23,9 +23,10 @@ require "chef/chef_fs/file_system/memory/memory_file"
module FileSystemSupport
def memory_fs(pretty_name, value, cannot_be_in_regex = nil)
- if !value.is_a?(Hash)
+ unless value.is_a?(Hash)
raise "memory_fs() must take a Hash"
end
+
dir = Chef::ChefFS::FileSystem::Memory::MemoryRoot.new(pretty_name, cannot_be_in_regex)
value.each do |key, child|
dir.add_child(memory_fs_value(child, key.to_s, dir))
@@ -55,7 +56,7 @@ module FileSystemSupport
def no_blocking_calls_allowed
[ Chef::ChefFS::FileSystem::Memory::MemoryFile, Chef::ChefFS::FileSystem::Memory::MemoryDir ].each do |c|
- [ :children, :exists?, :read ].each do |m|
+ %i{children exists? read}.each do |m|
allow_any_instance_of(c).to receive(m).and_raise("#{m} should not be called")
end
end
diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb
index 7b9cc0f94e..3b07fdd367 100644
--- a/spec/support/shared/unit/platform_introspector.rb
+++ b/spec/support/shared/unit/platform_introspector.rb
@@ -36,14 +36,14 @@ shared_examples_for "a platform introspector" do
@platform_family_hash = {
"debian" => "debian value",
- [:rhel, :fedora] => "redhatty value",
+ %i{rhel fedora} => "redhatty value",
"suse" => "suse value",
:default => "default value",
}
end
it "returns a default value when there is no known platform" do
- node = Hash.new
+ node = {}
expect(platform_introspector.value_for_platform(@platform_hash)).to eq("default")
end
@@ -125,7 +125,7 @@ shared_examples_for "a platform introspector" do
it "returns true if the node is a provided platform and platforms are provided as symbols" do
node.automatic_attrs[:platform] = "ubuntu"
- expect(platform_introspector.platform?([:redhat, :ubuntu])).to eq(true)
+ expect(platform_introspector.platform?(%i{redhat ubuntu})).to eq(true)
end
it "returns true if the node is a provided platform and platforms are provided as strings" do
@@ -143,7 +143,7 @@ shared_examples_for "a platform introspector" do
it "returns true if the node is in a provided platform family and families are provided as symbols" do
node.automatic_attrs[:platform_family] = "debian"
- expect(platform_introspector.platform_family?([:rhel, :debian])).to eq(true)
+ expect(platform_introspector.platform_family?(%i{rhel debian})).to eq(true)
end
it "returns true if the node is a provided platform and platforms are provided as strings" do
@@ -165,24 +165,24 @@ shared_examples_for "a platform introspector" do
describe "when the value is an array" do
before do
@platform_hash = {
- "debian" => { "4.0" => [ :restart, :reload ], "default" => [ :restart, :reload, :status ] },
- "ubuntu" => { "default" => [ :restart, :reload, :status ] },
- "centos" => { "default" => [ :restart, :reload, :status ] },
- "redhat" => { "default" => [ :restart, :reload, :status ] },
- "fedora" => { "default" => [ :restart, :reload, :status ] },
- "default" => { "default" => [:restart, :reload ] } }
+ "debian" => { "4.0" => %i{restart reload}, "default" => %i{restart reload status} },
+ "ubuntu" => { "default" => %i{restart reload status} },
+ "centos" => { "default" => %i{restart reload status} },
+ "redhat" => { "default" => %i{restart reload status} },
+ "fedora" => { "default" => %i{restart reload status} },
+ "default" => { "default" => %i{restart reload} } }
end
it "returns the correct default for a given platform" do
node.automatic_attrs[:platform] = "debian"
node.automatic_attrs[:platform_version] = "9000"
- expect(platform_introspector.value_for_platform(@platform_hash)).to eq([ :restart, :reload, :status ])
+ expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload status})
end
it "returns the correct platform+version specific value " do
node.automatic_attrs[:platform] = "debian"
node.automatic_attrs[:platform_version] = "4.0"
- expect(platform_introspector.value_for_platform(@platform_hash)).to eq([:restart, :reload])
+ expect(platform_introspector.value_for_platform(@platform_hash)).to eq(%i{restart reload})
end
end
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index b3039f9be4..2771a371d4 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -417,7 +417,7 @@ shared_examples_for Chef::Provider::File do
context "when the enclosing directory does not exist" do
before { setup_missing_enclosing_directory }
- [:create, :create_if_missing, :touch].each do |action|
+ %i{create create_if_missing touch}.each do |action|
context "action #{action}" do
it "raises EnclosingDirectoryDoesNotExist" do
expect { provider.run_action(action) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index 5c4f6eecbb..83d7d9dfe6 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -66,7 +66,7 @@ shared_examples_for "a script resource" do
it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do
inherited_difference = Chef::Resource::Script.guard_inherited_attributes -
- [:cwd, :environment, :group, :path, :user, :umask ]
+ %i{cwd environment group path user umask}
expect(inherited_difference).to eq([])
end
diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb
index 5b559bb83b..29238a3917 100644
--- a/spec/support/shared/unit/windows_script_resource.rb
+++ b/spec/support/shared/unit/windows_script_resource.rb
@@ -25,7 +25,7 @@ shared_examples_for "a Windows script resource" do
before(:each) do
node = Chef::Node.new
- node.default["kernel"] = Hash.new
+ node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
run_context = Chef::RunContext.new(node, nil, nil)
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb
index 948bde04f2..46820cbaae 100644
--- a/spec/tiny_server.rb
+++ b/spec/tiny_server.rb
@@ -135,7 +135,7 @@ module TinyServer
if response = response_for_request(env)
response.call
else
- debug_info = { message: "no data matches the request for #{env['REQUEST_URI']}",
+ debug_info = { message: "no data matches the request for #{env["REQUEST_URI"]}",
available_routes: @routes, request: env }
# Uncomment me for glorious debugging
# pp :not_found => debug_info
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb
index 6fd1d4d0e1..3e786c3c02 100644
--- a/spec/unit/api_client/registration_spec.rb
+++ b/spec/unit/api_client/registration_spec.rb
@@ -98,7 +98,7 @@ describe Chef::ApiClient::Registration do
it "has an HTTP client configured with validator credentials" do
expect(registration.http_api).to be_a_kind_of(Chef::ServerAPI)
expect(registration.http_api.options[:client_name]).to eq("test-validator")
- auth = registration.http_api.middlewares.find { |klass| klass.kind_of? Chef::HTTP::Authenticator }
+ auth = registration.http_api.middlewares.find { |klass| klass.is_a? Chef::HTTP::Authenticator }
expect(auth.client_name).to eq("test-validator")
end
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index e6b2eec820..f36cbc721d 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -41,7 +41,7 @@ describe Chef::ApiClient do
end
it "only allows string values for the name" do
- expect { @client.name Hash.new }.to raise_error(ArgumentError)
+ expect { @client.name({}) }.to raise_error(ArgumentError)
end
it "has an admin flag attribute" do
@@ -55,7 +55,7 @@ describe Chef::ApiClient do
it "allows only boolean values for the admin flag" do
expect { @client.admin(false) }.not_to raise_error
- expect { @client.admin(Hash.new) }.to raise_error(ArgumentError)
+ expect { @client.admin({}) }.to raise_error(ArgumentError)
end
it "has a 'validator' flag attribute" do
@@ -69,7 +69,7 @@ describe Chef::ApiClient do
it "allows only boolean values for the 'validator' flag" do
expect { @client.validator(false) }.not_to raise_error
- expect { @client.validator(Hash.new) }.to raise_error(ArgumentError)
+ expect { @client.validator({}) }.to raise_error(ArgumentError)
end
it "has a public key attribute" do
@@ -79,7 +79,7 @@ describe Chef::ApiClient do
it "accepts only String values for the public key" do
expect { @client.public_key "" }.not_to raise_error
- expect { @client.public_key Hash.new }.to raise_error(ArgumentError)
+ expect { @client.public_key({}) }.to raise_error(ArgumentError)
end
it "has a private key attribute" do
@@ -89,7 +89,7 @@ describe Chef::ApiClient do
it "accepts only String values for the private key" do
expect { @client.private_key "" }.not_to raise_error
- expect { @client.private_key Hash.new }.to raise_error(ArgumentError)
+ expect { @client.private_key({}) }.to raise_error(ArgumentError)
end
describe "when serializing to JSON" do
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index 6c4e7fe188..3bad466a13 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -36,7 +36,7 @@ describe Chef::ApiClientV1 do
end
it "only allows string values for the name" do
- expect { @client.name Hash.new }.to raise_error(ArgumentError)
+ expect { @client.name({}) }.to raise_error(ArgumentError)
end
it "has an admin flag attribute" do
@@ -50,7 +50,7 @@ describe Chef::ApiClientV1 do
it "allows only boolean values for the admin flag" do
expect { @client.admin(false) }.not_to raise_error
- expect { @client.admin(Hash.new) }.to raise_error(ArgumentError)
+ expect { @client.admin({}) }.to raise_error(ArgumentError)
end
it "has an create_key flag attribute" do
@@ -64,7 +64,7 @@ describe Chef::ApiClientV1 do
it "allows only boolean values for the create_key flag" do
expect { @client.create_key(false) }.not_to raise_error
- expect { @client.create_key(Hash.new) }.to raise_error(ArgumentError)
+ expect { @client.create_key({}) }.to raise_error(ArgumentError)
end
it "has a 'validator' flag attribute" do
@@ -78,7 +78,7 @@ describe Chef::ApiClientV1 do
it "allows only boolean values for the 'validator' flag" do
expect { @client.validator(false) }.not_to raise_error
- expect { @client.validator(Hash.new) }.to raise_error(ArgumentError)
+ expect { @client.validator({}) }.to raise_error(ArgumentError)
end
it "has a public key attribute" do
@@ -88,7 +88,7 @@ describe Chef::ApiClientV1 do
it "accepts only String values for the public key" do
expect { @client.public_key "" }.not_to raise_error
- expect { @client.public_key Hash.new }.to raise_error(ArgumentError)
+ expect { @client.public_key({}) }.to raise_error(ArgumentError)
end
it "has a private key attribute" do
@@ -98,7 +98,7 @@ describe Chef::ApiClientV1 do
it "accepts only String values for the private key" do
expect { @client.private_key "" }.not_to raise_error
- expect { @client.private_key Hash.new }.to raise_error(ArgumentError)
+ expect { @client.private_key({}) }.to raise_error(ArgumentError)
end
describe "when serializing to JSON" do
diff --git a/spec/unit/application/exit_code_spec.rb b/spec/unit/application/exit_code_spec.rb
index 6800ad0de5..7a02672796 100644
--- a/spec/unit/application/exit_code_spec.rb
+++ b/spec/unit/application/exit_code_spec.rb
@@ -70,7 +70,8 @@ describe Chef::Application::ExitCode do
it "does write a warning on non-standard exit codes" do
expect(Chef::Log).to receive(:warn).with(
- /attempted to exit with a non-standard exit code of 151/)
+ /attempted to exit with a non-standard exit code of 151/
+ )
expect(exit_codes.normalize_exit_code(151)).to eq(1)
end
@@ -79,7 +80,7 @@ describe Chef::Application::ExitCode do
end
it "returns GENERIC_FAILURE when no exit code is specified" do
- expect(exit_codes.normalize_exit_code()).to eq(1)
+ expect(exit_codes.normalize_exit_code).to eq(1)
end
it "returns SIGINT_RECEIVED when a SIGINT is received" do
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index f8f5560597..ea5083ac15 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -28,8 +28,7 @@ describe Chef::Application::Knife do
long: "-optwithdefault VALUE",
default: "default-value"
- def run
- end
+ def run; end
end
end
diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb
index 0adcbbfbfb..bdb9bc2c72 100644
--- a/spec/unit/chef_fs/config_spec.rb
+++ b/spec/unit/chef_fs/config_spec.rb
@@ -23,7 +23,7 @@ require "lib/chef/chef_fs/config.rb"
describe Chef::ChefFS::Config do
describe "initialize" do
it "warns when hosted setups use 'everything'" do
- base_config = Hash.new()
+ base_config = {}
base_config[:repo_mode] = "everything"
base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/"
@@ -34,7 +34,7 @@ describe Chef::ChefFS::Config do
end
it "doesn't warn when hosted setups use 'hosted_everything'" do
- base_config = Hash.new()
+ base_config = {}
base_config[:repo_mode] = "hosted_everything"
base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/"
@@ -45,7 +45,7 @@ describe Chef::ChefFS::Config do
end
it "doesn't warn when non-hosted setups use 'everything'" do
- base_config = Hash.new()
+ base_config = {}
base_config[:repo_mode] = "everything"
base_config[:chef_server_url] = "http://foo.com/"
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 5b2a0a47b8..ec147ba6a8 100644
--- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb
+++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb
@@ -106,7 +106,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do
end
it "filters invalid names" do
- expect(test_directory.children.map { |c| c.name }).to eql %w{ test1.json test2.json test3.json }
+ expect(test_directory.children.map(&:name)).to eql %w{ test1.json test2.json test3.json }
end
end
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 32e56c4231..d43e48b7bc 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -443,7 +443,7 @@ describe Chef::ChefFS::Parallelizer do
threads = 0.upto(99).map do |i|
Thread.new { outputs[i] = parallelizers[i].to_a }
end
- threads.each { |thread| thread.join }
+ threads.each(&:join)
outputs.each { |output| expect(output.sort).to eq(2.upto(501).to_a) }
end
end
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 476647a651..5182717af8 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -647,7 +647,7 @@ describe Chef::Client do
EOM
end
it "should not raise an error" do
- expect { client.load_required_recipe(rest, run_context) }.not_to raise_error()
+ expect { client.load_required_recipe(rest, run_context) }.not_to raise_error
end
end
end
diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb
index abaea6b2dc..8dadd9e681 100644
--- a/spec/unit/config_fetcher_spec.rb
+++ b/spec/unit/config_fetcher_spec.rb
@@ -7,7 +7,7 @@ describe Chef::ConfigFetcher do
let(:http) { double("Chef::HTTP::Simple") }
let(:config_location_regex) { Regexp.escape(config_location) }
- let(:invalid_json_error_regex) { %r{Could not parse the provided JSON file \(#{config_location_regex}\)} }
+ let(:invalid_json_error_regex) { /Could not parse the provided JSON file \(#{config_location_regex}\)/ }
let(:fetcher) { Chef::ConfigFetcher.new(config_location) }
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 8d65efbd6a..7f66fe0c32 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -26,10 +26,10 @@ describe Chef::Cookbook::Metadata do
describe "when comparing for equality" do
before do
- @fields = [ :name, :description, :long_description, :maintainer,
- :maintainer_email, :license, :platforms, :dependencies,
- :providing, :recipes, :version, :source_url, :issues_url,
- :privacy, :ohai_versions, :chef_versions, :gems ]
+ @fields = %i{name description long_description maintainer
+ maintainer_email license platforms dependencies
+ providing recipes version source_url issues_url
+ privacy ohai_versions chef_versions gems}
end
it "does not depend on object identity for equality" do
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index 9180f13f33..c747f14dd0 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -88,7 +88,7 @@ describe Chef::CookbookLoader do
describe "each" do
it "should allow you to iterate over cookbooks with each" do
- seen = Hash.new
+ seen = {}
cookbook_loader.each_key do |cookbook_name|
seen[cookbook_name] = true
end
@@ -97,7 +97,7 @@ describe Chef::CookbookLoader do
end
it "should iterate in alphabetical order" do
- seen = Array.new
+ seen = []
cookbook_loader.each_key do |cookbook_name|
seen << cookbook_name
end
@@ -113,19 +113,19 @@ describe Chef::CookbookLoader do
it "should load different attribute files from deeper paths" do
expect(full_paths_for_part(:openldap, "attributes").detect do |f|
- f =~ /cookbooks\/openldap\/attributes\/smokey.rb/
+ f =~ %r{cookbooks/openldap/attributes/smokey.rb}
end).not_to eql(nil)
end
it "should load definition files from deeper paths" do
expect(full_paths_for_part(:openldap, "definitions").detect do |f|
- f =~ /cookbooks\/openldap\/definitions\/server.rb/
+ f =~ %r{cookbooks/openldap/definitions/server.rb}
end).not_to eql(nil)
end
it "should load recipe files from deeper paths" do
expect(full_paths_for_part(:openldap, "recipes").detect do |f|
- f =~ /cookbooks\/openldap\/recipes\/one.rb/
+ f =~ %r{cookbooks/openldap/recipes/one.rb}
end).not_to eql(nil)
end
@@ -134,8 +134,8 @@ describe Chef::CookbookLoader do
f =~ /\.dotfile$/
end).to match(/\.dotfile$/)
expect(full_paths_for_part(:openldap, "files").detect do |f|
- f =~ /\.ssh\/id_rsa$/
- end).to match(/\.ssh\/id_rsa$/)
+ f =~ %r{\.ssh/id_rsa$}
+ end).to match(%r{\.ssh/id_rsa$})
end
it "should load the metadata for the cookbook" do
@@ -173,7 +173,7 @@ describe Chef::CookbookLoader do
end
it "should have loaded the correct cookbook" do
- seen = Hash.new
+ seen = {}
cookbook_loader.each_key do |cookbook_name|
seen[cookbook_name] = true
end
@@ -203,7 +203,7 @@ describe Chef::CookbookLoader do
end
it "should not load the other cookbooks" do
- seen = Hash.new
+ seen = {}
cookbook_loader.each_key do |cookbook_name|
seen[cookbook_name] = true
end
@@ -239,7 +239,7 @@ describe Chef::CookbookLoader do
end
it "should load all cookbooks" do
- seen = Hash.new
+ seen = {}
cookbook_loader.each_key do |cookbook_name|
seen[cookbook_name] = true
end
diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb
index 87ff7abdd7..af714094d0 100644
--- a/spec/unit/cookbook_site_streaming_uploader_spec.rb
+++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb
@@ -25,8 +25,7 @@ class FakeTempfile
@basename = basename
end
- def close
- end
+ def close; end
def path
"#{@basename}.ZZZ"
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 70fcd7041e..78953c6b6f 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,7 +43,7 @@ describe Chef::DataBagItem do
end
it "should throw an ArgumentError if you feed it anything but a string" do
- expect { data_bag_item.data_bag Hash.new }.to raise_error(ArgumentError)
+ expect { data_bag_item.data_bag({}) }.to raise_error(ArgumentError)
end
end
@@ -148,12 +148,12 @@ describe Chef::DataBagItem do
end
it "implements all the methods of Hash" do
- methods = [:rehash, :to_hash, :[], :fetch, :[]=, :store, :default,
- :default=, :default_proc, :index, :size, :length,
- :empty?, :each_value, :each_key, :each_pair, :each, :keys, :values,
- :values_at, :delete, :delete_if, :reject!, :clear,
- :invert, :update, :replace, :merge!, :merge, :has_key?, :has_value?,
- :key?, :value?]
+ methods = %i{rehash to_hash [] fetch []= store default
+ default= default_proc index size length
+ empty? each_value each_key each_pair each keys values
+ values_at delete delete_if reject! clear
+ invert update replace merge! merge has_key? has_value?
+ key? value?}
methods.each do |m|
expect(data_bag_item).to respond_to(m)
end
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 388c35232f..4b0ba42172 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -46,7 +46,7 @@ describe Chef::DataBag do
end
it "should throw an ArgumentError if you feed it anything but a string" do
- expect { @data_bag.name Hash.new }.to raise_error(ArgumentError)
+ expect { @data_bag.name({}) }.to raise_error(ArgumentError)
end
[ ".", "-", "_", "1"].each do |char|
diff --git a/spec/unit/decorator_spec.rb b/spec/unit/decorator_spec.rb
index 6d73db2cc4..80bbd73bdf 100644
--- a/spec/unit/decorator_spec.rb
+++ b/spec/unit/decorator_spec.rb
@@ -28,11 +28,11 @@ def impersonates_a(klass)
end
it "#kind_of?(#{klass}) is true" do
- expect(decorator.kind_of?(klass)).to be true
+ expect(decorator.is_a?(klass)).to be true
end
it "#kind_of?(Chef::Decorator) is true" do
- expect(decorator.kind_of?(Chef::Decorator)).to be true
+ expect(decorator.is_a?(Chef::Decorator)).to be true
end
it "#instance_of?(#{klass}) is false" do
diff --git a/spec/unit/deprecated_spec.rb b/spec/unit/deprecated_spec.rb
index 9c60080cef..7564c042c4 100644
--- a/spec/unit/deprecated_spec.rb
+++ b/spec/unit/deprecated_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Deprecated do
let(:location) { "the location" }
it "displays the full URL" do
- expect(TestDeprecation.new().url).to eql("https://docs.chef.io/deprecations_test.html")
+ expect(TestDeprecation.new.url).to eql("https://docs.chef.io/deprecations_test.html")
end
it "formats a complete deprecation message" do
@@ -59,7 +59,7 @@ describe Chef::Deprecated do
end
collisions = id_map.select { |k, v| v.size != 1 }
unless collisions.empty?
- raise "Found deprecation ID collisions:\n#{collisions.map { |k, v| "* #{k} #{v.map(&:name).join(', ')}" }.join("\n")}"
+ raise "Found deprecation ID collisions:\n#{collisions.map { |k, v| "* #{k} #{v.map(&:name).join(", ")}" }.join("\n")}"
end
end
end
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index f93f07bc52..afc2eacbd7 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -24,7 +24,7 @@ class DataQueryDSLTester
end
describe Chef::DSL::DataQuery do
- let(:node) { Hash.new }
+ let(:node) { {} }
let(:language) do
language = DataQueryDSLTester.new
@@ -68,7 +68,8 @@ describe Chef::DSL::DataQuery do
"a1" => [1, 2, 3],
"a2" => { "b1" => true },
},
- } end
+ }
+ end
let(:item) do
item = Chef::DataBagItem.new
diff --git a/spec/unit/dsl/declare_resource_spec.rb b/spec/unit/dsl/declare_resource_spec.rb
index 255e85e22e..ead0be2967 100644
--- a/spec/unit/dsl/declare_resource_spec.rb
+++ b/spec/unit/dsl/declare_resource_spec.rb
@@ -34,7 +34,7 @@ describe Chef::ResourceCollection do
describe "mixed in correctly" do
it "the resources() method winds up in the right classes" do
- methods = [ :resources, :find_resource, :find_resource!, :edit_resource, :edit_resource!, :delete_resource, :delete_resource!, :declare_resource, :build_resource ]
+ methods = %i{resources find_resource find_resource! edit_resource edit_resource! delete_resource delete_resource! declare_resource build_resource}
expect(Chef::Resource.instance_methods).to include(*methods)
expect(Chef::Recipe.instance_methods).to include(*methods)
expect(Chef::Provider.instance_methods).to include(*methods)
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 51123ba930..7af233a769 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -40,7 +40,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
before do
platform_hash = {
:openbsd => { default: "free, functional, secure" },
- [:redhat, :centos, :fedora, :scientific] => { default: '"stable"' },
+ %i{redhat centos fedora scientific} => { default: '"stable"' },
:ubuntu => { "10.04" => "using upstart more", :default => "using init more" },
:default => "bork da bork",
}
@@ -84,7 +84,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
before do
- @array_values = [:stop, :start, :reload]
+ @array_values = %i{stop start reload}
@platform_family_hash = {
"debian" => "debian value",
diff --git a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
index 7e885f8818..f8fcb654d9 100644
--- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
+++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
@@ -47,7 +47,8 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do
"a1" => [1, 2, 3],
"a2" => { "b1" => true },
},
- } end
+ }
+ end
let(:version) { 1 }
let(:encoded_data) do
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb
index 14b5d9eb28..f406aa2ad0 100644
--- a/spec/unit/encrypted_data_bag_item_spec.rb
+++ b/spec/unit/encrypted_data_bag_item_spec.rb
@@ -325,7 +325,8 @@ describe Chef::EncryptedDataBagItem do
"id" => "item_name",
"greeting" => "hello",
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
- } end
+ }
+ end
let(:secret) { "abc123SECRET" }
let(:encoded_data) { subject.encrypt_data_bag_item(plaintext_data, secret) }
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 4da3a9fa0e..42906ef772 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -48,8 +48,8 @@ describe Chef::Environment do
end
it "should not accept anything but strings" do
- expect { @environment.name(Array.new) }.to raise_error(ArgumentError)
- expect { @environment.name(Hash.new) }.to raise_error(ArgumentError)
+ expect { @environment.name([]) }.to raise_error(ArgumentError)
+ expect { @environment.name({}) }.to raise_error(ArgumentError)
expect { @environment.name(2) }.to raise_error(ArgumentError)
end
end
@@ -65,8 +65,8 @@ describe Chef::Environment do
end
it "should not accept anything but strings" do
- expect { @environment.description(Array.new) }.to raise_error(ArgumentError)
- expect { @environment.description(Hash.new) }.to raise_error(ArgumentError)
+ expect { @environment.description([]) }.to raise_error(ArgumentError)
+ expect { @environment.description({}) }.to raise_error(ArgumentError)
expect { @environment.description(42) }.to raise_error(ArgumentError)
end
end
@@ -82,7 +82,7 @@ describe Chef::Environment do
end
it "should throw an ArgumentError if we aren't a kind of hash" do
- expect { @environment.default_attributes(Array.new) }.to raise_error(ArgumentError)
+ expect { @environment.default_attributes([]) }.to raise_error(ArgumentError)
end
end
@@ -97,7 +97,7 @@ describe Chef::Environment do
end
it "should throw an ArgumentError if we aren't a kind of hash" do
- expect { @environment.override_attributes(Array.new) }.to raise_error(ArgumentError)
+ expect { @environment.override_attributes([]) }.to raise_error(ArgumentError)
end
end
@@ -121,7 +121,7 @@ describe Chef::Environment do
it "should not accept anything but a hash" do
expect { @environment.cookbook_versions("I am a string!") }.to raise_error(ArgumentError)
- expect { @environment.cookbook_versions(Array.new) }.to raise_error(ArgumentError)
+ expect { @environment.cookbook_versions([]) }.to raise_error(ArgumentError)
expect { @environment.cookbook_versions(42) }.to raise_error(ArgumentError)
end
@@ -257,7 +257,7 @@ describe Chef::Environment do
end
it "should return false if anything other than a hash is passed as the argument" do
- expect(Chef::Environment.validate_cookbook_versions(Array.new)).to eq(false)
+ expect(Chef::Environment.validate_cookbook_versions([])).to eq(false)
expect(Chef::Environment.validate_cookbook_versions(42)).to eq(false)
expect(Chef::Environment.validate_cookbook_versions(Chef::CookbookVersion.new("meta"))).to eq(false)
expect(Chef::Environment.validate_cookbook_versions("cookbook => 1.2.3")).to eq(false)
diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb
index 979b067fb6..009242f4fb 100644
--- a/spec/unit/event_dispatch/dsl_spec.rb
+++ b/spec/unit/event_dispatch/dsl_spec.rb
@@ -63,7 +63,7 @@ describe Chef::EventDispatch::DSL do
resource = Chef::Resource::RubyBlock.new("foo", run_context)
resource.block {}
resource.run_action(:run)
- expect(calls).to eq([:started, :updated])
+ expect(calls).to eq(%i{started updated})
end
it "preserve instance variables across handler callbacks" do
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 0cdb06c3b3..7add65150a 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -60,7 +60,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
@trace = [
"/var/chef/cache/cookbooks/syntax-err/recipes/default.rb:14:in `from_file'",
"/var/chef/cache/cookbooks/syntax-err/recipes/default.rb:11:in `from_file'",
- "/usr/local/lib/ruby/gems/chef/lib/chef/client.rb:123:in `run'" # should not display
+ "/usr/local/lib/ruby/gems/chef/lib/chef/client.rb:123:in `run'", # should not display
]
@exception = Chef::Exceptions::Package.new("No such package 'non-existing-package'")
@exception.set_backtrace(@trace)
@@ -122,7 +122,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
source_line = "C:/Users/btm/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)"
@resource.source_line = source_line
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
- expect(@inspector.recipe_snippet).to match(/^# In C:\/Users\/btm/)
+ expect(@inspector.recipe_snippet).to match(%r{^# In C:/Users/btm})
end
it "parses a Windows path" do
@@ -136,7 +136,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
source_line = "/home/btm/src/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)"
@resource.source_line = source_line
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
- expect(@inspector.recipe_snippet).to match(/^# In \/home\/btm/)
+ expect(@inspector.recipe_snippet).to match(%r{^# In /home/btm})
end
context "when the recipe file does not exist" do
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index b2ca8704b0..6d7f31c6f1 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -22,7 +22,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
let(:node) do
node = Chef::Node.new
- node.default["kernel"] = Hash.new
+ node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
node.automatic[:os] = "windows"
node
diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb
index a2d4cb4815..0713aacc24 100644
--- a/spec/unit/http/authenticator_spec.rb
+++ b/spec/unit/http/authenticator_spec.rb
@@ -23,7 +23,7 @@ describe Chef::HTTP::Authenticator do
let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
let(:method) { "GET" }
let(:url) { URI("https://chef.example.com/organizations/test") }
- let(:headers) { Hash.new }
+ let(:headers) { {} }
let(:data) { "" }
context "when handle_request is called" do
@@ -92,7 +92,8 @@ describe Chef::HTTP::Authenticator do
it "calls authentication_headers with the proper input" do
expect(class_instance).to receive(:authentication_headers).with(
method, url, data,
- { "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION }).and_return({})
+ { "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION }
+ ).and_return({})
class_instance.handle_request(method, url, headers, data)
end
end
diff --git a/spec/unit/http/json_input_spec.rb b/spec/unit/http/json_input_spec.rb
index a76c8d1dc7..cddad20f55 100644
--- a/spec/unit/http/json_input_spec.rb
+++ b/spec/unit/http/json_input_spec.rb
@@ -21,7 +21,7 @@ require "chef/http/json_input"
describe Chef::HTTP::JSONInput do
- let(:json_encoder) { described_class.new() }
+ let(:json_encoder) { described_class.new }
let(:url) { URI.parse("http://example.com") }
let(:headers) { {} }
diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb
index e3d9f8e7ad..efae549490 100644
--- a/spec/unit/key_spec.rb
+++ b/spec/unit/key_spec.rb
@@ -66,7 +66,7 @@ describe Chef::Key do
context "when you feed it anything but a string" do
it "should raise an ArgumentError" do
- expect { key.send(field, Hash.new) }.to raise_error(ArgumentError)
+ expect { key.send(field, {}) }.to raise_error(ArgumentError)
end
end
end
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index ee376e2bb4..5f4be8dfa2 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -35,7 +35,8 @@ describe Chef::Knife::Bootstrap do
double("TrainConnector",
windows?: windows_test,
linux?: linux_test,
- unix?: unix_test) end
+ unix?: unix_test)
+ end
let(:knife) do
Chef::Log.logger = Logger.new(StringIO.new)
@@ -107,7 +108,7 @@ describe Chef::Knife::Bootstrap do
expect(knife).to receive(:read_secret).and_return("secrets")
expect(rendered_template).to match("cat > /etc/chef/encrypted_data_bag_secret <<'EOP'")
expect(rendered_template).to match('{"run_list":\[\]}')
- expect(rendered_template).to match(%r{secrets})
+ expect(rendered_template).to match(/secrets/)
end
end
end
@@ -127,7 +128,7 @@ describe Chef::Knife::Bootstrap do
knife.render_template
end
it "configures the preinstall command in the bootstrap template correctly" do
- expect(rendered_template).to match(%r{command})
+ expect(rendered_template).to match(/command/)
end
end
@@ -138,7 +139,7 @@ describe Chef::Knife::Bootstrap do
knife.render_template
end
it "configures the https_proxy environment variable in the bootstrap template correctly" do
- expect(rendered_template).to match(%r{https_proxy="1.1.1.1" export https_proxy})
+ expect(rendered_template).to match(/https_proxy="1.1.1.1" export https_proxy/)
end
end
@@ -149,7 +150,7 @@ describe Chef::Knife::Bootstrap do
knife.render_template
end
it "configures the https_proxy environment variable in the bootstrap template correctly" do
- expect(rendered_template).to match(%r{no_proxy="localserver" export no_proxy})
+ expect(rendered_template).to match(/no_proxy="localserver" export no_proxy/)
end
end
@@ -360,7 +361,7 @@ describe Chef::Knife::Bootstrap do
it "should create a hint file when told to" do
knife.parse_options(["--hint", "openstack"])
knife.merge_configs
- expect(knife.render_template).to match(/\/etc\/chef\/ohai\/hints\/openstack.json/)
+ expect(knife.render_template).to match(%r{/etc/chef/ohai/hints/openstack.json})
end
it "should populate a hint file with JSON when given a file to read" do
@@ -393,7 +394,7 @@ describe Chef::Knife::Bootstrap do
let(:setting) { "api.opscode.com" }
it "renders the client.rb with a single FQDN no_proxy entry" do
- expect(rendered_template).to match(%r{.*no_proxy\s*"api.opscode.com".*})
+ expect(rendered_template).to match(/.*no_proxy\s*"api.opscode.com".*/)
end
end
@@ -401,7 +402,7 @@ describe Chef::Knife::Bootstrap do
let(:setting) { "api.opscode.com,172.16.10.*" }
it "renders the client.rb with comma-separated FQDN and wildcard IP address no_proxy entries" do
- expect(rendered_template).to match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*})
+ expect(rendered_template).to match(/.*no_proxy\s*"api.opscode.com,172.16.10.\*".*/)
end
end
@@ -459,7 +460,7 @@ describe Chef::Knife::Bootstrap do
it "creates a secret file" do
expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true)
expect(knife).to receive(:read_secret).and_return(secret)
- expect(rendered_template).to match(%r{#{secret}})
+ expect(rendered_template).to match(/#{secret}/)
end
it "renders the client.rb with an encrypted_data_bag_secret entry" do
@@ -569,7 +570,9 @@ describe Chef::Knife::Bootstrap do
context "when client_d_dir is set" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_00")) end
+ File.join(File.dirname(__FILE__), "../../data/client.d_00")
+ )
+ end
it "creates /etc/chef/client.d" do
expect(rendered_template).to match("mkdir -p /etc/chef/client\.d")
@@ -594,7 +597,9 @@ describe Chef::Knife::Bootstrap do
context "a nested directory structure" do
let(:client_d_dir) do
Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) end
+ File.join(File.dirname(__FILE__), "../../data/client.d_01")
+ )
+ end
it "creates a file foo/bar.rb" do
expect(rendered_template).to match("cat > /etc/chef/client.d/foo/bar.rb <<'EOP'")
expect(rendered_template).to match("1 / 0")
@@ -1554,7 +1559,8 @@ describe Chef::Knife::Bootstrap do
ssl: false,
ssl_peer_fingerprint: nil,
operation_timeout: 60,
- } end
+ }
+ end
it "generates a correct configuration hash with expected defaults" do
expect(knife.winrm_opts).to eq expected
@@ -1730,7 +1736,7 @@ describe Chef::Knife::Bootstrap do
before do
Chef::Config[:validation_key] = "/blah"
allow(vault_handler_mock).to receive(:doing_chef_vault?).and_return false
- allow(File).to receive(:exist?).with(/\/blah/).and_return false
+ allow(File).to receive(:exist?).with(%r{/blah}).and_return false
end
it_behaves_like "creating the client locally"
end
@@ -1738,7 +1744,7 @@ describe Chef::Knife::Bootstrap do
context "when a valid validation key is given and we're doing old-style client creation" do
before do
Chef::Config[:validation_key] = "/blah"
- allow(File).to receive(:exist?).with(/\/blah/).and_return true
+ allow(File).to receive(:exist?).with(%r{/blah}).and_return true
allow(vault_handler_mock).to receive(:doing_chef_vault?).and_return false
end
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index feebab4986..770ba8762f 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -42,10 +42,10 @@ describe Chef::Knife::ClientBulkDelete do
let(:nonvalidator_client_names) { %w{tim dan stephen} }
let(:nonvalidator_clients) do
- clients = Hash.new
+ clients = {}
nonvalidator_client_names.each do |client_name|
- client = Chef::ApiClientV1.new()
+ client = Chef::ApiClientV1.new
client.name(client_name)
allow(client).to receive(:destroy).and_return(true)
clients[client_name] = client
@@ -56,10 +56,10 @@ describe Chef::Knife::ClientBulkDelete do
let(:validator_client_names) { %w{myorg-validator} }
let(:validator_clients) do
- clients = Hash.new
+ clients = {}
validator_client_names.each do |validator_client_name|
- validator_client = Chef::ApiClientV1.new()
+ validator_client = Chef::ApiClientV1.new
validator_client.name(validator_client_name)
allow(validator_client).to receive(:validator).and_return(true)
allow(validator_client).to receive(:destroy).and_return(true)
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index c83ceed6cb..be76250e7c 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -58,7 +58,7 @@ describe Chef::Knife::ConfigureClient do
it "should write out the config file" do
allow(FileUtils).to receive(:mkdir_p)
@knife.run
- expect(@client_file.string).to match /chef_server_url\s+'https\:\/\/chef\.example\.com'/
+ expect(@client_file.string).to match %r{chef_server_url\s+'https\://chef\.example\.com'}
expect(@client_file.string).to match /validation_client_name\s+'chef-validator'/
end
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 1cdad0cd0e..6b41e54778 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -159,7 +159,7 @@ describe Chef::Knife::Configure do
@knife.run
expect(config_file.string).to match(/^client_name[\s]+=[\s]+'#{Etc.getlogin}'$/)
expect(config_file.string).to match(%r{^client_key[\s]+=[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$})
- expect(config_file.string).to match(%r{^chef_server_url\s+=[\s]+'#{default_server_url}'$})
+ expect(config_file.string).to match(/^chef_server_url\s+=[\s]+'#{default_server_url}'$/)
end
it "creates a new client when given the --initial option" do
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb
index c8c1873081..d01213227b 100644
--- a/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Knife::CookbookBulkDelete do
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife.ui).to receive(:confirm).and_return(true)
- @cookbooks = Hash.new
+ @cookbooks = {}
%w{cheezburger pizza lasagna}.each do |cookbook_name|
cookbook = Chef::CookbookVersion.new(cookbook_name)
@cookbooks[cookbook_name] = cookbook
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index b2f17778cd..4de907e94d 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -77,7 +77,7 @@ describe Chef::Knife::CookbookDelete do
@knife.version = "1.0.0"
expect(@knife).to receive(:delete_object).with(Chef::CookbookVersion,
"foobar version 1.0.0",
- "cookbook").and_yield()
+ "cookbook").and_yield
expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0")
@knife.delete_explicit_version
end
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 122c284b93..78dd20e2d2 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -112,7 +112,7 @@ describe Chef::Knife::CookbookDownload do
it "should print an error and exit if the cookbook download directory already exists" do
expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
- expect(@knife.ui).to receive(:fatal).with(/\/var\/tmp\/chef\/foobar-1\.0\.0 exists/i)
+ expect(@knife.ui).to receive(:fatal).with(%r{/var/tmp/chef/foobar-1\.0\.0 exists}i)
expect { @knife.run }.to raise_error(SystemExit)
end
@@ -141,7 +141,7 @@ describe Chef::Knife::CookbookDownload do
expect(@stderr.string).to match /downloading #{segment}/im
end
expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im
- expect(@stderr.string).to match /cookbook downloaded to \/var\/tmp\/chef\/foobar-1\.0\.0/im
+ expect(@stderr.string).to match %r{cookbook downloaded to /var/tmp/chef/foobar-1\.0\.0}im
end
describe "with -f or --force" do
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index c19fc5ae2d..04d851be6a 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -98,8 +98,8 @@ describe Chef::Knife::CookbookMetadata do
it "should generate the metadata for each cookbook" do
expect(Chef::CookbookLoader).to receive(:new).with(cookbook_dir).and_call_original
knife.run
- expect(stderr.string).to match /generating metadata for foo from #{cookbook_dir}\/foo\/metadata\.rb/im
- expect(stderr.string).to match /generating metadata for bar from #{cookbook_dir}\/bar\/metadata\.rb/im
+ expect(stderr.string).to match %r{generating metadata for foo from #{cookbook_dir}/foo/metadata\.rb}im
+ expect(stderr.string).to match %r{generating metadata for bar from #{cookbook_dir}/bar/metadata\.rb}im
end
it "with -o or --cookbook_path should look in the provided path and generate cookbook metadata" do
@@ -107,8 +107,8 @@ describe Chef::Knife::CookbookMetadata do
knife.config[:cookbook_path] = cookbook_dir
expect(Chef::CookbookLoader).to receive(:new).with(cookbook_dir).and_call_original
knife.run
- expect(stderr.string).to match /generating metadata for foo from #{cookbook_dir}\/foo\/metadata\.rb/im
- expect(stderr.string).to match /generating metadata for bar from #{cookbook_dir}\/bar\/metadata\.rb/im
+ expect(stderr.string).to match %r{generating metadata for foo from #{cookbook_dir}/foo/metadata\.rb}im
+ expect(stderr.string).to match %r{generating metadata for bar from #{cookbook_dir}/bar/metadata\.rb}im
end
end
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index 8bff31197c..9c371c4140 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -264,7 +264,8 @@ describe Chef::Knife::CookbookUpload do
it "should warn users that no cookbooks exist" do
knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"]
expect(knife.ui).to receive(:warn).with(
- /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./)
+ /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./
+ )
knife.run
end
end
@@ -273,7 +274,8 @@ describe Chef::Knife::CookbookUpload do
it "should warn users that no cookbooks exist" do
knife.config[:cookbook_path] = "/chef-repo/cookbooks"
expect(knife.ui).to receive(:warn).with(
- /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./)
+ /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./
+ )
knife.run
end
end
diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb
index 689426de1b..c8bd34d4a9 100644
--- a/spec/unit/knife/core/gem_glob_loader_spec.rb
+++ b/spec/unit/knife/core/gem_glob_loader_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
it "builds a list of the core subcommand file require paths" do
expect(loader.subcommand_files).not_to be_empty
loader.subcommand_files.each do |require_path|
- expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/)
+ expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*})
end
end
@@ -52,7 +52,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
expect($LOAD_PATH).to receive(:map).and_return([])
if Gem::Specification.respond_to? :latest_specs
expect(Gem::Specification).to receive(:latest_specs).with(true).and_return(gems)
- expect(gems[0]).to receive(:matches_for_glob).with(/chef\/knife\/\*\.rb\{(.*),\.rb,(.*)\}/).and_return(gem_files)
+ expect(gems[0]).to receive(:matches_for_glob).with(%r{chef/knife/\*\.rb\{(.*),\.rb,(.*)\}}).and_return(gem_files)
else
expect(Gem.source_index).to receive(:latest_specs).with(true).and_return(gems)
expect(gems[0]).to receive(:require_paths).twice.and_return(["lib"])
@@ -185,7 +185,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
expect(Gem.source_index).to receive(:latest_specs).and_call_original
end
loader.subcommand_files.each do |require_path|
- expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/)
+ expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*})
end
end
@@ -201,7 +201,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
expect(Gem.source_index).to receive(:latest_specs).and_call_original
end
loader.subcommand_files.each do |require_path|
- expect(require_path).to match(/chef\/knife\/.*|plugins\/knife\/.*/)
+ expect(require_path).to match(%r{chef/knife/.*|plugins/knife/.*})
end
end
end
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index c59838478e..c463a36fb4 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -44,7 +44,9 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
let(:loader) do
Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
File.join(CHEF_SPEC_DATA, "knife-site-subcommands"),
- plugin_manifest) end
+ plugin_manifest
+ )
+ end
describe "#list_commands" do
before do
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index ccf6776593..493de3c5b1 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -44,13 +44,13 @@ describe Chef::Knife::NodeEditor do
describe "#view" do
it "returns a Hash with only the name, chef_environment, normal, " +
"policy_name, policy_group, and run_list properties" do
- expected = node_data.select do |key,|
- %w{ name chef_environment normal
- policy_name policy_group run_list }.include?(key)
- end
+ expected = node_data.select do |key,|
+ %w{ name chef_environment normal
+ policy_name policy_group run_list }.include?(key)
+ end
- expect(subject.view).to eq(expected)
- end
+ expect(subject.view).to eq(expected)
+ end
context "when config[:all_attributes] == true" do
let(:config) { base_config.merge(all_attributes: true) }
@@ -190,8 +190,8 @@ describe Chef::Knife::NodeEditor do
it "returns an array of property names that doesn't include " +
"the non-editable properties" do
- expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list }
- end
+ expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list }
+ end
end
end
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index a662b1c203..e5a4e955e8 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -157,8 +157,7 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
validation_client_name: "chef-validator-testing",
file_cache_path: "c:/chef/cache",
file_backup_path: "c:/chef/backup",
- cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })
- ))
+ cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })))
end
it "generates the config file data" do
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index 3bea392ae2..bc0ca330e8 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -77,7 +77,8 @@ describe Chef::Knife::DataBagFromFile do
"id" => "item_name",
"greeting" => "hello",
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
- } end
+ }
+ end
let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) }
let(:rest) { double("Chef::ServerAPI") }
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 8dd0669993..6ac6dd3c95 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -47,7 +47,8 @@ describe Chef::Knife::DataBagShow do
let(:data_bag_contents) do
{ "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
- "qux" => "http://localhost:4000/data/bag_o_data/qux" } end
+ "qux" => "http://localhost:4000/data/bag_o_data/qux" }
+ end
let(:enc_hash) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(data_bag_contents, secret) }
let(:data_bag) { Chef::DataBagItem.from_hash(data_bag_contents) }
let(:data_bag_with_encoded_hash) { Chef::DataBagItem.from_hash(enc_hash) }
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index fcbfd40381..6437ba2bcd 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -84,7 +84,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
end
- let(:config) { Hash.new }
+ let(:config) { {} }
let(:actor) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 7c409f5ea0..1f8067c160 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -86,7 +86,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
end
- let(:config) { Hash.new }
+ let(:config) { {} }
let(:actor) { "charmander" }
let(:keyname) { "charmander-key" }
let(:ui) { instance_double("Chef::Knife::UI") }
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index e221a4da72..c65a11b08c 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -73,7 +73,7 @@ describe "key list commands that inherit knife" do
end
describe Chef::Knife::KeyList do
- let(:config) { Hash.new }
+ let(:config) { {} }
let(:actor) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb
index 2a3563e563..db9e2caab1 100644
--- a/spec/unit/knife/node_bulk_delete_spec.rb
+++ b/spec/unit/knife/node_bulk_delete_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::NodeBulkDelete do
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
allow(@knife.ui).to receive(:confirm).and_return(true)
- @nodes = Hash.new
+ @nodes = {}
%w{adam brent jacob}.each do |node_name|
@nodes[node_name] = "http://localhost:4000/nodes/#{node_name}"
end
@@ -44,14 +44,14 @@ describe Chef::Knife::NodeBulkDelete do
# I hate not having == defined for anything :(
actual = @knife.all_nodes
expect(actual.keys).to match_array(expected.keys)
- expect(actual.values.map { |n| n.name }).to match_array(%w{adam brent jacob})
+ expect(actual.values.map(&:name)).to match_array(%w{adam brent jacob})
end
end
describe "run" do
before do
@inflatedish_list = @nodes.keys.inject({}) do |nodes_by_name, name|
- node = Chef::Node.new()
+ node = Chef::Node.new
node.name(name)
allow(node).to receive(:destroy).and_return(true)
nodes_by_name[name] = node
diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb
index cc2e0b23af..c5b8925fb5 100644
--- a/spec/unit/knife/node_delete_spec.rb
+++ b/spec/unit/knife/node_delete_spec.rb
@@ -29,8 +29,8 @@ describe Chef::Knife::NodeDelete do
allow(@knife).to receive(:output).and_return(true)
allow(@knife).to receive(:confirm).and_return(true)
- @adam_node = Chef::Node.new()
- @ben_node = Chef::Node.new()
+ @adam_node = Chef::Node.new
+ @ben_node = Chef::Node.new
allow(@ben_node).to receive(:destroy).and_return(true)
allow(@adam_node).to receive(:destroy).and_return(true)
allow(Chef::Node).to receive(:load).with("adam").and_return(@adam_node)
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index dfc0986ebe..83d78b68f1 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Knife::NodeEdit do
print_after: nil,
}
@knife.name_args = [ "adam" ]
- @node = Chef::Node.new()
+ @node = Chef::Node.new
end
it "should load the node" do
diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index 7ceafdad78..5b704c4219 100644
--- a/spec/unit/knife/node_environment_set_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::NodeEnvironmentSet do
@knife = Chef::Knife::NodeEnvironmentSet.new
@knife.name_args = %w{adam bar}
allow(@knife).to receive(:output).and_return(true)
- @node = Chef::Node.new()
+ @node = Chef::Node.new
@node.name("knifetest-node")
@node.chef_environment << "foo"
allow(@node).to receive(:save).and_return(true)
diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb
index cf128a80a0..524780c0b8 100644
--- a/spec/unit/knife/node_from_file_spec.rb
+++ b/spec/unit/knife/node_from_file_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Knife::NodeFromFile do
@knife.name_args = [ "adam.rb" ]
allow(@knife).to receive(:output).and_return(true)
allow(@knife).to receive(:confirm).and_return(true)
- @node = Chef::Node.new()
+ @node = Chef::Node.new
allow(@node).to receive(:save)
allow(@knife.loader).to receive(:load_from).and_return(@node)
@stdout = StringIO.new
diff --git a/spec/unit/knife/node_policy_set_spec.rb b/spec/unit/knife/node_policy_set_spec.rb
index 35306937d8..da84019fe1 100644
--- a/spec/unit/knife/node_policy_set_spec.rb
+++ b/spec/unit/knife/node_policy_set_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodePolicySet do
let(:node) do
- node = Chef::Node.new()
+ node = Chef::Node.new
node.name("adam")
node.run_list = ["role[base]"]
node
diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb
index 03c89ff9eb..b793333c99 100644
--- a/spec/unit/knife/node_run_list_add_spec.rb
+++ b/spec/unit/knife/node_run_list_add_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::NodeRunListAdd do
}
@knife.name_args = [ "adam", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @node = Chef::Node.new()
+ @node = Chef::Node.new
allow(@node).to receive(:save).and_return(true)
allow(Chef::Node).to receive(:load).and_return(@node)
end
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index 4f753d7991..a62b6f4b71 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::NodeRunListRemove do
@knife = Chef::Knife::NodeRunListRemove.new
@knife.config[:print_after] = nil
@knife.name_args = [ "adam", "role[monkey]" ]
- @node = Chef::Node.new()
+ @node = Chef::Node.new
@node.name("knifetest-node")
@node.run_list << "role[monkey]"
allow(@node).to receive(:save).and_return(true)
diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb
index bd55edb997..6246dfce6a 100644
--- a/spec/unit/knife/node_run_list_set_spec.rb
+++ b/spec/unit/knife/node_run_list_set_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::NodeRunListSet do
@knife.config = {}
@knife.name_args = [ "adam", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @node = Chef::Node.new()
+ @node = Chef::Node.new
allow(@node).to receive(:save).and_return(true)
allow(Chef::Node).to receive(:load).and_return(@node)
end
diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb
index 2f684b27f4..f26bae4233 100644
--- a/spec/unit/knife/node_show_spec.rb
+++ b/spec/unit/knife/node_show_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::NodeShow do
let(:node) do
- node = Chef::Node.new()
+ node = Chef::Node.new
node.name("adam")
node.run_list = ["role[base]"]
node
diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb
index d49adb9354..07a9b484c4 100644
--- a/spec/unit/knife/role_bulk_delete_spec.rb
+++ b/spec/unit/knife/role_bulk_delete_spec.rb
@@ -29,9 +29,9 @@ describe Chef::Knife::RoleBulkDelete do
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
allow(@knife.ui).to receive(:confirm).and_return(true)
- @roles = Hash.new
+ @roles = {}
%w{dev staging production}.each do |role_name|
- role = Chef::Role.new()
+ role = Chef::Role.new
role.name(role_name)
allow(role).to receive(:destroy).and_return(true)
@roles[role_name] = role
diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb
index 5e2b2caeb5..fa3ef1c9e8 100644
--- a/spec/unit/knife/role_create_spec.rb
+++ b/spec/unit/knife/role_create_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::RoleCreate do
}
@knife.name_args = [ "adam" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:save)
allow(Chef::Role).to receive(:new).and_return(@role)
allow(@knife).to receive(:edit_data).and_return(@role)
diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb
index 98c0cde9b2..889287fd04 100644
--- a/spec/unit/knife/role_delete_spec.rb
+++ b/spec/unit/knife/role_delete_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Knife::RoleDelete do
@knife.name_args = [ "adam" ]
allow(@knife).to receive(:output).and_return(true)
allow(@knife).to receive(:confirm).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:destroy).and_return(true)
allow(Chef::Role).to receive(:load).and_return(@role)
@stdout = StringIO.new
diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb
index 5e03b7aef3..3828bc51b9 100644
--- a/spec/unit/knife/role_edit_spec.rb
+++ b/spec/unit/knife/role_edit_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Knife::RoleEdit do
@knife.config[:print_after] = nil
@knife.name_args = [ "adam" ]
allow(@knife.ui).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:save)
allow(Chef::Role).to receive(:load).and_return(@role)
allow(@knife.ui).to receive(:edit_data).and_return(@role)
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 242beeb4a2..39c9740f50 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Knife::RoleEnvRunListAdd do
}
@knife.name_args = [ "will", "QA", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:save).and_return(true)
allow(Chef::Role).to receive(:load).and_return(@role)
end
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 7a580ecd4a..14d818fa66 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListClear do
@knife.name_args = %w{will QA}
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 afbabec528..a9eedf9aa1 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListRemove do
@knife.name_args = [ "will", "QA", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 c4d231d638..94ef75fa07 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListReplace do
@knife.name_args = [ "will", "QA", "role[dude]", "role[person]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 79bd3b152e..4fdef5729f 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Knife::RoleEnvRunListSet do
@knife.name_args = [ "will", "QA", "role[owen]", "role[mauntel]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).and_return(true)
diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb
index 827b8ae04d..65a152c1f0 100644
--- a/spec/unit/knife/role_from_file_spec.rb
+++ b/spec/unit/knife/role_from_file_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Knife::RoleFromFile do
@knife.name_args = [ "adam.rb" ]
allow(@knife).to receive(:output).and_return(true)
allow(@knife).to receive(:confirm).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:save)
allow(@knife.loader).to receive(:load_from).and_return(@role)
@stdout = StringIO.new
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index a38b6de9da..38ead92d86 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Knife::RoleRunListAdd do
}
@knife.name_args = [ "will", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
allow(@role).to receive(:save).and_return(true)
allow(Chef::Role).to receive(:load).and_return(@role)
end
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index 8bbc816d6f..b62cc06571 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListClear do
@knife.name_args = [ "will" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 c18416feca..c4f0e6d32e 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListRemove do
@knife.name_args = [ "will", "role[monkey]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 9b212de0ae..aa76efe249 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListReplace do
@knife.name_args = [ "will", "role[dude]", "role[person]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).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 f8e440f524..69543dbda4 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Knife::RoleRunListSet do
@knife.name_args = [ "will", "role[owen]", "role[mauntel]" ]
allow(@knife).to receive(:output).and_return(true)
- @role = Chef::Role.new()
+ @role = Chef::Role.new
@role.name("will")
allow(@role).to receive(:save).and_return(true)
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 929a0f742b..dc66007c32 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -40,7 +40,8 @@ describe Chef::Knife::Status do
{ filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
- platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } end
+ platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }
+ end
it "should default to searching for everything" do
expect(@query).to receive(:search).with(:node, "*:*", opts)
diff --git a/spec/unit/knife/supermarket_install_spec.rb b/spec/unit/knife/supermarket_install_spec.rb
index d891de9268..9c969106fc 100644
--- a/spec/unit/knife/supermarket_install_spec.rb
+++ b/spec/unit/knife/supermarket_install_spec.rb
@@ -23,12 +23,13 @@ describe Chef::Knife::SupermarketInstall do
let(:knife) { Chef::Knife::SupermarketInstall.new }
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
- let(:downloader) { Hash.new }
+ let(:downloader) { {} }
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
+ merge_updates_from: true)
+ end
let(:install_path) do
if Chef::Platform.windows?
"C:/tmp/chef"
diff --git a/spec/unit/knife/supermarket_share_spec.rb b/spec/unit/knife/supermarket_share_spec.rb
index 6601cdcd31..6fdcc6c92f 100644
--- a/spec/unit/knife/supermarket_share_spec.rb
+++ b/spec/unit/knife/supermarket_share_spec.rb
@@ -175,7 +175,7 @@ describe Chef::Knife::SupermarketShare do
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())
+ expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything, anything, anything)
@knife.run
end
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 2c14e417b4..6ed7ddd70e 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -55,7 +55,7 @@ describe Chef::Knife do
allow(knife.ui).to receive(:print)
allow(Chef::Log).to receive(:init)
allow(Chef::Log).to receive(:level)
- [:debug, :info, :warn, :error, :crit].each do |level_sym|
+ %i{debug info warn error crit}.each do |level_sym|
allow(Chef::Log).to receive(level_sym)
end
allow(Chef::Knife).to receive(:puts)
@@ -166,7 +166,8 @@ describe Chef::Knife do
"X-Chef-Version" => Chef::VERSION,
"Host" => "api.opscode.piab",
"X-REMOTE-REQUEST-ID" => request_id,
- } end
+ }
+ end
let(:request_id) { "1234" }
@@ -205,7 +206,7 @@ describe Chef::Knife do
KnifeSpecs.send :remove_const, :TestYourself
end
Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
- Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) }
+ Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.is_a?(Class) }
end
it "confirms that the headers include X-Remote-Request-Id" do
@@ -220,7 +221,7 @@ describe Chef::Knife do
KnifeSpecs.send :remove_const, :TestYourself
end
Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
- Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) }
+ Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.is_a?(Class) }
end
it "merges the global knife CLI options" do
@@ -468,8 +469,8 @@ describe Chef::Knife do
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
- expect(stderr.string).to match(%r{Response: y u no administrator})
+ expect(stderr.string).to match(/ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action/)
+ expect(stderr.string).to match(/Response: y u no administrator/)
end
context "when proxy servers are set" do
@@ -488,9 +489,9 @@ describe Chef::Knife do
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
- expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your server url may need to be added to NO_PROXY.})
- expect(stderr.string).to match(%r{Response: y u no administrator})
+ expect(stderr.string).to match(/ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action/)
+ expect(stderr.string).to match(/ERROR: There are proxy servers configured, your server url may need to be added to NO_PROXY./)
+ expect(stderr.string).to match(/Response: y u no administrator/)
end
end
@@ -500,8 +501,8 @@ describe Chef::Knife do
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong"))
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("400 Bad Request", response))
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: The data in your request was invalid})
- expect(stderr.string).to match(%r{Response: y u search wrong})
+ expect(stderr.string).to match(/ERROR: The data in your request was invalid/)
+ expect(stderr.string).to match(/Response: y u search wrong/)
end
it "formats 404s nicely" do
@@ -510,8 +511,8 @@ describe Chef::Knife do
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here"))
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.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})
- expect(stderr.string).to match(%r{Response: nothing to see here})
+ expect(stderr.string).to match(/ERROR: The object you are looking for could not be found/)
+ expect(stderr.string).to match(/Response: nothing to see here/)
end
it "formats 406s (non-supported API version error) nicely" do
@@ -536,8 +537,8 @@ describe Chef::Knife do
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})
- expect(stderr.string).to match(%r{Response: sad trombone})
+ expect(stderr.string).to match(/ERROR: internal server error/)
+ expect(stderr.string).to match(/Response: sad trombone/)
end
it "formats 502s nicely" do
@@ -546,8 +547,8 @@ describe Chef::Knife do
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})
- expect(stderr.string).to match(%r{Response: sadder trombone})
+ expect(stderr.string).to match(/ERROR: bad gateway/)
+ expect(stderr.string).to match(/Response: sadder trombone/)
end
it "formats 503s nicely" do
@@ -556,8 +557,8 @@ describe Chef::Knife do
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})
- expect(stderr.string).to match(%r{Response: saddest trombone})
+ expect(stderr.string).to match(/ERROR: Service temporarily unavailable/)
+ expect(stderr.string).to match(/Response: saddest trombone/)
end
it "formats other HTTP errors nicely" do
@@ -566,16 +567,16 @@ describe Chef::Knife do
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy"))
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("402 Payment Required", response))
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: Payment Required})
- expect(stderr.string).to match(%r{Response: nobugfixtillyoubuy})
+ expect(stderr.string).to match(/ERROR: Payment Required/)
+ expect(stderr.string).to match(/Response: nobugfixtillyoubuy/)
end
it "formats NameError and NoMethodError nicely" do
allow(knife).to receive(:run).and_raise(NameError.new("Undefined constant FUUU"))
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: .* encountered an unexpected error})
- expect(stderr.string).to match(%r{This may be a bug in the 'knife' .* command or plugin})
- expect(stderr.string).to match(%r{Exception: NameError: Undefined constant FUUU})
+ expect(stderr.string).to match(/ERROR: .* encountered an unexpected error/)
+ expect(stderr.string).to match(/This may be a bug in the 'knife' .* command or plugin/)
+ expect(stderr.string).to match(/Exception: NameError: Undefined constant FUUU/)
end
it "formats missing private key errors nicely" do
@@ -583,7 +584,7 @@ describe Chef::Knife do
allow(knife).to receive(:api_key).and_return("/home/root/.chef/no-key-here.pem")
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem})
- expect(stderr.string).to match(%r{Check your configuration file and ensure that your private key is readable})
+ expect(stderr.string).to match(/Check your configuration file and ensure that your private key is readable/)
end
it "formats connection refused errors nicely" do
@@ -592,8 +593,8 @@ describe Chef::Knife do
# Errno::ECONNREFUSED message differs by platform
# *nix = Errno::ECONNREFUSED: Connection refused
# win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it.
- expect(stderr.string).to match(%r{ERROR: Network Error: .* - y u no shut up})
- expect(stderr.string).to match(%r{Check your .* configuration and network settings})
+ expect(stderr.string).to match(/ERROR: Network Error: .* - y u no shut up/)
+ expect(stderr.string).to match(/Check your .* configuration and network settings/)
end
it "formats SSL errors nicely and suggests to use `knife ssl check` and `knife ssl fetch`" do
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index a7f95f8bfd..def981801e 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -199,7 +199,7 @@ describe "LWRP" do
end
it "should create a method for each attribute" do
- expect(get_lwrp(:lwrp_foo).new("blah").methods.map { |m| m.to_sym }).to include(:monkey)
+ expect(get_lwrp(:lwrp_foo).new("blah").methods.map(&:to_sym)).to include(:monkey)
end
it "should build attribute methods that respect validation rules" do
@@ -264,12 +264,12 @@ describe "LWRP" do
let(:lwrp) do
Class.new(Chef::Resource::LWRPBase) do
actions :eat, :sleep
- default_action [:eat, :sleep]
+ default_action %i{eat sleep}
end
end
it "returns the array of default actions" do
- expect(lwrp.default_action).to eq([:eat, :sleep])
+ expect(lwrp.default_action).to eq(%i{eat sleep})
end
end
@@ -287,7 +287,7 @@ describe "LWRP" do
end
it "delegates #actions to the parent" do
- expect(child.actions).to eq([:nothing, :eat, :sleep])
+ expect(child.actions).to eq(%i{nothing eat sleep})
end
it "delegates #default_action to the parent" do
@@ -304,7 +304,7 @@ describe "LWRP" do
end
it "does not delegate #actions to the parent" do
- expect(child.actions).to eq([:nothing, :dont_eat, :dont_sleep])
+ expect(child.actions).to eq(%i{nothing dont_eat dont_sleep})
end
it "does not delegate #default_action to the parent" do
@@ -322,7 +322,7 @@ describe "LWRP" do
end
it "amends actions when they are already defined" do
- expect(child.actions).to eq([:nothing, :eat, :sleep, :drink])
+ expect(child.actions).to eq(%i{nothing eat sleep drink})
end
end
end
@@ -330,40 +330,40 @@ describe "LWRP" do
describe "when actions is set to an array" do
let(:resource_class) do
Class.new(Chef::Resource::LWRPBase) do
- actions [ :eat, :sleep ]
+ actions %i{eat sleep}
end
end
let(:resource) do
resource_class.new("blah")
end
it "actions includes those actions" do
- expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource_class.actions).to eq %i{nothing eat sleep}
end
it "allowed_actions includes those actions" do
- expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource_class.allowed_actions).to eq %i{nothing eat sleep}
end
it "resource.allowed_actions includes those actions" do
- expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource.allowed_actions).to eq %i{nothing eat sleep}
end
end
describe "when allowed_actions is set to an array" do
let(:resource_class) do
Class.new(Chef::Resource::LWRPBase) do
- allowed_actions [ :eat, :sleep ]
+ allowed_actions %i{eat sleep}
end
end
let(:resource) do
resource_class.new("blah")
end
it "actions includes those actions" do
- expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource_class.actions).to eq %i{nothing eat sleep}
end
it "allowed_actions includes those actions" do
- expect(resource_class.allowed_actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource_class.allowed_actions).to eq %i{nothing eat sleep}
end
it "resource.allowed_actions includes those actions" do
- expect(resource.allowed_actions).to eq [ :nothing, :eat, :sleep ]
+ expect(resource.allowed_actions).to eq %i{nothing eat sleep}
end
end
end
@@ -590,7 +590,7 @@ describe "LWRP" do
it "get_lwrp(:lwrp_once).new is an instance of the LWRP class" do
lwrp = get_lwrp(:lwrp_once).new("hi")
- expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy
+ expect(lwrp.is_a?(test_lwrp_class)).to be_truthy
expect(lwrp.is_a?(test_lwrp_class)).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
expect(test_lwrp_class === lwrp).to be_truthy
@@ -603,28 +603,28 @@ describe "LWRP" do
it "subclass.new is a subclass" do
lwrp = subclass.new("hi")
- expect(lwrp.kind_of?(subclass)).to be_truthy
+ expect(lwrp.is_a?(subclass)).to be_truthy
expect(lwrp.is_a?(subclass)).to be_truthy
expect(subclass === lwrp).to be_truthy
expect(lwrp.class === subclass)
end
it "subclass.new is an instance of the LWRP class" do
lwrp = subclass.new("hi")
- expect(lwrp.kind_of?(test_lwrp_class)).to be_truthy
+ expect(lwrp.is_a?(test_lwrp_class)).to be_truthy
expect(lwrp.is_a?(test_lwrp_class)).to be_truthy
expect(test_lwrp_class === lwrp).to be_truthy
expect(lwrp.class === test_lwrp_class)
end
it "subclass.new is a get_lwrp(:lwrp_once)" do
lwrp = subclass.new("hi")
- expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy
+ expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy
expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
expect(lwrp.class === get_lwrp(:lwrp_once))
end
it "get_lwrp(:lwrp_once).new is *not* a subclass" do
lwrp = get_lwrp(:lwrp_once).new("hi")
- expect(lwrp.kind_of?(subclass)).to be_falsey
+ expect(lwrp.is_a?(subclass)).to be_falsey
expect(lwrp.is_a?(subclass)).to be_falsey
expect(subclass === lwrp.class).to be_falsey
expect(subclass === get_lwrp(:lwrp_once)).to be_falsey
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb
index df89962cce..7d2da85e2d 100644
--- a/spec/unit/mixin/homebrew_user_spec.rb
+++ b/spec/unit/mixin/homebrew_user_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Mixin::HomebrewUser do
let(:brew_owner) { 2001 }
let(:default_brew_path) { "/usr/local/bin/brew" }
let(:stat_double) do
- d = double()
+ d = double
expect(d).to receive(:uid).and_return(brew_owner)
d
end
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index 1cc7fef58e..489742cb7d 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -30,7 +30,7 @@ end
describe Chef::Mixin::ParamsValidate do
before(:each) do
- @vo = TinyClass.new()
+ @vo = TinyClass.new
end
it "should allow a hash and a hash as arguments to validate" do
@@ -44,7 +44,7 @@ describe Chef::Mixin::ParamsValidate do
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" }, { {} => true }) }.to raise_error(ArgumentError)
end
it "should allow options to be required with true" do
@@ -163,7 +163,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should let you set a default value with default => value" do
- arguments = Hash.new
+ arguments = {}
@vo.validate(arguments, {
one: {
default: "is the loneliest number",
@@ -236,7 +236,7 @@ describe Chef::Mixin::ParamsValidate do
{
one: {
kind_of: String,
- respond_to: [ :to_s, :upcase ],
+ respond_to: %i{to_s upcase},
regex: /^is good/,
callbacks: {
"should be your friend" => lambda do |a|
@@ -260,7 +260,7 @@ describe Chef::Mixin::ParamsValidate do
{
one: {
kind_of: String,
- respond_to: [ :to_s, :upcase ],
+ respond_to: %i{to_s upcase},
regex: /^is good/,
callbacks: {
"should be your friend" => lambda do |a|
@@ -321,7 +321,7 @@ describe Chef::Mixin::ParamsValidate do
end.not_to raise_error
expect do
@vo.validate(
- { one: Hash.new },
+ { one: {} },
{
one: {
kind_of: [ String, Array ],
@@ -334,22 +334,22 @@ 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 ] } })
+ { not_blank: { cannot_be: %i{nil empty} } })
end.not_to raise_error
expect do
@vo.validate({ not_blank: "" },
- { not_blank: { cannot_be: [ :nil, :empty ] } })
+ { not_blank: { cannot_be: %i{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" } })
+ { not_blank: { cannot_be: %i{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" } })
+ { not_blank: { cannot_be: %i{nil empty}, validation_message: "my validation message" } })
end.to raise_error(Chef::Exceptions::ValidationFailed, "my validation message")
end
diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb
index ee0c252381..25b94178e5 100644
--- a/spec/unit/mixin/properties_spec.rb
+++ b/spec/unit/mixin/properties_spec.rb
@@ -31,7 +31,7 @@ module ChefMixinPropertiesSpec
end
it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do
- expect(A.properties.keys).to eq [ :a, :ab, :ac, :d ]
+ expect(A.properties.keys).to eq %i{a ab ac d}
expect(A.properties[:a].validation_options[:is]).to eq "a"
expect(A.properties[:ab].validation_options[:is]).to eq %w{a b}
expect(A.properties[:ac].validation_options[:is]).to eq %w{a c}
@@ -46,13 +46,13 @@ module ChefMixinPropertiesSpec
end
it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do
- expect(B.properties.keys).to eq [ :b, :ab, :bc ]
+ expect(B.properties.keys).to eq %i{b ab bc}
expect(B.properties[:b].validation_options[:is]).to eq "b"
expect(B.properties[:ab].validation_options[:is]).to be_nil
expect(B.properties[:bc].validation_options[:is]).to eq %w{b c}
end
it "C.properties has a, b, c, ac and bc with merged types" do
- expect(C.properties.keys).to eq [ :a, :ab, :ac, :d, :b, :bc, :c ]
+ expect(C.properties.keys).to eq %i{a ab ac d b bc c}
expect(C.properties[:a].validation_options[:is]).to eq "a"
expect(C.properties[:b].validation_options[:is]).to eq "b"
expect(C.properties[:c].validation_options[:is]).to eq "c"
@@ -99,7 +99,7 @@ module ChefMixinPropertiesSpec
end
it "Outerest.properties.validation_options[:is] inner, outer, outerest" do
- expect(Outerest.properties.keys).to eq [:inner, :outer, :outerest]
+ expect(Outerest.properties.keys).to eq %i{inner outer outerest}
end
end
end
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 4f8e4dafac..1c4f59b50b 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -51,7 +51,7 @@ describe Chef::Mixin::ShellOut do
let(:retobj) { instance_double(Mixlib::ShellOut, "error!" => false) }
let(:cmd) { "echo '#{rand(1000)}'" }
- [ :shell_out, :shell_out! ].each do |method|
+ %i{shell_out shell_out!}.each do |method|
describe "##{method}" do
describe "when the last argument is a Hash" do
@@ -248,7 +248,7 @@ describe Chef::Mixin::ShellOut do
let(:provider) { new_resource.provider_for_action(:install) }
describe "on Chef-15", chef: ">= 15" do
- [ :shell_out, :shell_out! ].each do |method|
+ %i{shell_out shell_out!}.each do |method|
stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted!
it "#{method} defaults to 900 seconds" do
expect(provider).to receive(stubbed_method).with("foo", timeout: 900)
@@ -284,7 +284,7 @@ describe Chef::Mixin::ShellOut do
let(:new_resource) { Chef::Resource::Package.new("foo") }
let(:provider) { new_resource.provider_for_action(:install) }
- [ :shell_out, :shell_out! ].each do |method|
+ %i{shell_out shell_out!}.each do |method|
stubbed_method = (method == :shell_out) ? :shell_out_compacted : :shell_out_compacted!
it "#{method} defaults to 900 seconds" do
expect(provider).to receive(stubbed_method).with("foo", timeout: 900)
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 96b983a9dd..04071988ad 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -242,17 +242,13 @@ describe Chef::Mixin::Template, "render_template" do
it "emits a warning when overriding 'core' methods" do
mod = Module.new do
- def render
- end
+ def render; end
- def node
- end
+ def node; end
- def render_template
- end
+ def render_template; end
- def render_template_from_string
- end
+ def render_template_from_string; end
end
%w{node render render_template render_template_from_string}.each do |method_name|
expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/)
diff --git a/spec/unit/mixin/unformatter_spec.rb b/spec/unit/mixin/unformatter_spec.rb
index b2b57c150c..3c8dba1962 100644
--- a/spec/unit/mixin/unformatter_spec.rb
+++ b/spec/unit/mixin/unformatter_spec.rb
@@ -22,8 +22,7 @@ require "chef/mixin/unformatter"
class Chef::UnformatterTest
include Chef::Mixin::Unformatter
- def foo
- end
+ def foo; end
end
diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb
index 896241f173..31e182d042 100644
--- a/spec/unit/mixin/user_context_spec.rb
+++ b/spec/unit/mixin/user_context_spec.rb
@@ -56,8 +56,7 @@ describe "a class that mixes in user_context" do
let(:block_object) do
class BlockClass
- def block_method
- end
+ def block_method; end
end
BlockClass.new
end
diff --git a/spec/unit/mixin/which.rb b/spec/unit/mixin/which.rb
index 1764b3b89f..c47eaf37ab 100644
--- a/spec/unit/mixin/which.rb
+++ b/spec/unit/mixin/which.rb
@@ -88,11 +88,13 @@ describe Chef::Mixin::Which do
test_which("passes in the filename as the arg", "foo1", finds: "/dir1/foo1") do |f|
raise "bad arg to block" unless f == "/dir1/foo1"
+
true
end
test_which("arrays with blocks", "foo1", "foo2", finds: "/dir2/foo1", others: [ "/dir1/foo2" ]) do |f|
raise "bad arg to block" unless f == "/dir2/foo1" || f == "/dir1/foo2"
+
true
end
end
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 4559702e1c..ad7bee0ec9 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do
include Chef::Mixin::WindowsArchitectureHelper
before do
- @valid_architectures = [ :i386, :x86_64 ]
+ @valid_architectures = %i{i386 x86_64}
@invalid_architectures = [ "i386", "x86_64", :x64, :x86, :arm ]
@node_i386 = Chef::Node.new
@@ -67,14 +67,14 @@ describe Chef::Mixin::WindowsArchitectureHelper do
it "returns true only when forced_32bit_override_required? has 64-bit node architecture and 32-bit desired architecture" do
with_node_architecture_combinations do |node, desired_arch|
expect(forced_32bit_override_required?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows?
- expect(forced_32bit_override_required?(node, desired_arch)).to be false if ! ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386))
+ expect(forced_32bit_override_required?(node, desired_arch)).to be false unless (node_windows_architecture(node) == :x86_64) && (desired_arch == :i386)
end
end
def with_node_architecture_combinations
@valid_architectures.each do |node_architecture|
new_node = Chef::Node.new
- new_node.default["kernel"] = Hash.new
+ new_node.default["kernel"] = {}
new_node.default["kernel"][:machine] = node_architecture.to_s
@valid_architectures.each do |architecture|
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 29e299566b..5055941d06 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -182,7 +182,7 @@ describe Chef::Node::Attribute do
expect { Chef::Node::Attribute.new({}, {}, {}, {}) }.not_to raise_error
end
- [ :normal, :default, :override, :automatic ].each do |accessor|
+ %i{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 })
expect(na.send(accessor)).to eq({ accessor.to_s => true })
@@ -546,7 +546,7 @@ describe Chef::Node::Attribute do
expect(@attributes["music"]["this"]).not_to have_key("must")
end
- [:include?, :key?, :member?].each do |method|
+ %i{include? key? member?}.each do |method|
it "should alias the method #{method} to itself" do
expect(@attributes).to respond_to(method)
end
@@ -589,7 +589,7 @@ describe Chef::Node::Attribute do
end
it "should yield each top level key" do
- collect = Array.new
+ collect = []
@attributes.each_key do |k|
collect << k
end
@@ -602,7 +602,7 @@ describe Chef::Node::Attribute do
end
it "should yield lower if we go deeper" do
- collect = Array.new
+ collect = []
@attributes["one"].each_key do |k|
collect << k
end
@@ -637,7 +637,7 @@ describe Chef::Node::Attribute do
end
it "should yield each top level key and value, post merge rules" do
- collect = Hash.new
+ collect = {}
@attributes.each do |k, v|
collect[k] = v
end
@@ -679,7 +679,7 @@ describe Chef::Node::Attribute do
end
it "should yield each top level key, post merge rules" do
- collect = Array.new
+ collect = []
@attributes.each_key do |k|
collect << k
end
@@ -715,7 +715,7 @@ describe Chef::Node::Attribute do
end
it "should yield each top level key and value pair, post merge rules" do
- collect = Hash.new
+ collect = {}
@attributes.each_pair do |k, v|
collect[k] = v
end
@@ -751,7 +751,7 @@ describe Chef::Node::Attribute do
end
it "should yield each value, post merge rules" do
- collect = Array.new
+ collect = []
@attributes.each_value do |v|
collect << v
end
@@ -762,7 +762,7 @@ describe Chef::Node::Attribute do
end
it "should yield four elements" do
- collect = Array.new
+ collect = []
@attributes.each_value do |v|
collect << v
end
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index 2208c45717..f23e40dc4c 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2018, Chef Software Inc.
+# Copyright:: Copyright 2012-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -145,25 +145,25 @@ describe Chef::Node::ImmutableMash do
end
end
- [
- :[]=,
- :clear,
- :default=,
- :default_proc=,
- :delete,
- :delete_if,
- :keep_if,
- :merge!,
- :update,
- :reject!,
- :replace,
- :select!,
- :shift,
- :write,
- :write!,
- :unlink,
- :unlink!,
- ].each do |mutator|
+ %i{
+ []=
+ clear
+ default=
+ default_proc=
+ delete
+ delete_if
+ keep_if
+ merge!
+ update
+ reject!
+ replace
+ select!
+ shift
+ write
+ write!
+ unlink
+ unlink!
+ }.each do |mutator|
it "doesn't allow mutation via `#{mutator}'" do
expect { @immutable_mash.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
end
@@ -190,36 +190,36 @@ describe Chef::Node::ImmutableArray do
# with ImmutableMash, above
###
- [
- :<<,
- :[]=,
- :clear,
- :collect!,
- :compact!,
- :default=,
- :default_proc=,
- :delete,
- :delete_at,
- :delete_if,
- :fill,
- :flatten!,
- :insert,
- :keep_if,
- :map!,
- :merge!,
- :pop,
- :push,
- :reject!,
- :reverse!,
- :replace,
- :select!,
- :shift,
- :slice!,
- :sort!,
- :sort_by!,
- :uniq!,
- :unshift,
- ].each do |mutator|
+ %i{
+ <<
+ []=
+ clear
+ collect!
+ compact!
+ default=
+ default_proc=
+ delete
+ delete_at
+ delete_if
+ fill
+ flatten!
+ insert
+ keep_if
+ map!
+ merge!
+ pop
+ push
+ reject!
+ reverse!
+ replace
+ select!
+ shift
+ slice!
+ sort!
+ sort_by!
+ uniq!
+ unshift
+ }.each do |mutator|
it "does not allow mutation via `#{mutator}" do
expect { @immutable_array.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 2d28a3e961..1c84278ad5 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -21,7 +21,7 @@ require "ostruct"
describe Chef::Node do
- let(:node) { Chef::Node.new() }
+ let(:node) { Chef::Node.new }
let(:platform_introspector) { node }
it_behaves_like "a platform introspector"
@@ -103,7 +103,7 @@ describe Chef::Node do
end
it "should always have a string for name" do
- expect { node.name(Hash.new) }.to raise_error(ArgumentError)
+ expect { node.name({}) }.to raise_error(ArgumentError)
end
it "cannot be blank" do
@@ -126,7 +126,7 @@ describe Chef::Node do
end
it "should disallow non-strings" do
- expect { node.chef_environment(Hash.new) }.to raise_error(ArgumentError)
+ expect { node.chef_environment({}) }.to raise_error(ArgumentError)
expect { node.chef_environment(42) }.to raise_error(ArgumentError)
end
@@ -162,7 +162,7 @@ describe Chef::Node do
end
it "disallows non-strings" do
- expect { node.policy_name(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.policy_name({}) }.to raise_error(Chef::Exceptions::ValidationFailed)
expect { node.policy_name(42) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
@@ -198,7 +198,7 @@ describe Chef::Node do
end
it "disallows non-strings" do
- expect { node.policy_group(Hash.new) }.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.policy_group({}) }.to raise_error(Chef::Exceptions::ValidationFailed)
expect { node.policy_group(42) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
@@ -769,7 +769,7 @@ describe Chef::Node do
it "caches both strings and symbols correctly" do
node.force_default[:solr][:version] = "4.10.2"
- node.force_default[:solr][:data_dir] = "/opt/solr-#{node['solr'][:version]}/example/solr"
+ node.force_default[:solr][:data_dir] = "/opt/solr-#{node["solr"][:version]}/example/solr"
node.force_default[:solr][:xms] = "512M"
expect(node[:solr][:xms]).to eql("512M")
expect(node["solr"][:xms]).to eql("512M")
@@ -778,8 +778,8 @@ describe Chef::Node do
it "method interpolation syntax also works" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
node.default["passenger"]["version"] = "4.0.57"
- node.default["passenger"]["root_path"] = "passenger-#{node['passenger']['version']}"
- node.default["passenger"]["root_path_2"] = "passenger-#{node[:passenger]['version']}"
+ node.default["passenger"]["root_path"] = "passenger-#{node["passenger"]["version"]}"
+ node.default["passenger"]["root_path_2"] = "passenger-#{node[:passenger]["version"]}"
expect(node["passenger"]["root_path_2"]).to eql("passenger-4.0.57")
expect(node[:passenger]["root_path_2"]).to eql("passenger-4.0.57")
end
@@ -793,7 +793,7 @@ describe Chef::Node do
it "should allow you to iterate over attributes with each_attribute" do
node.default["sunshine"] = "is bright"
node.default["canada"] = "is a nice place"
- seen_attributes = Hash.new
+ seen_attributes = {}
node.each_attribute do |a, v|
seen_attributes[a] = v
end
@@ -1207,7 +1207,7 @@ describe Chef::Node do
node.run_list << "role[leninist]"
node.run_list << "recipe[stalinist]"
- @example = Chef::Node.new()
+ @example = Chef::Node.new
@example.name("newname")
@example.chef_environment("prod")
@example.default_attrs = { "alpha" => { "bravo" => "charlie", "delta" => "echo" } }
@@ -1385,7 +1385,7 @@ describe Chef::Node do
describe "inflated" do
it "should return a hash of node names and objects" do
n1 = double("Chef::Node", name: "one")
- allow(n1).to receive(:kind_of?).with(Chef::Node) { true }
+ allow(n1).to receive(:is_a?).with(Chef::Node) { true }
expect(@query).to receive(:search).with(:node).and_yield(n1)
r = Chef::Node.list(true)
expect(r["one"]).to eq(n1)
diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb
index 79a29b1fff..b291b7cb86 100644
--- a/spec/unit/org_spec.rb
+++ b/spec/unit/org_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Org do
end
it "raises an ArgumentError if you feed it anything but a string" do
- expect { org.name Hash.new }.to raise_error(ArgumentError)
+ expect { org.name({}) }.to raise_error(ArgumentError)
end
end
@@ -63,7 +63,7 @@ describe Chef::Org do
end
it "raises an ArgumentError if you feed it anything but a string" do
- expect { org.name Hash.new }.to raise_error(ArgumentError)
+ expect { org.name({}) }.to raise_error(ArgumentError)
end
end
@@ -74,7 +74,7 @@ describe Chef::Org do
end
it "raises an ArgumentError if you feed it something lame" do
- expect { org.private_key Hash.new }.to raise_error(ArgumentError)
+ expect { org.private_key({}) }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index f22e2a74b3..d08a9f5b33 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -403,9 +403,9 @@ describe Chef::PolicyBuilder::Policyfile do
before do
allow(policy_builder).to receive(:run_list)
- .and_return(run_list)
+ .and_return(run_list)
allow(policy_builder).to receive(:cookbook_lock_for)
- .and_return(version_hash)
+ .and_return(version_hash)
end
it "sends the run_list_expanded event" do
diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb
index 5c54ec71b2..a6428e8617 100644
--- a/spec/unit/property/state_spec.rb
+++ b/spec/unit/property/state_spec.rb
@@ -28,7 +28,8 @@ describe "Chef::Resource#identity and #state" do
def self.english_join(values)
return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
- "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
+
+ "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}"
end
def self.with_property(*properties, &block)
@@ -256,29 +257,29 @@ describe "Chef::Resource#identity and #state" do
with_property ":x, identity: true, default: 'xxx'",
":y, identity: true, default: 'yyy'",
":z, identity: true, default: 'zzz'" do
- it "identity_property raises an error if multiple identity values are defined" do
- expect { resource_class.identity_property }.to raise_error Chef::Exceptions::MultipleIdentityError
- end
- it "identity_attr raises an error if multiple identity values are defined" do
- expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError
- end
- it "identity returns all identity values in a hash if multiple are defined" do
- resource.x "foo"
- resource.y "bar"
- resource.z "baz"
- expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz")
- end
- it "identity returns all values whether any value is set or not" do
- expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz")
- end
- it "identity_properties wipes out any other identity attributes if multiple are defined" do
- resource_class.identity_properties :y
- resource.x "foo"
- resource.y "bar"
- resource.z "baz"
- expect(resource.identity).to eq "bar"
+ it "identity_property raises an error if multiple identity values are defined" do
+ expect { resource_class.identity_property }.to raise_error Chef::Exceptions::MultipleIdentityError
+ end
+ it "identity_attr raises an error if multiple identity values are defined" do
+ expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError
+ end
+ it "identity returns all identity values in a hash if multiple are defined" do
+ resource.x "foo"
+ resource.y "bar"
+ resource.z "baz"
+ expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz")
+ end
+ it "identity returns all values whether any value is set or not" do
+ expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz")
+ end
+ it "identity_properties wipes out any other identity attributes if multiple are defined" do
+ resource_class.identity_properties :y
+ resource.x "foo"
+ resource.y "bar"
+ resource.z "baz"
+ expect(resource.identity).to eq "bar"
+ end
end
- end
with_property ":x, identity: true, name_property: true" do
it "identity when x is not defined returns the value of x" do
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb
index b05d8c4e17..dab2be8000 100644
--- a/spec/unit/property/validation_spec.rb
+++ b/spec/unit/property/validation_spec.rb
@@ -55,7 +55,8 @@ describe "Chef::Resource.property validation" do
def self.english_join(values)
return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
- "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
+
+ "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}"
end
def self.with_property(*properties, &block)
@@ -231,19 +232,19 @@ describe "Chef::Resource.property validation" do
[ :b ]
validation_test ":a, is: :b",
- [ :a, :b ],
+ %i{a b},
[ :c ]
validation_test ":a, is: [ :b, :c ]",
- [ :a, :b, :c ],
+ %i{a b c},
[ :d ]
validation_test "[ :a, :b ], is: :c",
- [ :a, :b, :c ],
+ %i{a b c},
[ :d ]
validation_test "[ :a, :b ], is: [ :c, :d ]",
- [ :a, :b, :c, :d ],
+ %i{a b c d},
[ :e ]
validation_test "nil",
@@ -279,12 +280,12 @@ describe "Chef::Resource.property validation" do
[ :b ]
validation_test "is: [ :a, :b ]",
- [ :a, :b ],
- [ [ :a, :b ] ]
+ %i{a b},
+ [ %i{a b} ]
validation_test "is: [ [ :a, :b ] ]",
- [ [ :a, :b ] ],
- [ :a, :b ]
+ [ %i{a b} ],
+ %i{a b}
# Regex
validation_test "is: /abc/",
@@ -352,13 +353,13 @@ describe "Chef::Resource.property validation" do
:nil_is_valid
validation_test "equal_to: [ :a, :b ]",
- [ :a, :b ],
- [ [ :a, :b ] ],
+ %i{a b},
+ [ %i{a b} ],
:nil_is_valid
validation_test "equal_to: [ [ :a, :b ] ]",
- [ [ :a, :b ] ],
- [ :a, :b ],
+ [ %i{a b} ],
+ %i{a b},
:nil_is_valid
validation_test "equal_to: nil",
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 56e44fd1d1..1fcbb77e8e 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -51,7 +51,8 @@ describe "Chef::Resource.property" do
def self.english_join(values)
return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
- "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
+
+ "#{values[0..-2].map(&:inspect).join(", ")} and #{values[-1].inspect}"
end
def self.with_property(*properties, &block)
@@ -1051,19 +1052,19 @@ describe "Chef::Resource.property" do
context "default ordering deprecation warnings" do
it "emits an error for property :x, default: 10, #{name}: true" do
expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error ArgumentError,
- /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
+ %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)}
end
it "emits an error for property :x, default: nil, #{name}: true" do
expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error ArgumentError,
- /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
+ %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)}
end
it "emits an error for property :x, #{name}: true, default: 10" do
expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error ArgumentError,
- /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
+ %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)}
end
it "emits an error for property :x, #{name}: true, default: nil" do
expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error ArgumentError,
- /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
+ %r{A property cannot be both a name_property/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)}
end
end
end
@@ -1085,13 +1086,13 @@ describe "Chef::Resource.property" do
expect do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
- property_type(is: [:a, :b], default: :c)
+ property_type(is: %i{a b}, default: :c)
end
end.to raise_error(Chef::Exceptions::ValidationFailed)
expect do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
- property_type(is: [:a, :b], default: :b)
+ property_type(is: %i{a b}, default: :b)
end
end.not_to raise_error
end
@@ -1100,8 +1101,8 @@ describe "Chef::Resource.property" do
before :all do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
- ABType = property_type(is: [:a, :b])
- CDType = property_type(is: [:c, :d])
+ ABType = property_type(is: %i{a b})
+ CDType = property_type(is: %i{c d})
end
end
@@ -1304,7 +1305,7 @@ describe "Chef::Resource.property" do
it "copies only foo when bar and name are excluded" do
thing_one_resource.foo "foo"
thing_one_resource.bar "bar"
- thing_two_resource.copy_properties_from(thing_one_resource, exclude: [ :name, :bar ])
+ thing_two_resource.copy_properties_from(thing_one_resource, exclude: %i{name bar})
expect(thing_two_resource.name).to eql("name_two")
expect(thing_two_resource.foo).to eql("foo")
expect(thing_two_resource.bar).to eql(nil)
diff --git a/spec/unit/provider/apt_update_spec.rb b/spec/unit/provider/apt_update_spec.rb
index 5cd327b66b..ed91131aff 100644
--- a/spec/unit/provider/apt_update_spec.rb
+++ b/spec/unit/provider/apt_update_spec.rb
@@ -47,7 +47,7 @@ describe Chef::Provider::AptUpdate do
before do
FileUtils.rmdir config_dir
expect(File.exist?(config_dir)).to be false
- allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ allow_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
end
it "should create the directory" do
@@ -66,7 +66,7 @@ describe Chef::Provider::AptUpdate do
describe "#action_update" do
it "should update the apt cache" do
provider.load_current_resource
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
provider.run_action(:update)
expect(new_resource).to be_updated_by_last_action
end
@@ -81,14 +81,14 @@ describe Chef::Provider::AptUpdate do
it "should run if the time stamp is old" do
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 86_500)
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
provider.run_action(:periodic)
expect(new_resource).to be_updated_by_last_action
end
it "should not run if the time stamp is new" do
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now)
- expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
provider.run_action(:periodic)
expect(new_resource).to_not be_updated_by_last_action
end
@@ -100,14 +100,14 @@ describe Chef::Provider::AptUpdate do
it "should run if the time stamp is old" do
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 500)
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
provider.run_action(:periodic)
expect(new_resource).to be_updated_by_last_action
end
it "should not run if the time stamp is new" do
expect(File).to receive(:mtime).with("#{stamp_dir}/update-success-stamp").and_return(Time.now - 300)
- expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything())
+ expect_any_instance_of(Chef::Provider::Execute).not_to receive(:shell_out_compacted!).with(*apt_update_cmd, anything)
provider.run_action(:periodic)
expect(new_resource).to_not be_updated_by_last_action
end
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 6bfc18c359..4cd8a140af 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -401,7 +401,7 @@ describe Chef::Provider::Cron do
@provider.current_resource = @current_resource
end
- [:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home].each do |property|
+ %i{minute hour day month weekday command mailto path shell home}.each do |property|
it "should return true if #{property} doesn't match" do
@new_resource.send(property, "something_else")
expect(@provider.cron_different?).to eql(true)
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 6edf0963b8..cf6ab88eb4 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -36,7 +36,8 @@ describe Chef::Provider::DscResource do
it "raises a ProviderNotFound exception" do
expect(provider).not_to receive(:meta_configuration)
expect { provider.run_action(:run) }.to raise_error(
- Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/)
+ Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/
+ )
end
end
@@ -52,7 +53,8 @@ describe Chef::Provider::DscResource do
it "raises an exception" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
expect { provider.run_action(:run) }.to raise_error(
- Chef::Exceptions::ProviderNotFound, /Disabled/)
+ Chef::Exceptions::ProviderNotFound, /Disabled/
+ )
end
end
context "and the WMF is 5 RTM or newer" do
@@ -157,7 +159,8 @@ describe Chef::Provider::DscResource do
[
{ "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
{ "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
- ] end
+ ]
+ end
it "raises MultipleDscResourcesFound" do
expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::MultipleDscResourcesFound)
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index c880683a0f..a1115150e8 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -99,7 +99,7 @@ describe Chef::Provider::DscScript do
it "should noop if neither code or command are provided" do
allow(provider).to receive(:load_current_resource)
generator = double("Chef::Util::DSC::ConfigurationGenerator")
- expect(generator).to receive(:configuration_document_from_script_code).with("", anything(), anything(), anything())
+ expect(generator).to receive(:configuration_document_from_script_code).with("", anything, anything, anything)
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
provider.send(:generate_configuration_document, "tmp", nil)
end
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index 94322a89f9..910470b1b7 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -121,7 +121,7 @@ describe Chef::Provider::Group::Dscl do
500
)
EOS
- )
+ )
end
it "should run safe_dscl with search /Groups gid" do
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index 84997a258d..79586eac71 100644
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -155,7 +155,7 @@ describe Chef::Provider::Group::Groupadd do
end
end
- [:add_member, :remove_member, :set_members].each do |m|
+ %i{add_member remove_member set_members}.each do |m|
it "should raise an error when calling #{m}" do
expect { provider.send(m, [ ]) }.to raise_error(Chef::Exceptions::Group, "you must override #{m} in #{provider}")
end
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index bacb711d1b..d7fdfb299c 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -39,8 +39,7 @@ describe Chef::Provider::User do
@pw_group = double("Struct::Group",
name: "wheel",
gid: 20,
- mem: %w{root aj}
- )
+ mem: %w{root aj})
allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group)
end
@@ -85,7 +84,7 @@ describe Chef::Provider::User do
end
describe "when determining if the system is already in the target state" do
- [ :gid, :members ].each do |property|
+ %i{gid members}.each do |property|
it "should return true if #{property} doesn't match" do
allow(@current_resource).to receive(property).and_return("looooooooooooooooooool")
expect(@provider.compare_group).to be_truthy
diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb
index 8b5edc68b5..53b56b4960 100644
--- a/spec/unit/provider/launchd_spec.rb
+++ b/spec/unit/provider/launchd_spec.rb
@@ -89,7 +89,8 @@ describe Chef::Provider::Launchd do
"Weekday" => 7,
},
"TimeOut" => 300,
- } end
+ }
+ end
before(:each) do
provider.load_current_resource
@@ -197,9 +198,11 @@ describe Chef::Provider::Launchd do
describe "and the file has been updated" do
before(:each) do
allow(provider).to receive(
- :manage_plist).with(:create).and_return(true)
+ :manage_plist
+ ).with(:create).and_return(true)
allow(provider).to receive(
- :manage_service).with(:restart).and_return(true)
+ :manage_service
+ ).with(:restart).and_return(true)
end
it "should call manage_service with a :restart action" do
@@ -215,9 +218,11 @@ describe Chef::Provider::Launchd do
describe "and the file has not been updated" do
before(:each) do
allow(provider).to receive(
- :manage_plist).with(:create).and_return(nil)
+ :manage_plist
+ ).with(:create).and_return(nil)
allow(provider).to receive(
- :manage_service).with(:enable).and_return(true)
+ :manage_service
+ ).with(:enable).and_return(true)
end
it "should call manage_service with a :enable action" do
@@ -236,9 +241,11 @@ describe Chef::Provider::Launchd do
before(:each) do
allow(File).to receive(:exists?).and_return(true)
allow(provider).to receive(
- :manage_service).with(:disable).and_return(true)
+ :manage_service
+ ).with(:disable).and_return(true)
allow(provider).to receive(
- :manage_plist).with(:delete).and_return(true)
+ :manage_plist
+ ).with(:delete).and_return(true)
end
it "should call manage_service with a :disable action" do
@@ -255,7 +262,8 @@ describe Chef::Provider::Launchd do
before(:each) do
allow(File).to receive(:exists?).and_return(false)
allow(provider).to receive(
- :manage_plist).with(:delete).and_return(true)
+ :manage_plist
+ ).with(:delete).and_return(true)
end
it "works with action :delete" do
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 027b318c7e..fff2c1ffa8 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -259,7 +259,8 @@ describe Chef::Resource::Link do
allow(stat).to receive(:gid).and_return(501)
allow(stat).to receive(:mode).and_return(0755)
allow(provider.file_class).to receive(:stat).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(stat)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(stat)
provider.load_current_resource
end
@@ -267,7 +268,8 @@ describe Chef::Resource::Link do
shared_context "delete link to directories on Windows" do
before do
allow(::File).to receive(:directory?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(true)
end
it "invokes Dir.delete method to delete the link" do
@@ -280,7 +282,8 @@ describe Chef::Resource::Link do
shared_context "delete link to directories on Linux" do
before do
allow(::File).to receive(:directory?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(true)
end
it "invokes File.delete method to delete the link" do
@@ -293,7 +296,8 @@ describe Chef::Resource::Link do
shared_context "delete link to files" do
before do
allow(::File).to receive(:directory?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(false)
end
it "invokes File.delete method to delete the link" do
@@ -306,9 +310,11 @@ describe Chef::Resource::Link do
shared_context "soft links prerequisites" do
before(:each) do
allow(provider.file_class).to receive(:symlink?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(true)
allow(provider.file_class).to receive(:readlink).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return("#{CHEF_SPEC_DATA}/fofile")
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return("#{CHEF_SPEC_DATA}/fofile")
end
end
@@ -327,15 +333,19 @@ describe Chef::Resource::Link do
allow(stat).to receive(:mode).and_return(0644)
allow(provider.file_class).to receive(:symlink?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(false)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(false)
allow(File).to receive(:exists?).with(
- "#{CHEF_SPEC_DATA}/fofile-link").and_return(true)
+ "#{CHEF_SPEC_DATA}/fofile-link"
+ ).and_return(true)
allow(File).to receive(:exists?).with(
- "#{CHEF_SPEC_DATA}/fofile").and_return(true)
+ "#{CHEF_SPEC_DATA}/fofile"
+ ).and_return(true)
allow(provider.file_class).to receive(:stat).with(
- "#{CHEF_SPEC_DATA}/fofile").and_return(stat)
+ "#{CHEF_SPEC_DATA}/fofile"
+ ).and_return(stat)
end
end
@@ -346,7 +356,8 @@ describe Chef::Resource::Link do
before(:each) do
allow(Chef::Resource::Link).to receive(:new).with(
- provider.new_resource.name).and_return(resource_link)
+ provider.new_resource.name
+ ).and_return(resource_link)
allow(resource_link).to receive(:verify_links_supported!)
allow(Chef::Platform).to receive(:windows?).and_return(true)
end
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 2353d992d0..5e1ffbf208 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -67,23 +67,23 @@ describe Chef::Provider::Mount::Mount do
describe "when dealing with network mounts" do
{ "nfs" => "nfsserver:/vol/path",
"cifs" => "//cifsserver/share" }.each do |type, fs_spec|
- it "should detect network fs_spec (#{type})" do
- @new_resource.device fs_spec
- expect(@provider.network_device?).to be_truthy
+ it "should detect network fs_spec (#{type})" do
+ @new_resource.device fs_spec
+ expect(@provider.network_device?).to be_truthy
+ end
+
+ 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"))
+ @provider.load_current_resource
+ expect(@provider.current_resource.mounted).to be_truthy
+ end
end
-
- 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"))
- @provider.load_current_resource
- expect(@provider.current_resource.mounted).to be_truthy
- end
- end
end
it "should raise an error if the mount device does not exist" do
allow(::File).to receive(:exists?).with("/dev/sdz1").and_return false
- expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
+ expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
end
it "should not call mountable? with load_current_resource - CHEF-1565" do
@@ -100,36 +100,36 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
expect(@provider).to receive(:shell_out_compacted).with("/sbin/findfs", "UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
expect(::File).to receive(:exists?).with("").and_return(false)
- expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
+ expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
end
it "should raise an error if the mount point does not exist" do
allow(::File).to receive(:exists?).with("/tmp/foo").and_return false
- expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
+ expect { @provider.load_current_resource; @provider.mountable? }.to raise_error(Chef::Exceptions::Mount)
end
%w{tmpfs fuse cgroup vboxsf zfs}.each do |fstype|
it "does not expect the device to exist for #{fstype}" do
@new_resource.fstype(fstype)
@new_resource.device("whatever")
- expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error
+ expect { @provider.load_current_resource; @provider.mountable? }.not_to raise_error
end
end
it "does not expect the device to exist if it's none" do
@new_resource.device("none")
- expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error
+ expect { @provider.load_current_resource; @provider.mountable? }.not_to raise_error
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"))
- @provider.load_current_resource()
+ @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"))
- @provider.load_current_resource()
+ @provider.load_current_resource
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -141,7 +141,7 @@ describe Chef::Provider::Mount::Mount do
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"))
- @provider.load_current_resource()
+ @provider.load_current_resource
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -155,7 +155,7 @@ describe Chef::Provider::Mount::Mount do
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"))
- @provider.load_current_resource()
+ @provider.load_current_resource
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -164,7 +164,7 @@ describe Chef::Provider::Mount::Mount do
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))
- @provider.load_current_resource()
+ @provider.load_current_resource
expect(@provider.current_resource.mounted).to be_truthy
end
@@ -173,13 +173,13 @@ describe Chef::Provider::Mount::Mount do
mount << "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(stdout: mount))
- @provider.load_current_resource()
+ @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"))
- @provider.load_current_resource()
+ @provider.load_current_resource
expect(@provider.current_resource.mounted).to be_falsey
end
@@ -297,14 +297,14 @@ describe Chef::Provider::Mount::Mount do
describe "mount_fs" do
it "should mount the filesystem if it is not mounted" do
expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", "ext3", "-o", "defaults", "/dev/sdz1", "/tmp/foo")
- @provider.mount_fs()
+ @provider.mount_fs
end
it "should mount the filesystem with options if options were passed" do
options = "rw,noexec,noauto"
@new_resource.options(%w{rw noexec noauto})
expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", "ext3", "-o", "rw,noexec,noauto", "/dev/sdz1", "/tmp/foo")
- @provider.mount_fs()
+ @provider.mount_fs
end
it "should mount the filesystem specified by uuid", :not_supported_on_solaris do
@@ -315,13 +315,13 @@ describe Chef::Provider::Mount::Mount do
@stdout_mock = double("stdout mock")
allow(@stdout_mock).to receive(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
expect(@provider).to receive(:shell_out_compacted!).with("mount", "-t", @new_resource.fstype, "-o", "defaults", "-U", @new_resource.device, @new_resource.mount_point).and_return(@stdout_mock)
- @provider.mount_fs()
+ @provider.mount_fs
end
it "should not mount the filesystem if it is mounted" do
allow(@current_resource).to receive(:mounted).and_return(true)
expect(@provider).not_to receive(:shell_out!)
- @provider.mount_fs()
+ @provider.mount_fs
end
end
@@ -330,13 +330,13 @@ describe Chef::Provider::Mount::Mount do
it "should umount the filesystem if it is mounted" do
@current_resource.mounted(true)
expect(@provider).to receive(:shell_out!).with("umount", "/tmp/foo")
- @provider.umount_fs()
+ @provider.umount_fs
end
it "should not umount the filesystem if it is not mounted" do
@current_resource.mounted(false)
expect(@provider).not_to receive(:shell_out!)
- @provider.umount_fs()
+ @provider.umount_fs
end
end
@@ -363,7 +363,7 @@ describe Chef::Provider::Mount::Mount do
expect(@provider).to receive(:umount_fs)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:mount_fs)
- @provider.remount_fs()
+ @provider.remount_fs
end
it "should not try to remount at all if mounted is false" do
@@ -371,7 +371,7 @@ describe Chef::Provider::Mount::Mount do
expect(@provider).not_to receive(:shell_out!)
expect(@provider).not_to receive(:umount_fs)
expect(@provider).not_to receive(:mount_fs)
- @provider.remount_fs()
+ @provider.remount_fs
end
end
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 4e73bc77b5..006eb690cb 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -103,7 +103,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
describe "#define_resource_requirements" do
before do
# we're not testing the actual actions so stub them all out
- [:mount_fs, :umount_fs, :remount_fs, :enable_fs, :disable_fs].each { |m| allow(provider).to receive(m) }
+ %i{mount_fs umount_fs remount_fs enable_fs disable_fs}.each { |m| allow(provider).to receive(m) }
end
it "run_action(:mount) should raise an error if the device does not exist" do
@@ -350,7 +350,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true)
expect(File).to receive(:readlink).with(device).at_least(:once).and_return(target)
- provider.load_current_resource()
+ provider.load_current_resource
end
it "should set mounted true if the symlink target of the device is found in the mounts list" do
@@ -387,7 +387,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true)
expect(File).to receive(:readlink).with(device).at_least(:once).and_return(target)
- provider.load_current_resource()
+ provider.load_current_resource
end
it "should set mounted true if the symlink target of the device is found in the mounts list" do
@@ -411,7 +411,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
EOF
end
it "should set mounted true" do
- provider.load_current_resource()
+ provider.load_current_resource
expect(provider.current_resource.mounted).to be_truthy
end
end
@@ -424,7 +424,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
EOF
end
it "should set mounted false" do
- provider.load_current_resource()
+ provider.load_current_resource
expect(provider.current_resource.mounted).to be_falsey
end
end
@@ -436,7 +436,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
EOF
end
it "should set mounted false" do
- provider.load_current_resource()
+ provider.load_current_resource
expect(provider.current_resource.mounted).to be_falsey
end
end
@@ -448,7 +448,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
EOF
end
it "should set mounted false" do
- provider.load_current_resource()
+ provider.load_current_resource
expect(provider.current_resource.mounted).to be_falsey
end
end
@@ -539,28 +539,28 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
describe "mount_fs" do
it "should mount the filesystem" do
expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, device, mountpoint)
- provider.mount_fs()
+ provider.mount_fs
end
it "should mount the filesystem with options if options were passed" do
options = "logging,noatime,largefiles,nosuid,rw,quota"
new_resource.options(options.split(/,/))
expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, "-o", options, device, mountpoint)
- provider.mount_fs()
+ provider.mount_fs
end
it "should delete the 'noauto' magic option" do
options = "rw,noauto"
new_resource.options(%w{rw noauto})
expect(provider).to receive(:shell_out_compacted!).with("mount", "-F", fstype, "-o", "rw", device, mountpoint)
- provider.mount_fs()
+ provider.mount_fs
end
end
describe "umount_fs" do
it "should umount the filesystem if it is mounted" do
expect(provider).to receive(:shell_out_compacted!).with("umount", mountpoint)
- provider.umount_fs()
+ provider.umount_fs
end
end
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index 8f99ad6817..017041bc60 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -132,7 +132,7 @@ describe Chef::Provider::OsxProfile do
provider.load_current_resource
expect(
provider.instance_variable_get(:@new_profile_identifier)
- ).to eql(test_profile["PayloadIdentifier"])
+ ).to eql(test_profile["PayloadIdentifier"])
end
it "should install when not installed" do
@@ -167,7 +167,7 @@ describe Chef::Provider::OsxProfile do
provider.load_current_resource
allow(provider).to receive(:write_profile_to_disk).and_return(profile_path)
expect(provider).to receive(:shell_out_compacted).with("/usr/bin/profiles", "-I", "-F", profile_path).and_return(shell_out_success)
- provider.action_install()
+ provider.action_install
end
it "should fail if there is no identifier inside the profile" do
@@ -228,16 +228,14 @@ describe Chef::Provider::OsxProfile do
new_resource.profile_name "com.testprofile.screensaver"
new_resource.action(:remove)
provider.load_current_resource
- expect(provider.instance_variable_get(:@new_profile_identifier)
- ).to eql(new_resource.profile_name)
+ expect(provider.instance_variable_get(:@new_profile_identifier)).to eql(new_resource.profile_name)
end
it "should use specified identifier" do
new_resource.identifier "com.testprofile.screensaver"
new_resource.action(:remove)
provider.load_current_resource
- expect(provider.instance_variable_get(:@new_profile_identifier)
- ).to eql(new_resource.identifier)
+ expect(provider.instance_variable_get(:@new_profile_identifier)).to eql(new_resource.identifier)
end
it "should work with spaces in the identifier" do
@@ -251,7 +249,7 @@ describe Chef::Provider::OsxProfile do
new_resource.action(:remove)
provider.load_current_resource
expect(provider).to receive(:shell_out_compacted).with("/usr/bin/profiles", "-R", "-p", new_resource.identifier).and_return(shell_out_success)
- provider.action_remove()
+ provider.action_remove
end
end
end
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index bfc78cbb7f..b2c051d2f1 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -511,8 +511,8 @@ describe Chef::Provider::Package::Apt do
allow(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "showhold", timeout: 900
).and_return(instance_double(
- Mixlib::ShellOut, stdout: "irssi")
- )
+ Mixlib::ShellOut, stdout: "irssi"
+ ))
expect(logger).to receive(:trace).with("#{@provider.new_resource} is already locked")
@provider.action_lock
@@ -532,8 +532,8 @@ describe Chef::Provider::Package::Apt do
allow(@provider).to receive(:shell_out_compacted!).with(
"apt-mark", "showhold", timeout: 900
).and_return(instance_double(
- Mixlib::ShellOut, stdout: "")
- )
+ Mixlib::ShellOut, stdout: ""
+ ))
expect(logger).to receive(:trace).with("#{@provider.new_resource} is already unlocked")
@provider.action_unlock
diff --git a/spec/unit/provider/package/bff_spec.rb b/spec/unit/provider/package/bff_spec.rb
index 7606092762..b428ec0a72 100644
--- a/spec/unit/provider/package/bff_spec.rb
+++ b/spec/unit/provider/package/bff_spec.rb
@@ -81,7 +81,7 @@ describe Chef::Provider::Package::Bff do
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})
+ expect(logger).to receive(:warn).once.with(/bff package by product name/)
@provider.load_current_resource
expect(@provider.current_resource.package_name).to eq("samba.base")
diff --git a/spec/unit/provider/package/cab_spec.rb b/spec/unit/provider/package/cab_spec.rb
index 2ed40566f4..0ffbcd4a51 100644
--- a/spec/unit/provider/package/cab_spec.rb
+++ b/spec/unit/provider/package/cab_spec.rb
@@ -260,7 +260,7 @@ describe Chef::Provider::Package::Cab do
end
before do
- new_resource.source = "#{ENV['TEMP']}/test6.1-kb2664825-v3-x64.cab"
+ new_resource.source = "#{ENV["TEMP"]}/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)
end
diff --git a/spec/unit/provider/package/msu_spec.rb b/spec/unit/provider/package/msu_spec.rb
index b2f0b22963..905d48649f 100644
--- a/spec/unit/provider/package/msu_spec.rb
+++ b/spec/unit/provider/package/msu_spec.rb
@@ -243,7 +243,7 @@ describe Chef::Provider::Package::Msu, :windows_only do
describe "#extract_msu_contents" do
it "extracts the msu contents by using mixlib shellout" do
- expect(provider).to receive(:shell_out!).with("#{ENV['SYSTEMROOT']}\\system32\\expand.exe -f:* msu_file destination")
+ expect(provider).to receive(:shell_out!).with("#{ENV["SYSTEMROOT"]}\\system32\\expand.exe -f:* msu_file destination")
provider.extract_msu_contents("msu_file", "destination")
end
end
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 01d6571f65..c8de4b7471 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -45,15 +45,16 @@ 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
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"))
+ expect(provider).to receive(:shell_out_compacted!).with("pkg_info", "-I", name, anything).and_return(
+ 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 }
@@ -69,8 +70,9 @@ 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"))
+ 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")
+ )
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
end
end
@@ -83,9 +85,10 @@ 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", "-I", name, anything()).and_return(
- instance_double("shellout", stdout: "#{name}-#{version}-#{flavor}\n"))
+ 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")
+ )
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 }
@@ -98,8 +101,9 @@ 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"))
+ 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")
+ )
new_resource.version("#{version}-#{flavor_b}")
expect(provider).to receive(:shell_out_compacted!).with(
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index cd85e1b3d9..726420fe23 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -75,7 +75,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
end
it "should lookup the candidate_version if the variable is not already set (pkgin separated by spaces)" do
- search = double()
+ 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")
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
end
it "should lookup the candidate_version if the variable is not already set (pkgin separated by semicolons)" do
- search = double()
+ 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")
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index 4f6a6121bd..6fa1747b03 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -117,7 +117,7 @@ describe Chef::Provider::Package::Windows::Exe do
context "no version given and one package installed with unquoted uninstall string" do
it "removes installed package and quotes uninstall string" do
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%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.remove_package
end
end
@@ -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(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, timeout: 300, returns: [0])
provider.remove_package
end
end
@@ -148,15 +148,15 @@ describe Chef::Provider::Package::Windows::Exe do
context "version given and installed" do
it "removes given version" do
new_resource.version("v2")
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir2\/uninst_file2\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir2/uninst_file2\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.remove_package
end
end
context "no version given" do
it "removes both versions" do
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir1\/uninst_file1\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir2\/uninst_file2\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir1/uninst_file1\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir2/uninst_file2\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.remove_package
end
end
@@ -167,7 +167,7 @@ describe Chef::Provider::Package::Windows::Exe do
let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :nsis, uninstall_entry) }
it "calls installer with the correct flags" do
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.install_package
end
end
@@ -176,7 +176,7 @@ describe Chef::Provider::Package::Windows::Exe do
let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :installshield, uninstall_entry) }
it "calls installer with the correct flags" do
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/s \/sms & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /s /sms & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.install_package
end
end
@@ -185,7 +185,7 @@ describe Chef::Provider::Package::Windows::Exe do
let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :inno, uninstall_entry) }
it "calls installer with the correct flags" do
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/VERYSILENT \/SUPPRESSMSGBOXES \/NORESTART & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.install_package
end
end
@@ -194,7 +194,7 @@ describe Chef::Provider::Package::Windows::Exe do
let(:provider) { Chef::Provider::Package::Windows::Exe.new(new_resource, :wise, uninstall_entry) }
it "calls installer with the correct flags" do
- expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"#{Regexp.quote(new_resource.source)}\" \/s & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"#{Regexp.quote(new_resource.source)}\" /s & exit %%%%ERRORLEVEL%%%%}, kind_of(Hash))
provider.install_package
end
end
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index 0e939610db..d2902e1bb1 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -104,14 +104,14 @@ describe Chef::Provider::Package::Windows::MSI do
describe "install_package" do
it "calls msiexec /qn /i" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/i \"#{Regexp.quote(new_resource.source)}\"/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /qn /i \"#{Regexp.quote(new_resource.source)}\"}, kind_of(Hash))
provider.install_package
end
end
describe "remove_package" do
it "calls msiexec /qn /x" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/x \"#{Regexp.quote(new_resource.source)}\"/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /qn /x \"#{Regexp.quote(new_resource.source)}\"}, kind_of(Hash))
provider.remove_package
end
@@ -121,7 +121,7 @@ describe Chef::Provider::Package::Windows::MSI do
end
it "removes installed package" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /q}, kind_of(Hash))
provider.remove_package
end
@@ -140,8 +140,8 @@ describe Chef::Provider::Package::Windows::MSI do
end
it "removes both installed package" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash))
- expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid2} \/q/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /q}, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid2} /q}, kind_of(Hash))
provider.remove_package
end
end
@@ -150,7 +150,7 @@ describe Chef::Provider::Package::Windows::MSI do
before { new_resource.options("/Q") }
it "does not duplicate quiet switch" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/Q/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /Q}, kind_of(Hash))
provider.remove_package
end
end
@@ -159,7 +159,7 @@ describe Chef::Provider::Package::Windows::MSI do
before { new_resource.options("/qn") }
it "does not duplicate quiet switch" do
- expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/qn/, kind_of(Hash))
+ expect(provider).to receive(:shell_out!).with(%r{msiexec /x {guid} /qn}, kind_of(Hash))
provider.remove_package
end
end
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index 6b85013f3d..2fafb3bd0e 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -436,7 +436,8 @@ describe Chef::Provider::Package::Windows, :windows_only do
it "raises the checksum mismatch exception" do
expect { provider.send(:validate_content!) }.to raise_error(
- Chef::Exceptions::ChecksumMismatch)
+ Chef::Exceptions::ChecksumMismatch
+ )
end
end
end
diff --git a/spec/unit/provider/package/yum/yum_cache_spec.rb b/spec/unit/provider/package/yum/yum_cache_spec.rb
index 6b2a617ac8..9867c31c37 100644
--- a/spec/unit/provider/package/yum/yum_cache_spec.rb
+++ b/spec/unit/provider/package/yum/yum_cache_spec.rb
@@ -60,7 +60,7 @@ describe Chef::Provider::Package::Yum::YumCache do
expect( yum_cache.version_available?("foo", "1.2.3", "x86_64") ).to be true
end
- [ :refresh, :reload, :reload_installed, :reload_provides, :reset, :reset_installed ].each do |method|
+ %i{refresh reload reload_installed reload_provides reset reset_installed}.each do |method|
it "restarts the python helper when #{method} is called" do
expect( python_helper ).to receive(:restart)
yum_cache.send(method)
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index 61c415f88d..cca0f34067 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -22,9 +22,9 @@ describe Chef::Provider::PowershellScript, "action_run" do
let(:powershell_version) { nil }
let(:node) do
node = Chef::Node.new
- node.default["kernel"] = Hash.new
+ node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
- if ! powershell_version.nil?
+ unless powershell_version.nil?
node.default[:languages] = { powershell: { version: powershell_version } }
end
node
@@ -107,19 +107,19 @@ describe Chef::Provider::PowershellScript, "action_run" do
"3.6" => "Bypass",
"4.0" => "Bypass",
"5.0" => "Bypass" }.each do |version_policy|
- let(:powershell_version) { version_policy[0].to_f }
- context "when running PowerShell version #{version_policy[0]}" do
let(:powershell_version) { version_policy[0].to_f }
-
- it "sets default -ExecutionPolicy flag to '#{version_policy[1]}'" do
- expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase)
- end
- it "sets user defined -ExecutionPolicy flag to 'RemoteSigned'" do
- set_user_defined_flag
- expect(execution_policy_flag.downcase).to eq("RemoteSigned".downcase)
+ context "when running PowerShell version #{version_policy[0]}" do
+ let(:powershell_version) { version_policy[0].to_f }
+
+ it "sets default -ExecutionPolicy flag to '#{version_policy[1]}'" do
+ expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase)
+ end
+ it "sets user defined -ExecutionPolicy flag to 'RemoteSigned'" do
+ set_user_defined_flag
+ expect(execution_policy_flag.downcase).to eq("RemoteSigned".downcase)
+ end
end
end
- end
end
end
end
diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb
index 9a7dd9996e..2df2c917f9 100644
--- a/spec/unit/provider/registry_key_spec.rb
+++ b/spec/unit/provider/registry_key_spec.rb
@@ -322,7 +322,7 @@ describe Chef::Provider::RegistryKey do
expect(@double_registry).to receive(:get_values).with(keyname).and_return(
[
{ name: "one", type: :string, data: "initial value" },
- { name: "two", type: :dword, data: 9001 }
+ { name: "two", type: :dword, data: 9001 },
]
)
end
diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb
index 67311aa6f7..ad5223a04f 100644
--- a/spec/unit/provider/route_spec.rb
+++ b/spec/unit/provider/route_spec.rb
@@ -125,7 +125,7 @@ describe Chef::Provider::Route do
@resource_add.action(:add)
@provider.run_action(:add)
expect(route_file.string.split("\n").size).to eq(1)
- expect(route_file.string).to match(/^192\.168\.1\.0\/24 via 192\.168\.0\.1$/)
+ expect(route_file.string).to match(%r{^192\.168\.1\.0/24 via 192\.168\.0\.1$})
end
end
@@ -150,12 +150,12 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "generate_command for action_add" do
it "should include a netmask when a one is specified" do
@new_resource.netmask("255.255.0.0")
- expect(@provider.generate_command(:add).join(" ")).to match(/\/\d{1,2}/)
+ expect(@provider.generate_command(:add).join(" ")).to match(%r{/\d{1,2}})
end
it "should not include a netmask when a one is specified" do
@new_resource.netmask(nil)
- expect(@provider.generate_command(:add).join(" ")).not_to match(/\/\d{1,2}/)
+ expect(@provider.generate_command(:add).join(" ")).not_to match(%r{/\d{1,2}})
end
it "should include ' via $gateway ' when a gateway is specified" do
@@ -176,12 +176,12 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "generate_command for action_delete" do
it "should include a netmask when a one is specified" do
@new_resource.netmask("255.255.0.0")
- expect(@provider.generate_command(:delete).join(" ")).to match(/\/\d{1,2}/)
+ expect(@provider.generate_command(:delete).join(" ")).to match(%r{/\d{1,2}})
end
it "should not include a netmask when a one is specified" do
@new_resource.netmask(nil)
- expect(@provider.generate_command(:delete).join(" ")).not_to match(/\/\d{1,2}/)
+ expect(@provider.generate_command(:delete).join(" ")).not_to match(%r{/\d{1,2}})
end
it "should include ' via $gateway ' when a gateway is specified" do
@@ -197,11 +197,11 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "config_file_contents for action_add" do
it "should include a netmask when a one is specified" do
@new_resource.netmask("255.255.0.0")
- expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(/\/\d{1,2}.*\n$/)
+ expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(%r{/\d{1,2}.*\n$})
end
it "should not include a netmask when a one is specified" do
- expect(@provider.config_file_contents(:add, target: @new_resource.target)).not_to match(/\/\d{1,2}.*\n$/)
+ expect(@provider.config_file_contents(:add, target: @new_resource.target)).not_to match(%r{/\d{1,2}.*\n$})
end
it "should include ' via $gateway ' when a gateway is specified" do
@@ -261,10 +261,10 @@ describe Chef::Provider::Route do
@provider.action = :add
@provider.generate_config
expect(route_file.string.split("\n").size).to eq(4)
- expect(route_file.string).to match(/^192\.168\.1\.0\/24 via 192\.168\.0\.1$/)
- expect(route_file.string).to match(/^192\.168\.2\.0\/24 via 192\.168\.0\.1$/)
- expect(route_file.string).to match(/^192\.168\.3\.0\/24 via 192\.168\.0\.1$/)
- expect(route_file.string).to match(/^192\.168\.4\.0\/24 via 192\.168\.0\.1$/)
+ expect(route_file.string).to match(%r{^192\.168\.1\.0/24 via 192\.168\.0\.1$})
+ expect(route_file.string).to match(%r{^192\.168\.2\.0/24 via 192\.168\.0\.1$})
+ expect(route_file.string).to match(%r{^192\.168\.3\.0/24 via 192\.168\.0\.1$})
+ expect(route_file.string).to match(%r{^192\.168\.4\.0/24 via 192\.168\.0\.1$})
end
end
end
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index faec7ff645..de2bb16a6a 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -181,7 +181,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should add chef to DAEMONS array" do
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)")
expect(@provider).to receive(:update_daemons).with(%w{network chef})
- @provider.enable_service()
+ @provider.enable_service
end
end
@@ -202,7 +202,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should remove chef from DAEMONS array" do
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)")
expect(@provider).to receive(:update_daemons).with(["network", "!chef"])
- @provider.disable_service()
+ @provider.disable_service
end
end
@@ -223,12 +223,12 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should call the start command if one is specified" do
@new_resource.start_command("/etc/rc.d/chef startyousillysally")
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
it "should call '/etc/rc.d/service_name start' if no start command is specified" do
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} start", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
end
@@ -249,12 +249,12 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/etc/rc.d/chef itoldyoutostop")
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/chef itoldyoutostop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
it "should call '/etc/rc.d/service_name stop' if no stop command is specified" do
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} stop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
end
@@ -276,20 +276,20 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should call 'restart' on the service_name if the resource supports it" do
@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()
+ @provider.restart_service
end
it "should call the restart_command if one has been specified" do
@new_resource.restart_command("/etc/rc.d/chef restartinafire")
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire", default_env: false)
- @provider.restart_service()
+ @provider.restart_service
end
it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do
expect(@provider).to receive(:stop_service)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:start_service)
- @provider.restart_service()
+ @provider.restart_service
end
end
@@ -311,13 +311,13 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should call 'reload' on the service if it supports it" do
@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()
+ @provider.reload_service
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/etc/rc.d/chef lollerpants")
expect(@provider).to receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
end
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 626abb10f7..5f89605b2e 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -89,7 +89,8 @@ describe Chef::Provider::Service::Debian do
"0" => [:stop, "20"],
"1" => [: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 d33b97d63d..4392786edc 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -261,7 +261,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{thing_#{new_resource.service_name}_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -273,7 +274,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{#{new_resource.service_name}_thing_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -285,7 +287,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{thing_#{new_resource.service_name}_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -297,7 +300,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{#{new_resource.service_name}_thing_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -445,12 +449,12 @@ describe Chef::Provider::Service::Freebsd do
it "should call the start command if one is specified" do
new_resource.start_command("/etc/rc.d/chef startyousillysally")
expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false)
- provider.start_service()
+ provider.start_service
end
it "should call '/usr/local/etc/rc.d/service_name faststart' if no start command is specified" do
expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart", default_env: false)
- provider.start_service()
+ provider.start_service
end
end
@@ -458,12 +462,12 @@ describe Chef::Provider::Service::Freebsd do
it "should call the stop command if one is specified" do
new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false)
- provider.stop_service()
+ provider.stop_service
end
it "should call '/usr/local/etc/rc.d/service_name faststop' if no stop command is specified" do
expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop", default_env: false)
- provider.stop_service()
+ provider.stop_service
end
end
@@ -471,19 +475,19 @@ describe Chef::Provider::Service::Freebsd do
it "should call 'restart' on the service_name if the resource supports it" do
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()
+ provider.restart_service
end
it "should call the restart_command if one has been specified" do
new_resource.restart_command("/etc/init.d/chef restartinafire")
expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire", default_env: false)
- provider.restart_service()
+ provider.restart_service
end
it "otherwise it should call stop and start" do
expect(provider).to receive(:stop_service)
expect(provider).to receive(:start_service)
- provider.restart_service()
+ provider.restart_service
end
end
end
@@ -550,21 +554,21 @@ describe Chef::Provider::Service::Freebsd do
allow(current_resource).to receive(:enabled).and_return(false)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"NO\"", "bar" ])
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""])
- provider.enable_service()
+ provider.enable_service
end
it "should not partial match an already enabled service" do
allow(current_resource).to receive(:enabled).and_return(false)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar" ])
expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar", "#{new_resource.service_name}_enable=\"YES\""])
- provider.enable_service()
+ provider.enable_service
end
it "should enable the service if it is not enabled and not already specified in the rc.conf file" do
allow(current_resource).to receive(:enabled).and_return(false)
expect(provider).to receive(:read_rc_conf).and_return(%w{foo bar})
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""])
- provider.enable_service()
+ provider.enable_service
end
it "should not enable the service if it is already enabled" do
@@ -577,7 +581,7 @@ describe Chef::Provider::Service::Freebsd do
allow(current_resource).to receive(:enabled).and_return(false)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar", "\# #{new_resource.service_name}_enable=\"YES\"", "\# #{new_resource.service_name}_enable=\"NO\""])
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""])
- provider.enable_service()
+ provider.enable_service
end
end
@@ -591,27 +595,27 @@ describe Chef::Provider::Service::Freebsd do
allow(current_resource).to receive(:enabled).and_return(true)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"YES\"", "bar" ])
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"NO\""])
- provider.disable_service()
+ provider.disable_service
end
it "should not disable an enabled service that partially matches" do
allow(current_resource).to receive(:enabled).and_return(true)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar" ])
expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar", "#{new_resource.service_name}_enable=\"NO\""])
- provider.disable_service()
+ provider.disable_service
end
it "should not disable the service if it is already disabled" do
allow(current_resource).to receive(:enabled).and_return(false)
expect(provider).not_to receive(:write_rc_conf)
- provider.disable_service()
+ provider.disable_service
end
it "should remove commented out versions of it being disabled or enabled" do
allow(current_resource).to receive(:enabled).and_return(true)
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar", "\# #{new_resource.service_name}_enable=\"YES\"", "\# #{new_resource.service_name}_enable=\"NO\""])
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"NO\""])
- provider.disable_service()
+ provider.disable_service
end
end
end
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index 6a928d849b..bc3d0b5c04 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -129,14 +129,14 @@ describe Chef::Provider::Service::Gentoo do
describe Chef::Provider::Service::Gentoo, "enable_service" do
it "should call rc-update add *service* default" do
expect(@provider).to receive(:shell_out!).with("/sbin/rc-update add chef default")
- @provider.enable_service()
+ @provider.enable_service
end
end
describe Chef::Provider::Service::Gentoo, "disable_service" do
it "should call rc-update del *service* default" do
expect(@provider).to receive(:shell_out!).with("/sbin/rc-update del chef default")
- @provider.disable_service()
+ @provider.disable_service
end
end
end
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index 38e9ad37de..b75d7c4981 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -165,12 +165,12 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
it "should call the start command if one is specified" do
@new_resource.start_command("/etc/init.d/chef startyousillysally")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef startyousillysally", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
it "should call '/etc/init.d/service_name start' if no start command is specified" do
expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} start", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
end
@@ -178,12 +178,12 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
it "should call '/etc/init.d/service_name stop' if no stop command is specified" do
expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} stop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
end
@@ -191,20 +191,20 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
it "should call 'restart' on the service_name if the resource supports it" do
@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()
+ @provider.restart_service
end
it "should call the restart_command if one has been specified" do
@new_resource.restart_command("/etc/init.d/chef restartinafire")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restartinafire", default_env: false)
- @provider.restart_service()
+ @provider.restart_service
end
it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do
expect(@provider).to receive(:stop_service)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:start_service)
- @provider.restart_service()
+ @provider.restart_service
end
end
@@ -212,13 +212,13 @@ describe Chef::Provider::Service::Init, "load_current_resource" do
it "should call 'reload' on the service if it supports it" do
@new_resource.supports({ reload: true })
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef reload", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/etc/init.d/chef lollerpants")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/chef lollerpants", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
end
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index fb1a29fa43..1b3344e77b 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -152,12 +152,12 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
it "should call the start command if one is specified" do
@new_resource.start_command("/usr/sbin/invoke-rc.d chef startyousillysally")
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef startyousillysally", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
it "should call '/usr/sbin/invoke-rc.d service_name start' if no start command is specified" do
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
end
@@ -165,12 +165,12 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/usr/sbin/invoke-rc.d chef itoldyoutostop")
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
it "should call '/usr/sbin/invoke-rc.d service_name stop' if no stop command is specified" do
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
end
@@ -178,20 +178,20 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
it "should call 'restart' on the service_name if the resource supports it" do
@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()
+ @provider.restart_service
end
it "should call the restart_command if one has been specified" do
@new_resource.restart_command("/usr/sbin/invoke-rc.d chef restartinafire")
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire", default_env: false)
- @provider.restart_service()
+ @provider.restart_service
end
it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do
expect(@provider).to receive(:stop_service)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:start_service)
- @provider.restart_service()
+ @provider.restart_service
end
end
@@ -199,13 +199,13 @@ describe Chef::Provider::Service::Invokercd, "load_current_resource" do
it "should call 'reload' on the service if it supports it" do
@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()
+ @provider.reload_service
end
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/usr/sbin/invoke-rc.d chef lollerpants")
expect(@provider).to receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef lollerpants", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
end
end
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index 913fddc1cf..dfa491fc38 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -178,7 +178,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{thing_#{provider.builtin_service_enable_variable_name}="YES"},
%Q{#{provider.builtin_service_enable_variable_name}="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -190,7 +191,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{#{provider.builtin_service_enable_variable_name}_thing="YES"},
(provider.builtin_service_enable_variable_name).to_s,
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -202,7 +204,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{thing_#{provider.builtin_service_enable_variable_name}="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -214,7 +217,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{#{provider.builtin_service_enable_variable_name}_thing="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -286,12 +290,12 @@ describe Chef::Provider::Service::Openbsd do
it "should call the start command if one is specified" do
new_resource.start_command("/etc/rc.d/chef startyousillysally")
expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally", default_env: false)
- provider.start_service()
+ provider.start_service
end
it "should call '/usr/local/etc/rc.d/service_name start' if no start command is specified" do
expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} start", default_env: false)
- provider.start_service()
+ provider.start_service
end
end
@@ -299,12 +303,12 @@ describe Chef::Provider::Service::Openbsd do
it "should call the stop command if one is specified" do
new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop", default_env: false)
- provider.stop_service()
+ provider.stop_service
end
it "should call '/usr/local/etc/rc.d/service_name stop' if no stop command is specified" do
expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} stop", default_env: false)
- provider.stop_service()
+ provider.stop_service
end
end
@@ -313,20 +317,20 @@ describe Chef::Provider::Service::Openbsd do
let(:supports) { { restart: true } }
it "should call 'restart' on the service_name if the resource supports it" do
expect(provider).to receive(:shell_out!).with("/etc/rc.d/#{new_resource.service_name} restart", default_env: false)
- provider.restart_service()
+ provider.restart_service
end
end
it "should call the restart_command if one has been specified" do
new_resource.restart_command("/etc/init.d/chef restartinafire")
expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire", default_env: false)
- provider.restart_service()
+ provider.restart_service
end
it "otherwise it should call stop and start" do
expect(provider).to receive(:stop_service)
expect(provider).to receive(:start_service)
- provider.restart_service()
+ provider.restart_service
end
end
end
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 2a0ebea1dc..2546f9cef7 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
it "should call the start command if one is specified" do
@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()
+ @provider.start_service
end
it "should raise an exception if no start command is specified" do
@@ -122,7 +122,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
it "should call the stop command if one is specified" do
@new_resource.stop_command("/etc/init.d/themadness stop")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/themadness stop", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
it "should raise an exception if no stop command is specified" do
@@ -136,7 +136,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
it "should call the restart command if one has been specified" do
@new_resource.restart_command("/etc/init.d/foo restart")
expect(@provider).to receive(:shell_out!).with("/etc/init.d/foo restart", default_env: false)
- @provider.restart_service()
+ @provider.restart_service
end
it "should raise an exception if the resource doesn't support restart, no restart command is provided, and no stop command is provided" do
@@ -149,7 +149,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
expect(@provider).to receive(:stop_service)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:start_service)
- @provider.restart_service()
+ @provider.restart_service
end
end
@@ -163,7 +163,7 @@ describe Chef::Provider::Service::Simple, "load_current_resource" do
it "should should run the user specified reload command if one is specified" do
@new_resource.reload_command("kill -9 1")
expect(@provider).to receive(:shell_out!).with("kill -9 1", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
end
end
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 365201cb38..572246a807 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -242,7 +242,7 @@ describe Chef::Provider::Service::Upstart do
allow(@current_resource).to receive(:enabled).and_return(false)
expect(@file).to receive(:search_file_replace)
expect(@file).to receive(:write_file)
- @provider.enable_service()
+ @provider.enable_service
end
it "should disable the service if it is enabled" do
@@ -251,7 +251,7 @@ describe Chef::Provider::Service::Upstart do
allow(@current_resource).to receive(:enabled).and_return(true)
expect(@file).to receive(:search_file_replace)
expect(@file).to receive(:write_file)
- @provider.disable_service()
+ @provider.disable_service
end
end
@@ -268,19 +268,19 @@ describe Chef::Provider::Service::Upstart do
@provider.upstart_service_running = false
@new_resource.start_command("/sbin/rsyslog startyousillysally")
expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog startyousillysally", default_env: false)
- @provider.start_service()
+ @provider.start_service
end
it "should call '/sbin/start service_name' if no start command is specified" do
@provider.upstart_service_running = false
expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
- @provider.start_service()
+ @provider.start_service
end
it "should not call '/sbin/start service_name' if it is already running" do
@provider.upstart_service_running = true
expect(@provider).not_to receive(:shell_out!)
- @provider.start_service()
+ @provider.start_service
end
it "should pass parameters to the start command if they are provided" do
@@ -289,14 +289,14 @@ describe Chef::Provider::Service::Upstart do
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
expect(@provider).to receive(:shell_out!).with("/sbin/start rsyslog OSD_ID=2", default_env: false).and_return(shell_out_success)
- @provider.start_service()
+ @provider.start_service
end
it "should call the restart command if one is specified" do
allow(@current_resource).to receive(:running).and_return(true)
@new_resource.restart_command("/sbin/rsyslog restartyousillysally")
expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog restartyousillysally", default_env: false)
- @provider.restart_service()
+ @provider.restart_service
end
it "should call start/sleep/stop if no restart command is specified" do
@@ -304,47 +304,47 @@ describe Chef::Provider::Service::Upstart do
expect(@provider).to receive(:stop_service)
expect(@provider).to receive(:sleep).with(1)
expect(@provider).to receive(:start_service)
- @provider.restart_service()
+ @provider.restart_service
end
it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
@provider.upstart_service_running = false
allow(@current_resource).to receive(:running).and_return(false)
expect(@provider).to receive(:shell_out!).with("/sbin/start #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
- @provider.restart_service()
+ @provider.restart_service
end
it "should call the reload command if one is specified" do
allow(@current_resource).to receive(:running).and_return(true)
@new_resource.reload_command("/sbin/rsyslog reloadyousillysally")
expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally", default_env: false)
- @provider.reload_service()
+ @provider.reload_service
end
it "should call '/sbin/reload service_name' if no reload command is specified" do
allow(@current_resource).to receive(:running).and_return(true)
expect(@provider).to receive(:shell_out!).with("/sbin/reload #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
- @provider.reload_service()
+ @provider.reload_service
end
it "should call the stop command if one is specified" do
@provider.upstart_service_running = true
@new_resource.stop_command("/sbin/rsyslog stopyousillysally")
expect(@provider).to receive(:shell_out!).with("/sbin/rsyslog stopyousillysally", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
end
it "should call '/sbin/stop service_name' if no stop command is specified" do
@provider.upstart_service_running = true
expect(@provider).to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false).and_return(shell_out_success)
- @provider.stop_service()
+ @provider.stop_service
end
it "should not call '/sbin/stop service_name' if it is already stopped" do
@provider.upstart_service_running = false
allow(@current_resource).to receive(:running).and_return(false)
expect(@provider).not_to receive(:shell_out!).with("/sbin/stop #{@new_resource.service_name}", default_env: false)
- @provider.stop_service()
+ @provider.stop_service
expect(@upstart_service_running).to be_falsey
end
end
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 9145a0caf4..860c0b1d6a 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -41,8 +41,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: ["Winmgmt"],
service_start_name: "LocalSystem",
- display_name: "Chef Client Service"
- )
+ display_name: "Chef Client Service")
end
# Actual response from Win32::Service.services
@@ -73,8 +72,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
command: nil,
num_actions: 0,
actions: nil,
- delayed_start: 1
- )
+ delayed_start: 1)
end
let(:provider) do
@@ -98,7 +96,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
allow(Win32::Service).to receive(:start).with(any_args).and_return(Win32::Service)
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)
@@ -155,8 +154,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: %w{NSI Tdx Afd},
service_start_name: 'NT Authority\\LocalService',
- display_name: "DHCP Client"
- ))
+ display_name: "DHCP Client")
+ )
end
context "startup_type is neither :automatic or :disabled" do
@@ -171,8 +170,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: %w{NSI Tdx Afd},
service_start_name: 'NT Authority\\LocalService',
- display_name: "DHCP Client"
- ))
+ display_name: "DHCP Client")
+ )
end
it "does not set the current resources enabled" do
@@ -357,14 +356,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
# properties that are Strings
%i{binary_path_name load_order_group dependencies run_as_user
display_name description}.each do |attr|
- it "configures service if #{attr} has changed" do
- provider.current_resource.send("#{attr}=", "old value")
- provider.new_resource.send("#{attr}=", "new value")
+ it "configures service if #{attr} has changed" do
+ provider.current_resource.send("#{attr}=", "old value")
+ provider.new_resource.send("#{attr}=", "new value")
- expect(Win32::Service).to receive(:configure)
- provider.action_configure
- end
- end
+ expect(Win32::Service).to receive(:configure)
+ provider.action_configure
+ end
+ end
# properties that are Integers
%i{service_type error_control}.each do |attr|
@@ -473,7 +472,8 @@ 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: "stopped"),
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
end
context "run_as_user user is specified" do
@@ -555,7 +555,8 @@ 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
@@ -565,7 +566,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
context "service is paused" do
before 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
end
@@ -590,7 +592,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
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: "running")
+ )
provider.load_current_resource
end
@@ -614,7 +617,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
context "service is in stop_pending" do
before 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
end
@@ -665,7 +669,8 @@ 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: "stopped")
+ )
end
it "calls the stop command if one is specified" do
@@ -690,7 +695,8 @@ 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
@@ -699,7 +705,8 @@ 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 )
@@ -710,7 +717,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
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: "stopped")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -719,7 +727,8 @@ 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 )
@@ -728,7 +737,8 @@ 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
@@ -753,7 +763,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
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")
+ )
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
@@ -764,7 +775,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
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: "running")
+ )
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
expect(new_resource).to be_updated_by_last_action
@@ -783,7 +795,8 @@ 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
@@ -803,14 +816,16 @@ 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
@@ -819,14 +834,16 @@ 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
@@ -835,7 +852,8 @@ 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
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index d3c5073b7e..a70b7cd48b 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -277,7 +277,8 @@ describe Chef::Provider::Subversion do
allow(ChefConfig).to receive(:windows?) { false }
expect(@provider).to receive(:svn_binary).and_return("svn")
expect(@provider.export_command).to eql(
- "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
+ "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
+ )
end
it "selects an svn binary with an exe extension on windows" do
@@ -285,21 +286,24 @@ describe Chef::Provider::Subversion do
allow(ChefConfig).to receive(:windows?) { true }
expect(@provider).to receive(:svn_binary).and_return("svn.exe")
expect(@provider.export_command).to eql(
- "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
+ "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
+ )
end
it "uses a custom svn binary as part of the svn command" do
@resource.svn_binary "teapot"
expect(@provider).to receive(:svn_binary).and_return("teapot")
expect(@provider.export_command).to eql(
- "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
+ "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
+ )
end
it "wraps custom svn binary with quotes if it contains whitespace" do
@resource.svn_binary "c:/program files (x86)/subversion/svn.exe"
expect(@provider).to receive(:svn_binary).and_return("c:/program files (x86)/subversion/svn.exe")
expect(@provider.export_command).to eql(
- '"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
+ '"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir'
+ )
end
end
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 00f39d0fd9..899d3dc87e 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -75,8 +75,8 @@ describe Chef::Provider::SystemdUnit do
before(:each) do
allow(Etc).to receive(:getpwnam).and_return(OpenStruct.new(uid: 1000))
allow(Chef::Resource::SystemdUnit).to receive(:new)
- .with(unit_name)
- .and_return(current_resource)
+ .with(unit_name)
+ .and_return(current_resource)
end
describe "define_resource_requirements" do
@@ -113,8 +113,8 @@ describe Chef::Provider::SystemdUnit do
it "should create a current resource with the name of the new resource" do
expect(Chef::Resource::SystemdUnit).to receive(:new)
- .with(unit_name)
- .and_return(current_resource)
+ .with(unit_name)
+ .and_return(current_resource)
provider.load_current_resource
end
@@ -188,26 +188,26 @@ describe Chef::Provider::SystemdUnit do
it "loads the system unit content if the file exists and user is not set" do
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(true)
+ .with(unit_path_system)
+ .and_return(true)
allow(File).to receive(:read)
- .with(unit_path_system)
- .and_return(unit_content_string)
+ .with(unit_path_system)
+ .and_return(unit_content_string)
expect(File).to receive(:exist?)
- .with(unit_path_system)
+ .with(unit_path_system)
expect(File).to receive(:read)
- .with(unit_path_system)
+ .with(unit_path_system)
provider.load_current_resource
expect(current_resource.content).to eq(unit_content_string)
end
it "does not load the system unit content if the unit file is not present and the user is not set" do
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(false)
+ .with(unit_path_system)
+ .and_return(false)
expect(File).to_not receive(:read)
- .with(unit_path_system)
+ .with(unit_path_system)
provider.load_current_resource
expect(current_resource.content).to eq(nil)
end
@@ -215,15 +215,15 @@ describe Chef::Provider::SystemdUnit do
it "loads the user unit content if the file exists and user is set" do
new_resource.user("joe")
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(true)
+ .with(unit_path_user)
+ .and_return(true)
allow(File).to receive(:read)
- .with(unit_path_user)
- .and_return(unit_content_string)
+ .with(unit_path_user)
+ .and_return(unit_content_string)
expect(File).to receive(:exist?)
- .with(unit_path_user)
+ .with(unit_path_user)
expect(File).to receive(:read)
- .with(unit_path_user)
+ .with(unit_path_user)
provider.load_current_resource
expect(current_resource.content).to eq(unit_content_string)
end
@@ -231,10 +231,10 @@ describe Chef::Provider::SystemdUnit do
it "does not load the user unit if the file does not exist and user is set" do
new_resource.user("joe")
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(false)
+ .with(unit_path_user)
+ .and_return(false)
expect(File).to_not receive(:read)
- .with(unit_path_user)
+ .with(unit_path_user)
provider.load_current_resource
expect(current_resource.content).to eq(nil)
end
@@ -245,27 +245,27 @@ describe Chef::Provider::SystemdUnit do
before(:each) do
provider.current_resource = current_resource
allow(provider).to receive(:which)
- .with("systemctl")
- .and_return(systemctl_path)
+ .with("systemctl")
+ .and_return(systemctl_path)
end
describe "creates/deletes/presets/reverts the unit" do
it "creates the unit file when it does not exist" do
allow(provider).to receive(:manage_unit_file)
- .with(:create)
- .and_return(true)
+ .with(:create)
+ .and_return(true)
allow(provider).to receive(:daemon_reload)
- .and_return(true)
+ .and_return(true)
expect(provider).to receive(:manage_unit_file).with(:create)
provider.action_create
end
it "creates the file when the unit content is different" do
allow(provider).to receive(:manage_unit_file)
- .with(:create)
- .and_return(true)
+ .with(:create)
+ .and_return(true)
allow(provider).to receive(:daemon_reload)
- .and_return(true)
+ .and_return(true)
expect(provider).to receive(:manage_unit_file).with(:create)
provider.action_create
end
@@ -274,7 +274,7 @@ describe Chef::Provider::SystemdUnit do
current_resource.content(unit_content_string)
allow(provider).to receive(:manage_unit_file).with(:create)
allow(provider).to receive(:daemon_reload)
- .and_return(true)
+ .and_return(true)
expect(provider).to_not receive(:manage_unit_file)
provider.action_create
end
@@ -286,20 +286,20 @@ describe Chef::Provider::SystemdUnit do
expect(new_resource.triggers_reload).to eq true
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_create
end
it "triggers a daemon-reload when deleting a unit with triggers_reload" do
new_resource.user("joe")
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(true)
+ .with(unit_path_user)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
expect(new_resource.triggers_reload).to eq true
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_delete
end
@@ -309,7 +309,7 @@ describe Chef::Provider::SystemdUnit do
allow(provider).to receive(:manage_unit_file).with(:create)
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to_not receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_create
end
@@ -317,23 +317,23 @@ describe Chef::Provider::SystemdUnit do
new_resource.user("joe")
new_resource.triggers_reload(false)
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(true)
+ .with(unit_path_user)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to_not receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_delete
end
it "deletes the file when it exists" do
new_resource.user("joe")
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(true)
+ .with(unit_path_user)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file)
- .with(:delete)
- .and_return(true)
+ .with(:delete)
+ .and_return(true)
allow(provider).to receive(:daemon_reload)
expect(provider).to receive(:manage_unit_file).with(:delete)
provider.action_delete
@@ -342,8 +342,8 @@ describe Chef::Provider::SystemdUnit do
it "does not delete the file when it is absent" do
new_resource.user("joe")
allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(false)
+ .with(unit_path_user)
+ .and_return(false)
allow(provider).to receive(:manage_unit_file).with(:delete)
expect(provider).to_not receive(:manage_unit_file)
provider.action_delete
@@ -352,16 +352,16 @@ describe Chef::Provider::SystemdUnit do
it "presets the unit" do
new_resource.user("joe")
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "preset", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "preset", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_preset
end
it "reverts the unit" do
new_resource.user("joe")
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "revert", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "revert", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_revert
end
end
@@ -372,19 +372,19 @@ describe Chef::Provider::SystemdUnit do
expect(new_resource.triggers_reload).to eq true
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "daemon-reload", default_env: false)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_create
end
it "triggers a daemon-reload when deleting a unit with triggers_reload" do
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(true)
+ .with(unit_path_system)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
expect(new_resource.triggers_reload).to eq true
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "daemon-reload", default_env: false)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_delete
end
@@ -393,27 +393,27 @@ describe Chef::Provider::SystemdUnit do
allow(provider).to receive(:manage_unit_file).with(:create)
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to_not receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "daemon-reload", default_env: false)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_create
end
it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do
new_resource.triggers_reload(false)
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(true)
+ .with(unit_path_system)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
allow(provider).to receive(:shell_out_compacted!)
expect(provider).to_not receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "daemon-reload", default_env: false)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_delete
end
it "deletes the file when it exists" do
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(true)
+ .with(unit_path_system)
+ .and_return(true)
allow(provider).to receive(:manage_unit_file)
- .with(:delete)
+ .with(:delete)
allow(provider).to receive(:daemon_reload)
expect(provider).to receive(:manage_unit_file).with(:delete)
provider.action_delete
@@ -421,8 +421,8 @@ describe Chef::Provider::SystemdUnit do
it "does not delete the file when it is absent" do
allow(File).to receive(:exist?)
- .with(unit_path_system)
- .and_return(false)
+ .with(unit_path_system)
+ .and_return(false)
allow(provider).to receive(:manage_unit_file).with(:delete)
allow(provider).to receive(:daemon_reload)
expect(provider).to_not receive(:manage_unit_file)
@@ -431,15 +431,15 @@ describe Chef::Provider::SystemdUnit do
it "presets the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "preset", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "preset", unit_name)
+ .and_return(shell_out_success)
provider.action_preset
end
it "reverts the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "revert", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "revert", unit_name)
+ .and_return(shell_out_success)
provider.action_revert
end
end
@@ -450,8 +450,8 @@ describe Chef::Provider::SystemdUnit do
it "reenables the unit" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "reenable", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "reenable", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_reenable
end
@@ -459,8 +459,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.enabled(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "enable", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "enable", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_enable
end
@@ -482,8 +482,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.enabled(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "disable", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "disable", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_disable
end
@@ -505,16 +505,16 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "reenables the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "reenable", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "reenable", unit_name)
+ .and_return(shell_out_success)
provider.action_reenable
end
it "enables the unit when it is disabled" do
current_resource.enabled(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "enable", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "enable", unit_name)
+ .and_return(shell_out_success)
provider.action_enable
end
@@ -533,8 +533,8 @@ describe Chef::Provider::SystemdUnit do
it "disables the unit when it is enabled" do
current_resource.enabled(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "disable", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "disable", unit_name)
+ .and_return(shell_out_success)
provider.action_disable
end
@@ -559,8 +559,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.masked(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "mask", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "mask", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_mask
end
@@ -575,8 +575,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.masked(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "unmask", unit_name, **user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "unmask", unit_name, **user_cmd_opts)
+ .and_return(shell_out_success)
provider.action_unmask
end
@@ -592,8 +592,8 @@ describe Chef::Provider::SystemdUnit do
it "masks the unit when it is unmasked" do
current_resource.masked(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "mask", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "mask", unit_name)
+ .and_return(shell_out_success)
provider.action_mask
end
@@ -606,8 +606,8 @@ describe Chef::Provider::SystemdUnit do
it "unmasks the unit when it is masked" do
current_resource.masked(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "unmask", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "unmask", unit_name)
+ .and_return(shell_out_success)
provider.action_unmask
end
@@ -625,8 +625,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.active(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "start", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "start", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_start
end
@@ -641,8 +641,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.active(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "stop", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "stop", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_stop
end
@@ -658,8 +658,8 @@ describe Chef::Provider::SystemdUnit do
it "starts the unit when it is inactive" do
current_resource.active(false)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "start", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "start", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_start
end
@@ -672,8 +672,8 @@ describe Chef::Provider::SystemdUnit do
it "stops the unit when it is active" do
current_resource.active(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "stop", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "stop", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_stop
end
@@ -690,8 +690,8 @@ describe Chef::Provider::SystemdUnit do
it "restarts the unit" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "restart", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "restart", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_restart
end
@@ -699,8 +699,8 @@ describe Chef::Provider::SystemdUnit do
current_resource.user(user_name)
current_resource.active(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "reload", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "reload", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload
end
@@ -715,16 +715,16 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "restarts the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "restart", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "restart", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_restart
end
it "reloads the unit if active" do
current_resource.active(true)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "reload", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "reload", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload
end
@@ -741,8 +741,8 @@ describe Chef::Provider::SystemdUnit do
it "try-restarts the unit" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "try-restart", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "try-restart", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_try_restart
end
end
@@ -750,8 +750,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "try-restarts the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "try-restart", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "try-restart", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_try_restart
end
end
@@ -762,8 +762,8 @@ describe Chef::Provider::SystemdUnit do
it "reload-or-restarts the unit" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "reload-or-restart", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "reload-or-restart", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload_or_restart
end
end
@@ -771,8 +771,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "reload-or-restarts the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "reload-or-restart", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "reload-or-restart", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload_or_restart
end
end
@@ -783,8 +783,8 @@ describe Chef::Provider::SystemdUnit do
it "reload-or-try-restarts the unit" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--user", "reload-or-try-restart", unit_name, **user_cmd_opts, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "reload-or-try-restart", unit_name, **user_cmd_opts, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload_or_try_restart
end
end
@@ -792,8 +792,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "reload-or-try-restarts the unit" do
expect(provider).to receive(:shell_out_compacted!)
- .with(systemctl_path, "--system", "reload-or-try-restart", unit_name, default_env: false)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "reload-or-try-restart", unit_name, default_env: false)
+ .and_return(shell_out_success)
provider.action_reload_or_try_restart
end
end
@@ -809,16 +809,16 @@ describe Chef::Provider::SystemdUnit do
it "returns true when unit is active" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
+ .and_return(shell_out_success)
expect(provider.active?).to be true
end
it "returns false when unit is inactive" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
- .and_return(shell_out_failure)
+ .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
+ .and_return(shell_out_failure)
expect(provider.active?).to be false
end
end
@@ -826,15 +826,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when unit is active" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-active", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "is-active", unit_name)
+ .and_return(shell_out_success)
expect(provider.active?).to be true
end
it "returns false when unit is not active" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-active", unit_name)
- .and_return(shell_out_failure)
+ .with(systemctl_path, "--system", "is-active", unit_name)
+ .and_return(shell_out_failure)
expect(provider.active?).to be false
end
end
@@ -850,16 +850,16 @@ describe Chef::Provider::SystemdUnit do
it "returns true when unit is enabled" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
+ .and_return(shell_out_success)
expect(provider.enabled?).to be true
end
it "returns false when unit is not enabled" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
- .and_return(shell_out_failure)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
+ .and_return(shell_out_failure)
expect(provider.enabled?).to be false
end
end
@@ -867,15 +867,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when unit is enabled" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-enabled", unit_name)
- .and_return(shell_out_success)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
+ .and_return(shell_out_success)
expect(provider.enabled?).to be true
end
it "returns false when unit is not enabled" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-enabled", unit_name)
- .and_return(shell_out_failure)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
+ .and_return(shell_out_failure)
expect(provider.enabled?).to be false
end
end
@@ -891,16 +891,16 @@ describe Chef::Provider::SystemdUnit do
it "returns true when the unit is masked" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
- .and_return(shell_out_masked)
+ .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
+ .and_return(shell_out_masked)
expect(provider.masked?).to be true
end
it "returns false when the unit is not masked" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
- .and_return(shell_out_static)
+ .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
+ .and_return(shell_out_static)
expect(provider.masked?).to be false
end
end
@@ -908,15 +908,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when the unit is masked" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "status", unit_name)
- .and_return(shell_out_masked)
+ .with(systemctl_path, "--system", "status", unit_name)
+ .and_return(shell_out_masked)
expect(provider.masked?).to be true
end
it "returns false when the unit is not masked" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "status", unit_name)
- .and_return(shell_out_static)
+ .with(systemctl_path, "--system", "status", unit_name)
+ .and_return(shell_out_static)
expect(provider.masked?).to be false
end
end
@@ -932,16 +932,16 @@ describe Chef::Provider::SystemdUnit do
it "returns true when the unit is static" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
- .and_return(shell_out_static)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
+ .and_return(shell_out_static)
expect(provider.static?).to be true
end
it "returns false when the unit is not static" do
current_resource.user(user_name)
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
- .and_return(shell_out_masked)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
+ .and_return(shell_out_masked)
expect(provider.static?).to be false
end
end
@@ -949,15 +949,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when the unit is static" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-enabled", unit_name)
- .and_return(shell_out_static)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
+ .and_return(shell_out_static)
expect(provider.static?).to be true
end
it "returns false when the unit is not static" do
expect(provider).to receive(:shell_out_compacted)
- .with(systemctl_path, "--system", "is-enabled", unit_name)
- .and_return(shell_out_masked)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
+ .and_return(shell_out_masked)
expect(provider.static?).to be false
end
end
diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb
index 8cce861f2a..74e1dc1de7 100644
--- a/spec/unit/provider/windows_task_spec.rb
+++ b/spec/unit/provider/windows_task_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::WindowsTask, :windows_only do
let(:new_resource) { Chef::Resource::WindowsTask.new("sample_task") }
- let(:current_resource) { Chef::Resource::WindowsTask.new() }
+ let(:current_resource) { Chef::Resource::WindowsTask.new }
let(:provider) do
node = Chef::Node.new
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index 9014b873de..94e0d6074b 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -869,7 +869,7 @@ describe Chef::ProviderResolver do
def self.create_provider_tests(providers, test, expected, filter)
expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) })
providers.each do |key, value|
- if !key.is_a?(Symbol)
+ unless key.is_a?(Symbol)
next_test = test.merge({ filter => key })
next_filter =
case filter
@@ -888,7 +888,7 @@ describe Chef::ProviderResolver do
end
end
# If there is no filter, we're as deep as we need to go
- if !filter
+ unless filter
on_platform test.delete(:platform), test do
expect_providers(expected)
end
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index 496871614a..d7db8e8c1c 100644
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -24,8 +24,7 @@ class NoWhyrunDemonstrator < Chef::Provider
false
end
- def load_current_resource
- end
+ def load_current_resource; end
def action_foo
@system_state_altered = true
@@ -39,8 +38,7 @@ class ConvergeActionDemonstrator < Chef::Provider
true
end
- def load_current_resource
- end
+ def load_current_resource; end
def action_foo
converge_by("running a state changing action") do
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 1bc84745ad..f2ec175243 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -94,7 +94,7 @@ describe Chef::Recipe do
end
end
- expect(run_context.resource_collection.map { |r| r.name }).to eql(%w{monkey dog cat})
+ expect(run_context.resource_collection.map(&:name)).to eql(%w{monkey dog cat})
end
it "should return the new resource after creating it" do
@@ -115,7 +115,7 @@ describe Chef::Recipe do
node.automatic[:platform_version] = "123"
res = recipe.laughter "timmy"
expect(res.name).to eql("timmy")
- res.kind_of?(ShaunTheSheep)
+ res.is_a?(ShaunTheSheep)
end
it "locate a resource for all platforms" do
@@ -124,7 +124,7 @@ describe Chef::Recipe do
YourMom.provides :love_and_caring
res = recipe.love_and_caring "mommy"
expect(res.name).to eql("mommy")
- res.kind_of?(YourMom)
+ res.is_a?(YourMom)
end
describe "when there is more than one resource that resolves on a node" do
diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb
index c161428a13..dd3082100e 100644
--- a/spec/unit/resource/batch_spec.rb
+++ b/spec/unit/resource/batch_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Resource::Batch do
let(:node) { Chef::Node.new }
before(:each) do
- node.default["kernel"] = Hash.new
+ node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
node.automatic[:os] = "windows"
diff --git a/spec/unit/resource/cab_package_spec.rb b/spec/unit/resource/cab_package_spec.rb
index 7e80abf41a..e534748a0c 100644
--- a/spec/unit/resource/cab_package_spec.rb
+++ b/spec/unit/resource/cab_package_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@msystechnologies.com>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index a8429d0812..b512b8b17f 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -53,7 +53,7 @@ describe Chef::Resource::ChefGem, "gem_binary" do
end
it "sets the gem_binary based on computing it from RbConfig" do
- expect(resource.gem_binary).to eql("#{RbConfig::CONFIG['bindir']}/gem")
+ expect(resource.gem_binary).to eql("#{RbConfig::CONFIG["bindir"]}/gem")
end
it "sets compile_time to false by default" do
diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb
index 3dd68211db..0c0c0d8287 100644
--- a/spec/unit/resource/directory_spec.rb
+++ b/spec/unit/resource/directory_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Resource::Directory do
it "accepts a string as the path" do
expect { resource.path "/tmp" }.not_to raise_error
expect(resource.path).to eql("/tmp")
- expect { resource.path Hash.new }.to raise_error(ArgumentError)
+ expect { resource.path({}) }.to raise_error(ArgumentError)
end
it "allows you to have specify whether the action is recursive with true/false" do
diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb
index f4262a0396..70d949c340 100644
--- a/spec/unit/resource/dnf_package_spec.rb
+++ b/spec/unit/resource/dnf_package_spec.rb
@@ -64,7 +64,7 @@ describe Chef::Resource::DnfPackage, "flush_cache" do
end
it "allows you to set the flush timing with an array" do
- flush_array = [ :before, :after ]
+ flush_array = %i{before after}
flush_hash = { before: true, after: true }
resource.flush_cache(flush_array)
expect(resource.flush_cache).to eq(flush_hash)
diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb
index 04e1305163..e0beb309ab 100644
--- a/spec/unit/resource/dsc_resource_spec.rb
+++ b/spec/unit/resource/dsc_resource_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Resource::DscResource do
end
it "has an ed_actions property with only the `:run` and `:nothing` properties" do
- expect(dsc_test_resource.allowed_actions.to_set).to eq([:run, :nothing].to_set)
+ expect(dsc_test_resource.allowed_actions.to_set).to eq(%i{run nothing}.to_set)
end
it "allows the resource property to be set" do
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index f0ec999019..57c58249eb 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -128,8 +128,7 @@ describe Chef::Resource::File::Verification do
before(:each) do
class Chef::Resource::File::Verification::Turtle < Chef::Resource::File::Verification
provides :cats
- def verify(path, opts)
- end
+ def verify(path, opts); end
end
allow(Chef::Resource::File::Verification::Turtle).to receive(:new).and_return(registered_verification)
end
diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb
index 54dc8ab92b..b49fc4564b 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_spec.rb
@@ -85,7 +85,7 @@ describe Chef::Resource::File do
it "accepts a string as the path" do
expect { resource.path "/tmp" }.not_to raise_error
expect(resource.path).to eql("/tmp")
- expect { resource.path Hash.new }.to raise_error(ArgumentError)
+ expect { resource.path({}) }.to raise_error(ArgumentError)
end
describe "when it has a path, owner, group, mode, and checksum" do
diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb
index 6d9df79299..ae7103b9b5 100644
--- a/spec/unit/resource/group_spec.rb
+++ b/spec/unit/resource/group_spec.rb
@@ -96,7 +96,7 @@ end
describe Chef::Resource::Group, "members" do
let(:resource) { Chef::Resource::Group.new("fakey_fakerton") }
- [ :users, :members].each do |method|
+ %i{users members}.each do |method|
it "(#{method}) allows a String and coerces it to an Array" do
resource.send(method, "some_user")
expect(resource.send(method)).to eql(["some_user"])
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index 05a39835d8..ae32e4aa30 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Resource::Link do
end
it "does not accept a Hash for the link source via 'to'" do
- expect { resource.to Hash.new }.to raise_error(ArgumentError)
+ expect { resource.to({}) }.to raise_error(ArgumentError)
end
it "allows you to set a link source via 'to'" do
diff --git a/spec/unit/resource/locale_spec.rb b/spec/unit/resource/locale_spec.rb
index 544f6342c5..9d0061eb5b 100644
--- a/spec/unit/resource/locale_spec.rb
+++ b/spec/unit/resource/locale_spec.rb
@@ -91,7 +91,7 @@ describe Chef::Resource::Locale do
end
context "without lang" do
it "returns an empty array" do
- resource.lang()
+ resource.lang
resource.lc_env({ "LC_TIME" => "en_AG.utf8", "LC_MESSAGES" => "en_AG.utf8" })
expect(provider.unavailable_locales).to eq([])
end
@@ -99,14 +99,14 @@ describe Chef::Resource::Locale do
context "without lc_env" do
it "returns an empty array" do
resource.lang("en_US")
- resource.lc_env()
+ resource.lc_env
expect(provider.unavailable_locales).to eq([])
end
end
context "without both" do
it "returns an empty array" do
- resource.lang()
- resource.lc_env()
+ resource.lang
+ resource.lc_env
expect(provider.unavailable_locales).to eq([])
end
end
@@ -122,7 +122,7 @@ describe Chef::Resource::Locale do
end
context "without lang" do
it "returns list" do
- resource.lang()
+ resource.lang
resource.lc_env({ "LC_TIME" => "en_AG.utf8", "LC_MESSAGES" => "en_US.utf8" })
expect(provider.unavailable_locales).to eq(["en_US.utf8"])
end
@@ -130,14 +130,14 @@ describe Chef::Resource::Locale do
context "without lc_env" do
it "returns list" do
resource.lang("de_DE")
- resource.lc_env()
+ resource.lc_env
expect(provider.unavailable_locales).to eq(["de_DE"])
end
end
context "without both" do
it "returns an empty array" do
- resource.lang()
- resource.lc_env()
+ resource.lang
+ resource.lc_env
expect(provider.unavailable_locales).to eq([])
end
end
@@ -166,7 +166,7 @@ describe Chef::Resource::Locale do
end
context "without lang" do
it "returns a valid string" do
- resource.lang()
+ resource.lang
resource.lc_env({ "LC_TIME" => "en_AG.utf8", "LC_MESSAGES" => "en_AG.utf8" })
expect(provider.new_content).to eq("LC_MESSAGES=en_AG.utf8\nLC_TIME=en_AG.utf8\n")
end
@@ -174,14 +174,14 @@ describe Chef::Resource::Locale do
context "without lc_env" do
it "returns a valid string" do
resource.lang("en_US")
- resource.lc_env()
+ resource.lc_env
expect(provider.new_content).to eq("LANG=en_US\n")
end
end
context "without both" do
it "returns string with only new-line character" do
- resource.lang()
- resource.lc_env()
+ resource.lang
+ resource.lc_env
expect(provider.new_content).to eq("\n")
end
end
diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb
index 41a6071893..5653044358 100644
--- a/spec/unit/resource/osx_profile_spec.rb
+++ b/spec/unit/resource/osx_profile_spec.rb
@@ -21,7 +21,8 @@ require "spec_helper"
describe Chef::Resource::OsxProfile do
let(:resource) do
Chef::Resource::OsxProfile.new(
- "fakey_fakerton")
+ "fakey_fakerton"
+ )
end
it "has a resource name of profile" do
diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb
index dc9b62b16c..5566f32725 100644
--- a/spec/unit/resource/powershell_script_spec.rb
+++ b/spec/unit/resource/powershell_script_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Resource::PowershellScript do
before(:each) do
node = Chef::Node.new
- node.default["kernel"] = Hash.new
+ node.default["kernel"] = {}
node.default["kernel"][:machine] = :x86_64.to_s
node.automatic[:os] = "windows"
@@ -61,7 +61,7 @@ describe Chef::Resource::PowershellScript do
it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated properties from a parent resource class" do
inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes -
- [:cwd, :environment, :group, :path, :user, :umask, :architecture, :elevated ]
+ %i{cwd environment group path user umask architecture elevated}
expect(inherited_difference).to eq([])
end
@@ -87,7 +87,8 @@ 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,21 +99,24 @@ 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 }
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 }
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
@@ -120,7 +124,8 @@ describe Chef::Resource::PowershellScript do
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 {})
+ parameters_with_boolean_disabled
+ ).and_return(Proc.new {})
resource.only_if("$true", parameters_with_boolean_disabled)
end
end
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index 47d624a758..c674e3eddd 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -152,7 +152,7 @@ describe Chef::Resource::RegistryKey, "recursive" do
end
it "does not allow an array" do
- expect { resource.recursive([:nose, :chin]) }.to raise_error(ArgumentError)
+ expect { resource.recursive(%i{nose chin}) }.to raise_error(ArgumentError)
end
it "does not allow a string" do
@@ -167,7 +167,7 @@ end
describe Chef::Resource::RegistryKey, "architecture" do
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
- [ :i386, :x86_64, :machine ].each do |arch|
+ %i{i386 x86_64 machine}.each do |arch|
it "allows #{arch} as a symbol" do
resource.architecture(arch)
expect(resource.architecture).to eql(arch)
@@ -183,7 +183,7 @@ describe Chef::Resource::RegistryKey, "architecture" do
end
it "does not allow an array" do
- expect { resource.architecture([:nose, :chin]) }.to raise_error(ArgumentError)
+ expect { resource.architecture(%i{nose chin}) }.to raise_error(ArgumentError)
end
it "does not allow a string" do
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index 7c2b46a0dc..be88d82f3b 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -167,7 +167,7 @@ describe Chef::Resource::Service do
end
it "allows you to set what features this resource supports as an array" do
- support_array = [ :status, :restart ]
+ support_array = %i{status restart}
support_hash = { status: true, restart: true }
resource.supports(support_array)
expect(resource.supports).to eq(support_hash)
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 9ca1f7617f..2f8e234c85 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -147,7 +147,7 @@ describe Chef::Resource::Template do
end
it "compiles helper methods with arguments into a module" do
- resource.helper(:shout) { |quiet| quiet.upcase }
+ resource.helper(:shout, &:upcase)
modules = resource.helper_modules
o = Object.new
modules.each { |m| o.extend(m) }
@@ -186,7 +186,7 @@ describe Chef::Resource::Template do
end
it "raises an error when no block or module name is given for helpers definition" do
- expect { resource.helpers() }.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { resource.helpers }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "raises an error when a non-module is given for helpers definition" do
diff --git a/spec/unit/resource/windows_env_spec.rb b/spec/unit/resource/windows_env_spec.rb
index 06b5af630a..3ba5b18881 100644
--- a/spec/unit/resource/windows_env_spec.rb
+++ b/spec/unit/resource/windows_env_spec.rb
@@ -47,7 +47,7 @@ describe Chef::Resource::WindowsEnv do
end
it "does not accept a Hash for the env value via 'to'" do
- expect { resource.value Hash.new }.to raise_error(ArgumentError)
+ expect { resource.value({}) }.to raise_error(ArgumentError)
end
it "allows you to set an env value via 'to'" do
diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb
index b44a86d04a..a416ca0a05 100644
--- a/spec/unit/resource/windows_service_spec.rb
+++ b/spec/unit/resource/windows_service_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Resource::WindowsService, "initialize" do
expect { resource.action :unmask }.not_to raise_error
end
- [:automatic, :manual, :disabled].each do |type|
+ %i{automatic manual disabled}.each do |type|
it "supports setting startup_type property to #{type.inspect}" do
resource.startup_type type
expect(resource.startup_type).to eql(type)
@@ -69,7 +69,7 @@ describe Chef::Resource::WindowsService, "initialize" do
end
end
- [:automatic, :manual, :disabled].each do |type|
+ %i{automatic manual disabled}.each do |type|
it "supports setting startup_type property to #{type.inspect}" do
resource.startup_type type
expect(resource.startup_type).to eql(type)
@@ -84,11 +84,11 @@ describe Chef::Resource::WindowsService, "initialize" do
# Properties that are Strings
%i{description service_name binary_path_name load_order_group dependencies
run_as_user run_as_password display_name}.each do |prop|
- it "support setting #{prop} property with a String" do
- resource.send("#{prop}=", "some value")
- expect(resource.send(prop)).to eq("some value")
- end
- end
+ it "support setting #{prop} property with a String" do
+ resource.send("#{prop}=", "some value")
+ expect(resource.send(prop)).to eq("some value")
+ end
+ end
# Properties that are Integers
%i{desired_access error_control service_type}.each do |prop|
diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb
index b152d879f6..d08849d4be 100644
--- a/spec/unit/resource/windows_task_spec.rb
+++ b/spec/unit/resource/windows_task_spec.rb
@@ -356,7 +356,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
context "#validate_idle_time" do
it "raises error if frequency is not :on_idle" do
- [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency|
+ %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency|
expect { resource.send(:validate_idle_time, 5, frequency) }.to raise_error(ArgumentError, "idle_time property is only valid for tasks that run on_idle")
end
end
@@ -374,7 +374,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
end
it "does not raises error if idle_time is not set for other frequencies" do
- [:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :none].each do |frequency|
+ %i{minute hourly daily weekly monthly once on_logon onstart none}.each do |frequency|
expect { resource.send(:validate_idle_time, nil, frequency) }.not_to raise_error
end
end
diff --git a/spec/unit/resource/windows_uac_spec.rb b/spec/unit/resource/windows_uac_spec.rb
index 05c1cad4a0..6f9137c341 100644
--- a/spec/unit/resource/windows_uac_spec.rb
+++ b/spec/unit/resource/windows_uac_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Resource::WindowsUac do
expect(resource.resource_name).to eql(:windows_uac)
end
- [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries].each do |val|
+ %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.each do |val|
it "the consent_behavior_admins property accepts :#{val}" do
expect { resource.consent_behavior_admins val }.not_to raise_error(ArgumentError)
end
@@ -34,7 +34,7 @@ describe Chef::Resource::WindowsUac do
expect { resource.consent_behavior_admins :bogus }.to raise_error(ArgumentError)
end
- [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds].each do |val|
+ %i{auto_deny secure_prompt_for_creds prompt_for_creds}.each do |val|
it "the consent_behavior_users property accepts :#{val}" do
expect { resource.consent_behavior_users val }.not_to raise_error(ArgumentError)
end
diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb
index 0b79a447a3..d0383a8cec 100644
--- a/spec/unit/resource/yum_package_spec.rb
+++ b/spec/unit/resource/yum_package_spec.rb
@@ -95,7 +95,7 @@ describe Chef::Resource::YumPackage, "flush_cache" do
end
it "should allow you to set the flush timing with an array" do
- flush_array = [ :before, :after ]
+ flush_array = %i{before after}
flush_hash = { before: true, after: true }
@resource.flush_cache(flush_array)
expect(@resource.flush_cache).to eq(flush_hash)
diff --git a/spec/unit/resource_collection/resource_list_spec.rb b/spec/unit/resource_collection/resource_list_spec.rb
index dabb8f037d..05363c20b1 100644
--- a/spec/unit/resource_collection/resource_list_spec.rb
+++ b/spec/unit/resource_collection/resource_list_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
describe Chef::ResourceCollection::ResourceList do
- let(:resource_list) { Chef::ResourceCollection::ResourceList.new() }
+ let(:resource_list) { Chef::ResourceCollection::ResourceList.new }
let(:resource) { Chef::Resource::ZenMaster.new("makoto") }
let(:second_resource) { Chef::Resource::ZenMaster.new("hattori") }
diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb
index 60053d2b71..30a55cd3e1 100644
--- a/spec/unit/resource_collection/resource_set_spec.rb
+++ b/spec/unit/resource_collection/resource_set_spec.rb
@@ -172,7 +172,7 @@ describe Chef::ResourceCollection::ResourceSet do
end
it "should raise an exception if you pass something other than a string or hash to resource" do
- expect { collection.find([Array.new]) }.to raise_error(ArgumentError)
+ expect { collection.find([[]]) }.to raise_error(ArgumentError)
end
it "raises an error when attempting to find a resource that does not exist" do
diff --git a/spec/unit/resource_collection/stepable_iterator_spec.rb b/spec/unit/resource_collection/stepable_iterator_spec.rb
index 6354b1b7fb..ec831c9afe 100644
--- a/spec/unit/resource_collection/stepable_iterator_spec.rb
+++ b/spec/unit/resource_collection/stepable_iterator_spec.rb
@@ -72,7 +72,7 @@ describe Chef::ResourceCollection::StepableIterator do
@collection << lambda { @snitch_var = 42 }
@iterator = CRSI.for_collection(@collection)
- @iterator.each { |proc| proc.call }
+ @iterator.each(&:call)
end
it "allows the iteration to be paused" do
@@ -124,7 +124,7 @@ describe Chef::ResourceCollection::StepableIterator do
it "allows the iteration to start by being stepped" do
@snitch_var = nil
@iterator = CRSI.for_collection(@collection)
- @iterator.iterate_on(:element) { |proc| proc.call }
+ @iterator.iterate_on(:element, &:call)
@iterator.step
expect(@iterator.position).to eq(1)
expect(@snitch_var).to eq(23)
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 7f59246a88..60f17b6934 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -20,7 +20,7 @@
require "spec_helper"
describe Chef::ResourceCollection do
- let(:rc) { Chef::ResourceCollection.new() }
+ let(:rc) { Chef::ResourceCollection.new }
let(:resource) { Chef::Resource::ZenMaster.new("makoto") }
it "should throw an error when calling a non-delegated method" do
@@ -97,7 +97,7 @@ describe Chef::ResourceCollection do
describe "each" do
it "should allow you to iterate over every resource in the collection" do
load_up_resources
- results = Array.new
+ results = []
expect do
rc.each do |r|
results << r.name
@@ -119,7 +119,7 @@ describe Chef::ResourceCollection do
describe "each_index" do
it "should allow you to iterate over every resource by index" do
load_up_resources
- results = Array.new
+ results = []
expect do
rc.each_index do |i|
results << rc[i].name
@@ -246,7 +246,7 @@ describe Chef::ResourceCollection do
end
it "should raise an exception if you pass something other than a string or hash to resource" do
- expect { rc.resources([Array.new]) }.to raise_error(ArgumentError)
+ expect { rc.resources([[]]) }.to raise_error(ArgumentError)
end
it "raises an error when attempting to find a resource that does not exist" do
diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb
index 5be3e59009..a1c59eaaca 100644
--- a/spec/unit/resource_definition_spec.rb
+++ b/spec/unit/resource_definition_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
describe Chef::ResourceDefinition do
- let(:defn) { Chef::ResourceDefinition.new() }
+ let(:defn) { Chef::ResourceDefinition.new }
describe "initialize" do
it "should be a Chef::ResourceDefinition" do
@@ -92,7 +92,7 @@ describe Chef::ResourceDefinition do
it "should raise an exception if prototype_params is not a hash" do
expect do
- defn.define :monkey, Array.new do
+ defn.define :monkey, [] do
end
end.to raise_error(ArgumentError)
end
diff --git a/spec/unit/resource_inspector_spec.rb b/spec/unit/resource_inspector_spec.rb
index aef92732b3..c0852be3b2 100644
--- a/spec/unit/resource_inspector_spec.rb
+++ b/spec/unit/resource_inspector_spec.rb
@@ -39,7 +39,7 @@ describe ResourceInspector do
it "returns a hash with required data" do
expect(subject[:description]).to eq "A dummy resource"
- expect(subject[:actions]).to match_array [:nothing, :dummy]
+ expect(subject[:actions]).to match_array %i{nothing dummy}
end
context "excluding built in properties" do
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 1c8e991566..6745dd448d 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -115,14 +115,14 @@ describe Chef::Resource do
it "sets a list of state attributes" do
resource_class = Class.new(Chef::Resource)
resource_class.state_attrs(:checksum, :owner, :group, :mode)
- expect(resource_class.state_attrs).to match_array([:checksum, :owner, :group, :mode])
+ expect(resource_class.state_attrs).to match_array(%i{checksum owner group mode})
end
it "inherits state attributes from the superclass" do
resource_class = Class.new(Chef::Resource)
resource_subclass = Class.new(resource_class)
resource_class.state_attrs(:checksum, :owner, :group, :mode)
- expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode])
+ expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode})
end
it "combines inherited state attributes with non-inherited state attributes" do
@@ -130,7 +130,7 @@ describe Chef::Resource do
resource_subclass = Class.new(resource_class)
resource_class.state_attrs(:checksum, :owner)
resource_subclass.state_attrs(:group, :mode)
- expect(resource_subclass.state_attrs).to match_array([:checksum, :owner, :group, :mode])
+ expect(resource_subclass.state_attrs).to match_array(%i{checksum owner group mode})
end
end
@@ -157,7 +157,7 @@ describe Chef::Resource do
it "describes its state" do
resource_state = file_resource.state_for_resource_reporter
- expect(resource_state.keys).to match_array([:checksum, :owner, :group, :mode])
+ expect(resource_state.keys).to match_array(%i{checksum owner group mode})
expect(resource_state[:checksum]).to eq("abc123")
expect(resource_state[:owner]).to eq("root")
expect(resource_state[:group]).to eq("wheel")
@@ -510,11 +510,11 @@ describe Chef::Resource do
context "when the resource has a property with a default" do
let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } }
it "should include the default in the hash" do
- expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated,
- :updated_by_last_action, :before,
- :name, :source_line,
- :action, :elapsed_time,
- :default_guard_interpreter, :guard_interpreter].sort)
+ expect(resource.to_hash.keys.sort).to eq(%i{a allowed_actions params provider updated
+ updated_by_last_action before
+ name source_line
+ action elapsed_time
+ default_guard_interpreter guard_interpreter}.sort)
expect(resource.to_hash[:name]).to eq "funk"
expect(resource.to_hash[:a]).to eq 1
end
@@ -522,11 +522,11 @@ describe Chef::Resource do
it "should convert to a hash" do
hash = resource.to_hash
- expected_keys = [ :allowed_actions, :params, :provider, :updated,
- :updated_by_last_action, :before,
- :name, :source_line,
- :action, :elapsed_time,
- :default_guard_interpreter, :guard_interpreter ]
+ expected_keys = %i{allowed_actions params provider updated
+ updated_by_last_action before
+ name source_line
+ action elapsed_time
+ default_guard_interpreter guard_interpreter}
expect(hash.keys - expected_keys).to eq([])
expect(expected_keys - hash.keys).to eq([])
expect(hash[:name]).to eql("funk")
@@ -838,7 +838,7 @@ describe Chef::Resource do
it "should print \"skipped due to action :nothing\" message for doc formatter when action is :nothing" do
fdoc = Chef::Formatters.new(:doc, STDOUT, STDERR)
allow(run_context).to receive(:events).and_return(fdoc)
- expect(fdoc).to receive(:puts).with(" (skipped due to action :nothing)", anything())
+ expect(fdoc).to receive(:puts).with(" (skipped due to action :nothing)", anything)
resource.should_skip?(:nothing)
end
@@ -1118,8 +1118,8 @@ describe Chef::Resource do
end
context "with an array action" do
- before { resource.action([:two, :one]) }
- it { is_expected.to eq [:two, :one] }
+ before { resource.action(%i{two one}) }
+ it { is_expected.to eq %i{two one} }
end
context "with an assignment" do
@@ -1128,8 +1128,8 @@ describe Chef::Resource do
end
context "with an array assignment" do
- before { resource.action = [:two, :one] }
- it { is_expected.to eq [:two, :one] }
+ before { resource.action = %i{two one} }
+ it { is_expected.to eq %i{two one} }
end
context "with an invalid action" do
@@ -1166,8 +1166,8 @@ describe Chef::Resource do
end
context "with an array default action" do
- let(:default_action) { [:two, :one] }
- it { is_expected.to eq [:two, :one] }
+ let(:default_action) { %i{two one} }
+ it { is_expected.to eq %i{two one} }
end
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 46ee71bb1c..13932ab3ee 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -113,7 +113,7 @@ describe Chef::Role do
end
it "should throw an ArgumentError if we aren't a kind of hash" do
- expect { @role.default_attributes(Array.new) }.to raise_error(ArgumentError)
+ expect { @role.default_attributes([]) }.to raise_error(ArgumentError)
end
end
@@ -128,7 +128,7 @@ describe Chef::Role do
end
it "should throw an ArgumentError if we aren't a kind of hash" do
- expect { @role.override_attributes(Array.new) }.to raise_error(ArgumentError)
+ expect { @role.override_attributes([]) }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index 607333416d..cc9330a1b6 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -217,14 +217,14 @@ describe Chef::RunContext::CookbookCompiler do
it "should return an array of cookbook names as symbols without duplicates" do
node.run_list("test-with-circular-deps::default", "circular-dep1::default", "circular-dep2::default")
- expect(compiler.cookbook_order).to eq([:"circular-dep2",
- :"circular-dep1",
- :"test-with-circular-deps"])
+ expect(compiler.cookbook_order).to eq(%i{circular-dep2
+ circular-dep1
+ test-with-circular-deps})
end
it "determines if a cookbook is in the list of cookbooks reachable by dependency" do
node.run_list("test-with-deps::default", "test-with-deps::server")
- expect(compiler.cookbook_order).to eq([:dependency1, :dependency2, :"test-with-deps"])
+ expect(compiler.cookbook_order).to eq(%i{dependency1 dependency2 test-with-deps})
expect(compiler.unreachable_cookbook?(:dependency1)).to be_falsey
expect(compiler.unreachable_cookbook?(:dependency2)).to be_falsey
expect(compiler.unreachable_cookbook?(:'test-with-deps')).to be_falsey
diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb
index 3a39bc79cc..4ddc75f002 100644
--- a/spec/unit/run_list/run_list_expansion_spec.rb
+++ b/spec/unit/run_list/run_list_expansion_spec.rb
@@ -94,12 +94,15 @@ describe Chef::RunList::RunListExpansion do
allow(@expansion).to receive(:fetch_role).and_return(@first_role, @second_role)
@expansion.expand
@json = '{"id":"_default","run_list":[{"type":"recipe","name":"lobster::mastercookbook","version":"0.1.0",'
- .concat(
-'"skipped":false},{"type":"role","name":"rage","children":[{"type":"role","name":"mollusk","children":[],"missing":null,'
- .concat(
-'"error":null,"skipped":null},{"type":"recipe","name":"crabrevenge","version":null,"skipped":false}],"missing":null,'
- .concat(
-'"error":null,"skipped":null},{"type":"recipe","name":"fist","version":"0.1","skipped":false}]}')))
+ .concat(
+ '"skipped":false},{"type":"role","name":"rage","children":[{"type":"role","name":"mollusk","children":[],"missing":null,'
+ .concat(
+ '"error":null,"skipped":null},{"type":"recipe","name":"crabrevenge","version":null,"skipped":false}],"missing":null,'
+ .concat(
+ '"error":null,"skipped":null},{"type":"recipe","name":"fist","version":"0.1","skipped":false}]}'
+ )
+ )
+ )
end
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index ac062c665d..5dc877ad9a 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -133,7 +133,7 @@ describe Chef::RunList do
it "should yield each member to your block" do
@run_list << "foo"
@run_list << "bar"
- seen = Array.new
+ seen = []
@run_list.each { |r| seen << r }
expect(seen).to be_include("recipe[foo]")
expect(seen).to be_include("recipe[bar]")
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index 1effe3157c..ffb0cd523f 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -295,7 +295,7 @@ describe Chef::Runner do
# execution, and schedule delayed actions :second and :third on the first
# resource. The duplicate actions should "collapse" to a single notification
# and order should be preserved.
- expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third])
+ expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third})
end
it "executes delayed notifications in the order they were declared" do
@@ -321,7 +321,7 @@ describe Chef::Runner do
third_resource.notifies(:third_action, first_resource, :delayed)
runner.converge
- expect(SnitchyProvider.all_actions_called).to eq([:first, :first, :second, :third])
+ expect(SnitchyProvider.all_actions_called).to eq(%i{first first second third})
end
it "does not fire notifications if the resource was not updated by the last action executed" do
@@ -347,7 +347,7 @@ describe Chef::Runner do
runner.converge
# All of the resources should only fire once:
- expect(SnitchyProvider.all_actions_called).to eq([:first, :second, :third])
+ expect(SnitchyProvider.all_actions_called).to eq(%i{first second third})
# all of the resources should be marked as updated for reporting purposes
expect(first_resource).to be_updated
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index 151fcb51b3..83f988911c 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -149,7 +149,8 @@ describe Chef::Search::Query do
],
"start" => 0,
"total" => 4,
- } end
+ }
+ end
let(:big_response_empty) do
{
@@ -169,7 +170,7 @@ describe Chef::Search::Query do
it "accepts a type as the first argument" do
expect { query.search("node") }.not_to raise_error
expect { query.search(:node) }.not_to raise_error
- expect { query.search(Hash.new) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/)
+ expect { query.search({}) }.to raise_error(Chef::Exceptions::InvalidSearchQuery, /(Hash)/)
end
it "queries for every object of a type by default" do
diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb
index bcce7c1a08..7ca5f74bef 100644
--- a/spec/unit/shell/model_wrapper_spec.rb
+++ b/spec/unit/shell/model_wrapper_spec.rb
@@ -57,7 +57,7 @@ describe Shell::ModelWrapper do
end
it "maps the listed nodes when given a block" do
- expect(@wrapper.all { |n| n.name }.sort.reverse).to eq(%w{yummy sammich})
+ expect(@wrapper.all(&:name).sort.reverse).to eq(%w{yummy sammich})
end
end
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index 6644ff6e0c..c98989491d 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -57,8 +57,7 @@ describe Shell::ClientSession do
load_node: true,
build_node: true,
register: true,
- sync_cookbooks: {}
- )
+ sync_cookbooks: {})
end
before do
@@ -94,8 +93,7 @@ describe Shell::SoloSession do
load_node: true,
build_node: true,
register: true,
- sync_cookbooks: {}
- )
+ sync_cookbooks: {})
end
before do
@@ -132,8 +130,7 @@ describe Shell::StandAloneSession do
load_node: true,
build_node: true,
register: true,
- sync_cookbooks: {}
- )
+ sync_cookbooks: {})
end
let(:recipe) { Chef::Recipe.new(nil, nil, run_context) }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index 8ba1afa72a..aa573706b1 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -30,8 +30,7 @@ ObjectTestHarness = Proc.new do
end
desc "rspecin'"
- def rspec_method
- end
+ def rspec_method; end
end
class TestJobManager
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index 48dbf010e9..492dc147d9 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -65,7 +65,7 @@ describe Chef::User do
end
it "should throw an ArgumentError if you feed it anything but a string" do
- expect { @user.name Hash.new }.to raise_error(ArgumentError)
+ expect { @user.name({}) }.to raise_error(ArgumentError)
end
end
@@ -84,7 +84,7 @@ describe Chef::User do
end
it "should throw an ArgumentError if you feed it anything but true or false" do
- expect { @user.name Hash.new }.to raise_error(ArgumentError)
+ expect { @user.name({}) }.to raise_error(ArgumentError)
end
end
@@ -99,7 +99,7 @@ describe Chef::User do
end
it "should throw an ArgumentError if you feed it something lame" do
- expect { @user.public_key Hash.new }.to raise_error(ArgumentError)
+ expect { @user.public_key({}) }.to raise_error(ArgumentError)
end
end
@@ -114,7 +114,7 @@ describe Chef::User do
end
it "should throw an ArgumentError if you feed it something lame" do
- expect { @user.private_key Hash.new }.to raise_error(ArgumentError)
+ expect { @user.private_key({}) }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index 37b2252492..4bde7278fe 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -37,7 +37,7 @@ describe Chef::UserV1 do
end
it "should throw an ArgumentError if you feed it something lame" do
- expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError)
+ expect { @user.send(method, {}) }.to raise_error(ArgumentError)
end
end
@@ -57,7 +57,7 @@ describe Chef::UserV1 do
end
it "should throw an ArgumentError if you feed it anything but true or false" do
- expect { @user.send(method, Hash.new) }.to raise_error(ArgumentError)
+ expect { @user.send(method, {}) }.to raise_error(ArgumentError)
end
end
@@ -95,7 +95,7 @@ describe Chef::UserV1 do
end
it "should throw an ArgumentError if you feed it anything but a string" do
- expect { @user.username Hash.new }.to raise_error(ArgumentError)
+ expect { @user.username({}) }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index 8bc68ec160..3a9a45b841 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -110,7 +110,7 @@ describe Chef::Util::Backup do
end
it "should strip the drive letter off for windows" do
expect(@backup).to receive(:path).and_return('c:\a\b\c.txt')
- expect(@backup.send(:backup_filename)).to match(%r|^\\a\\b\\c.txt.chef-\d{14}.\d{6}$|)
+ expect(@backup.send(:backup_filename)).to match(/^\\a\\b\\c.txt.chef-\d{14}.\d{6}$/)
end
it "should strip the drive letter off for windows (with forwardslashes)" do
expect(@backup).to receive(:path).and_return("c:/a/b/c.txt")
diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb
index e53bc9662a..ac851a835e 100644
--- a/spec/unit/util/editor_spec.rb
+++ b/spec/unit/util/editor_spec.rb
@@ -9,7 +9,7 @@ describe Chef::Util::Editor do
end
it "makes a copy of an Array" do
- array = Array.new
+ array = []
editor = described_class.new(array)
expect(editor.lines).to_not be(array)
end
diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb
index 6f65174d15..65207d5dfb 100644
--- a/spec/unit/util/powershell/ps_credential_spec.rb
+++ b/spec/unit/util/powershell/ps_credential_spec.rb
@@ -29,8 +29,9 @@ describe Chef::Util::Powershell::PSCredential do
it "should create the script to create a PSCredential when calling" do
allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted")
expect(ps_credential.to_psobject).to eq(
- "New-Object System.Management.Automation.PSCredential("\
- "'#{username}',('encrypted' | ConvertTo-SecureString))")
+ "New-Object System.Management.Automation.PSCredential("\
+ "'#{username}',('encrypted' | ConvertTo-SecureString))"
+ )
end
end
diff --git a/spec/unit/util/threaded_job_queue_spec.rb b/spec/unit/util/threaded_job_queue_spec.rb
index 8a89943a8a..48a34bce31 100644
--- a/spec/unit/util/threaded_job_queue_spec.rb
+++ b/spec/unit/util/threaded_job_queue_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Util::ThreadedJobQueue do
let(:queue) { Chef::Util::ThreadedJobQueue.new }
it "should pass mutex to jobs with an arity of 1" do
- job = double()
+ job = double
expect(job).to receive(:arity).at_least(:once).and_return(1)
expect(job).to receive(:call).exactly(5).times.with(an_instance_of(Mutex))
@@ -31,7 +31,7 @@ describe Chef::Util::ThreadedJobQueue do
end
it "should pass nothing to jobs with an arity of 0" do
- job = double()
+ job = double
expect(job).to receive(:arity).at_least(:once).and_return(0)
expect(job).to receive(:call).exactly(5).times.with(no_args)
diff --git a/spec/unit/version_class_spec.rb b/spec/unit/version_class_spec.rb
index 9dc981bd4c..c6848491ee 100644
--- a/spec/unit/version_class_spec.rb
+++ b/spec/unit/version_class_spec.rb
@@ -105,7 +105,7 @@ describe Chef::Version do
a = %w{0.0.0 0.0.1 0.1.0 0.1.1 1.0.0 1.1.0 1.1.1}.map do |s|
Chef::Version.new(s)
end
- got = a.sort.map { |v| v.to_s }
+ got = a.sort.map(&:to_s)
expect(got).to eq(%w{0.0.0 0.0.1 0.1.0 0.1.1 1.0.0 1.1.0 1.1.1})
end
@@ -113,7 +113,7 @@ describe Chef::Version do
a = %w{9.8.7 1.0.0 1.2.3 4.4.6 4.5.6 0.8.6 4.5.5 5.9.8 3.5.7}.map do |s|
Chef::Version.new(s)
end
- got = a.sort.map { |v| v.to_s }
+ got = a.sort.map(&:to_s)
expect(got).to eq(%w{0.8.6 1.0.0 1.2.3 3.5.7 4.4.6 4.5.5 4.5.6 5.9.8 9.8.7})
end
@@ -160,7 +160,7 @@ describe Chef::Version do
[ "1.2.2", :<=, "1.2.1", false ],
[ "1.2.2", :<, "1.2.1", false ],
].each do |spec|
- it "(#{spec.first(3).join(' ')}) should be #{spec[3]}" do
+ it "(#{spec.first(3).join(" ")}) should be #{spec[3]}" do
got = Chef::Version.new(spec[0]).send(spec[1],
Chef::Version.new(spec[2]))
expect(got).to eq(spec[3])
diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb
index 574f38d8e2..2485d9ee47 100644
--- a/spec/unit/win32/registry_spec.rb
+++ b/spec/unit/win32/registry_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Win32::Registry do
let(:key_to_delete) { "OpscodeNumbers" }
let(:sub_key) { "OpscodePrimes" }
let(:missing_key_path) { 'HKCU\Software' }
- let(:registry) { Chef::Win32::Registry.new() }
+ let(:registry) { Chef::Win32::Registry.new }
let(:hive_mock) { double("::Win32::Registry::KHKEY_CURRENT_USER") }
let(:reg_mock) { double("reg") }
@@ -252,7 +252,7 @@ describe Chef::Win32::Registry do
expect(registry).to receive(:key_exists!).with(key_path).and_return(true)
expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key])
expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock)
- expect(reg_mock).to receive(:each_key).and_return(no_args())
+ expect(reg_mock).to receive(:each_key).and_return(no_args)
expect(registry.has_subkeys?(key_path)).to eq(false)
end
@@ -290,7 +290,7 @@ describe Chef::Win32::Registry do
expect(registry).to receive(:key_exists!).with(key_path).and_return(true)
expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key])
expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock)
- expect(reg_mock).to receive(:any?).and_yield(no_args())
+ expect(reg_mock).to receive(:any?).and_yield(no_args)
registry.value_exists?(key_path, value1) == false
end
end
@@ -305,7 +305,7 @@ describe Chef::Win32::Registry do
expect(registry).to receive(:key_exists!).with(key_path).and_return(true)
expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key])
expect(registry).to receive(:get_type_from_name).with(:string).and_return(1)
- expect(reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "1")
+ expect(reg_mock).to receive(:each).with(no_args).and_yield("one", 1, "1")
expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock)
expect(registry.data_exists?(key_path, value1)).to eq(true)
end
@@ -315,7 +315,7 @@ describe Chef::Win32::Registry do
expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key])
expect(hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | registry.registry_system_architecture).and_yield(reg_mock)
expect(registry).to receive(:get_type_from_name).with(:string).and_return(1)
- expect(reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "2")
+ expect(reg_mock).to receive(:each).with(no_args).and_yield("one", 1, "2")
expect(registry.data_exists?(key_path, value1)).to eq(false)
end
end
diff --git a/spec/unit/win32/security_spec.rb b/spec/unit/win32/security_spec.rb
index 3c612aef10..efbb290adf 100644
--- a/spec/unit/win32/security_spec.rb
+++ b/spec/unit/win32/security_spec.rb
@@ -98,7 +98,8 @@ describe "Chef::Win32::Security", :windows_only do
let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
- token_rights)
+ token_rights
+ )
end
it "raises error if GetTokenInformation fails" do