summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /spec
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/audit/runner_spec.rb4
-rw-r--r--spec/functional/dsl/reboot_pending_spec.rb4
-rw-r--r--spec/functional/dsl/registry_helper_spec.rb8
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb6
-rw-r--r--spec/functional/file_content_management/deploy_strategies_spec.rb3
-rw-r--r--spec/functional/knife/cookbook_delete_spec.rb8
-rw-r--r--spec/functional/knife/exec_spec.rb2
-rw-r--r--spec/functional/knife/smoke_test.rb2
-rw-r--r--spec/functional/knife/ssh_spec.rb2
-rw-r--r--spec/functional/mixin/shell_out_spec.rb4
-rw-r--r--spec/functional/notifications_spec.rb5
-rwxr-xr-xspec/functional/provider/remote_file/cache_control_data_spec.rb13
-rw-r--r--spec/functional/provider/whyrun_safe_ruby_block_spec.rb2
-rwxr-xr-xspec/functional/resource/aix_service_spec.rb1
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb22
-rw-r--r--spec/functional/resource/base.rb2
-rw-r--r--spec/functional/resource/bff_spec.rb2
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb12
-rw-r--r--spec/functional/resource/cron_spec.rb2
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb4
-rw-r--r--spec/functional/resource/dpkg_package_spec.rb6
-rw-r--r--spec/functional/resource/dsc_resource_spec.rb2
-rw-r--r--spec/functional/resource/dsc_script_spec.rb56
-rwxr-xr-xspec/functional/resource/env_spec.rb6
-rw-r--r--spec/functional/resource/file_spec.rb3
-rw-r--r--spec/functional/resource/git_spec.rb4
-rw-r--r--spec/functional/resource/group_spec.rb20
-rw-r--r--spec/functional/resource/link_spec.rb9
-rw-r--r--spec/functional/resource/ohai_spec.rb3
-rw-r--r--spec/functional/resource/package_spec.rb10
-rw-r--r--spec/functional/resource/powershell_script_spec.rb76
-rw-r--r--spec/functional/resource/registry_spec.rb131
-rw-r--r--spec/functional/resource/remote_directory_spec.rb4
-rw-r--r--spec/functional/resource/remote_file_spec.rb2
-rw-r--r--spec/functional/resource/template_spec.rb4
-rw-r--r--spec/functional/resource/user/useradd_spec.rb26
-rw-r--r--spec/functional/resource/windows_package_spec.rb8
-rw-r--r--spec/functional/resource/windows_service_spec.rb6
-rw-r--r--spec/functional/run_lock_spec.rb9
-rw-r--r--spec/functional/shell_spec.rb4
-rw-r--r--spec/functional/tiny_server_spec.rb12
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb30
-rw-r--r--spec/functional/win32/crypto_spec.rb2
-rw-r--r--spec/functional/win32/registry_spec.rb180
-rw-r--r--spec/functional/win32/security_spec.rb6
-rw-r--r--spec/functional/win32/service_manager_spec.rb7
-rw-r--r--spec/functional/win32/versions_spec.rb2
-rw-r--r--spec/integration/client/client_spec.rb7
-rw-r--r--spec/integration/client/ipv6_spec.rb11
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb8
-rw-r--r--spec/integration/knife/cookbook_api_ipv6_spec.rb4
-rw-r--r--spec/integration/knife/delete_spec.rb2
-rw-r--r--spec/integration/knife/diff_spec.rb4
-rw-r--r--spec/integration/knife/download_spec.rb8
-rw-r--r--spec/integration/knife/raw_spec.rb4
-rw-r--r--spec/integration/knife/redirection_spec.rb2
-rw-r--r--spec/integration/knife/show_spec.rb2
-rw-r--r--spec/integration/knife/upload_spec.rb19
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb4
-rw-r--r--spec/integration/recipes/provider_choice.rb1
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb31
-rw-r--r--spec/integration/recipes/resource_action_spec.rb790
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb1
-rw-r--r--spec/integration/recipes/resource_load_spec.rb20
-rw-r--r--spec/integration/solo/solo_spec.rb9
-rw-r--r--spec/scripts/ssl-serve.rb13
-rw-r--r--spec/spec_helper.rb13
-rw-r--r--spec/support/chef_helpers.rb1
-rw-r--r--spec/support/lib/chef/resource/cat.rb4
-rw-r--r--spec/support/lib/chef/resource/one_two_three_four.rb2
-rw-r--r--spec/support/lib/chef/resource/openldap_includer.rb1
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb3
-rw-r--r--spec/support/lib/library_load_order.rb2
-rw-r--r--spec/support/matchers/leak.rb4
-rw-r--r--spec/support/mock/constant.rb2
-rw-r--r--spec/support/mock/platform.rb8
-rw-r--r--spec/support/platform_helpers.rb9
-rw-r--r--spec/support/platforms/prof/gc.rb1
-rw-r--r--spec/support/platforms/prof/win32.rb1
-rw-r--r--spec/support/shared/context/client.rb8
-rw-r--r--spec/support/shared/examples/client.rb4
-rw-r--r--spec/support/shared/functional/diff_disabled.rb2
-rw-r--r--spec/support/shared/functional/directory_resource.rb2
-rw-r--r--spec/support/shared/functional/file_resource.rb29
-rw-r--r--spec/support/shared/functional/http.rb3
-rw-r--r--spec/support/shared/functional/securable_resource.rb2
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb8
-rw-r--r--spec/support/shared/functional/win32_service.rb2
-rw-r--r--spec/support/shared/functional/windows_script.rb4
-rw-r--r--spec/support/shared/integration/integration_helper.rb4
-rw-r--r--spec/support/shared/matchers/exit_with_code.rb2
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb2
-rw-r--r--spec/support/shared/unit/api_versioning.rb6
-rw-r--r--spec/support/shared/unit/knife_shared.rb1
-rw-r--r--spec/support/shared/unit/mock_shellout.rb3
-rw-r--r--spec/support/shared/unit/platform_introspector.rb12
-rw-r--r--spec/support/shared/unit/provider/file.rb28
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb37
-rw-r--r--spec/support/shared/unit/resource/static_provider_resolution.rb5
-rw-r--r--spec/support/shared/unit/script_resource.rb2
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb7
-rw-r--r--spec/support/shared/unit/windows_script_resource.rb1
-rw-r--r--spec/tiny_server.rb26
-rw-r--r--spec/unit/api_client/registration_spec.rb21
-rw-r--r--spec/unit/api_client_spec.rb7
-rw-r--r--spec/unit/api_client_v1_spec.rb10
-rw-r--r--spec/unit/application/apply_spec.rb2
-rw-r--r--spec/unit/application/client_spec.rb3
-rw-r--r--spec/unit/application/knife_spec.rb6
-rw-r--r--spec/unit/application/solo_spec.rb8
-rw-r--r--spec/unit/application_spec.rb2
-rw-r--r--spec/unit/audit/audit_event_proxy_spec.rb6
-rw-r--r--spec/unit/audit/audit_reporter_spec.rb24
-rw-r--r--spec/unit/audit/control_group_data_spec.rb23
-rw-r--r--spec/unit/audit/runner_spec.rb5
-rw-r--r--spec/unit/chef_fs/config_spec.rb2
-rw-r--r--spec/unit/chef_fs/data_handler/group_handler_spec.rb4
-rw-r--r--spec/unit/chef_fs/diff_spec.rb90
-rw-r--r--spec/unit/chef_fs/file_pattern_spec.rb1
-rw-r--r--spec/unit/chef_fs/parallelizer.rb70
-rw-r--r--spec/unit/chef_fs/path_util_spec.rb2
-rw-r--r--spec/unit/client_spec.rb10
-rw-r--r--spec/unit/config_fetcher_spec.rb13
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb1
-rw-r--r--spec/unit/cookbook/file_vendor_spec.rb7
-rw-r--r--spec/unit/cookbook/metadata_spec.rb63
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb6
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb8
-rw-r--r--spec/unit/cookbook_loader_spec.rb3
-rw-r--r--spec/unit/cookbook_manifest_spec.rb19
-rw-r--r--spec/unit/cookbook_uploader_spec.rb7
-rw-r--r--spec/unit/cookbook_version_file_specificity_spec.rb19
-rw-r--r--spec/unit/cookbook_version_spec.rb7
-rw-r--r--spec/unit/data_bag_item_spec.rb9
-rw-r--r--spec/unit/data_bag_spec.rb10
-rw-r--r--spec/unit/digester_spec.rb1
-rw-r--r--spec/unit/dsl/audit_spec.rb6
-rw-r--r--spec/unit/dsl/data_query_spec.rb10
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb15
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb18
-rw-r--r--spec/unit/dsl/recipe_spec.rb2
-rw-r--r--spec/unit/dsl/regsitry_helper_spec.rb3
-rw-r--r--spec/unit/dsl/resources_spec.rb6
-rw-r--r--spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb2
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb12
-rw-r--r--spec/unit/environment_spec.rb18
-rw-r--r--spec/unit/event_dispatch/dispatcher_spec.rb1
-rw-r--r--spec/unit/event_dispatch/dsl_spec.rb8
-rw-r--r--spec/unit/exceptions_spec.rb10
-rw-r--r--spec/unit/file_cache_spec.rb2
-rw-r--r--spec/unit/file_content_management/deploy/cp_spec.rb2
-rw-r--r--spec/unit/file_content_management/deploy/mv_unix_spec.rb2
-rw-r--r--spec/unit/file_content_management/deploy/mv_windows_spec.rb9
-rw-r--r--spec/unit/formatters/doc_spec.rb8
-rw-r--r--spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb7
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb6
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb3
-rw-r--r--spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb1
-rw-r--r--spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb1
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb6
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb6
-rw-r--r--spec/unit/guard_interpreter_spec.rb2
-rw-r--r--spec/unit/handler/json_file_spec.rb1
-rw-r--r--spec/unit/handler_spec.rb4
-rw-r--r--spec/unit/http/authenticator_spec.rb8
-rw-r--r--spec/unit/http/json_input_spec.rb6
-rw-r--r--spec/unit/http/socketless_chef_zero_client_spec.rb3
-rw-r--r--spec/unit/http/ssl_policies_spec.rb13
-rw-r--r--spec/unit/http/validate_content_length_spec.rb6
-rw-r--r--spec/unit/json_compat_spec.rb4
-rw-r--r--spec/unit/key_spec.rb35
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb7
-rw-r--r--spec/unit/knife/bootstrap_spec.rb21
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb6
-rw-r--r--spec/unit/knife/client_create_spec.rb3
-rw-r--r--spec/unit/knife/client_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_show_spec.rb2
-rw-r--r--spec/unit/knife/configure_client_spec.rb5
-rw-r--r--spec/unit/knife/configure_spec.rb6
-rw-r--r--spec/unit/knife/cookbook_bulk_delete_spec.rb14
-rw-r--r--spec/unit/knife/cookbook_create_spec.rb32
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb42
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb18
-rw-r--r--spec/unit/knife/cookbook_metadata_from_file_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb20
-rw-r--r--spec/unit/knife/cookbook_show_spec.rb9
-rw-r--r--spec/unit/knife/cookbook_site_download_spec.rb28
-rw-r--r--spec/unit/knife/cookbook_site_share_spec.rb12
-rw-r--r--spec/unit/knife/cookbook_test_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb24
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb42
-rw-r--r--spec/unit/knife/core/cookbook_scm_repo_spec.rb12
-rw-r--r--spec/unit/knife/core/gem_glob_loader_spec.rb19
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb4
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb6
-rw-r--r--spec/unit/knife/core/ui_spec.rb32
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb10
-rw-r--r--spec/unit/knife/data_bag_edit_spec.rb12
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb12
-rw-r--r--spec/unit/knife/environment_compare_spec.rb18
-rw-r--r--spec/unit/knife/environment_from_file_spec.rb4
-rw-r--r--spec/unit/knife/environment_list_spec.rb2
-rw-r--r--spec/unit/knife/index_rebuild_spec.rb21
-rw-r--r--spec/unit/knife/key_create_spec.rb3
-rw-r--r--spec/unit/knife/key_delete_spec.rb6
-rw-r--r--spec/unit/knife/key_edit_spec.rb9
-rw-r--r--spec/unit/knife/key_list_spec.rb14
-rw-r--r--spec/unit/knife/key_show_spec.rb4
-rw-r--r--spec/unit/knife/node_bulk_delete_spec.rb9
-rw-r--r--spec/unit/knife/node_delete_spec.rb2
-rw-r--r--spec/unit/knife/node_edit_spec.rb25
-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_list_spec.rb3
-rw-r--r--spec/unit/knife/node_run_list_add_spec.rb5
-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/raw_spec.rb2
-rw-r--r--spec/unit/knife/role_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_create_spec.rb2
-rw-r--r--spec/unit/knife/role_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_edit_spec.rb4
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb8
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb76
-rw-r--r--spec/unit/knife/role_env_run_list_remove_spec.rb92
-rw-r--r--spec/unit/knife/role_env_run_list_replace_spec.rb95
-rw-r--r--spec/unit/knife/role_env_run_list_set_spec.rb11
-rw-r--r--spec/unit/knife/role_from_file_spec.rb2
-rw-r--r--spec/unit/knife/role_list_spec.rb4
-rw-r--r--spec/unit/knife/role_run_list_add_spec.rb8
-rw-r--r--spec/unit/knife/role_run_list_clear_spec.rb56
-rw-r--r--spec/unit/knife/role_run_list_remove_spec.rb72
-rw-r--r--spec/unit/knife/role_run_list_replace_spec.rb81
-rw-r--r--spec/unit/knife/role_run_list_set_spec.rb9
-rw-r--r--spec/unit/knife/role_show_spec.rb4
-rw-r--r--spec/unit/knife/ssh_spec.rb28
-rw-r--r--spec/unit/knife/ssl_check_spec.rb8
-rw-r--r--spec/unit/knife/ssl_fetch_spec.rb8
-rw-r--r--spec/unit/knife/status_spec.rb6
-rw-r--r--spec/unit/knife/user_create_spec.rb6
-rw-r--r--spec/unit/knife/user_delete_spec.rb4
-rw-r--r--spec/unit/knife/user_edit_spec.rb6
-rw-r--r--spec/unit/knife/user_reregister_spec.rb4
-rw-r--r--spec/unit/knife/user_show_spec.rb4
-rw-r--r--spec/unit/knife_spec.rb26
-rw-r--r--spec/unit/log/winevt_spec.rb2
-rw-r--r--spec/unit/lwrp_spec.rb8
-rw-r--r--spec/unit/mash_spec.rb10
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb15
-rw-r--r--spec/unit/mixin/checksum_spec.rb1
-rw-r--r--spec/unit/mixin/command_spec.rb14
-rw-r--r--spec/unit/mixin/deep_merge_spec.rb202
-rw-r--r--spec/unit/mixin/params_validate_spec.rb68
-rw-r--r--spec/unit/mixin/path_sanity_spec.rb12
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb4
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb8
-rw-r--r--spec/unit/mixin/proxified_socket_spec.rb2
-rw-r--r--spec/unit/mixin/securable_spec.rb2
-rw-r--r--spec/unit/mixin/shell_out_spec.rb6
-rw-r--r--spec/unit/mixin/template_spec.rb7
-rw-r--r--spec/unit/mixin/uris_spec.rb2
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb23
-rw-r--r--spec/unit/node/attribute_spec.rb335
-rw-r--r--spec/unit/node/immutable_collections_spec.rb15
-rw-r--r--spec/unit/node_map_spec.rb2
-rw-r--r--spec/unit/node_spec.rb74
-rw-r--r--spec/unit/org_spec.rb14
-rw-r--r--spec/unit/platform/query_helpers_spec.rb4
-rw-r--r--spec/unit/platform_spec.rb4
-rw-r--r--spec/unit/policy_builder/dynamic_spec.rb10
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb14
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb31
-rw-r--r--spec/unit/property/state_spec.rb14
-rw-r--r--spec/unit/property/validation_spec.rb20
-rw-r--r--spec/unit/property_spec.rb9
-rw-r--r--spec/unit/provider/breakpoint_spec.rb1
-rw-r--r--spec/unit/provider/cookbook_file/content_spec.rb1
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb2
-rw-r--r--spec/unit/provider/cron_spec.rb8
-rw-r--r--spec/unit/provider/deploy/revision_spec.rb9
-rw-r--r--spec/unit/provider/deploy_spec.rb31
-rw-r--r--spec/unit/provider/directory_spec.rb8
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb14
-rw-r--r--spec/unit/provider/dsc_script_spec.rb3
-rw-r--r--spec/unit/provider/env/windows_spec.rb14
-rw-r--r--spec/unit/provider/env_spec.rb6
-rw-r--r--spec/unit/provider/erl_call_spec.rb1
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/file/content_spec.rb2
-rw-r--r--spec/unit/provider/file_spec.rb3
-rw-r--r--spec/unit/provider/git_spec.rb79
-rw-r--r--spec/unit/provider/group/dscl_spec.rb2
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb8
-rw-r--r--spec/unit/provider/group/groupmod_spec.rb20
-rw-r--r--spec/unit/provider/group_spec.rb20
-rw-r--r--spec/unit/provider/http_request_spec.rb2
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb3
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb6
-rw-r--r--spec/unit/provider/mdadm_spec.rb10
-rw-r--r--spec/unit/provider/mount/aix_spec.rb6
-rw-r--r--spec/unit/provider/mount/mount_spec.rb14
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb2
-rw-r--r--spec/unit/provider/mount/windows_spec.rb12
-rw-r--r--spec/unit/provider/mount_spec.rb3
-rw-r--r--spec/unit/provider/ohai_spec.rb4
-rw-r--r--spec/unit/provider/osx_profile_spec.rb168
-rw-r--r--spec/unit/provider/package/aix_spec.rb6
-rw-r--r--spec/unit/provider/package/apt_spec.rb44
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb48
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb6
-rw-r--r--spec/unit/provider/package/freebsd/pkg_spec.rb10
-rw-r--r--spec/unit/provider/package/freebsd/pkgng_spec.rb9
-rw-r--r--spec/unit/provider/package/freebsd/port_spec.rb15
-rw-r--r--spec/unit/provider/package/homebrew_spec.rb2
-rw-r--r--spec/unit/provider/package/ips_spec.rb11
-rw-r--r--spec/unit/provider/package/macports_spec.rb2
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb22
-rw-r--r--spec/unit/provider/package/pacman_spec.rb12
-rw-r--r--spec/unit/provider/package/paludis_spec.rb13
-rw-r--r--spec/unit/provider/package/rpm_spec.rb4
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb28
-rw-r--r--spec/unit/provider/package/smartos_spec.rb10
-rw-r--r--spec/unit/provider/package/solaris_spec.rb4
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb6
-rw-r--r--spec/unit/provider/package/windows_spec.rb10
-rw-r--r--spec/unit/provider/package/yum_spec.rb66
-rw-r--r--spec/unit/provider/package/zypper_spec.rb22
-rw-r--r--spec/unit/provider/powershell_script_spec.rb4
-rw-r--r--spec/unit/provider/remote_directory_spec.rb16
-rw-r--r--spec/unit/provider/remote_file/cache_control_data_spec.rb3
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb3
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb16
-rw-r--r--spec/unit/provider/remote_file_spec.rb4
-rw-r--r--spec/unit/provider/route_spec.rb7
-rw-r--r--spec/unit/provider/ruby_block_spec.rb3
-rw-r--r--spec/unit/provider/script_spec.rb2
-rw-r--r--spec/unit/provider/service/aix_service_spec.rb1
-rw-r--r--spec/unit/provider/service/aixinit_service_spec.rb40
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb16
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb42
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb14
-rw-r--r--spec/unit/provider/service/init_service_spec.rb12
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb2
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb12
-rw-r--r--spec/unit/provider/service/macosx_spec.rb38
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb6
-rw-r--r--spec/unit/provider/service/redhat_spec.rb28
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb6
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb24
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb4
-rw-r--r--spec/unit/provider/service/windows_spec.rb2
-rw-r--r--spec/unit/provider/service_spec.rb1
-rw-r--r--spec/unit/provider/subversion_spec.rb29
-rw-r--r--spec/unit/provider/template/content_spec.rb2
-rw-r--r--spec/unit/provider/template_spec.rb5
-rw-r--r--spec/unit/provider/user/dscl_spec.rb9
-rw-r--r--spec/unit/provider/user/pw_spec.rb10
-rw-r--r--spec/unit/provider/user/windows_spec.rb8
-rw-r--r--spec/unit/provider/user_spec.rb7
-rw-r--r--spec/unit/provider/whyrun_safe_ruby_block_spec.rb3
-rw-r--r--spec/unit/provider_spec.rb9
-rw-r--r--spec/unit/recipe_spec.rb11
-rw-r--r--spec/unit/resource/conditional_spec.rb4
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb29
-rw-r--r--spec/unit/resource/cron_spec.rb2
-rw-r--r--spec/unit/resource/deploy_spec.rb37
-rw-r--r--spec/unit/resource/dsc_resource_spec.rb2
-rw-r--r--spec/unit/resource/dsc_script_spec.rb6
-rw-r--r--spec/unit/resource/env_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb10
-rw-r--r--spec/unit/resource/file_spec.rb14
-rw-r--r--spec/unit/resource/freebsd_package_spec.rb3
-rw-r--r--spec/unit/resource/http_request_spec.rb2
-rw-r--r--spec/unit/resource/link_spec.rb2
-rw-r--r--spec/unit/resource/mount_spec.rb4
-rw-r--r--spec/unit/resource/ohai_spec.rb1
-rw-r--r--spec/unit/resource/openbsd_package_spec.rb1
-rw-r--r--spec/unit/resource/osx_profile_spec.rb4
-rw-r--r--spec/unit/resource/package_spec.rb4
-rw-r--r--spec/unit/resource/powershell_script_spec.rb20
-rw-r--r--spec/unit/resource/registry_key_spec.rb6
-rw-r--r--spec/unit/resource/remote_file_spec.rb16
-rw-r--r--spec/unit/resource/resource_notification_spec.rb30
-rw-r--r--spec/unit/resource/scm_spec.rb10
-rw-r--r--spec/unit/resource/service_spec.rb3
-rw-r--r--spec/unit/resource/template_spec.rb9
-rw-r--r--spec/unit/resource/user_spec.rb2
-rw-r--r--spec/unit/resource_collection/resource_list_spec.rb8
-rw-r--r--spec/unit/resource_collection/resource_set_spec.rb12
-rw-r--r--spec/unit/resource_collection/stepable_iterator_spec.rb8
-rw-r--r--spec/unit/resource_collection_spec.rb9
-rw-r--r--spec/unit/resource_reporter_spec.rb58
-rw-r--r--spec/unit/resource_resolver_spec.rb1
-rw-r--r--spec/unit/resource_spec.rb40
-rw-r--r--spec/unit/rest/auth_credentials_spec.rb14
-rw-r--r--spec/unit/rest_spec.rb99
-rw-r--r--spec/unit/role_spec.rb16
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb2
-rw-r--r--spec/unit/run_context_spec.rb4
-rw-r--r--spec/unit/run_list/run_list_expansion_spec.rb14
-rw-r--r--spec/unit/run_list/run_list_item_spec.rb10
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb29
-rw-r--r--spec/unit/run_list_spec.rb1
-rw-r--r--spec/unit/run_lock_spec.rb8
-rw-r--r--spec/unit/run_status_spec.rb1
-rw-r--r--spec/unit/runner_spec.rb8
-rw-r--r--spec/unit/scan_access_control_spec.rb1
-rw-r--r--spec/unit/search/query_spec.rb6
-rw-r--r--spec/unit/shell/model_wrapper_spec.rb13
-rw-r--r--spec/unit/shell/shell_ext_spec.rb4
-rw-r--r--spec/unit/shell/shell_session_spec.rb3
-rw-r--r--spec/unit/shell_spec.rb10
-rw-r--r--spec/unit/user_spec.rb19
-rw-r--r--spec/unit/user_v1_spec.rb13
-rw-r--r--spec/unit/util/backup_spec.rb1
-rw-r--r--spec/unit/util/diff_spec.rb7
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb36
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb8
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb9
-rw-r--r--spec/unit/util/dsc/resource_store.rb4
-rw-r--r--spec/unit/util/file_edit_spec.rb4
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb16
-rw-r--r--spec/unit/util/powershell/ps_credential_spec.rb2
-rw-r--r--spec/unit/util/selinux_spec.rb9
-rw-r--r--spec/unit/version/platform_spec.rb1
-rw-r--r--spec/unit/version_class_spec.rb3
-rw-r--r--spec/unit/version_constraint/platform_spec.rb1
-rw-r--r--spec/unit/win32/registry_spec.rb32
433 files changed, 3223 insertions, 3520 deletions
diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb
index dcfa69c349..54f014e28f 100644
--- a/spec/functional/audit/runner_spec.rb
+++ b/spec/functional/audit/runner_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Audit::Runner do
expect(2 - 2).to eq(0)
end
end
- { control_group_name => Struct.new(:args, :block).new([control_group_name], should_pass)}
+ { control_group_name => Struct.new(:args, :block).new([control_group_name], should_pass) }
end
end
@@ -74,7 +74,7 @@ describe Chef::Audit::Runner do
expect(2 - 1).to eq(0)
end
end
- { control_group_name => Struct.new(:args, :block).new([control_group_name], should_fail)}
+ { control_group_name => Struct.new(:args, :block).new([control_group_name], should_fail) }
end
end
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb
index 6f600ca325..c7a93c6822 100644
--- a/spec/functional/dsl/reboot_pending_spec.rb
+++ b/spec/functional/dsl/reboot_pending_spec.rb
@@ -22,7 +22,7 @@ require "spec_helper"
describe Chef::DSL::RebootPending, :windows_only do
def run_ohai
- node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ node.consume_external_attrs(OHAI_SYSTEM.data, {})
end
let(:node) { Chef::Node.new }
@@ -98,7 +98,7 @@ describe Chef::DSL::RebootPending, :windows_only do
describe "when there is nothing to indicate a reboot is pending" do
it "should return false" do
- skip "reboot pending" if @any_flag.any? { |_,v| v == true }
+ skip "reboot pending" if @any_flag.any? { |_, v| v == true }
expect(recipe.reboot_pending?).to be_falsey
end
end
diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb
index 885615b6d7..d90d5090e4 100644
--- a/spec/functional/dsl/registry_helper_spec.rb
+++ b/spec/functional/dsl/registry_helper_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
- node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ node.consume_external_attrs(OHAI_SYSTEM.data, {})
run_context = Chef::RunContext.new(node, {}, events)
@resource = Chef::Resource.new("foo", run_context)
end
@@ -42,7 +42,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
end
it "returns true if registry has specified value" do
values = @resource.registry_get_values("HKCU\\Software\\Root")
- expect(values.include?({:name=>"RootType1",:type=>:string,:data=>"fibrous"})).to eq(true)
+ expect(values.include?({ :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
end
it "returns true if specified registry_has_subkey" do
expect(@resource.registry_has_subkeys?("HKCU\\Software\\Root")).to eq(true)
@@ -52,10 +52,10 @@ describe Chef::Resource::RegistryKey, :windows_only do
expect(subkeys.include?("Branch")).to eq(true)
end
it "returns true if registry_value_exists" do
- expect(@resource.registry_value_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"})).to eq(true)
+ expect(@resource.registry_value_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
end
it "returns true if data_value_exists" do
- expect(@resource.registry_data_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"})).to eq(true)
+ expect(@resource.registry_data_exists?("HKCU\\Software\\Root", { :name => "RootType1", :type => :string, :data => "fibrous" })).to eq(true)
end
end
end
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 0f59e64f25..031405f718 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -26,7 +26,7 @@ end
describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_on_win2k3 do
def rand
- random.rand(1<<32).to_s
+ random.rand(1 << 32).to_s
end
let(:random) { Random.new }
@@ -36,10 +36,10 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_o
let(:logger) { Chef::EventLoggers::WindowsEventLogger.new }
let(:flags) { nil }
let(:node) { nil }
- let(:run_status) { double("Run Status", {run_id: run_id, elapsed_time: elapsed_time }) }
+ let(:run_status) { double("Run Status", { run_id: run_id, elapsed_time: elapsed_time }) }
let(:event_log) { EventLog.new("Application") }
let!(:offset) { event_log.read_last_event.record_number }
- let(:mock_exception) { double("Exception", {message: rand, backtrace: [rand, rand]})}
+ let(:mock_exception) { double("Exception", { message: rand, backtrace: [rand, rand] }) }
it "is available" do
expect(Chef::EventLoggers::WindowsEventLogger.available?).to be_truthy
diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb
index d3fc6bcd37..7c54af347c 100644
--- a/spec/functional/file_content_management/deploy_strategies_spec.rb
+++ b/spec/functional/file_content_management/deploy_strategies_spec.rb
@@ -38,7 +38,6 @@ shared_examples_for "a content deploy strategy" do
let(:content_deployer) { described_class.new }
let(:target_file_path) { File.join(sandbox_dir, "cp-deploy-strategy-target-file.txt") }
-
describe "creating the file" do
##
@@ -69,7 +68,7 @@ shared_examples_for "a content deploy strategy" do
def ace_inherits?(ace)
flags = ace.flags
- (flags & masks::OBJECT_INHERIT_ACE) !=0
+ (flags & masks::OBJECT_INHERIT_ACE) != 0
end
let(:parent_inheritable_aces) do
diff --git a/spec/functional/knife/cookbook_delete_spec.rb b/spec/functional/knife/cookbook_delete_spec.rb
index 1757b22842..a43e3a36c4 100644
--- a/spec/functional/knife/cookbook_delete_spec.rb
+++ b/spec/functional/knife/cookbook_delete_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Knife::CookbookDelete do
before do
@knife.name_args = %w{no-such-cookbook}
- @api.get("/cookbooks/no-such-cookbook", 404, Chef::JSONCompat.to_json({"error"=>"dear Tim, no. -Sent from my iPad"}))
+ @api.get("/cookbooks/no-such-cookbook", 404, Chef::JSONCompat.to_json({ "error" => "dear Tim, no. -Sent from my iPad" }))
end
around do |ex|
@@ -62,7 +62,7 @@ describe Chef::Knife::CookbookDelete do
it "logs an error and exits" do
allow(@knife.ui).to receive(:stderr).and_return(log_output)
- expect {@knife.run}.to raise_error(SystemExit)
+ expect { @knife.run }.to raise_error(SystemExit)
expect(log_output.string).to match(/Cannot find a cookbook named no-such-cookbook to delete/)
end
@@ -71,7 +71,7 @@ describe Chef::Knife::CookbookDelete do
context "when there is only one version of a cookbook" do
before do
@knife.name_args = %w{obsolete-cookbook}
- @cookbook_list = {"obsolete-cookbook" => { "versions" => ["version" => "1.0.0"]} }
+ @cookbook_list = { "obsolete-cookbook" => { "versions" => ["version" => "1.0.0"] } }
@api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list))
end
@@ -114,7 +114,7 @@ describe Chef::Knife::CookbookDelete do
@knife.name_args = %w{obsolete-cookbook}
versions = ["1.0.0", "1.1.0", "1.2.0"]
with_version = lambda { |version| { "version" => version } }
- @cookbook_list = {"obsolete-cookbook" => { "versions" => versions.map(&with_version) } }
+ @cookbook_list = { "obsolete-cookbook" => { "versions" => versions.map(&with_version) } }
@api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list))
end
diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb
index 62e3a4c214..838d15671c 100644
--- a/spec/functional/knife/exec_spec.rb
+++ b/spec/functional/knife/exec_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Knife::Exec do
it "executes a script in the context of the chef-shell main context" do
@node = Chef::Node.new
@node.name("ohai-world")
- response = {"rows" => [@node],"start" => 0,"total" => 1}
+ response = { "rows" => [@node], "start" => 0, "total" => 1 }
@api.get(%r{^/search/node}, 200, Chef::JSONCompat.to_json(response))
code = "$output.puts nodes.all"
@knife.config[:exec] = code
diff --git a/spec/functional/knife/smoke_test.rb b/spec/functional/knife/smoke_test.rb
index 8681a01873..350644d177 100644
--- a/spec/functional/knife/smoke_test.rb
+++ b/spec/functional/knife/smoke_test.rb
@@ -31,7 +31,7 @@ describe "knife smoke tests" do
knife_cmd.error!
expect(knife_cmd.stdout).to include(Chef::VERSION)
end
-
+
it "can run and show help" do
knife_path = File.expand_path("../../bin/knife", CHEF_SPEC_DATA)
knife_cmd = Mixlib::ShellOut.new("#{knife_path} --help")
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index e516590905..a23220ed52 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -262,7 +262,7 @@ describe Chef::Knife::Ssh do
end
end
- def setup_knife(params=[])
+ def setup_knife(params = [])
@knife = Chef::Knife::Ssh.new(params)
# We explicitly avoid running #configure_chef, which would read a knife.rb
# if available, but #merge_configs (which is called by #configure_chef) is
diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb
index edbfaa9ec8..48f6b7d912 100644
--- a/spec/functional/mixin/shell_out_spec.rb
+++ b/spec/functional/mixin/shell_out_spec.rb
@@ -36,9 +36,9 @@ describe Chef::Mixin::ShellOut do
describe "when environment['LC_ALL'] is set" do
it "should use the option's setting" do
cmd = if windows?
- shell_out_with_systems_locale("echo %LC_ALL%", :environment => {"LC_ALL" => "POSIX"})
+ shell_out_with_systems_locale("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" })
else
- shell_out_with_systems_locale("echo $LC_ALL", :environment => {"LC_ALL" => "POSIX"})
+ shell_out_with_systems_locale("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" })
end
expect(cmd.stdout.chomp).to eq "POSIX"
diff --git a/spec/functional/notifications_spec.rb b/spec/functional/notifications_spec.rb
index ec6e514836..1b1ef83294 100644
--- a/spec/functional/notifications_spec.rb
+++ b/spec/functional/notifications_spec.rb
@@ -1,7 +1,6 @@
require "spec_helper"
require "chef/recipe"
-
# The goal of these tests is to make sure that loading resources from a file creates the necessary notifications.
# Then once converge has started, both immediate and delayed notifications are called as the resources are converged.
# We want to do this WITHOUT actually converging any resources - we don't want to take time changing the system,
@@ -136,7 +135,7 @@ describe "Notifications" do
expect(actions).to eq [
# First it runs why-run to check if the resource would update
- { resource: log_resource.to_s, action: :write, why_run: true },
+ { resource: log_resource.to_s, action: :write, why_run: true },
# Then it does NOT run the before action
# Then it runs the actual action
{ resource: log_resource.to_s, action: :write },
@@ -228,7 +227,7 @@ describe "Notifications" do
end
# Mocks having the provider run successfully and update the resource
- def update_action(resource, times=1)
+ def update_action(resource, times = 1)
p = Chef::Provider.new(resource, run_context)
expect(resource).to receive(:provider_for_action).exactly(times).times.and_return(p)
expect(p).to receive(:run_action).exactly(times).times {
diff --git a/spec/functional/provider/remote_file/cache_control_data_spec.rb b/spec/functional/provider/remote_file/cache_control_data_spec.rb
index e567c0b876..c56787e7e5 100755
--- a/spec/functional/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/functional/provider/remote_file/cache_control_data_spec.rb
@@ -22,13 +22,13 @@ require "uri"
describe Chef::Provider::RemoteFile::CacheControlData do
before do
- @original_config = Chef::Config.hash_dup
+ @original_config = Chef::Config.hash_dup
end
after do
- Chef::Config.configuration = @original_config if @original_config
+ Chef::Config.configuration = @original_config if @original_config
end
-
+
before(:each) do
Chef::Config[:file_cache_path] = Dir.mktmpdir
end
@@ -38,7 +38,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
end
let(:uri) { URI.parse("http://www.bing.com/robots.txt") }
-
+
describe "when the cache control data save method is invoked" do
subject(:cache_control_data) do
@@ -66,7 +66,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
expect(saved_cache_control_data.etag).to eq(cache_control_data.etag)
expect(saved_cache_control_data.mtime).to eq(cache_control_data.mtime)
- expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
+ expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
end
# Cover the very long remote file path case -- see CHEF-4422 where
@@ -91,11 +91,10 @@ describe Chef::Provider::RemoteFile::CacheControlData do
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
expect(saved_cache_control_data.etag).to eq(cache_control_data.etag)
expect(saved_cache_control_data.mtime).to eq(cache_control_data.mtime)
- expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
+ expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
end
end
end
end
-
diff --git a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
index b68193e8b9..892e1080db 100644
--- a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
@@ -43,7 +43,7 @@ describe Chef::Resource::WhyrunSafeRubyBlock do
end
it "updates the evil laugh, even in why-run mode" do
- Array(new_resource.action).each {|action| new_resource.run_action(action) }
+ Array(new_resource.action).each { |action| new_resource.run_action(action) }
expect($evil_global_evil_laugh).to eq(:mwahahaha)
expect(new_resource).to be_updated
end
diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb
index fe71f10cb3..5fff3e00d7 100755
--- a/spec/functional/resource/aix_service_spec.rb
+++ b/spec/functional/resource/aix_service_spec.rb
@@ -94,7 +94,6 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
shell_out!("rmssys -s ctestsys")
end
-
let(:new_resource) do
new_resource = Chef::Resource::Service.new("ctestsys", run_context)
new_resource
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index 63c9cf618a..92ddb52c33 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
directory = []
if priority.is_a? Hash
- priority.each do |level,o|
+ priority.each do |level, o|
directory << "/etc/rc.d/rc#{level}.d/#{(o[0] == :start ? 'S' : 'K')}#{o[1]}#{new_resource.service_name}"
end
directory
@@ -59,7 +59,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
let(:new_resource) do
new_resource = Chef::Resource::Service.new("chefinittest", run_context)
new_resource.provider Chef::Provider::Service::AixInit
- new_resource.supports({:status => true, :restart => true, :reload => true})
+ new_resource.supports({ :status => true, :restart => true, :reload => true })
new_resource
end
@@ -70,7 +70,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
before(:all) do
File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
- FileUtils.cp("#{File.join(File.dirname(__FILE__), "/../assets/chefinittest")}", "/etc/rc.d/init.d/chefinittest")
+ FileUtils.cp("#{File.join(File.dirname(__FILE__), "/../assets/chefinittest")}", "/etc/rc.d/init.d/chefinittest")
end
after(:all) do
@@ -130,7 +130,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
context "when the service doesn't set a priority" do
it "creates symlink with status S" do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"],2,"S")
+ valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"], 2, "S")
end
end
@@ -141,19 +141,19 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates a symlink with status S and a priority" do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2,"S",75)
+ valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2, "S", 75)
end
end
context "when the service sets complex priorities (hash)" do
before do
- priority = {2 => [:start, 20], 3 => [:stop, 10]}
+ priority = { 2 => [:start, 20], 3 => [:stop, 10] }
new_resource.priority(priority)
end
it "create symlink with status start (S) or stop (K) and a priority " do
new_resource.run_action(:enable)
- valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2,"S",new_resource.priority)
+ valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2, "S", new_resource.priority)
end
end
end
@@ -171,7 +171,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates symlink with status K" do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2,"K")
+ valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2, "K")
end
end
@@ -187,13 +187,13 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "creates a symlink with status K and a priority" do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2,"K",25)
+ valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2, "K", 25)
end
end
context "when the service sets complex priorities (hash)" do
before do
- @priority = {2 => [:stop, 20], 3 => [:start, 10]}
+ @priority = { 2 => [:stop, 20], 3 => [:start, 10] }
new_resource.priority(@priority)
File.symlink("/etc/rc.d/init.d/chefinittest", "/etc/rc.d/rc2.d/Schefinittest")
end
@@ -204,7 +204,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
it "create symlink with status stop (K) and a priority " do
new_resource.run_action(:disable)
- valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2,"K",80)
+ valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2, "K", 80)
end
end
end
diff --git a/spec/functional/resource/base.rb b/spec/functional/resource/base.rb
index 40d178479b..38175e81c0 100644
--- a/spec/functional/resource/base.rb
+++ b/spec/functional/resource/base.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
def run_context
@run_context ||= begin
node = Chef::Node.new
@@ -27,4 +26,3 @@ def run_context
Chef::RunContext.new(node, {}, events)
end
end
-
diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb
index 326340606d..3a1d5840e8 100644
--- a/spec/functional/resource/bff_spec.rb
+++ b/spec/functional/resource/bff_spec.rb
@@ -39,7 +39,6 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
!::File.exists?("/usr/PkgA/bin/acommand")
end
-
before(:all) do
@pkg_name = "PkgA.rte"
@pkg_path = "/tmp/PkgA.1.0.0.0.bff"
@@ -119,4 +118,3 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
end
end
end
-
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index 7cbaaf0d6b..e442008060 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
let(:package_name) { "test-A" }
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
new_resource = Chef::Resource::ChocolateyPackage.new("test choco package", run_context)
new_resource.package_name package_name
@@ -80,13 +80,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
it "raises if package is not found" do
subject.package_name "blah"
- expect{ subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
+ expect { subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
end
- it "raises if package version is not found" do
+ it "raises if package version is not found" do
subject.version "3.0"
- expect{ subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
- end
+ expect { subject.run_action(:install) }.to raise_error Chef::Exceptions::Package
+ end
end
context "upgrading a package" do
@@ -121,4 +121,4 @@ describe Chef::Resource::ChocolateyPackage, :windows_only do
expect(package_list.call).to eq("")
end
end
-end \ No newline at end of file
+end
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb
index 8c12b6e867..2906715f7a 100644
--- a/spec/functional/resource/cron_spec.rb
+++ b/spec/functional/resource/cron_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
describe "create action with various attributes", :external => exclude_solaris do
def create_and_validate_with_attribute(resource, attribute, value)
if ohai[:platform] == "aix"
- expect {resource.run_action(:create)}.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
else
resource.run_action(:create)
# Verify if the cron is created successfully
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index 184c1cd017..4772067949 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -799,7 +799,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
let(:deploy_that_fails) do
resource = deploy_to_latest_rev.dup
- errant_callback = lambda {|x| raise Exception, "I am a failed deploy" }
+ errant_callback = lambda { |x| raise Exception, "I am a failed deploy" }
resource.send(callback, &errant_callback)
resource
end
@@ -862,7 +862,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
let(:deploy_that_fails) do
resource = deploy_to_previous_rev.dup
- resource.after_restart {|x| raise Exception, "I am a failed deploy" }
+ resource.after_restart { |x| raise Exception, "I am a failed deploy" }
resource
end
diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb
index 3a09faf0d6..d65256231b 100644
--- a/spec/functional/resource/dpkg_package_spec.rb
+++ b/spec/functional/resource/dpkg_package_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
Chef::RunContext.new(node, {}, events)
}
- let(:dpkg_package) { Chef::Resource::DpkgPackage.new(test1_0, run_context)}
+ let(:dpkg_package) { Chef::Resource::DpkgPackage.new(test1_0, run_context) }
before(:each) do
shell_out("dpkg -P chef-integration-test chef-integration-test2")
@@ -45,7 +45,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.package_name name
end
- def should_be_purged_or_removed(package, action=nil)
+ def should_be_purged_or_removed(package, action = nil)
status = shell_out("dpkg -s #{package}")
output = status.stdout + status.stderr
if action.nil? || action == :purge
@@ -318,7 +318,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name "chef-integration-test2"
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- shell_out!("dpkg -s chef-integration-test2") # its still 'installed'
+ shell_out!("dpkg -s chef-integration-test2") # its still 'installed'
end
end
diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb
index f2c943f21d..129333c190 100644
--- a/spec/functional/resource/dsc_resource_spec.rb
+++ b/spec/functional/resource/dsc_resource_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
context "with a valid dsc resource" do
let(:tmp_file_name) { Dir::Tmpname.create("tmpfile") {} }
- let(:test_text) { "'\"!@#$%^&*)(}{][\u2713~n"}
+ let(:test_text) { "'\"!@#$%^&*)(}{][\u2713~n" }
before do
new_resource.resource :File
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index cb8d73f746..5f264fdca1 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
data_suffix = data ? "_config_data" : ""
extension = data ? "psd1" : "ps1"
script_path = "#{@temp_dir}/dsc_functional_test#{data_suffix}.#{extension}"
- ::File.open(script_path, "wt") do | script |
+ ::File.open(script_path, "wt") do |script|
script.write(script_code)
end
script_path
@@ -68,7 +68,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
node = Chef::Node.new
node.automatic["platform"] = "windows"
node.automatic["platform_version"] = "6.1"
- node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
+ node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
node.automatic[:languages][:powershell][:version] = "4.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
@@ -83,7 +83,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:test_registry_data2) { "LL928" }
let(:reg_key_name_param_name) { "testregkeyname" }
let(:reg_key_value_param_name) { "testregvaluename" }
- let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'"}
+ let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'" }
let(:dsc_reg_code) { <<-EOH
#{registry_embedded_parameters}
Registry "ChefRegKey"
@@ -105,17 +105,17 @@ EOH
let(:dsc_user_prefix) { "dsc" }
let(:dsc_user_suffix) { "chefx" }
- let(:dsc_user) {"#{dsc_user_prefix}_usr_#{dsc_user_suffix}" }
+ let(:dsc_user) { "#{dsc_user_prefix}_usr_#{dsc_user_suffix}" }
let(:dsc_user_prefix_env_var_name) { "dsc_user_env_prefix" }
let(:dsc_user_suffix_env_var_name) { "dsc_user_env_suffix" }
- let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}"}
- let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}"}
+ let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}" }
+ let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}" }
let(:dsc_user_prefix_param_name) { "dsc_user_prefix_param" }
let(:dsc_user_suffix_param_name) { "dsc_user_suffix_param" }
- let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}"}
- let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}"}
- let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\""}
- let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\""}
+ let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}" }
+ let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}" }
+ let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\"" }
+ let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\"" }
let(:config_flags) { nil }
let(:config_params) { <<-EOH
@@ -157,7 +157,7 @@ EOH
}
let(:dsc_user_config_data) {
-<<-EOH
+ <<-EOH
@{
AllNodes = @(
@{
@@ -220,7 +220,7 @@ EOH
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
end
it_should_behave_like "a dsc_script resource with configuration affected by cwd"
@@ -243,12 +243,12 @@ EOH
let(:dsc_code) { dsc_environment_config }
it "should not raise an exception if the cwd is not etc" do
dsc_test_resource.cwd(dsc_environment_no_fail_not_etc_directory)
- expect {dsc_test_resource.run_action(:run)}.not_to raise_error
+ expect { dsc_test_resource.run_action(:run) }.not_to raise_error
end
it "should raise an exception if the cwd is etc" do
dsc_test_resource.cwd(dsc_environment_fail_etc_directory)
- expect {dsc_test_resource.run_action(:run)}.to raise_error(Chef::Exceptions::PowershellCmdletException)
+ expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::Exceptions::PowershellCmdletException)
begin
dsc_test_resource.run_action(:run)
rescue Chef::Exceptions::PowershellCmdletException => e
@@ -280,7 +280,7 @@ EOH
end
let(:test_registry_data) { test_registry_data1 }
- let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s }
+ let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s }
it "should have a default value of nil for the configuration_data attribute" do
expect(dsc_test_resource.configuration_data).to eql(nil)
@@ -296,11 +296,11 @@ EOH
it "should set a registry key according to parameters passed to the configuration" do
dsc_test_resource.configuration_name(config_name_value)
- dsc_test_resource.flags({:"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value})
+ dsc_test_resource.flags({ :"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value })
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
dsc_test_resource.run_action(:run)
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
- expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
+ expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true)
end
end
end
@@ -320,12 +320,12 @@ EOH
if configuration_data_attribute == "configuration_data_script"
config_data_value = create_config_script_from_code(dsc_user_config_data, "", true)
end
- dsc_test_resource.environment({dsc_user_prefix_env_var_name => dsc_user_prefix,
- dsc_user_suffix_env_var_name => dsc_user_suffix})
+ dsc_test_resource.environment({ dsc_user_prefix_env_var_name => dsc_user_prefix,
+ dsc_user_suffix_env_var_name => dsc_user_suffix })
dsc_test_resource.send(configuration_data_attribute, config_data_value)
dsc_test_resource.flags(config_flags)
expect(user_exists?(dsc_user)).to eq(false)
- expect {dsc_test_resource.run_action(:run)}.not_to raise_error
+ expect { dsc_test_resource.run_action(:run) }.not_to raise_error
expect(user_exists?(dsc_user)).to eq(true)
end
end
@@ -333,9 +333,9 @@ EOH
shared_examples_for "a dsc_script with configuration data that takes parameters" do
let(:dsc_user_code) { dsc_user_param_code }
let(:config_param_section) { config_params }
- let(:config_flags) {{:"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}"}}
+ let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}" } }
it "does not directly contain the user name" do
- configuration_script_content = ::File.open(dsc_test_resource.command) do | file |
+ configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
file.read
end
expect(configuration_script_content.include?(dsc_user)).to be(false)
@@ -347,7 +347,7 @@ EOH
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 |
+ configuration_script_content = ::File.open(dsc_test_resource.command) do |file|
file.read
end
expect(configuration_script_content.include?(dsc_user)).to be(false)
@@ -385,7 +385,7 @@ EOH
before(:each) do
delete_user(dsc_user)
- dsc_test_run_context.node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ dsc_test_run_context.node.consume_external_attrs(OHAI_SYSTEM.data, {})
end
let(:configuration_data_path) { 'C:\\configurationdata.psd1' }
@@ -422,12 +422,12 @@ if($cert -eq $null) {
}
lcm -thumbprint $cert.thumbprint
-set-dsclocalconfigurationmanager -path ./LCM
+set-dsclocalconfigurationmanager -path ./LCM
$ConfigurationData = @"
@{
-AllNodes = @(
- @{
- NodeName = "localhost";
+AllNodes = @(
+ @{
+ NodeName = "localhost";
CertificateID = '$($cert.thumbprint)';
};
);
diff --git a/spec/functional/resource/env_spec.rb b/spec/functional/resource/env_spec.rb
index 91fa860cd7..83328a6738 100755
--- a/spec/functional/resource/env_spec.rb
+++ b/spec/functional/resource/env_spec.rb
@@ -90,7 +90,7 @@ describe Chef::Resource::Env, :windows_only do
expect(ENV[chef_env_test_lower_case]).to eq(nil)
test_resource.key_name(chef_env_test_lower_case)
test_resource.value(env_value1)
- expect {test_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Env)
+ expect { test_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Env)
end
it "should modify an existing variable's value to a new value" do
@@ -127,7 +127,7 @@ describe Chef::Resource::Env, :windows_only do
context "when using PATH" do
let(:random_name) { Time.now.to_i }
- let(:env_val) { "#{env_value_expandable}_#{random_name}"}
+ let(:env_val) { "#{env_value_expandable}_#{random_name}" }
let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value("PATH") || "" }
let!(:env_path_before) { ENV["PATH"] }
@@ -165,7 +165,7 @@ describe Chef::Resource::Env, :windows_only do
expect(ENV[chef_env_test_lower_case]).to eq(nil)
test_resource.key_name(chef_env_test_lower_case)
test_resource.value(env_value1)
- expect{test_resource.run_action(:delete)}.not_to raise_error
+ expect { test_resource.run_action(:delete) }.not_to raise_error
expect(ENV[chef_env_test_lower_case]).to eq(nil)
end
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index d7ca34ecb8..0fa1317032 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Resource::File do
let(:file_base) { "file_spec" }
let(:expected_content) { "Don't fear the ruby." }
- def create_resource(opts={})
+ def create_resource(opts = {})
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
run_context = Chef::RunContext.new(node, {}, events)
@@ -86,7 +86,6 @@ describe Chef::Resource::File do
end
end
-
describe "when using backup" do
before do
Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb
index 8710b22f31..7174a99451 100644
--- a/spec/functional/resource/git_spec.rb
+++ b/spec/functional/resource/git_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Resource::Git do
let(:v1_tag) { "9b73fb5e316bfaff7b822b0ccb3e1e08f9885085" }
let(:rev_foo) { "ed181b3419b6f489bedab282348162a110d6d3a1" }
let(:rev_testing) { "972d153654503bccec29f630c5dd369854a561e8" }
- let(:rev_head) { "d294fbfd05aa7709ad9a9b8ef6343b17d355bf5f"}
+ let(:rev_head) { "d294fbfd05aa7709ad9a9b8ef6343b17d355bf5f" }
let(:git_user_config) do
<<-E
@@ -76,7 +76,7 @@ E
Chef::Log.level = :warn # silence git command live streams
@old_file_cache_path = Chef::Config[:file_cache_path]
shell_out!("git clone \"#{git_bundle_repo}\" example", :cwd => origin_repo_dir)
- File.open("#{origin_repo}/.git/config", "a+") {|f| f.print(git_user_config) }
+ File.open("#{origin_repo}/.git/config", "a+") { |f| f.print(git_user_config) }
Chef::Config[:file_cache_path] = file_cache_path
end
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index cb460fe7b4..063b5d9004 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -334,7 +334,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
invalid_resource = group_resource.dup
invalid_resource.members(["Jack"])
invalid_resource.excluded_members(["Jack"])
- expect { invalid_resource.run_action(:create)}.to raise_error(Chef::Exceptions::ConflictingMembersInGroup)
+ expect { invalid_resource.run_action(:create) }.to raise_error(Chef::Exceptions::ConflictingMembersInGroup)
end
end
end
@@ -361,7 +361,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
describe "group modify action", :not_supported_on_solaris do
- let(:spec_members){ ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
+ let(:spec_members) { ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
let(:included_members) { [spec_members[0], spec_members[1]] }
let(:excluded_members) { [spec_members[2]] }
let(:tested_action) { :modify }
@@ -379,7 +379,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "when running on Windows", :windows_only do
describe "when members are Active Directory domain identities", :windows_domain_joined_only do
let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] }
- let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
+ let(:spec_members) { ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
include_examples "correct group management"
end
@@ -389,7 +389,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
describe "group manage action", :not_supported_on_solaris do
- let(:spec_members){ ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
+ let(:spec_members) { ["mnou5sdz", "htulrvwq", "x4c3g1lu"] }
let(:included_members) { [spec_members[0], spec_members[1]] }
let(:excluded_members) { [spec_members[2]] }
let(:tested_action) { :manage }
@@ -416,7 +416,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "running on windows", :windows_only do
describe "when members are Windows domain identities", :windows_domain_joined_only do
let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] }
- let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
+ let(:spec_members) { ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] }
include_examples "correct group management"
end
@@ -430,15 +430,15 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
let(:excluded_members) { ["x4c3g1lu"] }
it ":manage should raise an error" do
- expect {group_resource.run_action(:manage) }.to raise_error
+ expect { group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- expect {group_resource.run_action(:modify) }.to raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
it ":create should raise an error" do
- expect {group_resource.run_action(:create) }.to raise_error
+ expect { group_resource.run_action(:create) }.to raise_error
end
end
@@ -450,11 +450,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
it ":manage should raise an error" do
- expect {group_resource.run_action(:manage) }.to raise_error
+ expect { group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- expect {group_resource.run_action(:modify) }.to raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
end
end
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index cfb20f0c69..9b9d696979 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -25,7 +25,7 @@ end
describe Chef::Resource::Link do
let(:file_base) { "file_spec" }
- let(:expect_updated?) {true}
+ let(:expect_updated?) { true }
# We create the files in a different directory than tmp to exercise
# different file deployment strategies more completely.
@@ -83,6 +83,7 @@ describe Chef::Resource::Link do
File.symlink(a, b)
end
end
+
def symlink?(file)
if windows?
Chef::ReservedNames::Win32::File.symlink?(file)
@@ -90,6 +91,7 @@ describe Chef::Resource::Link do
File.symlink?(file)
end
end
+
def readlink(file)
if windows?
Chef::ReservedNames::Win32::File.readlink(file)
@@ -97,6 +99,7 @@ describe Chef::Resource::Link do
File.readlink(file)
end
end
+
def link(a, b)
if windows?
Chef::ReservedNames::Win32::File.link(a, b)
@@ -354,9 +357,11 @@ describe Chef::Resource::Link do
def allowed_acl(sid, expected_perms)
[ ACE.access_allowed(sid, expected_perms[:specific]) ]
end
+
def denied_acl(sid, expected_perms)
[ ACE.access_denied(sid, expected_perms[:specific]) ]
end
+
def parent_inheritable_acls
dummy_file_path = File.join(test_file_dir, "dummy_file")
FileUtils.touch(dummy_file_path)
@@ -602,7 +607,7 @@ describe Chef::Resource::Link do
describe "when not supported on platform", :win2k3_only do
it "raises error" do
- expect {resource}.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
+ expect { resource }.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
end
end
end
diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb
index ff7666392a..9ce989d8df 100644
--- a/spec/functional/resource/ohai_spec.rb
+++ b/spec/functional/resource/ohai_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Resource::Ohai do
end
describe "when reloading all plugins" do
- let(:ohai_resource) { Chef::Resource::Ohai.new("reload all", run_context)}
+ let(:ohai_resource) { Chef::Resource::Ohai.new("reload all", run_context) }
it_behaves_like "reloaded :uptime"
end
@@ -57,7 +57,6 @@ describe Chef::Resource::Ohai do
r
}
-
it_behaves_like "reloaded :uptime"
end
end
diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb
index 499b2d6b78..36b106bf1c 100644
--- a/spec/functional/resource/package_spec.rb
+++ b/spec/functional/resource/package_spec.rb
@@ -87,9 +87,9 @@ module AptServer
end
metadata = { :unix_only => true,
- :requires_root => true,
- :provider => {:package => Chef::Provider::Package::Apt},
- :arch => "x86_64" # test packages are 64bit
+ :requires_root => true,
+ :provider => { :package => Chef::Provider::Package::Apt },
+ :arch => "x86_64" # test packages are 64bit
}
describe Chef::Resource::Package, metadata do
@@ -112,7 +112,6 @@ describe Chef::Resource::Package, metadata do
shell_out!("apt-get clean")
end
-
after do
shell_out!("dpkg -r chef-integration-test")
shell_out("dpkg --clear-avail")
@@ -325,14 +324,13 @@ describe Chef::Resource::Package, metadata do
# un chef-integration-test <none> (no description available)
def pkg_should_be_removed
# will raise if exit code != 0,1
- pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0,1])
+ pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0, 1])
if pkg_check.exitstatus == 0
expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/)
end
end
-
it "removes the package for action :remove" do
package_resource.run_action(:remove)
pkg_should_be_removed
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index 2d9e1458a7..7a7f7a2ded 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -164,7 +164,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "returns 1 if the last command was a cmdlet that failed and was preceded by an unsuccessfully executed non-cmdlet Windows binary" do
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
- resource.code([arbitrary_nonzero_process_exit_code_content,cmdlet_exit_code_not_found_content].join(";"))
+ resource.code([arbitrary_nonzero_process_exit_code_content, cmdlet_exit_code_not_found_content].join(";"))
resource.returns(arbitrary_nonzero_process_exit_code)
resource.run_action(:run)
end
@@ -325,7 +325,7 @@ configuration LCM
it "raises an error when executing a script with a 32-bit process on Windows Nano Server", :windows_nano_only do
resource.code(processor_architecture_script_content + " | out-file -encoding ASCII #{script_output_path}")
- expect{ resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect,
+ expect { resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect,
"cannot execute script with requested architecture 'i386' on Windows Nano Server")
end
end
@@ -342,22 +342,22 @@ configuration LCM
end
it "evaluates a succeeding not_if block using cmd.exe as false by default" do
- resource.not_if "exit /b 0"
+ resource.not_if "exit /b 0"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failing not_if block using cmd.exe as true by default" do
- resource.not_if "exit /b 2"
+ resource.not_if "exit /b 2"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates an succeeding only_if block using cmd.exe as true by default" do
- resource.only_if "exit /b 0"
+ resource.only_if "exit /b 0"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failing only_if block using cmd.exe as false by default" do
- resource.only_if "exit /b 2"
+ resource.only_if "exit /b 2"
expect(resource.should_skip?(:run)).to be_truthy
end
end
@@ -383,77 +383,77 @@ configuration LCM
it "evaluates a powershell $false for a not_if block as true" do
pending "powershell.exe always exits with $true on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "$false"
+ resource.not_if "$false"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a powershell $true for a not_if block as false" do
- resource.not_if "$true"
+ resource.not_if "$true"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $false for an only_if block as false" do
pending "powershell.exe always exits with $true on nano" if Chef::Platform.windows_nano_server?
- resource.only_if "$false"
+ resource.only_if "$false"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $true for a only_if block as true" do
- resource.only_if "$true"
+ resource.only_if "$true"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using powershell.exe" do
- resource.not_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
+ resource.not_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using powershell.exe" do
- resource.only_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
+ resource.only_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a non-zero powershell exit status for not_if as true" do
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "exit 37"
+ resource.not_if "exit 37"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a zero powershell exit status for not_if as false" do
- resource.not_if "exit 0"
+ resource.not_if "exit 0"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for not_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.not_if windows_process_exit_code_not_found_content
+ resource.not_if windows_process_exit_code_not_found_content
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a successful executable exit status for not_if as true" do
- resource.not_if windows_process_exit_code_success_content
+ resource.not_if windows_process_exit_code_success_content
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for only_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.only_if windows_process_exit_code_not_found_content
+ resource.only_if windows_process_exit_code_not_found_content
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful executable exit status for only_if as true" do
- resource.only_if windows_process_exit_code_success_content
+ resource.only_if windows_process_exit_code_success_content
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failed cmdlet exit status for not_if as true" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.not_if "throw 'up'"
+ resource.not_if "throw 'up'"
expect(resource.should_skip?(:run)).to be_falsey
end
@@ -465,44 +465,44 @@ configuration LCM
it "evaluates a failed cmdlet exit status for only_if as false" do
pending "powershell.exe always exits with success on nano" if Chef::Platform.windows_nano_server?
- resource.only_if "throw 'up'"
+ resource.only_if "throw 'up'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful cmdlet exit status for only_if as true" do
- resource.only_if "cd ."
+ resource.only_if "cd ."
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
- resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
+ resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for only_if" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.cwd custom_cwd
- resource.only_if "exit ! [int32]($pwd.path -eq '#{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"
resource.cwd custom_cwd
- resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean false as zero status code", :windows64_only do
resource.architecture :x86_64
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
expect(resource.should_skip?(:run)).to be_falsey
end
@@ -510,19 +510,19 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.architecture :x86_64
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code", :not_supported_on_nano do
resource.architecture :i386
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'X86')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'X86')"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code", :not_supported_on_nano do
resource.architecture :i386
- resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
+ resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
expect(resource.should_skip?(:run)).to be_truthy
end
@@ -530,7 +530,7 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.convert_boolean_return true
- resource.only_if "$false"
+ resource.only_if "$false"
expect(resource.should_skip?(:run)).to be_truthy
end
@@ -538,53 +538,53 @@ configuration LCM
pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server?
resource.convert_boolean_return true
- resource.not_if "$false"
+ resource.not_if "$false"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for only_if" do
resource.convert_boolean_return true
- resource.only_if "$true"
+ resource.only_if "$true"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for not_if" do
resource.convert_boolean_return true
- resource.not_if "$true"
+ resource.not_if "$true"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for only_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for not_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for only_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for not_if", :not_supported_on_nano do
resource.convert_boolean_return true
resource.architecture :i386
- resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
expect(resource.should_skip?(:run)).to be_truthy
end
it "raises an error when a 32-bit guard is used on Windows Nano Server", :windows_nano_only do
resource.only_if "$true", :architecture => :i386
- expect{resource.run_action(:run)}.to raise_error(
+ expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
end
diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb
index 9d7de1f183..6cf8524883 100644
--- a/spec/functional/resource/registry_spec.rb
+++ b/spec/functional/resource/registry_spec.rb
@@ -27,15 +27,15 @@ describe Chef::Resource::RegistryKey, :unix_only do
node = Chef::Node.new
ohai = Ohai::System.new
ohai.all_plugins
- node.consume_external_attrs(ohai.data,{})
+ node.consume_external_attrs(ohai.data, {})
run_context = Chef::RunContext.new(node, {}, events)
@resource = Chef::Resource::RegistryKey.new("HKCU\\Software", run_context)
end
context "when load_current_resource is run on a non-windows node" do
it "throws an exception because you don't have a windows registry (derp)" do
@resource.key("HKCU\\Software\\Opscode")
- @resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
- expect{@resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32NotWindows)
+ @resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
+ expect { @resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32NotWindows)
end
end
end
@@ -98,7 +98,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@node = Chef::Node.new
ohai = Ohai::System.new
ohai.all_plugins
- @node.consume_external_attrs(ohai.data,{})
+ @node.consume_external_attrs(ohai.data, {})
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::RegistryKey.new(resource_name, @run_context)
@@ -113,8 +113,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@rest_client = double("Chef::ServerAPI (mock)")
allow(@rest_client).to receive(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}");
- allow(@rest_client).to receive(:raw_http_request).and_return({"result"=>"ok"});
- allow(@rest_client).to receive(:post_rest).and_return({"uri"=>"https://example.com/reports/nodes/windowsbox/runs/#{@run_id}"});
+ allow(@rest_client).to receive(:raw_http_request).and_return({ "result" => "ok" });
+ allow(@rest_client).to receive(:post_rest).and_return({ "uri" => "https://example.com/reports/nodes/windowsbox/runs/#{@run_id}" });
@resource_reporter = Chef::ResourceReporter.new(@rest_client)
@events.register(@resource_reporter)
@@ -122,7 +122,6 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
@resource_reporter.run_started(@run_status)
@run_id = @resource_reporter.run_id
-
@new_resource.cookbook_name = "monkey"
@cookbook_version = double("Cookbook::Version", :version => "1.2.3")
allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version)
@@ -138,76 +137,76 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
+ @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
end
it "modifies the data if the key and value exist and type matches" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Not just Orange - OpscodeOrange!" })).to eq(true)
end
it "modifys the type if the key and value exist and the type does not match" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]}])
+ @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] }])
@new_resource.run_action(:create)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :multi_string, :data => ["Not just Orange - OpscodeOrange!"] })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\OpscodeTest')
- @new_resource.values([{:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}])
+ @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\OpscodeTest', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\OpscodeTest', { :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] })).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(false)
- expect{@new_resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Missing1\Missing2')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Missing1\Missing2')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"one", :type=>:string, :data=>"1"},{:name=>"two", :type=>:string, :data=>"2"},{:name=>"three", :type=>:string, :data=>"3"}])
+ @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@@ -226,12 +225,12 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "creates a key in a 32-bit registry that is not viewable in 64-bit" do
@new_resource.key(reg_child + '\Atraxi' )
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"Data"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "Data" }])
@new_resource.recursive(true)
@new_resource.architecture(:i386)
@new_resource.run_action(:create)
@registry.architecture = :i386
- expect(@registry.data_exists?(reg_child + '\Atraxi', {:name=>"OC", :type=>:string, :data=>"Data"})).to eq(true)
+ expect(@registry.data_exists?(reg_child + '\Atraxi', { :name => "OC", :type => :string, :data => "Data" })).to eq(true)
@registry.architecture = :x86_64
expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false)
end
@@ -239,7 +238,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for action :create" do
@new_resource.key(reg_child + '\Ood')
- @new_resource.values([{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},{:name=>"ReportingVal2", :type=>:string, :data=>"report2"}])
+ @new_resource.values([{ :name => "ReportingVal1", :type => :string, :data => "report1" }, { :name => "ReportingVal2", :type => :string, :data => "report2" }])
@new_resource.recursive(true)
@new_resource.run_action(:create)
@report = @resource_reporter.prepare_run_data
@@ -248,8 +247,8 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood')
- expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},
- {:name=>"ReportingVal2", :type=>:string, :data=>"report2"}])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal1", :type => :string, :data => "report1" },
+ { :name => "ReportingVal2", :type => :string, :data => "report2" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create")
expect(@report["status"]).to eq("success")
@@ -263,7 +262,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -271,7 +270,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does not create key if the action is create" do
@new_resource.key(reg_child + '\Slitheen')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create)
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
@@ -286,61 +285,61 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "creates registry key, value if the key is missing" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_parent)).to eq(true)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
+ @new_resource.values([{ :name => "Color", :type => :string, :data => "Orange" }])
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child)).to eq(true)
- expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "creates a value if it does not exist" do
@new_resource.key(reg_child)
- @new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
+ @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
@new_resource.run_action(:create_if_missing)
- expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?(reg_child, { :name => "Mango", :type => :string, :data => "Yellow" })).to eq(true)
end
it "creates subkey if parent exists" do
@new_resource.key(reg_child + '\Pyrovile')
- @new_resource.values([{:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}])
+ @new_resource.values([{ :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Pyrovile', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Pyrovile', { :name => "Chef", :type => :multi_string, :data => ["OpscodeOrange", "Rules"] })).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(false)
- expect{@new_resource.run_action(:create_if_missing)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
- @new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
+ @new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true)
- expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { :name => "OC", :type => :string, :data => "MissingData" })).to eq(true)
end
it "creates key with multiple value as specified" do
@new_resource.key(reg_child + '\Adipose')
- @new_resource.values([{:name=>"one", :type=>:string, :data=>"1"},{:name=>"two", :type=>:string, :data=>"2"},{:name=>"three", :type=>:string, :data=>"3"}])
+ @new_resource.values([{ :name => "one", :type => :string, :data => "1" }, { :name => "two", :type => :string, :data => "2" }, { :name => "three", :type => :string, :data => "3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@@ -351,7 +350,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "prepares the reporting data for :create_if_missing" do
@new_resource.key(reg_child + '\Judoon')
- @new_resource.values([{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}])
+ @new_resource.values([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
@report = @resource_reporter.prepare_run_data
@@ -360,7 +359,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon')
- expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}])
+ expect(@report["resources"][0]["after"][:values]).to eq([{ :name => "ReportingVal3", :type => :string, :data => "report3" }])
expect(@report["resources"][0]["before"][:values]).to eq([])
expect(@report["resources"][0]["result"]).to eq("create_if_missing")
expect(@report["status"]).to eq("success")
@@ -374,7 +373,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the keys do not exist but recursive is set to false" do
@new_resource.key(reg_child + '\Zygons\Zygor')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing) # should not raise_error
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -382,7 +381,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does nothing if the action is create_if_missing" do
@new_resource.key(reg_child + '\Zygons')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
@@ -399,7 +398,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "takes no action if the specified key path does not exist in the system" do
expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
- @new_resource.key(reg_parent+ '\Osirian')
+ @new_resource.key(reg_parent + '\Osirian')
@new_resource.recursive(false)
@new_resource.run_action(:delete)
@@ -407,53 +406,53 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "takes no action if the key exists but the value does not" do
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"LooksLike", :type=>:multi_string, :data=>["SeattleGrey", "OCOrange"]}])
+ @new_resource.values([{ :name => "LooksLike", :type => :multi_string, :data => ["SeattleGrey", "OCOrange"] }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
end
it "deletes only specified values under a key path" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]}, {:name=>"AKA", :type=>:string, :data=>"OC"}])
+ @new_resource.values([{ :name => "Opscode", :type => :multi_string, :data => ["Seattle", "Washington"] }, { :name => "AKA", :type => :string, :data => "OC" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"AKA", :type=>:string, :data=>"OC"})).to eq(false)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]})).to eq(false)
+ expect(@registry.data_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "AKA", :type => :string, :data => "OC" })).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Opscode", :type => :multi_string, :data => ["Seattle", "Washington"] })).to eq(false)
end
it "it deletes the values with the same name irrespective of it type and data" do
@new_resource.key(reg_parent + '\Opscode')
- @new_resource.values([{:name=>"Color", :type=>:multi_string, :data=>["Black", "Orange"]}])
+ @new_resource.values([{ :name => "Color", :type => :multi_string, :data => ["Black", "Orange"] }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', { :name => "Color", :type => :string, :data => "Orange" })).to eq(false)
end
it "prepares the reporting data for action :delete" do
@new_resource.key(reg_parent + '\ReportKey')
- @new_resource.values([{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}])
+ @new_resource.values([{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])
@new_resource.recursive(true)
@new_resource.run_action(:delete)
@report = @resource_reporter.prepare_run_data
- expect(@registry.value_exists?(reg_parent + '\ReportKey', [{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}])).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ :name => "ReportVal4", :type => :string, :data => "report4" }, { :name => "ReportVal5", :type => :string, :data => "report5" }])).to eq(false)
expect(@report["action"]).to eq("end")
expect(@report["resources"].count).to eq(1)
expect(@report["resources"][0]["type"]).to eq("registry_key")
expect(@report["resources"][0]["name"]).to eq(resource_name)
expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
- expect(@report["resources"][0]["before"][:values]).to eq([{:name=>"ReportVal4", :type=>:string, :data=>"report4"},
- {:name=>"ReportVal5", :type=>:string, :data=>"report5"}])
+ expect(@report["resources"][0]["before"][:values]).to eq([{ :name => "ReportVal4", :type => :string, :data => "report4" },
+ { :name => "ReportVal5", :type => :string, :data => "report5" }])
#Not testing for after values to match since after -> new_resource values.
expect(@report["resources"][0]["result"]).to eq("delete")
expect(@report["status"]).to eq("success")
@@ -466,7 +465,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
end
it "does nothing if the action is delete" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
@@ -502,7 +501,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "raises an exception if the key has subkeys and recursive == false" do
@new_resource.key(reg_parent)
@new_resource.recursive(false)
- expect{@new_resource.run_action(:delete_key)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @new_resource.run_action(:delete_key) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "ignores the values under a key" do
@@ -544,13 +543,13 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
it "does not throw an exception if the key has subkeys but recursive is set to false" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
end
it "does nothing if the action is delete_key" do
@new_resource.key(reg_parent + '\OpscodeWhyRun')
- @new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
+ @new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb
index 8e01464e86..c25e51cf2a 100644
--- a/spec/functional/resource/remote_directory_spec.rb
+++ b/spec/functional/resource/remote_directory_spec.rb
@@ -136,8 +136,8 @@ describe Chef::Resource::RemoteDirectory do
FileUtils.mkdir_p(File.join(path, "remotesubdir"))
modified_file = File.join(path, "remote_dir_file1.txt")
modified_subdir_file = File.join(path, "remotesubdir", "remote_subdir_file1.txt")
- File.open(modified_file, "a") {|f| f.puts "santa is real"}
- File.open(modified_subdir_file, "a") {|f| f.puts "so is rudolph"}
+ File.open(modified_file, "a") { |f| f.puts "santa is real" }
+ File.open(modified_subdir_file, "a") { |f| f.puts "so is rudolph" }
modified_file_checksum = sha256_checksum(modified_file)
modified_subdir_file_checksum = sha256_checksum(modified_subdir_file)
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 876467d490..b394bd0240 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -232,7 +232,7 @@ describe Chef::Resource::RemoteFile do
end
it "should not create the file" do
- expect{ resource.run_action(:create) }.to raise_error
+ expect { resource.run_action(:create) }.to raise_error
expect(File).not_to exist(path)
end
end
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 6ce4a3cc3d..da8cbfc68a 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") { |f| f.read }
end
include_context Chef::Resource::File
@@ -73,7 +73,7 @@ describe Chef::Resource::Template do
end
it "creates the template with the rendered content using a local erb file when the :create action is run" do
- resource.source(File.expand_path(File.join(CHEF_SPEC_DATA,"cookbooks","openldap","templates","default","openldap_stuff.conf.erb")))
+ resource.source(File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks", "openldap", "templates", "default", "openldap_stuff.conf.erb")))
resource.cookbook(nil)
resource.local(true)
resource.run_action(:create)
diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb
index ab16a1672f..84757cc197 100644
--- a/spec/functional/resource/user/useradd_spec.rb
+++ b/spec/functional/resource/user/useradd_spec.rb
@@ -31,23 +31,22 @@ def user_provider_for_platform
end
metadata = { :unix_only => true,
- :requires_root => true,
- :not_supported_on_mac_osx => true,
- :provider => {:user => user_provider_for_platform},
+ :requires_root => true,
+ :not_supported_on_mac_osx => true,
+ :provider => { :user => user_provider_for_platform },
}
describe Chef::Provider::User::Useradd, metadata do
include Chef::Mixin::ShellOut
-
# Utility code for /etc/passwd interaction, avoid any caching of user records:
PwEntry = Struct.new(:name, :passwd, :uid, :gid, :gecos, :home, :shell)
class UserNotFound < StandardError; end
def pw_entry
- passwd_file = File.open("/etc/passwd", "rb") {|f| f.read}
+ passwd_file = File.open("/etc/passwd", "rb") { |f| f.read }
matcher = /^#{Regexp.escape(username)}.+$/
if passwd_entry = passwd_file.scan(matcher).first
PwEntry.new(*passwd_entry.split(":"))
@@ -59,9 +58,9 @@ describe Chef::Provider::User::Useradd, metadata do
def etc_shadow
case ohai[:platform]
when "aix"
- File.open("/etc/security/passwd") {|f| f.read }
+ File.open("/etc/security/passwd") { |f| f.read }
else
- File.open("/etc/shadow") {|f| f.read }
+ File.open("/etc/shadow") { |f| f.read }
end
end
@@ -104,7 +103,7 @@ describe Chef::Provider::User::Useradd, metadata do
while max_retries > 0
begin
pw_entry # will raise if the user doesn't exist
- status = shell_out!("userdel", "-r", username, :returns => [0,8,12])
+ status = shell_out!("userdel", "-r", username, :returns => [0, 8, 12])
# Error code 8 during userdel indicates that the user is logged in.
# This occurs randomly because the accounts daemon holds a lock due to which userdel fails.
@@ -160,7 +159,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:expected_shadow) do
if ohai[:platform] == "aix"
- expected_shadow = "cf-test" # For aix just check user entry in shadow file
+ expected_shadow = "cf-test" # For aix just check user entry in shadow file
else
expected_shadow = "cf-test:$1$RRa/wMM/$XltKfoX5ffnexVF4dHZZf/"
end
@@ -174,7 +173,6 @@ describe Chef::Provider::User::Useradd, metadata do
expect(user_resource).to be_updated_by_last_action
end
-
it "ensures the user exists" do
expect(pw_entry.name).to eq(username)
end
@@ -194,7 +192,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
context "when uid is set" do
# Should verify uid not in use...
let(:uid) { 1999 }
@@ -296,7 +293,7 @@ describe Chef::Provider::User::Useradd, metadata do
# Ubuntu 13.04 system, these are commented out, so we'll look at
# UID_MIN to find the lower limit of the non-system-user range, and
# use that value in our assertions.
- login_defs = File.open("/etc/login.defs", "rb") {|f| f.read }
+ login_defs = File.open("/etc/login.defs", "rb") { |f| f.read }
uid_min_scan = /^UID_MIN\s+(\d+)/
login_defs.match(uid_min_scan)[1]
end
@@ -455,7 +452,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "ensures the password is set" do
password_should_be_set
expect(etc_shadow).to include(expected_shadow)
@@ -484,7 +480,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "ensures the password is set to the desired value" do
password_should_be_set
expect(etc_shadow).to include(expected_shadow)
@@ -518,7 +513,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:user_locked_context?) { false }
def shadow_entry
- etc_shadow.lines.select {|l| l.include?(username) }.first
+ etc_shadow.lines.select { |l| l.include?(username) }.first
end
def shadow_password
@@ -596,7 +591,6 @@ describe Chef::Provider::User::Useradd, metadata do
end
end
-
it "locks the user's password" do
user_account_should_be_locked
end
diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb
index 02559bcd97..bc508dc526 100644
--- a/spec/functional/resource/windows_package_spec.rb
+++ b/spec/functional/resource/windows_package_spec.rb
@@ -70,7 +70,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
subject { Chef::Resource::WindowsPackage.new(pkg_name, run_context) }
context "multiple versions and a version given to remove" do
- before { subject.version("8.0.56336")}
+ before { subject.version("8.0.56336") }
it "removes specified version" do
subject.run_action(:remove)
@@ -127,7 +127,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
let(:pkg_name) { "Ultra Defragmenter" }
let(:pkg_path) { "http://iweb.dl.sourceforge.net/project/ultradefrag/stable-release/6.1.1/ultradefrag-6.1.1.bin.amd64.exe" }
let(:pkg_checksum) { "11d53ed4c426c8c867ad43f142b7904226ffd9938c02e37086913620d79e3c09" }
-
+
it "finds the correct installer type" do
subject.run_action(:install)
expect(subject.provider_for_action(:install).installer_type).to eq(:nsis)
@@ -164,5 +164,5 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
subject.run_action(:remove)
expect(subject).to be_updated_by_last_action
end
- end
-end \ No newline at end of file
+ end
+end
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index 6e19998995..80faaece34 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -23,9 +23,9 @@ 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(:password) { "1a2b3c4X!&narf"}
+ let(:username) { "service_spec_user" }
+ let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}" }
+ let(:password) { "1a2b3c4X!&narf" }
let(:user_resource) {
r = Chef::Resource::User.new(username, run_context)
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 8680816d13..288341bcb6 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -31,15 +31,16 @@ describe Chef::RunLock do
"/tmp/#{Kernel.rand(Time.now.to_i + Process.pid)}"
end
- let(:lockfile){ "#{random_temp_root}/this/long/path/does/not/exist/chef-client-running.pid" }
+ let(:lockfile) { "#{random_temp_root}/this/long/path/does/not/exist/chef-client-running.pid" }
# make sure to start with a clean slate.
- before(:each){ log_event("rm -rf before"); FileUtils.rm_r(random_temp_root) if File.exist?(random_temp_root) }
- after(:each){ log_event("rm -rf after"); FileUtils.rm_r(random_temp_root) if File.exist?(random_temp_root) }
+ before(:each) { log_event("rm -rf before"); FileUtils.rm_r(random_temp_root) if File.exist?(random_temp_root) }
+ after(:each) { log_event("rm -rf after"); FileUtils.rm_r(random_temp_root) if File.exist?(random_temp_root) }
- def log_event(message, time=Time.now.strftime("%H:%M:%S.%L"))
+ def log_event(message, time = Time.now.strftime("%H:%M:%S.%L"))
events << [ message, time ]
end
+
def events
@events ||= []
end
diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb
index a2c44bd949..fe2abdb12a 100644
--- a/spec/functional/shell_spec.rb
+++ b/spec/functional/shell_spec.rb
@@ -30,7 +30,7 @@ describe Shell do
describe "smoke tests", :unix_only => true do
include Chef::Mixin::Command::Unix
- TIMEOUT=300
+ TIMEOUT = 300
def read_until(io, expected_value)
start = Time.new
@@ -43,7 +43,7 @@ describe Shell do
end
if Time.new - start > TIMEOUT
raise "did not read expected value `#{expected_value}' within #{TIMEOUT}s\n" +
- "Buffer so far: `#{buffer}'"
+ "Buffer so far: `#{buffer}'"
end
end
buffer
diff --git a/spec/functional/tiny_server_spec.rb b/spec/functional/tiny_server_spec.rb
index 9540234ba6..3e394f335e 100644
--- a/spec/functional/tiny_server_spec.rb
+++ b/spec/functional/tiny_server_spec.rb
@@ -26,7 +26,7 @@ describe TinyServer::API do
end
it "is a Singleton" do
- expect {TinyServer::API.new}.to raise_error
+ expect { TinyServer::API.new }.to raise_error
end
it "clears the router" do
@@ -39,26 +39,26 @@ describe TinyServer::API do
@api.get("/foo/bar", 200, "hello foobar")
# WEBrick gives you the full URI with host, Thin only gave the part after scheme+host+port
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "http://localhost:1974/foo/bar")
- expect(response).to eq([200, {"Content-Type" => "application/json"}, [ "hello foobar" ]])
+ expect(response).to eq([200, { "Content-Type" => "application/json" }, [ "hello foobar" ]])
end
it "creates a route for a request with a block" do
block_called = false
@api.get("/bar/baz", 200) { block_called = true; "hello barbaz" }
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "http://localhost:1974/bar/baz")
- expect(response).to eq([200, {"Content-Type" => "application/json"}, [ "hello barbaz" ]])
+ expect(response).to eq([200, { "Content-Type" => "application/json" }, [ "hello barbaz" ]])
expect(block_called).to be_truthy
end
it "returns debugging info for 404s" do
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "/no_such_thing")
expect(response[0]).to eq(404)
- expect(response[1]).to eq({"Content-Type" => "application/json"})
+ expect(response[1]).to eq({ "Content-Type" => "application/json" })
expect(response[2]).to be_a_kind_of(Array)
response_obj = Chef::JSONCompat.from_json(response[2].first)
expect(response_obj["message"]).to eq("no data matches the request for /no_such_thing")
- expect(response_obj["available_routes"]).to eq({"GET"=>[], "PUT"=>[], "POST"=>[], "DELETE"=>[]})
- expect(response_obj["request"]).to eq({"REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"/no_such_thing"})
+ expect(response_obj["available_routes"]).to eq({ "GET" => [], "PUT" => [], "POST" => [], "DELETE" => [] })
+ expect(response_obj["request"]).to eq({ "REQUEST_METHOD" => "GET", "REQUEST_URI" => "/no_such_thing" })
end
end
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 741d8a78d4..6ddbea2f42 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -19,18 +19,18 @@
require "chef/json_compat"
require File.expand_path("../../../../spec_helper", __FILE__)
-describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
+describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
before(:all) do
@node = Chef::Node.new
@node.consume_external_attrs(OHAI_SYSTEM.data, {})
end
let(:cmd_output_format) { :text }
- let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, {:depth => 2}) }
+ let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { :depth => 2 }) }
let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) }
- let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, {:depth => 2}) }
- let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, {:depth => 2}) }
+ let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { :depth => 2 }) }
+ let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { :depth => 2 }) }
let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
- let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE")}
+ let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") }
it "executes a simple process" do
result = simple_cmdlet.run
@@ -38,11 +38,11 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "#run does not raise a PowershellCmdletException exception if the command cannot be executed" do
- expect {invalid_cmdlet.run}.not_to raise_error
+ expect { invalid_cmdlet.run }.not_to raise_error
end
it "#run! raises a PowershellCmdletException exception if the command cannot be executed" do
- expect {invalid_cmdlet.run!}.to raise_error(Chef::Exceptions::PowershellCmdletException)
+ expect { invalid_cmdlet.run! }.to raise_error(Chef::Exceptions::PowershellCmdletException)
end
it "executes a 64-bit command on a 64-bit OS, 32-bit otherwise" do
@@ -58,17 +58,17 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "passes command line switches to the command" do
- result = cmdlet_alias_requires_switch_or_argument.run({:name => "ls"})
+ result = cmdlet_alias_requires_switch_or_argument.run({ :name => "ls" })
expect(result.succeeded?).to eq(true)
end
it "passes command line arguments to the command" do
- result = cmdlet_alias_requires_switch_or_argument.run({},{},"ls")
+ result = cmdlet_alias_requires_switch_or_argument.run({}, {}, "ls")
expect(result.succeeded?).to eq(true)
end
it "passes command line arguments and switches to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{}," | select-object -property fullname | format-table -hidetableheaders")
+ result = cmdlet_get_item_requires_switch_or_argument.run({ :path => etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders")
expect(result.succeeded?).to eq(true)
returned_directory = result.return_value
returned_directory.strip!
@@ -76,7 +76,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
end
it "passes execution options to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},". | select-object -property fullname | format-table -hidetableheaders")
+ result = cmdlet_get_item_requires_switch_or_argument.run({}, { :cwd => etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders")
expect(result.succeeded?).to eq(true)
returned_directory = result.return_value
returned_directory.strip!
@@ -86,16 +86,16 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
context "when returning json" do
let(:cmd_output_format) { :json }
it "returns json format data" do
- result = cmdlet_alias_requires_switch_or_argument.run({},{},"ls")
+ result = cmdlet_alias_requires_switch_or_argument.run({}, {}, "ls")
expect(result.succeeded?).to eq(true)
- expect(lambda{Chef::JSONCompat.parse(result.return_value)}).not_to raise_error
+ expect(lambda { Chef::JSONCompat.parse(result.return_value) }).not_to raise_error
end
end
context "when returning Ruby objects" do
let(:cmd_output_format) { :object }
it "returns object format data" do
- result = simple_cmdlet.run({},{:cwd => etc_directory}, "hosts")
+ result = simple_cmdlet.run({}, { :cwd => etc_directory }, "hosts")
expect(result.succeeded?).to eq(true)
data = result.return_value
expect(data["Name"]).to eq("hosts")
@@ -105,7 +105,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
context "when constructor is given invalid arguments" do
let(:cmd_output_format) { :invalid }
it "throws an exception if an invalid format is passed to the constructor" do
- expect(lambda{simple_cmdlet}).to raise_error
+ expect(lambda { simple_cmdlet }).to raise_error
end
end
end
diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb
index b12193ced0..75a8bfbd24 100644
--- a/spec/functional/win32/crypto_spec.rb
+++ b/spec/functional/win32/crypto_spec.rb
@@ -25,7 +25,7 @@ describe "Chef::ReservedNames::Win32::Crypto", :windows_only do
describe '#encrypt' do
before(:all) do
new_node = Chef::Node.new
- new_node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ new_node.consume_external_attrs(OHAI_SYSTEM.data, {})
events = Chef::EventDispatch::Dispatcher.new
diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb
index 5818d7c7e5..f0258ab3b9 100644
--- a/spec/functional/win32/registry_spec.rb
+++ b/spec/functional/win32/registry_spec.rb
@@ -41,7 +41,7 @@ describe "Chef::Win32::Registry", :windows_only do
#Create the node with ohai data
events = Chef::EventDispatch::Dispatcher.new
@node = Chef::Node.new
- @node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ @node.consume_external_attrs(OHAI_SYSTEM.data, {})
@run_context = Chef::RunContext.new(@node, {}, events)
#Create a registry object that has access ot the node previously created
@@ -81,7 +81,7 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception if the hive does not exist" do
- expect {@registry.key_exists?("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.key_exists?("JKLM\\Software\\Branch\\Flower") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -91,95 +91,95 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception if the key path does not exist" do
- expect {@registry.key_exists!("HKCU\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.key_exists!("HKCU\\Software\\Branch\\Flower") }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect {@registry.key_exists!("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.key_exists!("JKLM\\Software\\Branch\\Flower") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
describe "value_exists?" do
it "throws an exception if the hive does not exist" do
- expect {@registry.value_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.value_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect {@registry.value_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true)
end
it "returns true if the value exists with a case mismatch on the value name" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals"})).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true)
end
it "returns false if the value does not exist" do
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})).to eq(false)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" })).to eq(false)
end
end
describe "value_exists!" do
it "throws an exception if the hive does not exist" do
- expect {@registry.value_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.value_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect {@registry.value_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.value_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals" })).to eq(true)
end
it "returns true if the value exists with a case mismatch on the value name" do
- expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals"})).to eq(true)
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals" })).to eq(true)
end
it "throws an exception if the value does not exist" do
- expect {@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
+ expect { @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "FOOBAR" }) }.to raise_error(Chef::Exceptions::Win32RegValueMissing)
end
end
describe "data_exists?" do
it "throws an exception if the hive does not exist" do
- expect {@registry.data_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.data_exists?("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect {@registry.data_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists?("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] })).to eq(true)
end
it "returns true if all the data matches with a case mismatch on the data name" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => ["Pink", "Delicate"] })).to eq(true)
end
it "returns false if the name does not exist" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => ["Pink", "Delicate"] })).to eq(false)
end
it "returns false if the types do not match" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"})).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" })).to eq(false)
end
it "returns false if the data does not match" do
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]})).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Mauve", "Delicate"] })).to eq(false)
end
end
describe "data_exists!" do
it "throws an exception if the hive does not exist" do
- expect {@registry.data_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.data_exists!("JKLM\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- expect {@registry.data_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Pink", "Delicate"] })).to eq(true)
end
it "returns true if all the data matches with a case mismatch on the data name" do
- expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "petals", :type => :multi_string, :data => ["Pink", "Delicate"] })).to eq(true)
end
it "throws an exception if the name does not exist" do
- expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "slateP", :type => :multi_string, :data => ["Pink", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the types do not match" do
- expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Pink" }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the data does not match" do
- expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Mauve", "Delicate"] }) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
end
@@ -187,85 +187,85 @@ describe "Chef::Win32::Registry", :windows_only do
it "returns all values for a key if it exists" do
values = @registry.get_values("HKCU\\Software\\Root")
expect(values).to be_an_instance_of Array
- expect(values).to eq([{:name=>"RootType1", :type=>:string, :data=>"fibrous"},
- {:name=>"Roots", :type=>:multi_string, :data=>["strong roots", "healthy tree"]}])
+ expect(values).to eq([{ :name => "RootType1", :type => :string, :data => "fibrous" },
+ { :name => "Roots", :type => :multi_string, :data => ["strong roots", "healthy tree"] }])
end
it "throws an exception if the key does not exist" do
- expect {@registry.get_values("HKCU\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.get_values("HKCU\\Software\\Branch\\Flower") }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect {@registry.get_values("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.get_values("JKLM\\Software\\Branch\\Flower") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
describe "set_value" do
it "updates a value if the key, value exist and type matches and value different" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
end
it "updates a value if the type does match and the values are different" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(false)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :string, :data => "Yellow" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false)
end
it "creates a value if key exists and value does not" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
end
it "does nothing if data,type and name parameters for the value are same" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(false)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "Stamen", :type => :multi_string, :data => ["Yellow", "Changed Color"] })).to eq(true)
end
it "throws an exception if the key does not exist" do
- expect {@registry.set_value("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.set_value("HKCU\\Software\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect {@registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", { :name => "Petals", :type => :multi_string, :data => ["Yellow", "Changed Color"] }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
# we are validating that the data gets .to_i called on it when type is a :dword
it "casts an integer string given as a dword into an integer" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>"32767"})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>32767})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => "32767" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe32767", :type => :dword, :data => 32767 })).to eq(true)
end
it "casts a nonsense string given as a dword into zero" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>"whatdoesthisdo"})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>0})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => "whatdoesthisdo" })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeZero", :type => :dword, :data => 0 })).to eq(true)
end
it "throws an exception when trying to cast an array to an int for a dword" do
- expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:dword, :data=>["one","two"]})}.to raise_error
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :dword, :data => ["one", "two"] }) }.to raise_error
end
# we are validating that the data gets .to_s called on it when type is a :string
it "stores the string representation of an array into a string if you pass it an array" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>["one","two"]})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>'["one", "two"]'})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => ["one", "two"] })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBePainful", :type => :string, :data => '["one", "two"]' })).to eq(true)
end
it "stores the string representation of a number into a string if you pass it an number" do
- expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>65535})).to eq(true)
- expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>"65535"})).to eq(true)
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => 65535 })).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBe65535", :type => :string, :data => "65535" })).to eq(true)
end
# we are validating that the data gets .to_a called on it when type is a :multi_string
it "throws an exception when a multi-string is passed a number" do
- expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:multi_string, :data=>65535})}.to raise_error
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldThrow", :type => :multi_string, :data => 65535 }) }.to raise_error
end
it "throws an exception when a multi-string is passed a string" do
- expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeWat", :type=>:multi_string, :data=>"foo"})}.to raise_error
+ expect { @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", { :name => "ShouldBeWat", :type => :multi_string, :data => "foo" }) }.to raise_error
end
end
@@ -280,7 +280,7 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception if the path has missing keys but recursive set to false" do
- expect {@registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { @registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker")).to eq(false)
end
@@ -295,7 +295,7 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception of the hive does not exist" do
- expect {@registry.create_key("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.create_key("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", false) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -308,21 +308,21 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "deletes values if the value exists" do
- expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(true)
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(false)
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false)
end
it "does nothing if value does not exist" do
- expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(true)
- expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(false)
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" })).to eq(false)
end
it "throws an exception if the key does not exist?" do
- expect {@registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect {@registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", { :name => "Peter", :type => :string, :data => "Tiny" }) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -359,7 +359,7 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception if the hive does not exist" do
- expect {@registry.delete_key("JKLM\\Software\\Root\\Branch\\Flower", false)}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.delete_key("JKLM\\Software\\Root\\Branch\\Flower", false) }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -375,11 +375,11 @@ describe "Chef::Win32::Registry", :windows_only do
end
it "throws an exception if the hive was missing" do
- expect {@registry.has_subkeys?("LMNO\\Software\\Root")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.has_subkeys?("LMNO\\Software\\Root") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key is missing" do
- expect {@registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red") }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the key has subkeys" do
@@ -394,16 +394,16 @@ describe "Chef::Win32::Registry", :windows_only do
describe "get_subkeys" do
it "throws an exception if the key is missing" do
- expect {@registry.get_subkeys("HKCU\\Software\\Trunk\\Red")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { @registry.get_subkeys("HKCU\\Software\\Trunk\\Red") }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- expect {@registry.get_subkeys("JKLM\\Software\\Root")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect { @registry.get_subkeys("JKLM\\Software\\Root") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "returns the array of subkeys for a given key" do
subkeys = @registry.get_subkeys("HKCU\\Software\\Root")
reg_subkeys = []
::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root", Win32::Registry::KEY_ALL_ACCESS) do |reg|
- reg.each_key{|name| reg_subkeys << name}
+ reg.each_key { |name| reg_subkeys << name }
end
expect(reg_subkeys).to eq(subkeys)
end
@@ -422,7 +422,7 @@ describe "Chef::Win32::Registry", :windows_only do
context "registry constructor" do
it "throws an exception if requested architecture is 64bit but running on 32bit" do
- expect {Chef::Win32::Registry.new(@run_context, :x86_64)}.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
+ expect { Chef::Win32::Registry.new(@run_context, :x86_64) }.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
end
it "can correctly set the requested architecture to 32-bit" do
@@ -440,7 +440,7 @@ describe "Chef::Win32::Registry", :windows_only do
context "architecture setter" do
it "throws an exception if requested architecture is 64bit but running on 32bit" do
- expect {@registry.architecture = :x86_64}.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
+ expect { @registry.architecture = :x86_64 }.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
end
it "sets the requested architecture to :machine if passed :machine" do
@@ -545,58 +545,58 @@ describe "Chef::Win32::Registry", :windows_only do
describe "key_exists?" do
it "does not find 64-bit keys in the 32-bit registry" do
- @registry.architecture=:i386
+ @registry.architecture = :i386
expect(@registry.key_exists?("HKLM\\Software\\Root\\Mauve")).to eq(false)
end
it "finds 32-bit keys in the 32-bit registry" do
- @registry.architecture=:i386
+ @registry.architecture = :i386
expect(@registry.key_exists?("HKLM\\Software\\Root\\Poosh")).to eq(true)
end
it "does not find 32-bit keys in the 64-bit registry" do
- @registry.architecture=:x86_64
+ @registry.architecture = :x86_64
expect(@registry.key_exists?("HKLM\\Software\\Root\\Mauve")).to eq(true)
end
it "finds 64-bit keys in the 64-bit registry" do
- @registry.architecture=:x86_64
+ @registry.architecture = :x86_64
expect(@registry.key_exists?("HKLM\\Software\\Root\\Poosh")).to eq(false)
end
end
describe "value_exists?" do
it "does not find 64-bit values in the 32-bit registry" do
- @registry.architecture=:i386
- expect{@registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ @registry.architecture = :i386
+ expect { @registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit values in the 32-bit registry" do
- @registry.architecture=:i386
- expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"})).to eq(true)
+ @registry.architecture = :i386
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" })).to eq(true)
end
it "does not find 32-bit values in the 64-bit registry" do
- @registry.architecture=:x86_64
- expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"})).to eq(true)
+ @registry.architecture = :x86_64
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert" })).to eq(true)
end
it "finds 64-bit values in the 64-bit registry" do
- @registry.architecture=:x86_64
- expect{@registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ @registry.architecture = :x86_64
+ expect { @registry.value_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
describe "data_exists?" do
it "does not find 64-bit keys in the 32-bit registry" do
- @registry.architecture=:i386
- expect{@registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ @registry.architecture = :i386
+ expect { @registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit keys in the 32-bit registry" do
- @registry.architecture=:i386
- expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"})).to eq(true)
+ @registry.architecture = :i386
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" })).to eq(true)
end
it "does not find 32-bit keys in the 64-bit registry" do
- @registry.architecture=:x86_64
- expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"})).to eq(true)
+ @registry.architecture = :x86_64
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", { :name => "Alert", :type => :string, :data => "Universal" })).to eq(true)
end
it "finds 64-bit keys in the 64-bit registry" do
- @registry.architecture=:x86_64
- expect{@registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ @registry.architecture = :x86_64
+ expect { @registry.data_exists?("HKLM\\Software\\Root\\Poosh", { :name => "Status", :type => :string, :data => "Lost" }) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index abf6b42e10..c4951f375c 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -70,7 +70,7 @@ describe "Chef::Win32::Security", :windows_only do
let(:desired_access) { Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ }
it "should check if the provided token has the desired access" do
- expect(Chef::ReservedNames::Win32::Security.access_check(security_descriptor,
+ expect(Chef::ReservedNames::Win32::Security.access_check(security_descriptor,
token, desired_access, mapping)).to be true
end
end
@@ -85,7 +85,7 @@ describe "Chef::Win32::Security", :windows_only do
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS }
it "can duplicate a token" do
- expect{ token.duplicate_token(:SecurityImpersonation) }.not_to raise_error
+ expect { token.duplicate_token(:SecurityImpersonation) }.not_to raise_error
end
end
@@ -93,7 +93,7 @@ describe "Chef::Win32::Security", :windows_only do
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_READ }
it "raises an exception when trying to duplicate" do
- expect{ token.duplicate_token(:SecurityImpersonation) }.to raise_error(Chef::Exceptions::Win32APIError)
+ expect { token.duplicate_token(:SecurityImpersonation) }.to raise_error(Chef::Exceptions::Win32APIError)
end
end
end
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index b2bf04ed0c..7f8e943367 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -101,8 +101,8 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
end
it "install => should say service already exists" do
- service_manager.run(["-a", "install"])
- expect(@service_manager_output.grep(/already exists/).length).to be > 0
+ service_manager.run(["-a", "install"])
+ expect(@service_manager_output.grep(/already exists/).length).to be > 0
end
context "and service is stopped" do
@@ -133,7 +133,6 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
expect(test_service_state).to eq("stopped")
end
-
["pause", "resume"].each do |action|
it "#{action} => should raise error" do
expect { service_manager.run(["-a", action]) }.to raise_error(SystemCallError)
@@ -211,7 +210,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
end
it "start should raise an error" do
- expect {service_manager.run(["-a", "start"])}.to raise_error(::Win32::Service::Error)
+ expect { service_manager.run(["-a", "start"]) }.to raise_error(::Win32::Service::Error)
end
end
diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb
index 345df303a4..aee5bbbcd4 100644
--- a/spec/functional/win32/versions_spec.rb
+++ b/spec/functional/win32/versions_spec.rb
@@ -52,7 +52,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
def for_each_windows_version(&block)
@version.methods.each do |method_name|
- if Chef::ReservedNames::Win32::Version::WIN_VERSIONS.keys.find { | key | method_name.to_s == Chef::ReservedNames::Win32::Version.send(:method_name_from_marketing_name,key) }
+ if Chef::ReservedNames::Win32::Version::WIN_VERSIONS.keys.find { |key| method_name.to_s == Chef::ReservedNames::Win32::Version.send(:method_name_from_marketing_name, key) }
yield method_name
end
end
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 24ce69ac03..bfc88659e0 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -3,17 +3,16 @@ require "chef/mixin/shell_out"
require "tiny_server"
require "tmpdir"
-
describe "chef-client" do
def recipes_filename
File.join(CHEF_SPEC_DATA, "recipes.tgz")
end
- def start_tiny_server(server_opts={})
+ def start_tiny_server(server_opts = {})
@server = TinyServer::Manager.new(server_opts)
@server.start
- @api = TinyServer::API.instance
+ @api = TinyServer::API.instance
@api.clear
#
# trivial endpoints
@@ -48,7 +47,7 @@ describe "chef-client" do
# cf. CHEF-4914
let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
- let(:critical_env_vars) { %w{PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH}.map {|o| "#{o}=#{ENV[o]}"} .join(" ") }
+ let(:critical_env_vars) { %w{PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH}.map { |o| "#{o}=#{ENV[o]}" } .join(" ") }
when_the_repository "has a cookbook with a no-op recipe" do
before { file "cookbooks/x/recipes/default.rb", "" }
diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb
index 45086611bc..68c58bb8ea 100644
--- a/spec/integration/client/ipv6_spec.rb
+++ b/spec/integration/client/ipv6_spec.rb
@@ -22,7 +22,7 @@ describe "chef-client" do
include IntegrationSupport
include Chef::Mixin::ShellOut
- let(:chef_zero_opts) { {:host => "::1"} }
+ let(:chef_zero_opts) { { :host => "::1" } }
let(:validation_pem) do
<<-END_VALIDATION_PEM
@@ -73,7 +73,6 @@ END_CLIENT_RB
basic_config_file
end
-
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
let(:chef_client_cmd) { %Q{ruby '#{chef_dir}/chef-client' --minimal-ohai -c "#{path_to('config/client.rb')}" -lwarn} }
@@ -88,7 +87,7 @@ END_CLIENT_RB
when_the_repository "has a cookbook with a no-op recipe" do
before do
- cookbook "noop", "1.0.0", { }, "recipes" => {"default.rb" => "#raise 'foo'"}
+ cookbook "noop", "1.0.0", {}, "recipes" => { "default.rb" => "#raise 'foo'" }
file "config/client.rb", client_rb_content
file "config/validator.pem", validation_pem
end
@@ -103,7 +102,7 @@ END_CLIENT_RB
when_the_repository "has a cookbook that hits server APIs" do
before do
- recipe=<<-END_RECIPE
+ recipe = <<-END_RECIPE
actual_item = data_bag_item("expect_bag", "expect_item")
if actual_item.key?("expect_key") and actual_item["expect_key"] == "expect_value"
Chef::Log.info "lookin good"
@@ -115,9 +114,9 @@ END_CLIENT_RB
END_RECIPE
- data_bag("expect_bag", { "expect_item" => {"expect_key" => "expect_value"} })
+ data_bag("expect_bag", { "expect_item" => { "expect_key" => "expect_value" } })
- cookbook "api-smoke-test", "1.0.0", { }, "recipes" => {"default.rb" => recipe}
+ cookbook "api-smoke-test", "1.0.0", {}, "recipes" => { "default.rb" => recipe }
end
before do
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index e9a2ea4824..02508b799d 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -179,7 +179,7 @@ EOM
context "PUT /TYPE/NAME" do
before do
file "empty.json", {}
- file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}}
+ file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => { "foo" => "bar" } }
file "rolestuff.json", '{"description":"hi there","name":"x"}'
file "cookbooks_to_upload/x/metadata.rb", cookbook_x_100_metadata_rb
end
@@ -234,7 +234,7 @@ EOM
context "POST /TYPE/NAME" do
before do
file "empty.json", { "name" => "z" }
- file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}}
+ file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => { "foo" => "bar" } }
file "empty_x.json", { "name" => "x" }
file "empty_id.json", { "id" => "z" }
file "rolestuff.json", '{"description":"hi there","name":"x"}'
@@ -479,7 +479,7 @@ EOM
context "PUT /TYPE/NAME" do
before do
file "empty.json", {}
- file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}}
+ file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => { "foo" => "bar" } }
file "rolestuff.json", '{"description":"hi there","name":"x"}'
file "cookbooks_to_upload/x/metadata.rb", cookbook_x_100_metadata_rb
end
@@ -505,7 +505,7 @@ EOM
context "POST /TYPE/NAME" do
before do
file "empty.json", { "name" => "z" }
- file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}}
+ file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => { "foo" => "bar" } }
file "empty_x.json", { "name" => "x" }
file "empty_id.json", { "id" => "z" }
file "rolestuff.json", '{"description":"hi there","name":"x"}'
diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb
index 3126c93a1c..0a4a6a6e94 100644
--- a/spec/integration/knife/cookbook_api_ipv6_spec.rb
+++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb
@@ -23,7 +23,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
include Chef::Mixin::ShellOut
when_the_chef_server "is bound to IPv6" do
- let(:chef_zero_opts) { {:host => "::1"} }
+ let(:chef_zero_opts) { { :host => "::1" } }
let(:client_key) do
<<-END_VALIDATION_PEM
@@ -102,7 +102,7 @@ END_CLIENT_RB
it "downloads the cookbook" do
shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir)
- expect(Dir["#{cache_path}/*"].map {|entry| File.basename(entry)}).to include("apache2-0.0.1")
+ expect(Dir["#{cache_path}/*"].map { |entry| File.basename(entry) }).to include("apache2-0.0.1")
end
end
diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb
index 9f2accdbfa..d8cb8d950f 100644
--- a/spec/integration/knife/delete_spec.rb
+++ b/spec/integration/knife/delete_spec.rb
@@ -916,7 +916,7 @@ EOM
when_the_chef_server "has an earlier version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb
index 3cc2518915..b7d2f4d1c3 100644
--- a/spec/integration/knife/diff_spec.rb
+++ b/spec/integration/knife/diff_spec.rb
@@ -174,7 +174,7 @@ EOM
when_the_chef_server "has a later version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" }
end
@@ -470,7 +470,7 @@ EOM
when_the_chef_server "has a later version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" }
end
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index ec322ca01c..2c9f64b61a 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -489,7 +489,7 @@ EOM
when_the_chef_server "has an earlier version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
@@ -986,7 +986,7 @@ EOM
when_the_chef_server "has an earlier version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
@@ -1254,8 +1254,8 @@ EOM
file "members.json", [ "bar" ]
file "nodes/x.json", {}
file "org.json", { "full_name" => "Something" }
- file "policies/x-1.0.0.json", { }
- file "policies/blah-1.0.0.json", { }
+ file "policies/x-1.0.0.json", {}
+ file "policies/blah-1.0.0.json", {}
file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } }
file "roles/x.json", {}
end
diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb
index 8d3499617c..9078bf09a1 100644
--- a/spec/integration/knife/raw_spec.rb
+++ b/spec/integration/knife/raw_spec.rb
@@ -186,7 +186,7 @@ EOM
before :each do
Chef::Config.chef_server_url = "http://localhost:9018"
app = lambda do |env|
- [200, {"Content-Type" => "application/json" }, ['{ "x": "y", "a": "b" }'] ]
+ [200, { "Content-Type" => "application/json" }, ['{ "x": "y", "a": "b" }'] ]
end
@raw_server, @raw_server_thread = start_app_server(app, 9018)
end
@@ -216,7 +216,7 @@ EOM
before :each do
Chef::Config.chef_server_url = "http://localhost:9018"
app = lambda do |env|
- [200, {"Content-Type" => "text" }, ['{ "x": "y", "a": "b" }'] ]
+ [200, { "Content-Type" => "text" }, ['{ "x": "y", "a": "b" }'] ]
end
@raw_server, @raw_server_thread = start_app_server(app, 9018)
end
diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb
index 9febfc0ce5..29c1ee6ffb 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, @redirector_server_thread = start_app_server(app, 9018)
end
diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb
index a1de48e121..ed4802fef9 100644
--- a/spec/integration/knife/show_spec.rb
+++ b/spec/integration/knife/show_spec.rb
@@ -129,7 +129,7 @@ EOM
before do
environment "x", {
"default_attributes" => { "foo" => "bar" },
- "cookbook_versions" => { "blah" => "= 1.0.0"},
+ "cookbook_versions" => { "blah" => "= 1.0.0" },
"override_attributes" => { "x" => "y" },
"description" => "woo",
"name" => "x",
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 2ecbd4e64a..6f8dce5ae7 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -80,7 +80,7 @@ Deleted extra entry /roles/x.json (purge is on)
Deleted extra entry /users/admin.json (purge is on)
Deleted extra entry /users/x.json (purge is on)
EOM
- knife("diff --name-status /").should_succeed <<EOM
+ knife("diff --name-status /").should_succeed <<EOM
D\t/environments/_default.json
EOM
end
@@ -565,7 +565,7 @@ EOM
when_the_chef_server "has an earlier version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
@@ -1129,7 +1129,7 @@ EOM
when_the_chef_server "has an earlier version for the cookbook" do
before do
- cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""}
+ cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" }
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
it "knife upload /cookbooks uploads the local version" do
@@ -1248,7 +1248,6 @@ EOM
end
end # with versioned cookbooks
-
when_the_chef_server "has a user" do
before do
user "x", {}
@@ -1296,8 +1295,8 @@ EOM
file "members.json", [ "bar" ]
file "org.json", { "full_name" => "wootles" }
file "nodes/x.json", {}
- file "policies/x-1.0.0.json", { }
- file "policies/blah-1.0.0.json", { }
+ file "policies/x-1.0.0.json", {}
+ file "policies/blah-1.0.0.json", {}
file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } }
file "roles/x.json", {}
end
@@ -1397,9 +1396,9 @@ EOM
environment "x", { "description" => "foo" }
group "x", { "groups" => [ "admin" ] }
node "x", { "run_list" => [ "blah" ] }
- policy "x", "1.0.0", { }
- policy "x", "1.0.1", { }
- policy "y", "1.0.0", { }
+ policy "x", "1.0.0", {}
+ policy "x", "1.0.1", {}
+ policy "y", "1.0.0", {}
policy_group "x", {
"policies" => {
"x" => { "revision_id" => "1.0.1" },
@@ -1443,7 +1442,7 @@ EOM
when_the_repository "has an org.json that changes full_name" do
before do
- file "org.json", { "full_name" => "Something Else"}
+ file "org.json", { "full_name" => "Something Else" }
end
it "knife upload / emits a warning for bar and adds foo and foobar" do
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index dc7e19a3cb..0fc2c338fd 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -82,8 +82,8 @@ describe "LWRPs with inline resources" do
action :b
end
}.to have_updated("lwrp_inline_resources_test2[hi]", :b).
- and have_updated("ruby_block[run a]", :run).
- and have_updated("ruby_block[run b]", :run)
+ and have_updated("ruby_block[run a]", :run).
+ and have_updated("ruby_block[run b]", :run)
expect(r.ran_b).to eq "ran b: ran_a value was \"ran a\""
end
end
diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb
index d08090bbe8..a9fc06038a 100644
--- a/spec/integration/recipes/provider_choice.rb
+++ b/spec/integration/recipes/provider_choice.rb
@@ -18,6 +18,7 @@ describe "Recipe DSL methods" do
class Chef::Provider::ProviderThingy < Chef::Provider
def load_current_resource
end
+
def action_create
Chef::Log.warn("hello from #{self.class.name}")
end
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index db4d158eec..f96be7ea91 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -30,6 +30,7 @@ describe "Recipe DSL methods" do
class Provider < Chef::Provider
def load_current_resource
end
+
def action_create
BaseThingy.created_name = new_resource.name
BaseThingy.created_resource = new_resource.class
@@ -89,6 +90,7 @@ describe "Recipe DSL methods" do
class Chef::Provider::BackcompatThingy < Chef::Provider
def load_current_resource
end
+
def action_create
BaseThingy.created_resource = new_resource.class
BaseThingy.created_provider = self.class
@@ -832,7 +834,9 @@ describe "Recipe DSL methods" do
def self.name
"B"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -846,7 +850,9 @@ describe "Recipe DSL methods" do
def self.name
"A"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -874,7 +880,9 @@ describe "Recipe DSL methods" do
def self.name
"Z"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -1009,7 +1017,9 @@ describe "Recipe DSL methods" do
def self.name
"B"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.provides two_classes_one_dsl
@@ -1023,7 +1033,9 @@ describe "Recipe DSL methods" do
def self.name
"A"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result
@@ -1060,7 +1072,9 @@ describe "Recipe DSL methods" do
def self.name
"Z"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result
@@ -1132,7 +1146,9 @@ describe "Recipe DSL methods" do
def self.name
"Blarghle"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
end
result.resource_name two_classes_one_dsl
@@ -1170,6 +1186,7 @@ describe "Recipe DSL methods" do
def self.called_provides
@called_provides
end
+
def to_s
"MyResource"
end
@@ -1237,8 +1254,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1256,7 +1276,7 @@ describe "Recipe DSL methods" do
context "with supports? returning true" do
before do
- provider_class.define_singleton_method(:supports?) { |resource,action| true }
+ provider_class.define_singleton_method(:supports?) { |resource, action| true }
end
it "my_resource runs the provider and does not emit a warning" do
@@ -1274,8 +1294,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider2"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1299,7 +1322,7 @@ describe "Recipe DSL methods" do
context "with supports? returning false" do
before do
- provider_class.define_singleton_method(:supports?) { |resource,action| false }
+ provider_class.define_singleton_method(:supports?) { |resource, action| false }
end
# TODO no warning? ick
@@ -1319,8 +1342,11 @@ describe "Recipe DSL methods" do
def self.name
"MyProvider2"
end
+
def self.to_s; name; end
+
def self.inspect; name.inspect; end
+
def self.called_provides
@called_provides
end
@@ -1475,6 +1501,7 @@ describe "Recipe DSL methods" do
class Chef::Provider::LwResourceWithHwProviderTestCase < Chef::Provider
def load_current_resource
end
+
def action_create
new_resource.created_provider = self.class
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index 5778c467c5..8f6f4b7f46 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -3,89 +3,89 @@ require "support/shared/integration/integration_helper"
# Houses any classes we declare
module ResourceActionSpec
-describe "Resource.action" do
- include IntegrationSupport
+ describe "Resource.action" do
+ include IntegrationSupport
- shared_context "ActionJackson" do
- it "the default action is the first declared action" do
- converge <<-EOM, __FILE__, __LINE__+1
+ shared_context "ActionJackson" do
+ it "the default action is the first declared action" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
end
EOM
- expect(ActionJackson.ran_action).to eq :access_recipe_dsl
- expect(ActionJackson.succeeded).to eq true
- end
+ expect(ActionJackson.ran_action).to eq :access_recipe_dsl
+ expect(ActionJackson.succeeded).to eq true
+ end
- it "the action can access recipe DSL" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action can access recipe DSL" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_recipe_dsl
end
EOM
- expect(ActionJackson.ran_action).to eq :access_recipe_dsl
- expect(ActionJackson.succeeded).to eq true
- end
+ expect(ActionJackson.ran_action).to eq :access_recipe_dsl
+ expect(ActionJackson.succeeded).to eq true
+ end
- it "the action can access attributes" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action can access attributes" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_attribute
end
EOM
- expect(ActionJackson.ran_action).to eq :access_attribute
- expect(ActionJackson.succeeded).to eq "foo!"
- end
+ expect(ActionJackson.ran_action).to eq :access_attribute
+ expect(ActionJackson.succeeded).to eq "foo!"
+ end
- it "the action can access public methods" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action can access public methods" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_method
end
EOM
- expect(ActionJackson.ran_action).to eq :access_method
- expect(ActionJackson.succeeded).to eq "foo_public!"
- end
+ expect(ActionJackson.ran_action).to eq :access_method
+ expect(ActionJackson.succeeded).to eq "foo_public!"
+ end
- it "the action can access protected methods" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action can access protected methods" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_protected_method
end
EOM
- expect(ActionJackson.ran_action).to eq :access_protected_method
- expect(ActionJackson.succeeded).to eq "foo_protected!"
- end
+ expect(ActionJackson.ran_action).to eq :access_protected_method
+ expect(ActionJackson.succeeded).to eq "foo_protected!"
+ end
- it "the action cannot access private methods" do
- expect {
- converge(<<-EOM, __FILE__, __LINE__+1)
+ it "the action cannot access private methods" do
+ expect {
+ converge(<<-EOM, __FILE__, __LINE__ + 1)
#{resource_dsl} "hi" do
foo "foo!"
action :access_private_method
end
EOM
- }.to raise_error(NameError)
- expect(ActionJackson.ran_action).to eq :access_private_method
- end
+ }.to raise_error(NameError)
+ expect(ActionJackson.ran_action).to eq :access_private_method
+ end
- it "the action cannot access resource instance variables" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action cannot access resource instance variables" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_instance_variable
end
EOM
- expect(ActionJackson.ran_action).to eq :access_instance_variable
- expect(ActionJackson.succeeded).to be_nil
- end
+ expect(ActionJackson.ran_action).to eq :access_instance_variable
+ expect(ActionJackson.succeeded).to be_nil
+ end
- it "the action does not compile until the prior resource has converged" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action does not compile until the prior resource has converged" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
ruby_block "wow" do
block do
ResourceActionSpec::ActionJackson.ruby_block_converged = "ruby_block_converged!"
@@ -97,12 +97,12 @@ describe "Resource.action" do
action :access_class_method
end
EOM
- expect(ActionJackson.ran_action).to eq :access_class_method
- expect(ActionJackson.succeeded).to eq "ruby_block_converged!"
- end
+ expect(ActionJackson.ran_action).to eq :access_class_method
+ expect(ActionJackson.succeeded).to eq "ruby_block_converged!"
+ end
- it "the action's resources converge before the next resource converges" do
- converge <<-EOM, __FILE__, __LINE__+1
+ it "the action's resources converge before the next resource converges" do
+ converge <<-EOM, __FILE__, __LINE__ + 1
#{resource_dsl} "hi" do
foo "foo!"
action :access_attribute
@@ -114,427 +114,407 @@ describe "Resource.action" do
end
end
EOM
- expect(ActionJackson.ran_action).to eq :access_attribute
- expect(ActionJackson.succeeded).to eq "foo!"
- expect(ActionJackson.ruby_block_converged).to eq "foo!"
- end
- end
-
- context "With resource 'action_jackson'" do
- class ActionJackson < Chef::Resource
- use_automatic_resource_name
- def foo(value=nil)
- @foo = value if value
- @foo
- end
- def blarghle(value=nil)
- @blarghle = value if value
- @blarghle
+ expect(ActionJackson.ran_action).to eq :access_attribute
+ expect(ActionJackson.succeeded).to eq "foo!"
+ expect(ActionJackson.ruby_block_converged).to eq "foo!"
end
+ end
- class <<self
- attr_accessor :ran_action
- attr_accessor :succeeded
- attr_accessor :ruby_block_converged
- end
+ context "With resource 'action_jackson'" do
+ class ActionJackson < Chef::Resource
+ use_automatic_resource_name
+ def foo(value = nil)
+ @foo = value if value
+ @foo
+ end
- public
- def foo_public
- "foo_public!"
- end
- protected
- def foo_protected
- "foo_protected!"
- end
- private
- def foo_private
- "foo_private!"
- end
+ def blarghle(value = nil)
+ @blarghle = value if value
+ @blarghle
+ end
- public
- action :access_recipe_dsl do
- ActionJackson.ran_action = :access_recipe_dsl
- ruby_block "hi there" do
- block do
- ActionJackson.succeeded = true
- end
+ class <<self
+ attr_accessor :ran_action
+ attr_accessor :succeeded
+ attr_accessor :ruby_block_converged
end
- end
- action :access_attribute do
- ActionJackson.ran_action = :access_attribute
- ActionJackson.succeeded = foo
- ActionJackson.succeeded += " #{blarghle}" if blarghle
- ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
- end
- action :access_attribute2 do
- ActionJackson.ran_action = :access_attribute2
- ActionJackson.succeeded = foo
- ActionJackson.succeeded += " #{blarghle}" if blarghle
- ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
- end
- action :access_method do
- ActionJackson.ran_action = :access_method
- ActionJackson.succeeded = foo_public
- end
- action :access_protected_method do
- ActionJackson.ran_action = :access_protected_method
- ActionJackson.succeeded = foo_protected
- end
- action :access_private_method do
- ActionJackson.ran_action = :access_private_method
- ActionJackson.succeeded = foo_private
- end
- action :access_instance_variable do
- ActionJackson.ran_action = :access_instance_variable
- ActionJackson.succeeded = @foo
- end
- action :access_class_method do
- ActionJackson.ran_action = :access_class_method
- ActionJackson.succeeded = ActionJackson.ruby_block_converged
- end
- end
- before(:each) {
- ActionJackson.ran_action = :error
- ActionJackson.succeeded = :error
- ActionJackson.ruby_block_converged = :error
- }
+ public
- it_behaves_like "ActionJackson" do
- let(:resource_dsl) { :action_jackson }
- end
+ def foo_public
+ "foo_public!"
+ end
- it "Can retrieve ancestors of action class without crashing" do
- converge { action_jackson "hi" }
- expect { ActionJackson.action_class.ancestors.join(",") }.not_to raise_error
- end
+ protected
- context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
- before(:context) {
- class ActionJackgrandson < ActionJackson
- use_automatic_resource_name
+ def foo_protected
+ "foo_protected!"
end
- }
- it_behaves_like "ActionJackson" do
- let(:resource_dsl) { :action_jackgrandson }
- end
- end
+ private
- context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute, action and custom method" do
- class ActionJackalope < ActionJackson
- use_automatic_resource_name
+ def foo_private
+ "foo_private!"
+ end
- def foo(value=nil)
- @foo = "#{value}alope" if value
- @foo
+ public
+
+ action :access_recipe_dsl do
+ ActionJackson.ran_action = :access_recipe_dsl
+ ruby_block "hi there" do
+ block do
+ ActionJackson.succeeded = true
+ end
+ end
end
- def bar(value=nil)
- @bar = "#{value}alope" if value
- @bar
+ action :access_attribute do
+ ActionJackson.ran_action = :access_attribute
+ ActionJackson.succeeded = foo
+ ActionJackson.succeeded += " #{blarghle}" if blarghle
+ ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
end
- class <<self
- attr_accessor :load_current_resource_ran
- attr_accessor :jackalope_ran
+ action :access_attribute2 do
+ ActionJackson.ran_action = :access_attribute2
+ ActionJackson.succeeded = foo
+ ActionJackson.succeeded += " #{blarghle}" if blarghle
+ ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
end
- action :access_jackalope do
- ActionJackalope.jackalope_ran = :access_jackalope
- ActionJackalope.succeeded = "#{foo} #{blarghle} #{bar}"
+ action :access_method do
+ ActionJackson.ran_action = :access_method
+ ActionJackson.succeeded = foo_public
end
- action :access_attribute do
- super()
- ActionJackalope.jackalope_ran = :access_attribute
- ActionJackalope.succeeded = ActionJackson.succeeded
+ action :access_protected_method do
+ ActionJackson.ran_action = :access_protected_method
+ ActionJackson.succeeded = foo_protected
+ end
+ action :access_private_method do
+ ActionJackson.ran_action = :access_private_method
+ ActionJackson.succeeded = foo_private
+ end
+ action :access_instance_variable do
+ ActionJackson.ran_action = :access_instance_variable
+ ActionJackson.succeeded = @foo
+ end
+ action :access_class_method do
+ ActionJackson.ran_action = :access_class_method
+ ActionJackson.succeeded = ActionJackson.ruby_block_converged
end
end
- before do
- ActionJackalope.jackalope_ran = nil
- ActionJackalope.load_current_resource_ran = nil
+
+ before(:each) {
+ ActionJackson.ran_action = :error
+ ActionJackson.succeeded = :error
+ ActionJackson.ruby_block_converged = :error
+ }
+
+ it_behaves_like "ActionJackson" do
+ let(:resource_dsl) { :action_jackson }
end
- context "action_jackson still behaves the same" do
- it_behaves_like "ActionJackson" do
- let(:resource_dsl) { :action_jackson }
- end
+ it "Can retrieve ancestors of action class without crashing" do
+ converge { action_jackson "hi" }
+ expect { ActionJackson.action_class.ancestors.join(",") }.not_to raise_error
end
- it "the default action remains the same even though new actions were specified first" do
- converge {
- action_jackalope "hi" do
- foo "foo!"
- bar "bar!"
+ context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
+ before(:context) {
+ class ActionJackgrandson < ActionJackson
+ use_automatic_resource_name
end
}
- expect(ActionJackson.ran_action).to eq :access_recipe_dsl
- expect(ActionJackson.succeeded).to eq true
+
+ it_behaves_like "ActionJackson" do
+ let(:resource_dsl) { :action_jackgrandson }
+ end
end
- it "new actions run, and can access overridden, new, and overridden attributes" do
- converge {
- action_jackalope "hi" do
- foo "foo!"
- bar "bar!"
- blarghle "blarghle!"
- action :access_jackalope
+ context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute, action and custom method" do
+ class ActionJackalope < ActionJackson
+ use_automatic_resource_name
+
+ def foo(value = nil)
+ @foo = "#{value}alope" if value
+ @foo
end
- }
- expect(ActionJackalope.jackalope_ran).to eq :access_jackalope
- expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope"
- end
- it "overridden actions run, call super, and can access overridden, new, and overridden attributes" do
- converge {
- action_jackalope "hi" do
- foo "foo!"
- bar "bar!"
- blarghle "blarghle!"
- action :access_attribute
+ def bar(value = nil)
+ @bar = "#{value}alope" if value
+ @bar
end
- }
- expect(ActionJackson.ran_action).to eq :access_attribute
- expect(ActionJackson.succeeded).to eq "foo!alope blarghle! bar!alope"
- expect(ActionJackalope.jackalope_ran).to eq :access_attribute
- expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope"
- end
+ class <<self
+ attr_accessor :load_current_resource_ran
+ attr_accessor :jackalope_ran
+ end
+ action :access_jackalope do
+ ActionJackalope.jackalope_ran = :access_jackalope
+ ActionJackalope.succeeded = "#{foo} #{blarghle} #{bar}"
+ end
+ action :access_attribute do
+ super()
+ ActionJackalope.jackalope_ran = :access_attribute
+ ActionJackalope.succeeded = ActionJackson.succeeded
+ end
+ end
+ before do
+ ActionJackalope.jackalope_ran = nil
+ ActionJackalope.load_current_resource_ran = nil
+ end
- it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do
- converge {
- action_jackalope "hi" do
- foo "foo!"
- bar "bar!"
- blarghle "blarghle!"
- action :access_attribute2
+ context "action_jackson still behaves the same" do
+ it_behaves_like "ActionJackson" do
+ let(:resource_dsl) { :action_jackson }
end
- }
- expect(ActionJackson.ran_action).to eq :access_attribute2
- expect(ActionJackson.succeeded).to eq("foo!alope blarghle! bar!alope").or(eq("foo!alope blarghle!"))
+ end
+
+ it "the default action remains the same even though new actions were specified first" do
+ converge {
+ action_jackalope "hi" do
+ foo "foo!"
+ bar "bar!"
+ end
+ }
+ expect(ActionJackson.ran_action).to eq :access_recipe_dsl
+ expect(ActionJackson.succeeded).to eq true
+ end
+
+ it "new actions run, and can access overridden, new, and overridden attributes" do
+ converge {
+ action_jackalope "hi" do
+ foo "foo!"
+ bar "bar!"
+ blarghle "blarghle!"
+ action :access_jackalope
+ end
+ }
+ expect(ActionJackalope.jackalope_ran).to eq :access_jackalope
+ expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope"
+ end
+
+ it "overridden actions run, call super, and can access overridden, new, and overridden attributes" do
+ converge {
+ action_jackalope "hi" do
+ foo "foo!"
+ bar "bar!"
+ blarghle "blarghle!"
+ action :access_attribute
+ end
+ }
+ expect(ActionJackson.ran_action).to eq :access_attribute
+ expect(ActionJackson.succeeded).to eq "foo!alope blarghle! bar!alope"
+ expect(ActionJackalope.jackalope_ran).to eq :access_attribute
+ expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope"
+ end
+
+ it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do
+ converge {
+ action_jackalope "hi" do
+ foo "foo!"
+ bar "bar!"
+ blarghle "blarghle!"
+ action :access_attribute2
+ end
+ }
+ expect(ActionJackson.ran_action).to eq :access_attribute2
+ expect(ActionJackson.succeeded).to eq("foo!alope blarghle! bar!alope").or(eq("foo!alope blarghle!"))
+ end
end
end
- end
- context "With a resource with no actions" do
- class NoActionJackson < Chef::Resource
- use_automatic_resource_name
+ context "With a resource with no actions" do
+ class NoActionJackson < Chef::Resource
+ use_automatic_resource_name
- def foo(value=nil)
- @foo = value if value
- @foo
- end
+ def foo(value = nil)
+ @foo = value if value
+ @foo
+ end
- class <<self
- attr_accessor :action_was
+ class <<self
+ attr_accessor :action_was
+ end
end
- end
- it "the default action is :nothing" do
- converge {
- no_action_jackson "hi" do
- foo "foo!"
- NoActionJackson.action_was = action
- end
- }
- expect(NoActionJackson.action_was).to eq [:nothing]
+ it "the default action is :nothing" do
+ converge {
+ no_action_jackson "hi" do
+ foo "foo!"
+ NoActionJackson.action_was = action
+ end
+ }
+ expect(NoActionJackson.action_was).to eq [:nothing]
+ end
end
- end
- context "With a resource with action a-b-c d" do
- class WeirdActionJackson < Chef::Resource
- use_automatic_resource_name
+ context "With a resource with action a-b-c d" do
+ class WeirdActionJackson < Chef::Resource
+ use_automatic_resource_name
- class <<self
- attr_accessor :action_was
- end
+ class <<self
+ attr_accessor :action_was
+ end
- action "a-b-c d" do
- WeirdActionJackson.action_was = action
+ action "a-b-c d" do
+ WeirdActionJackson.action_was = action
+ end
end
- end
-
- it "Running the action works" do
- expect_recipe {
- weird_action_jackson "hi"
- }.to be_up_to_date
- expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
- end
- end
- context "With a resource with property x" do
- class ResourceActionSpecWithX < Chef::Resource
- resource_name :resource_action_spec_with_x
- property :x, default: 20
- action :set do
- # Access x during converge to ensure that we emit no warnings there
- x
+ it "Running the action works" do
+ expect_recipe {
+ weird_action_jackson "hi"
+ }.to be_up_to_date
+ expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
end
end
- context "And another resource with a property x and an action that sets property x to its value" do
- class ResourceActionSpecAlsoWithX < Chef::Resource
- resource_name :resource_action_spec_also_with_x
- property :x
- action :set_x_to_x do
- resource_action_spec_with_x "hi" do
- x x
- end
- end
- def self.x_warning_line
- __LINE__-4
- end
- action :set_x_to_x_in_non_initializer do
- r = resource_action_spec_with_x "hi" do
- x 10
- end
- x_times_2 = r.x*2
- end
- action :set_x_to_10 do
- resource_action_spec_with_x "hi" do
- x 10
- end
+ context "With a resource with property x" do
+ class ResourceActionSpecWithX < Chef::Resource
+ resource_name :resource_action_spec_with_x
+ property :x, default: 20
+ action :set do
+ # Access x during converge to ensure that we emit no warnings there
+ x
end
end
- attr_reader :x_warning_line
-
- it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do
- recipe = converge {
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_x
+ context "And another resource with a property x and an action that sets property x to its value" do
+ class ResourceActionSpecAlsoWithX < Chef::Resource
+ resource_name :resource_action_spec_also_with_x
+ property :x
+ action :set_x_to_x do
+ resource_action_spec_with_x "hi" do
+ x x
+ end
end
- }
- warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
- expect(warnings.size).to eq 1
- expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/)
- end
-
- it "Using the enclosing resource to set x to x outside the initializer emits no warning" do
- expect_recipe {
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_x_in_non_initializer
+ def self.x_warning_line
+ __LINE__ - 4
end
- }.to emit_no_warnings_or_errors
- end
-
- it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe {
- resource_action_spec_also_with_x "hi" do
- x 1
- action :set_x_to_10
+ action :set_x_to_x_in_non_initializer do
+ r = resource_action_spec_with_x "hi" do
+ x 10
+ end
+ x_times_2 = r.x * 2
end
- }.to emit_no_warnings_or_errors
- end
-
- it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe {
- r = resource_action_spec_also_with_x "hi"
- r.x 1
- r.action :set_x_to_10
- }.to emit_no_warnings_or_errors
- end
- end
+ action :set_x_to_10 do
+ resource_action_spec_with_x "hi" do
+ x 10
+ end
+ end
+ end
- end
+ attr_reader :x_warning_line
- context "With a resource with a set_or_return property named group (same name as a resource)" do
- class ResourceActionSpecWithGroupAction < Chef::Resource
- resource_name :resource_action_spec_set_group_to_nil
- action :set_group_to_nil do
- # Access x during converge to ensure that we emit no warnings there
- resource_action_spec_with_group "hi" do
- group nil
- action :nothing
+ it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do
+ recipe = converge {
+ resource_action_spec_also_with_x "hi" do
+ x 1
+ action :set_x_to_x
+ end
+ }
+ warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
+ expect(warnings.size).to eq 1
+ expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/)
end
- end
- end
- class ResourceActionSpecWithGroup < Chef::Resource
- resource_name :resource_action_spec_with_group
- def group(value=nil)
- set_or_return(:group, value, {})
- end
- end
+ it "Using the enclosing resource to set x to x outside the initializer emits no warning" do
+ expect_recipe {
+ resource_action_spec_also_with_x "hi" do
+ x 1
+ action :set_x_to_x_in_non_initializer
+ end
+ }.to emit_no_warnings_or_errors
+ end
- it "Setting group to nil in an action does not emit a warning about it being defined in two places" do
- expect_recipe {
- resource_action_spec_set_group_to_nil "hi" do
- action :set_group_to_nil
+ it "Using the enclosing resource to set x to 10 emits no warning" do
+ expect_recipe {
+ resource_action_spec_also_with_x "hi" do
+ x 1
+ action :set_x_to_10
+ end
+ }.to emit_no_warnings_or_errors
end
- }.to emit_no_warnings_or_errors
- end
- end
- context "When a resource has a property with the same name as another resource" do
- class HasPropertyNamedTemplate < Chef::Resource
- use_automatic_resource_name
- property :template
- action :create do
- template "x" do
- "blah"
+ it "Using the enclosing resource to set x to 10 emits no warning" do
+ expect_recipe {
+ r = resource_action_spec_also_with_x "hi"
+ r.x 1
+ r.action :set_x_to_10
+ }.to emit_no_warnings_or_errors
end
end
- end
- it "Raises an error when attempting to use a template in the action" do
- expect_converge {
- has_property_named_template "hi"
- }.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./)
end
- end
- context "When a resource declares methods in action_class and declare_action_class" do
- class DeclaresActionClassMethods < Chef::Resource
- use_automatic_resource_name
- property :x
- action :create do
- new_resource.x = a + b + c + d
- end
- action_class do
- def a
- 1
- end
- end
- declare_action_class do
- def b
- 2
+ context "With a resource with a set_or_return property named group (same name as a resource)" do
+ class ResourceActionSpecWithGroupAction < Chef::Resource
+ resource_name :resource_action_spec_set_group_to_nil
+ action :set_group_to_nil do
+ # Access x during converge to ensure that we emit no warnings there
+ resource_action_spec_with_group "hi" do
+ group nil
+ action :nothing
+ end
end
end
- action_class do
- def c
- 3
+
+ class ResourceActionSpecWithGroup < Chef::Resource
+ resource_name :resource_action_spec_with_group
+ def group(value = nil)
+ set_or_return(:group, value, {})
end
end
- declare_action_class do
- def d
- 4
- end
+
+ it "Setting group to nil in an action does not emit a warning about it being defined in two places" do
+ expect_recipe {
+ resource_action_spec_set_group_to_nil "hi" do
+ action :set_group_to_nil
+ end
+ }.to emit_no_warnings_or_errors
end
end
- it "the methods are not available on the resource" do
- expect { DeclaresActionClassMethods.new("hi").a }.to raise_error(NameError)
- expect { DeclaresActionClassMethods.new("hi").b }.to raise_error(NameError)
- expect { DeclaresActionClassMethods.new("hi").c }.to raise_error(NameError)
- expect { DeclaresActionClassMethods.new("hi").d }.to raise_error(NameError)
- end
+ context "When a resource has a property with the same name as another resource" do
+ class HasPropertyNamedTemplate < Chef::Resource
+ use_automatic_resource_name
+ property :template
+ action :create do
+ template "x" do
+ "blah"
+ end
+ end
+ end
- it "the methods are available to the action" do
- r = nil
- expect_recipe {
- r = declares_action_class_methods "hi"
- }.to emit_no_warnings_or_errors
- expect(r.x).to eq(10)
+ it "Raises an error when attempting to use a template in the action" do
+ expect_converge {
+ has_property_named_template "hi"
+ }.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./)
+ end
end
- context "And a subclass also creates a method" do
- class DeclaresActionClassMethodsToo < DeclaresActionClassMethods
+ context "When a resource declares methods in action_class and declare_action_class" do
+ class DeclaresActionClassMethods < Chef::Resource
use_automatic_resource_name
+ property :x
action :create do
- new_resource.x a+b+c+d+e
+ new_resource.x = a + b + c + d
end
action_class do
- def e
- 5
+ def a
+ 1
+ end
+ end
+ declare_action_class do
+ def b
+ 2
+ end
+ end
+ action_class do
+ def c
+ 3
+ end
+ end
+ declare_action_class do
+ def d
+ 4
end
end
end
@@ -544,18 +524,46 @@ describe "Resource.action" do
expect { DeclaresActionClassMethods.new("hi").b }.to raise_error(NameError)
expect { DeclaresActionClassMethods.new("hi").c }.to raise_error(NameError)
expect { DeclaresActionClassMethods.new("hi").d }.to raise_error(NameError)
- expect { DeclaresActionClassMethods.new("hi").e }.to raise_error(NameError)
end
it "the methods are available to the action" do
r = nil
expect_recipe {
- r = declares_action_class_methods_too "hi"
+ r = declares_action_class_methods "hi"
}.to emit_no_warnings_or_errors
- expect(r.x).to eq(15)
+ expect(r.x).to eq(10)
+ end
+
+ context "And a subclass also creates a method" do
+ class DeclaresActionClassMethodsToo < DeclaresActionClassMethods
+ use_automatic_resource_name
+ action :create do
+ new_resource.x a + b + c + d + e
+ end
+ action_class do
+ def e
+ 5
+ end
+ end
+ end
+
+ it "the methods are not available on the resource" do
+ expect { DeclaresActionClassMethods.new("hi").a }.to raise_error(NameError)
+ expect { DeclaresActionClassMethods.new("hi").b }.to raise_error(NameError)
+ expect { DeclaresActionClassMethods.new("hi").c }.to raise_error(NameError)
+ expect { DeclaresActionClassMethods.new("hi").d }.to raise_error(NameError)
+ expect { DeclaresActionClassMethods.new("hi").e }.to raise_error(NameError)
+ end
+
+ it "the methods are available to the action" do
+ r = nil
+ expect_recipe {
+ r = declares_action_class_methods_too "hi"
+ }.to emit_no_warnings_or_errors
+ expect(r.x).to eq(15)
+ end
end
end
end
-end
end
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index 2bcccd9831..f1ea79daf9 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -22,6 +22,7 @@ describe "Resource::ActionClass#converge_if_changed" do
let(:resource_class) {
result = Class.new(Chef::Resource) do
def self.to_s; resource_name; end
+
def self.inspect; resource_name.inspect; end
property :identity1, identity: true, default: "default_identity1"
property :control1, desired_state: false, default: "default_control1"
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 66a36b1431..b48eb2daa5 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -21,11 +21,13 @@ describe "Resource.load_current_value" do
let(:resource_class) {
result = Class.new(Chef::Resource) do
def self.to_s; resource_name; end
+
def self.inspect; resource_name.inspect; end
property :x, default: lazy { "default #{Namer.incrementing_value}" }
def self.created_x=(value)
@created = value
end
+
def self.created_x
@created
end
@@ -43,9 +45,9 @@ describe "Resource.load_current_value" do
context "with a resource with load_current_value" do
before :each do
resource_class.load_current_value do
- x "loaded #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name,p| name }.
- select { |name,p| p.is_set?(self) }.
- map { |name,p| "#{name}=#{p.get(self)}" }.
+ x "loaded #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
+ select { |name, p| p.is_set?(self) }.
+ map { |name, p| "#{name}=#{p.get(self)}" }.
join(", ") })"
end
end
@@ -170,9 +172,9 @@ describe "Resource.load_current_value" do
context "And a child resource class with load_current_value" do
before {
subresource_class.load_current_value do
- y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name,p| name }.
- select { |name,p| p.is_set?(self) }.
- map { |name,p| "#{name}=#{p.get(self)}" }.
+ y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
+ select { |name, p| p.is_set?(self) }.
+ map { |name, p| "#{name}=#{p.get(self)}" }.
join(", ") })"
end
}
@@ -188,9 +190,9 @@ describe "Resource.load_current_value" do
before {
subresource_class.load_current_value do
super()
- y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name,p| name }.
- select { |name,p| p.is_set?(self) }.
- map { |name,p| "#{name}=#{p.get(self)}" }.
+ y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
+ select { |name, p| p.is_set?(self) }.
+ map { |name, p| "#{name}=#{p.get(self)}" }.
join(", ") })"
end
}
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 4849cb4d40..567f1a2c6f 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -39,7 +39,7 @@ cookbook_path "#{path_to('cookbooks')}"
file_cache_path "#{path_to('config/cache')}"
EOM
- file "config/node.json",<<-E
+ file "config/node.json", <<-E
{"run_list":["x::default"]}
E
@@ -104,7 +104,6 @@ EOM
end
end
-
when_the_repository "has a cookbook with a recipe with sleep" do
before do
directory "logs"
@@ -152,12 +151,12 @@ EOM
run_log = File.read(path_to("logs/runs.log"))
# both of the runs should succeed
- expect(run_log.lines.reject {|l| !l.include? "INFO: Chef Run complete in"}.length).to eq(2)
+ expect(run_log.lines.reject { |l| !l.include? "INFO: Chef Run complete in" }.length).to eq(2)
# second run should have a message which indicates it's waiting for the first run
- pid_lines = run_log.lines.reject {|l| !l.include? "Chef-client pid:"}
+ pid_lines = run_log.lines.reject { |l| !l.include? "Chef-client pid:" }
expect(pid_lines.length).to eq(2)
- pids = pid_lines.map {|l| l.split(" ").last}
+ pids = pid_lines.map { |l| l.split(" ").last }
expect(run_log).to include("Chef client #{pids[0]} is running, will wait for it to finish and then run.")
# second run should start after first run ends
diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb
index 0a2376049b..284c58aa78 100644
--- a/spec/scripts/ssl-serve.rb
+++ b/spec/scripts/ssl-serve.rb
@@ -10,7 +10,6 @@ require "openssl"
require "webrick"
require "webrick/https"
-
$ssl = true
CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
@@ -21,14 +20,12 @@ key = OpenSSL::PKey::RSA.new(key_text)
server_opts = {}
if $ssl
-server_opts.merge!( { :SSLEnable => true,
- :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
- :SSLCertificate => cert,
- :SSLPrivateKey => key })
+ server_opts.merge!( { :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => cert,
+ :SSLPrivateKey => key })
end
-
-
# 5 == debug, 3 == warning
LOGGER = WEBrick::Log.new(STDOUT, 5)
DEFAULT_OPTIONS = {
@@ -48,5 +45,3 @@ server = WEBrick::HTTPServer.new(webrick_opts)
trap "INT" do server.shutdown end
server.start
-
-
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 7ada1fac9d..47432f5a77 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -27,7 +27,6 @@ end
# Ruby 1.9 Compat
$:.unshift File.expand_path("../..", __FILE__)
-
require "rubygems"
require "rspec/mocks"
@@ -50,9 +49,9 @@ require "chef"
require "chef/knife"
Dir["lib/chef/knife/**/*.rb"].
- map {|f| f.gsub("lib/", "") }.
- map {|f| f.gsub(%r{\.rb$}, "") }.
- each {|f| require f }
+ map { |f| f.gsub("lib/", "") }.
+ map { |f| f.gsub(%r{\.rb$}, "") }.
+ each { |f| require f }
require "chef/resource_resolver"
require "chef/provider_resolver"
@@ -86,7 +85,7 @@ Dir["spec/support/**/*.rb"].
reject { |f| f =~ %r{^spec/support/platforms} }.
reject { |f| f =~ %r{^spec/support/pedant} }.
map { |f| f.gsub(%r{.rb$}, "") }.
- map { |f| f.gsub(%r{spec/}, "")}.
+ map { |f| f.gsub(%r{spec/}, "") }.
each { |f| require f }
OHAI_SYSTEM = Ohai::System.new
@@ -131,8 +130,8 @@ RSpec.configure do |config|
config.filter_run_excluding :windows_only => true unless windows?
config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106?
- config.filter_run_excluding :not_supported_on_mac_osx=> true if mac_osx?
- config.filter_run_excluding :mac_osx_only=> true if !mac_osx?
+ config.filter_run_excluding :not_supported_on_mac_osx => true if mac_osx?
+ config.filter_run_excluding :mac_osx_only => true if !mac_osx?
config.filter_run_excluding :not_supported_on_win2k3 => true if windows_win2k3?
config.filter_run_excluding :not_supported_on_solaris => true if solaris?
config.filter_run_excluding :not_supported_on_gce => true if gce?
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index a7c3b849cd..aa60737c86 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -25,7 +25,6 @@ Chef::Log.init(StringIO.new)
Chef::Log.level(Chef::Config.log_level)
Chef::Config.solo(false)
-
def sha256_checksum(path)
OpenSSL::Digest::SHA256.hexdigest(File.read(path))
end
diff --git a/spec/support/lib/chef/resource/cat.rb b/spec/support/lib/chef/resource/cat.rb
index 44acddb653..94190e1f5b 100644
--- a/spec/support/lib/chef/resource/cat.rb
+++ b/spec/support/lib/chef/resource/cat.rb
@@ -22,12 +22,12 @@ class Chef
attr_accessor :action
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@action = "sell"
end
- def pretty_kitty(arg=nil)
+ def pretty_kitty(arg = nil)
if arg == true or arg == false
@pretty_kitty = arg
end
diff --git a/spec/support/lib/chef/resource/one_two_three_four.rb b/spec/support/lib/chef/resource/one_two_three_four.rb
index efeeff0710..d46d20d2b5 100644
--- a/spec/support/lib/chef/resource/one_two_three_four.rb
+++ b/spec/support/lib/chef/resource/one_two_three_four.rb
@@ -26,7 +26,7 @@ class Chef
@i_can_count = tf
end
- def something(arg=nil)
+ def something(arg = nil)
if arg == true or arg == false
@something = arg
end
diff --git a/spec/support/lib/chef/resource/openldap_includer.rb b/spec/support/lib/chef/resource/openldap_includer.rb
index 7a284cfc61..5a7651b10d 100644
--- a/spec/support/lib/chef/resource/openldap_includer.rb
+++ b/spec/support/lib/chef/resource/openldap_includer.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
class Chef
class Resource
class OpenldapIncluder < Chef::Resource::LWRPBase
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 135aeb1513..84fc71cc99 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -24,7 +24,7 @@ class Chef
provides :follower, platform: "zen"
- def master(arg=nil)
+ def master(arg = nil)
if !arg.nil?
@master = arg
end
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 530f2ea703..f5137c18ec 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -26,12 +26,11 @@ class Chef
attr_reader :peace
-
def peace(tf)
@peace = tf
end
- def something(arg=nil)
+ def something(arg = nil)
if !arg.nil?
@something = arg
end
diff --git a/spec/support/lib/library_load_order.rb b/spec/support/lib/library_load_order.rb
index c47a2f2c74..6b4c54fe4f 100644
--- a/spec/support/lib/library_load_order.rb
+++ b/spec/support/lib/library_load_order.rb
@@ -18,5 +18,3 @@ module LibraryLoadOrder
load_order << file
end
end
-
-
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index 0e31415940..f50a1bf5f7 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -20,7 +20,7 @@ module Matchers
module LeakBase
include RSpec::Matchers
- def initialize(opts={}, &block)
+ def initialize(opts = {}, &block)
@warmup = opts[:warmup] || 5
@iterations = opts[:iterations] || 100
@variance = opts[:variance] || 5000
@@ -35,6 +35,7 @@ module Matchers
end
private
+
def match(measure, given_proc)
profiler.start
@@ -90,6 +91,7 @@ module Matchers
def leak_memory(opts, &block)
Matchers::LeakMemory.new(opts, &block)
end
+
def leak_handles(opts, &block)
Matchers::LeakHandles.new(opts, &block)
end
diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb
index 98756d715f..a2abc1905e 100644
--- a/spec/support/mock/constant.rb
+++ b/spec/support/mock/constant.rb
@@ -9,7 +9,7 @@ def mock_constants(constants, &block)
constants.each do |constant, val|
source_object, const_name = parse_constant(constant)
saved_constants[constant] = source_object.const_get(const_name)
- with_warnings(nil) {source_object.const_set(const_name, val) }
+ with_warnings(nil) { source_object.const_set(const_name, val) }
end
begin
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index a8bbf13589..ef94678b64 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -16,10 +16,10 @@ def platform_mock(platform = :unix, &block)
end
if block_given?
- 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
+ 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
end
end
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index a29cb61d00..b50c2a01f0 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -65,10 +65,10 @@ def windows_2008r2_or_later?
host = wmi.first_of("Win32_OperatingSystem")
version = host["version"]
return false unless version
- components = version.split(".").map do | component |
+ components = version.split(".").map do |component|
component.to_i
end
- components.length >=2 && components[0] >= 6 && components[1] >= 1
+ components.length >= 2 && components[0] >= 6 && components[1] >= 1
end
def windows_powershell_dsc?
@@ -114,7 +114,6 @@ def mac_osx?
false
end
-
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
def windows64?
windows? && ( ENV["PROCESSOR_ARCHITECTURE"] == "AMD64" || ENV["PROCESSOR_ARCHITEW6432"] == "AMD64" )
@@ -166,7 +165,7 @@ def selinux_enabled?
# specs independent of product.
selinuxenabled_path = which("selinuxenabled")
if selinuxenabled_path
- cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0,1])
+ cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0, 1])
cmd_result = cmd.run_command
case cmd_result.exitstatus
when 1
@@ -213,7 +212,7 @@ class GCEDetector
end
def gce?
- GCEDetector.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)
+ GCEDetector.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
rescue SocketError
false
end
diff --git a/spec/support/platforms/prof/gc.rb b/spec/support/platforms/prof/gc.rb
index 81fb28dda7..2e1b45c294 100644
--- a/spec/support/platforms/prof/gc.rb
+++ b/spec/support/platforms/prof/gc.rb
@@ -51,4 +51,3 @@ module RSpec
end
end
end
-
diff --git a/spec/support/platforms/prof/win32.rb b/spec/support/platforms/prof/win32.rb
index 61e9eec853..1cfbecc95d 100644
--- a/spec/support/platforms/prof/win32.rb
+++ b/spec/support/platforms/prof/win32.rb
@@ -43,4 +43,3 @@ module RSpec
end
end
end
-
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 3c88e36fbb..d8676ef168 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -98,7 +98,7 @@ shared_context "a client run" do
# previous step.
expect(Chef::ServerAPI).to receive(:new).
with(Chef::Config[:chef_server_url], client_name: fqdn,
- signing_key_filename: Chef::Config[:client_key]).
+ signing_key_filename: Chef::Config[:client_key]).
exactly(:once).
and_return(http_node_load)
@@ -123,7 +123,7 @@ shared_context "a client run" do
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(http_cookbook_sync)
expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", {:run_list => []}).
+ with("environments/_default/cookbook_versions", { :run_list => [] }).
and_return({})
end
@@ -183,7 +183,7 @@ shared_context "converge completed" do
# --Client#save_updated_node
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], client_name: fqdn,
- signing_key_filename: Chef::Config[:client_key], validate_utf8: false).and_return(http_node_save)
+ signing_key_filename: Chef::Config[:client_key], validate_utf8: false).and_return(http_node_save)
expect(http_node_save).to receive(:put).with("nodes/#{fqdn}", node.for_json).and_return(true)
end
end
@@ -231,7 +231,7 @@ end
shared_context "audit phase completed with failed controls" do
let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) }
+ :num_failed => 1, :num_total => 3) }
let(:audit_error) do
err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
diff --git a/spec/support/shared/examples/client.rb b/spec/support/shared/examples/client.rb
index 5af63dc307..3c13cd767e 100644
--- a/spec/support/shared/examples/client.rb
+++ b/spec/support/shared/examples/client.rb
@@ -24,7 +24,7 @@ shared_examples "a completed run with audit failure" do
end
it "converges, runs audits, saves the node and raises the error in a wrapping error" do
- expect{ client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
+ expect { client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
expect(error.wrapped_errors.size).to eq(run_errors.size)
run_errors.each do |run_error|
expect(error.wrapped_errors).to include(run_error)
@@ -42,7 +42,7 @@ shared_examples "a failed run" do
include_context "run failed"
it "skips node save and raises the error in a wrapping error" do
- expect{ client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
+ expect { client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
expect(error.wrapped_errors.size).to eq(run_errors.size)
run_errors.each do |run_error|
expect(error.wrapped_errors).to include(run_error)
diff --git a/spec/support/shared/functional/diff_disabled.rb b/spec/support/shared/functional/diff_disabled.rb
index 7ee9808a94..c40b1e6e49 100644
--- a/spec/support/shared/functional/diff_disabled.rb
+++ b/spec/support/shared/functional/diff_disabled.rb
@@ -1,5 +1,5 @@
-shared_context "diff disabled" do
+shared_context "diff disabled" do
before do
Chef::Config[:diff_disabled] = true
end
diff --git a/spec/support/shared/functional/directory_resource.rb b/spec/support/shared/functional/directory_resource.rb
index 88e716b498..084cd43009 100644
--- a/spec/support/shared/functional/directory_resource.rb
+++ b/spec/support/shared/functional/directory_resource.rb
@@ -20,7 +20,7 @@ shared_examples_for "a directory resource" do
include_context "diff disabled"
- let(:expect_updated?) {true}
+ let(:expect_updated?) { true }
context "when the target directory does not exist" do
before do
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index c7a9611786..5f34f1efe6 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -44,7 +44,6 @@ shared_context "deploying via destdir" do
end
end
-
shared_examples_for "a file with the wrong content" do
before do
# Assert starting state is as expected
@@ -103,7 +102,7 @@ shared_examples_for "a file with the wrong content" do
end
it "raises an exception" do
- expect{ resource.run_action(:create) }.to raise_error(Chef::Exceptions::ChecksumMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ChecksumMismatch)
end
end
end
@@ -308,14 +307,14 @@ shared_examples_for "a file resource" do
describe "when setting atomic_update" do
it "booleans should work" do
- expect {resource.atomic_update(true)}.not_to raise_error
- expect {resource.atomic_update(false)}.not_to raise_error
+ expect { resource.atomic_update(true) }.not_to raise_error
+ expect { resource.atomic_update(false) }.not_to raise_error
end
it "anything else should raise an error" do
- expect {resource.atomic_update(:copy)}.to raise_error(ArgumentError)
- expect {resource.atomic_update(:move)}.to raise_error(ArgumentError)
- expect {resource.atomic_update(958)}.to raise_error(ArgumentError)
+ expect { resource.atomic_update(:copy) }.to raise_error(ArgumentError)
+ expect { resource.atomic_update(:move) }.to raise_error(ArgumentError)
+ expect { resource.atomic_update(958) }.to raise_error(ArgumentError)
end
end
@@ -351,13 +350,13 @@ shared_examples_for "file resource not pointing to a real file" do
describe "when force_unlink is set to false" do
it ":create raises an error" do
- expect {resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
end
end
describe "when force_unlink is not set (default)" do
it ":create raises an error" do
- expect {resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
end
end
end
@@ -405,7 +404,6 @@ shared_examples_for "a configured file resource" do
File.join(CHEF_SPEC_DATA, "file-test-target")
}
-
describe "when configured not to manage symlink's target" do
before(:each) do
# configure not to manage symlink source
@@ -574,7 +572,6 @@ shared_examples_for "a configured file resource" do
File.open(path, "wb") { |f| f.write(expected_content) }
end
-
include_context "setup broken permissions"
include_examples "a securable resource with existing target"
@@ -721,7 +718,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a blockdev",:unix_only, :requires_root, :not_supported_on_solaris do
+ context "when the target file is a blockdev", :unix_only, :requires_root, :not_supported_on_solaris do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testdev")
@@ -739,7 +736,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a chardev",:unix_only, :requires_root, :not_supported_on_solaris do
+ context "when the target file is a chardev", :unix_only, :requires_root, :not_supported_on_solaris do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testdev")
@@ -757,7 +754,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a pipe",:unix_only do
+ context "when the target file is a pipe", :unix_only do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testpipe")
@@ -775,7 +772,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a socket",:unix_only do
+ context "when the target file is a socket", :unix_only do
require "socket"
# It turns out that the path to a socket can have at most ~104
@@ -1018,7 +1015,7 @@ shared_examples_for "a configured file resource" do
end
-shared_context Chef::Resource::File do
+shared_context Chef::Resource::File do
if windows?
require "chef/win32/file"
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 2779730268..8e6b5bfa89 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -37,7 +37,7 @@ module ChefHTTPShared
content
end
- def start_tiny_server(server_opts={})
+ def start_tiny_server(server_opts = {})
nyan_uncompressed_size = File::Stat.new(nyan_uncompressed_filename).size
nyan_compressed_size = File::Stat.new(nyan_compressed_filename).size
@@ -162,7 +162,6 @@ module ChefHTTPShared
#
@api.get("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
@api.post("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
-
end
def stop_tiny_server
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 330183ebb1..dd8a0216bc 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -515,7 +515,7 @@ shared_examples_for "a securable resource without existing target" do
resource.inherits(false)
resource.run_action(:create)
- descriptor.dacl.each do | ace |
+ descriptor.dacl.each do |ace|
expect(ace.inherited?).to eq(false)
end
end
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index c9b5bae465..0bec29783a 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -21,7 +21,6 @@ ALL_EXPANDED_PERMISSIONS = ["generic read",
"read attributes",
"write attributes"]
-
shared_examples_for "a securable resource with reporting" do
include_context "diff disabled"
@@ -273,7 +272,6 @@ shared_examples_for "a securable resource with reporting" do
# Windows reporting data should look like this (+/- ish):
# { "owner" => "bob", "checksum" => "ffff", "access control" => { "bob" => { "permissions" => ["perm1", "perm2", ...], "flags" => [] }}}
-
before do
resource.action(:create)
end
@@ -293,14 +291,13 @@ shared_examples_for "a securable resource with reporting" do
resource.run_action(:create)
# TODO: most stable way to specify?
expect(resource.owner).to eq(etc.getpwuid(process.uid).name)
- expect(resource.state[:expanded_rights]).to eq({ "CURRENTUSER" => { "permissions" => ALL_EXPANDED_PERMISSIONS, "flags" => [] }})
+ expect(resource.state[:expanded_rights]).to eq({ "CURRENTUSER" => { "permissions" => ALL_EXPANDED_PERMISSIONS, "flags" => [] } })
expect(resource.state[:expanded_deny_rights]).to eq({})
expect(resource.state[:inherits]).to be_truthy
end
end
-
- context "and owner is specified with a string (username) in new_resource" do
+ context "and owner is specified with a string (username) in new_resource" do
# TODO/bug: duplicated from the "securable resource" tests
let(:expected_user_name) { "Guest" }
@@ -392,7 +389,6 @@ shared_examples_for "a securable resource with reporting" do
end
end
-
end
end
end
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 5bd2d772cb..0f9072bdef 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -35,10 +35,8 @@ shared_context "using Win32::Service" do
if File.exists?(test_service_file)
File.delete(test_service_file)
end
-
end
-
# Definition for the test-service
let(:test_service) {
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index cad0d7e12d..67a53306ba 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -27,7 +27,7 @@ shared_context Chef::Resource::WindowsScript do
@ohai_reader.all_plugins(["platform", "kernel"])
new_node = Chef::Node.new
- new_node.consume_external_attrs(@ohai_reader.data,{})
+ new_node.consume_external_attrs(@ohai_reader.data, {})
events = Chef::EventDispatch::Dispatcher.new
@@ -116,7 +116,7 @@ shared_context Chef::Resource::WindowsScript do
let (:guard_architecture) { :i386 }
it "raises an error" do
resource.only_if resource_guard_command, :architecture => guard_architecture
- expect{ resource.run_action(:run) }.to raise_error(
+ expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
end
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 5d4c01a44e..29f2eef50f 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -99,7 +99,7 @@ module IntegrationSupport
File.expand_path(relative_path, (@parent_path || @repository_dir))
end
- def cb_metadata(name, version, extra_text="")
+ def cb_metadata(name, version, extra_text = "")
"name #{name.inspect}; version #{version.inspect}#{extra_text}"
end
@@ -128,7 +128,7 @@ module IntegrationSupport
# TODO: "force" actually means "silence all exceptions". this
# silences a weird permissions error on Windows that we should track
# down, but for now there's no reason for it to blow up our CI.
- FileUtils.remove_entry_secure(@repository_dir, force=Chef::Platform.windows?)
+ FileUtils.remove_entry_secure(@repository_dir, force = Chef::Platform.windows?)
ensure
@repository_dir = nil
end
diff --git a/spec/support/shared/matchers/exit_with_code.rb b/spec/support/shared/matchers/exit_with_code.rb
index cf1825f2ed..c5458eea0e 100644
--- a/spec/support/shared/matchers/exit_with_code.rb
+++ b/spec/support/shared/matchers/exit_with_code.rb
@@ -14,7 +14,7 @@ RSpec::Matchers.define :exit_with_code do |exp_code|
failure_message do |block|
"expected block to call exit(#{exp_code}) but exit" +
- (actual.nil? ? " not called" : "(#{actual}) was called")
+ (actual.nil? ? " not called" : "(#{actual}) was called")
end
failure_message_when_negated do |block|
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index 6e074d38a7..45bfcc67da 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -16,8 +16,6 @@
# limitations under the License.
#
-
-
# == API Error Inspector Examples
# These tests are work in progress. They exercise the code enough to ensure it
# runs without error, but don't make assertions about the output. This is
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index 195b65ff5b..b61469a2d0 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -32,7 +32,7 @@ shared_examples_for "version handling" do
end
it "raises the original exception" do
- expect{ object.send(method) }.to raise_error(exception_406)
+ expect { object.send(method) }.to raise_error(exception_406)
end
end # when the server does not support the min or max server API version that Chef::UserV1 supports
end # version handling
@@ -60,7 +60,7 @@ shared_examples_for "user and client reregister" do
it "raises an error about only V0 being supported" do
expect(object).to receive(:reregister_only_v0_supported_error_msg).with(max_version, min_version)
- expect{ object.reregister }.to raise_error(Chef::Exceptions::OnlyApiVersion0SupportedForAction)
+ expect { object.reregister }.to raise_error(Chef::Exceptions::OnlyApiVersion0SupportedForAction)
end
end
@@ -70,7 +70,7 @@ shared_examples_for "user and client reregister" do
end
it "raises the original error" do
- expect{ object.reregister }.to raise_error(generic_exception)
+ expect { object.reregister }.to raise_error(generic_exception)
end
end
end
diff --git a/spec/support/shared/unit/knife_shared.rb b/spec/support/shared/unit/knife_shared.rb
index 8f97cf60c0..0af05ffb80 100644
--- a/spec/support/shared/unit/knife_shared.rb
+++ b/spec/support/shared/unit/knife_shared.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
shared_examples_for "mandatory field missing" do
context "when field is nil" do
before do
diff --git a/spec/support/shared/unit/mock_shellout.rb b/spec/support/shared/unit/mock_shellout.rb
index 05924e8a40..dac51be798 100644
--- a/spec/support/shared/unit/mock_shellout.rb
+++ b/spec/support/shared/unit/mock_shellout.rb
@@ -34,12 +34,15 @@ class MockShellout
exitstatus: 0,
}.merge(properties)
end
+
def method_missing(name, *args)
@properties[name.to_sym]
end
+
def error?
exitstatus != 0
end
+
def error!
raise Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with 0, but received #{exitstatus}" if error?
end
diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb
index 30a2f61a70..2e6f74fb14 100644
--- a/spec/support/shared/unit/platform_introspector.rb
+++ b/spec/support/shared/unit/platform_introspector.rb
@@ -17,7 +17,6 @@
# limitations under the License.
#
-
shared_examples_for "a platform introspector" do
before(:each) do
@platform_hash = {}
@@ -27,12 +26,12 @@ shared_examples_for "a platform introspector" do
"1.2.3" => "#{x}-1.2.3",
}
end
- @platform_hash["debian"] = {["5", "6"] => "debian-5/6", "default" => "debian"}
+ @platform_hash["debian"] = { ["5", "6"] => "debian-5/6", "default" => "debian" }
@platform_hash["default"] = "default"
# The following @platform_hash keys are used for testing version constraints
- @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact"}
+ @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact" }
@platform_hash["multiple_matches"] = { "~> 2.3.4" => "matched ~> 2.3.4", ">= 2.3" => "matched >=2.3" }
- @platform_hash["invalid_cookbook_version"] = {">= 21" => "Matches a single number"}
+ @platform_hash["invalid_cookbook_version"] = { ">= 21" => "Matches a single number" }
@platform_hash["successful_matches"] = { "< 3.0" => "matched < 3.0", ">= 3.0" => "matched >= 3.0" }
@platform_family_hash = {
@@ -93,7 +92,7 @@ shared_examples_for "a platform introspector" do
it "raises RuntimeError" do
node.automatic_attrs[:platform] = "multiple_matches"
node.automatic_attrs[:platform_version] = "2.3.4"
- expect {platform_introspector.value_for_platform(@platform_hash)}.to raise_error(RuntimeError)
+ expect { platform_introspector.value_for_platform(@platform_hash) }.to raise_error(RuntimeError)
end
it "should not require .0 to match >= 21.0" do
@@ -171,7 +170,7 @@ shared_examples_for "a platform introspector" do
"centos" => { "default" => [ :restart, :reload, :status ] },
"redhat" => { "default" => [ :restart, :reload, :status ] },
"fedora" => { "default" => [ :restart, :reload, :status ] },
- "default" => { "default" => [:restart, :reload ] }}
+ "default" => { "default" => [:restart, :reload ] } }
end
it "returns the correct default for a given platform" do
@@ -188,4 +187,3 @@ shared_examples_for "a platform introspector" do
end
end
-
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 8ed67eb5a8..5e5fc058e7 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -117,7 +117,7 @@ class BasicTempfile < ::File
end
def self.new(basename)
- super(make_tmp_path(basename), File::RDWR|File::CREAT|File::EXCL, 0600)
+ super(make_tmp_path(basename), File::RDWR | File::CREAT | File::EXCL, 0600)
end
def unlink
@@ -419,12 +419,12 @@ shared_examples_for Chef::Provider::File do
[: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)
+ expect { provider.run_action(action) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
end
it "does not raise an exception in why-run mode" do
Chef::Config[:why_run] = true
- expect {provider.run_action(action)}.not_to raise_error
+ expect { provider.run_action(action) }.not_to raise_error
Chef::Config[:why_run] = false
end
end
@@ -435,19 +435,19 @@ shared_examples_for Chef::Provider::File do
before { setup_unwritable_file }
it "action delete raises InsufficientPermissions" do
- expect {provider.run_action(:delete)}.to raise_error(Chef::Exceptions::InsufficientPermissions)
+ expect { provider.run_action(:delete) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
end
it "action delete also raises InsufficientPermissions in why-run mode" do
Chef::Config[:why_run] = true
- expect {provider.run_action(:delete)}.to raise_error(Chef::Exceptions::InsufficientPermissions)
+ expect { provider.run_action(:delete) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
Chef::Config[:why_run] = false
end
end
end
context "action create" do
- it "should create the file, update its contents and then set the acls on the file" do
+ it "should create the file, update its contents and then set the acls on the file" do
setup_missing_file
expect(provider).to receive(:do_create_file)
expect(provider).to receive(:do_contents_changes)
@@ -476,7 +476,7 @@ shared_examples_for Chef::Provider::File do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
provider.new_resource.verify windows? ? "REM" : "true"
provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
- expect{provider.send(:do_validate_content)}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
end
@@ -520,14 +520,14 @@ shared_examples_for Chef::Provider::File do
let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" }
before do
allow(provider).to receive(:contents_changed?).and_return(true)
- diff = double("Diff", :for_output => ["+++","---","+foo","-bar"],
+ diff = double("Diff", :for_output => ["+++", "---", "+foo", "-bar"],
:for_reporting => diff_for_reporting )
allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true)
expect(provider).to receive(:diff).at_least(:once).and_return(diff)
expect(provider).to receive(:checksum).with(tempfile_path).and_return(tempfile_sha256)
allow(provider).to receive(:managing_content?).and_return(true)
allow(provider).to receive(:checksum).with(resource_path).and_return(tempfile_sha256)
- expect(resource).not_to receive(:checksum).with(tempfile_sha256) # do not mutate the new resource
+ expect(resource).not_to receive(:checksum).with(tempfile_sha256) # do not mutate the new resource
expect(provider.deployment_strategy).to receive(:deploy).with(tempfile_path, normalized_path)
end
context "when the file was created" do
@@ -549,7 +549,7 @@ shared_examples_for Chef::Provider::File do
end
context "when the file was not created" do
before do
- allow(provider).to receive(:do_backup) # stub do_backup
+ allow(provider).to receive(:do_backup) # stub do_backup
expect(provider).to receive(:needs_creating?).at_least(:once).and_return(false)
end
@@ -570,7 +570,7 @@ shared_examples_for Chef::Provider::File do
end
end
- it "does nothing when the contents have not changed" do
+ it "does nothing when the contents have not changed" do
allow(provider).to receive(:contents_changed?).and_return(false)
expect(provider).not_to receive(:diff)
provider.send(:do_contents_changes)
@@ -580,20 +580,20 @@ shared_examples_for Chef::Provider::File do
it "does nothing when there is no content to deploy (tempfile returned from contents is nil)" do
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(nil)
expect(provider).not_to receive(:diff)
- expect{ provider.send(:do_contents_changes) }.not_to raise_error
+ expect { provider.send(:do_contents_changes) }.not_to raise_error
end
it "raises an exception when the content object returns a tempfile with a nil path" do
tempfile = double("Tempfile", :path => nil)
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
- expect{ provider.send(:do_contents_changes) }.to raise_error
+ expect { provider.send(:do_contents_changes) }.to raise_error
end
it "raises an exception when the content object returns a tempfile that does not exist" do
tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false)
- expect{ provider.send(:do_contents_changes) }.to raise_error
+ expect { provider.send(:do_contents_changes) }.to raise_error
end
end
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index ccc6e3fec6..6694aa346c 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -46,7 +46,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@current_resource.manage_home false
@current_resource.force false
@current_resource.non_unique false
- @current_resource.supports({:manage_home => false, :non_unique => false})
+ @current_resource.supports({ :manage_home => false, :non_unique => false })
end
describe "when setting option" do
@@ -64,8 +64,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do
- allow(@new_resource).to receive(:supports).and_return({:manage_home => false,
- :non_unique => false})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => false,
+ :non_unique => false })
allow(@new_resource).to receive(attribute).and_return("hola")
expect(provider.universal_options).to eql([option, "hola"])
end
@@ -81,7 +81,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should combine all the possible options" do
combined_opts = []
- supported_useradd_options.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
+ supported_useradd_options.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
allow(@new_resource).to receive(attribute).and_return("hola")
combined_opts << option << "hola"
end
@@ -103,8 +103,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when the resource has a different home directory and supports home directory management" do
before do
allow(@new_resource).to receive(:home).and_return("/wowaweea")
- allow(@new_resource).to receive(:supports).and_return({:manage_home => true,
- :non_unique => false})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => true,
+ :non_unique => false })
end
it "should set -m -d /homedir" do
@@ -128,8 +128,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when the resource supports non_unique ids" do
before do
- allow(@new_resource).to receive(:supports).and_return({:manage_home => false,
- :non_unique => true})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => false,
+ :non_unique => true })
end
it "should set -m -o" do
@@ -161,7 +161,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "runs useradd with the computed command options" do
command = ["useradd",
- "-c", "Adam Jacob",
+ "-c", "Adam Jacob",
"-g", "23" ]
command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password")
command.concat([ "-s", "/usr/bin/zsh",
@@ -247,14 +247,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should run userdel with the new resources user name and -r if manage_home is true" do
@new_resource.supports({ :manage_home => true,
- :non_unique => false})
+ :non_unique => false })
expect(provider).to receive(:shell_out!).with("userdel", "-r", @new_resource.username).and_return(true)
provider.remove_user
end
it "should run userdel with the new resources user name if non_unique is true" do
@new_resource.supports({ :manage_home => false,
- :non_unique => true})
+ :non_unique => true })
expect(provider).to receive(:shell_out!).with("userdel", @new_resource.username).and_return(true)
provider.remove_user
end
@@ -285,7 +285,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return false if status begins with P" do
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
@@ -293,7 +293,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return false if status begins with N" do
@stdout = "root N"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
@@ -301,7 +301,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return true if status begins with L" do
@stdout = "root L"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(true)
end
@@ -309,7 +309,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should raise a Chef::Exceptions::User if passwd -S fails on anything other than redhat/centos" do
@node.automatic_attrs[:platform] = "ubuntu"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect { provider.check_lock }.to raise_error(Chef::Exceptions::User)
@@ -320,7 +320,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@node.automatic_attrs[:platform] = os
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-1\n", :stderr => "")
expect(provider).to receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
@@ -331,7 +331,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@node.automatic_attrs[:platform] = os
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-2\n", :stderr => "")
expect(provider).to receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
@@ -349,7 +349,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
before do
passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_status)
Chef::Config[:why_run] = true
end
@@ -431,4 +431,3 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
end
end
-
diff --git a/spec/support/shared/unit/resource/static_provider_resolution.rb b/spec/support/shared/unit/resource/static_provider_resolution.rb
index 56ed49e00d..4ae5d4576f 100644
--- a/spec/support/shared/unit/resource/static_provider_resolution.rb
+++ b/spec/support/shared/unit/resource/static_provider_resolution.rb
@@ -16,8 +16,6 @@
# limitations under the License.
#
-
-
#
# This is for typical "static" provider resolution which maps resources onto
# providers based only on the node data. Its not really 'static' because it
@@ -25,7 +23,7 @@
# a static mapping for the node (unlike the service resource which is
# complicated).
#
-def static_provider_resolution(opts={})
+def static_provider_resolution(opts = {})
action = opts[:action]
provider_class = opts[:provider]
resource_class = opts[:resource]
@@ -63,4 +61,3 @@ def static_provider_resolution(opts={})
end
end
end
-
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index ba33d69a59..a80ab81fb9 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -74,7 +74,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 ]
+ [:cwd, :environment, :group, :path, :user, :umask ]
expect(inherited_difference).to eq([])
end
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index c8208c149b..e3862943bc 100644
--- a/spec/support/shared/unit/user_and_client_shared.rb
+++ b/spec/support/shared/unit/user_and_client_shared.rb
@@ -27,7 +27,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v1).to receive(:post).with(url, payload.merge({:public_key => "some_public_key"})).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
object.create
end
@@ -49,7 +49,7 @@ shared_examples_for "user or client create" do
end
it "creates a new object via the API with create_key" do
- expect(rest_v1).to receive(:post).with(url, payload.merge({:create_key => true})).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ :create_key => true })).and_return({})
object.create
end
end
@@ -104,7 +104,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v0).to receive(:post).with(url, payload.merge({:public_key => "some_public_key"})).and_return({})
+ expect(rest_v0).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
object.create
end
@@ -112,4 +112,3 @@ shared_examples_for "user or client create" do
end # when server API V1 is not valid on the Chef Server receiving the request
end # user or client create
-
diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb
index 1dcbae76aa..2dc0229c90 100644
--- a/spec/support/shared/unit/windows_script_resource.rb
+++ b/spec/support/shared/unit/windows_script_resource.rb
@@ -78,4 +78,3 @@ shared_examples_for "a Windows script resource" do
end
end
-
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb
index 7a58328224..a3711e4dbd 100644
--- a/spec/tiny_server.rb
+++ b/spec/tiny_server.rb
@@ -31,7 +31,7 @@ module TinyServer
attr_writer :app
- def self.setup(options=nil, &block)
+ def self.setup(options = nil, &block)
tiny_app = new(options)
app_code = Rack::Builder.new(&block).to_app
tiny_app.app = app_code
@@ -56,7 +56,7 @@ module TinyServer
:AccessLog => [] # Remove this option to enable the access log when debugging.
}
- def initialize(options=nil)
+ def initialize(options = nil)
@options = options ? DEFAULT_OPTIONS.merge(options) : DEFAULT_OPTIONS
@creator = caller.first
end
@@ -128,22 +128,22 @@ module TinyServer
end
def clear
- @routes = {GET => [], PUT => [], POST => [], DELETE => []}
+ @routes = { GET => [], PUT => [], POST => [], DELETE => [] }
end
- def get(path, response_code, data=nil, headers=nil, &block)
+ def get(path, response_code, data = nil, headers = nil, &block)
@routes[GET] << Route.new(path, Response.new(response_code, data, headers, &block))
end
- def put(path, response_code, data=nil, headers=nil, &block)
+ def put(path, response_code, data = nil, headers = nil, &block)
@routes[PUT] << Route.new(path, Response.new(response_code, data, headers, &block))
end
- def post(path, response_code, data=nil, headers=nil, &block)
+ def post(path, response_code, data = nil, headers = nil, &block)
@routes[POST] << Route.new(path, Response.new(response_code, data, headers, &block))
end
- def delete(path, response_code, data=nil, headers=nil, &block)
+ def delete(path, response_code, data = nil, headers = nil, &block)
@routes[DELETE] << Route.new(path, Response.new(response_code, data, headers, &block))
end
@@ -151,11 +151,11 @@ module TinyServer
if response = response_for_request(env)
response.call
else
- debug_info = {:message => "no data matches the request for #{env['REQUEST_URI']}",
- :available_routes => @routes, :request => env}
+ debug_info = { :message => "no data matches the request for #{env['REQUEST_URI']}",
+ :available_routes => @routes, :request => env }
# Uncomment me for glorious debugging
# pp :not_found => debug_info
- [404, {"Content-Type" => "application/json"}, [ Chef::JSONCompat.to_json(debug_info) ]]
+ [404, { "Content-Type" => "application/json" }, [ Chef::JSONCompat.to_json(debug_info) ]]
end
end
@@ -185,9 +185,9 @@ module TinyServer
end
class Response
- HEADERS = {"Content-Type" => "application/json"}
+ HEADERS = { "Content-Type" => "application/json" }
- def initialize(response_code=200, data=nil, headers=nil, &block)
+ def initialize(response_code = 200, data = nil, headers = nil, &block)
@response_code, @data = response_code, data
@response_headers = headers ? HEADERS.merge(headers) : HEADERS
@block = block_given? ? block : nil
@@ -199,7 +199,7 @@ module TinyServer
end
def to_s
- "#{@response_code} => #{(@data|| @block)}"
+ "#{@response_code} => #{(@data || @block)}"
end
end
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb
index f41c5d8653..750223ad14 100644
--- a/spec/unit/api_client/registration_spec.rb
+++ b/spec/unit/api_client/registration_spec.rb
@@ -32,7 +32,7 @@ describe Chef::ApiClient::Registration do
subject(:registration) { Chef::ApiClient::Registration.new(client_name, key_location) }
let(:private_key_data) do
- File.open(Chef::Config[:validation_key], "r") {|f| f.read.chomp }
+ File.open(Chef::Config[:validation_key], "r") { |f| f.read.chomp }
end
let(:http_mock) { double("Chef::ServerAPI mock") }
@@ -67,7 +67,6 @@ describe Chef::ApiClient::Registration do
let(:generated_private_key) { OpenSSL::PKey::RSA.new(generated_private_key_pem) }
let(:generated_public_key) { generated_private_key.public_key }
-
let(:create_with_pkey_response) do
{
"uri" => "",
@@ -78,12 +77,12 @@ describe Chef::ApiClient::Registration do
end
let(:update_with_pkey_response) do
- {"name"=>client_name,
- "admin"=>false,
- "public_key"=> generated_public_key,
- "validator"=>false,
- "private_key"=>false,
- "clientname"=>client_name}
+ { "name" => client_name,
+ "admin" => false,
+ "public_key" => generated_public_key,
+ "validator" => false,
+ "private_key" => false,
+ "clientname" => client_name }
end
before do
@@ -217,7 +216,7 @@ describe Chef::ApiClient::Registration do
context "when the client key location is a symlink" do
it "does not follow the symlink", :unix_only do
- expected_flags = (File::CREAT|File::TRUNC|File::RDWR)
+ expected_flags = (File::CREAT | File::TRUNC | File::RDWR)
if defined?(File::NOFOLLOW)
expected_flags |= File::NOFOLLOW
@@ -232,7 +231,7 @@ describe Chef::ApiClient::Registration do
end
it "follows the symlink", :unix_only do
- expect(registration.file_flags).to eq(File::CREAT|File::TRUNC|File::RDWR)
+ expect(registration.file_flags).to eq(File::CREAT | File::TRUNC | File::RDWR)
end
end
end
@@ -271,7 +270,7 @@ describe Chef::ApiClient::Registration do
expect(http_mock).to receive(:post).exactly(6).times.and_raise(exception_500)
- expect {registration.run}.to raise_error(Net::HTTPFatalError)
+ expect { registration.run }.to raise_error(Net::HTTPFatalError)
end
end
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index 398181bfd0..a8ac4f747b 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -82,7 +82,6 @@ describe Chef::ApiClient do
expect { @client.public_key Hash.new }.to raise_error(ArgumentError)
end
-
it "has a private key attribute" do
@client.private_key("super private")
expect(@client.private_key).to eq("super private")
@@ -267,12 +266,11 @@ describe Chef::ApiClient do
end
let :private_key_data do
- File.open(Chef::Config[:client_key], "r") {|f| f.read.chomp }
+ File.open(Chef::Config[:client_key], "r") { |f| f.read.chomp }
end
end
-
describe "when requesting a new key" do
before do
@http_client = double("Chef::ServerAPI mock")
@@ -299,7 +297,6 @@ describe Chef::ApiClient do
expect(@http_client).to receive(:get).with("clients/lost-my-key").and_return(@api_client_without_key)
end
-
context "and the client exists on a Chef 11-like server" do
before do
@api_client_with_key = Chef::ApiClient.new
@@ -322,7 +319,7 @@ describe Chef::ApiClient do
context "and the client exists on a Chef 10-like server" do
before do
- @api_client_with_key = {"name" => "lost-my-key", "private_key" => "the new private key"}
+ @api_client_with_key = { "name" => "lost-my-key", "private_key" => "the new private key" }
expect(@http_client).to receive(:put).
with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :validator => false, :private_key => true).
and_return(@api_client_with_key)
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index 6fb5ae40f2..8c90d5ad38 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -91,7 +91,6 @@ describe Chef::ApiClientV1 do
expect { @client.public_key Hash.new }.to raise_error(ArgumentError)
end
-
it "has a private key attribute" do
@client.private_key("super private")
expect(@client.private_key).to eq("super private")
@@ -299,12 +298,11 @@ describe Chef::ApiClientV1 do
end
let :private_key_data do
- File.open(Chef::Config[:client_key], "r") {|f| f.read.chomp }
+ File.open(Chef::Config[:client_key], "r") { |f| f.read.chomp }
end
end
-
describe "when requesting a new key" do
before do
@http_client = double("Chef::ServerAPI mock")
@@ -328,7 +326,7 @@ describe Chef::ApiClientV1 do
describe "Versioned API Interactions" do
let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
- let(:payload) {
+ let(:payload) {
{
:name => "some_name",
:validator => true,
@@ -391,7 +389,7 @@ describe Chef::ApiClientV1 do
end
it "updates the client with only the name" do
- expect(rest). to receive(:put).with("clients/some_name", {:name => "some_name"}).and_return({:name => "some_name"})
+ expect(rest). to receive(:put).with("clients/some_name", { :name => "some_name" }).and_return({ :name => "some_name" })
@client.update
end
end
@@ -439,7 +437,7 @@ describe Chef::ApiClientV1 do
describe "reregister" do
context "when server API V0 is valid on the Chef Server receiving the request" do
it "creates a new object via the API" do
- expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({:private_key => true})).and_return({})
+ expect(@client.chef_rest_v0).to receive(:put).with("clients/#{@client.name}", payload.merge({ :private_key => true })).and_return({})
@client.reregister
end
end # when server API V0 is valid on the Chef Server receiving the request
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index 61d4150950..d7298d07fa 100644
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -92,7 +92,7 @@ describe Chef::Application::Apply do
end
describe "when the json_attribs configuration option is specified" do
- let(:json_attribs) { {"a" => "b"} }
+ let(:json_attribs) { { "a" => "b" } }
let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index dc3add6fd9..b675c9384a 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -156,7 +156,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
describe "when the json_attribs configuration option is specified" do
- let(:json_attribs) { {"a" => "b"} }
+ let(:json_attribs) { { "a" => "b" } }
let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
@@ -255,7 +255,6 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
end
end
-
describe Chef::Application::Client, "setup_application" do
before do
@app = Chef::Application::Client.new
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index ba02e44481..90ecde608e 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -182,7 +182,7 @@ describe Chef::Application::Knife do
end
it "should load the environment from the config file" do
- config_file = File.join(CHEF_SPEC_DATA,"environment-config.rb")
+ config_file = File.join(CHEF_SPEC_DATA, "environment-config.rb")
with_argv(*%W{noop knife command -c #{config_file}}) do
expect(@knife).to receive(:exit).with(0)
@knife.run
@@ -199,7 +199,7 @@ describe Chef::Application::Knife do
end
it "should override the config file environment with the CLI environment" do
- config_file = File.join(CHEF_SPEC_DATA,"environment-config.rb")
+ config_file = File.join(CHEF_SPEC_DATA, "environment-config.rb")
with_argv(*%W{noop knife command -c #{config_file} -E override}) do
expect(@knife).to receive(:exit).with(0)
@knife.run
@@ -208,7 +208,7 @@ describe Chef::Application::Knife do
end
it "should override the config file environment with the CLI environment regardless of order" do
- config_file = File.join(CHEF_SPEC_DATA,"environment-config.rb")
+ config_file = File.join(CHEF_SPEC_DATA, "environment-config.rb")
with_argv(*%W{noop knife command -E override -c #{config_file}}) do
expect(@knife).to receive(:exit).with(0)
@knife.run
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 0f95e9d0d6..e2de4aa7b1 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -87,7 +87,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
end
describe "when the json_attribs configuration option is specified" do
- let(:json_attribs) { {"a" => "b"} }
+ let(:json_attribs) { { "a" => "b" } }
let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
@@ -107,7 +107,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
let(:tarfile) { StringIO.new("remote_tarball_content") }
let(:target_file) { StringIO.new }
let(:shellout) { double(run_command: nil, error!: nil, stdout: "") }
-
+
before do
Chef::Config[:cookbook_path] = "#{Dir.tmpdir}/chef-solo/cookbooks"
Chef::Config[:recipe_url] = "http://junglist.gen.nz/recipes.tgz"
@@ -137,14 +137,14 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
end
it "should untar the target file to the parent of the cookbook path" do
- expect(Mixlib::ShellOut).to receive(:new).with("tar zxvf #{Dir.tmpdir}/chef-solo/recipes.tgz -C #{Dir.tmpdir}/chef-solo")
+ expect(Mixlib::ShellOut).to receive(:new).with("tar zxvf #{Dir.tmpdir}/chef-solo/recipes.tgz -C #{Dir.tmpdir}/chef-solo")
app.reconfigure
end
end
end
describe "when the json_attribs and recipe_url configuration options are both specified" do
- let(:json_attribs) { {"a" => "b"} }
+ let(:json_attribs) { { "a" => "b" } }
let(:config_fetcher) { double(Chef::ConfigFetcher, :fetch_json => json_attribs) }
let(:json_source) { "https://foo.com/foo.json" }
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index 1b91aafe8d..462b7314c4 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -250,7 +250,6 @@ describe Chef::Application do
end
end
-
context "with an invalid log location" do
it "logs a fatal error and exits" do
@@ -261,7 +260,6 @@ describe Chef::Application do
end
end
-
describe "class method: fatal!" do
before do
allow(STDERR).to receive(:puts).with("FATAL: blah").and_return(true)
diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb
index 39fa057cba..2496aef3e7 100644
--- a/spec/unit/audit/audit_event_proxy_spec.rb
+++ b/spec/unit/audit/audit_event_proxy_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Audit::AuditEventProxy do
let(:description) { "poots" }
let(:group) { double("ExampleGroup", :parent_groups => parents,
- :description => description) }
+ :description => description) }
let(:notification) { double("Notification", :group => group) }
context "when notified from a top-level example group" do
@@ -121,8 +121,8 @@ describe Chef::Audit::AuditEventProxy do
let(:examples) { [example] }
let(:example) { double("Example", :metadata => metadata,
- :description => example_description,
- :full_description => full_description, :exception => nil) }
+ :description => example_description,
+ :full_description => full_description, :exception => nil) }
let(:metadata) {
{
diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb
index 28f2f2db45..ed0aa622cc 100644
--- a/spec/unit/audit/audit_reporter_spec.rb
+++ b/spec/unit/audit/audit_reporter_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Audit::AuditReporter do
let(:start_time) { Time.new(2014, 12, 3, 9, 31, 05, "-08:00") }
let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") }
let(:run_status) { instance_double(Chef::RunStatus, :node => node, :run_id => run_id,
- :start_time => start_time, :end_time => end_time) }
+ :start_time => start_time, :end_time => end_time) }
describe "#audit_phase_start" do
@@ -86,12 +86,12 @@ describe Chef::Audit::AuditReporter do
context "when audit phase failed" do
let(:audit_error) { double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
+ :message => "Audit phase failed with error message: derpderpderp",
+ :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
- before do
- reporter.instance_variable_set(:@audit_phase_error, audit_error)
- end
+ before do
+ reporter.instance_variable_set(:@audit_phase_error, audit_error)
+ end
it "reports an error" do
reporter.run_completed(node)
@@ -191,7 +191,7 @@ EOM
expect(error).to receive(:respond_to?).with(:response).and_return(false)
allow(Chef::Log).to receive(:error).and_return(true)
expect(Chef::Log).to receive(:error).with(/Reporting fatals enabled. Aborting run./)
- expect{ reporter.run_completed(node) }.to raise_error(error)
+ expect { reporter.run_completed(node) }.to raise_error(error)
end
end
@@ -234,12 +234,12 @@ EOM
let(:run_data) { audit_data.to_hash }
let(:audit_error) { double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
+ :message => "Audit phase failed with error message: derpderpderp",
+ :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
let(:run_error) { double("RunError", :class => "Chef::Exceptions::RunError",
- :message => "This error shouldn't be reported.",
- :backtrace => ["fix it", "fix it", "fix it"]) }
+ :message => "This error shouldn't be reported.",
+ :backtrace => ["fix it", "fix it", "fix it"]) }
before do
allow(reporter).to receive(:auditing_enabled?).and_return(true)
@@ -366,7 +366,7 @@ EOM
context "when a control group with the same name has been seen" do
it "raises an exception" do
expect(ordered_control_groups).to receive(:has_key?).with(name).and_return(true)
- expect{ reporter.control_group_started(name) }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
+ expect { reporter.control_group_started(name) }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
end
end
end
diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb
index a18e33a40a..f6935a4c75 100644
--- a/spec/unit/audit/control_group_data_spec.rb
+++ b/spec/unit/audit/control_group_data_spec.rb
@@ -72,8 +72,8 @@ describe Chef::Audit::AuditData do
describe ":control_groups" do
- let(:control_hash_1) { {:name => "control group 1"} }
- let(:control_hash_2) { {:name => "control group 2"} }
+ let(:control_hash_1) { { :name => "control group 1" } }
+ let(:control_hash_2) { { :name => "control group 2" } }
let(:control_groups) { audit_data_hash[:control_groups] }
@@ -123,9 +123,8 @@ describe Chef::Audit::ControlData do
let(:line_number) { 27 }
let(:control_data) { described_class.new(name: name,
- resource_type: resource_type, resource_name: resource_name,
- context: context, line_number: line_number) }
-
+ resource_type: resource_type, resource_name: resource_name,
+ context: context, line_number: line_number) }
describe "#to_hash" do
@@ -188,14 +187,14 @@ describe Chef::Audit::ControlGroupData do
include_context "control data"
let(:control) { Chef::Audit::ControlData.new(name: name,
- resource_type: resource_type, resource_name: resource_name,
- context: context, line_number: line_number) }
+ resource_type: resource_type, resource_name: resource_name,
+ context: context, line_number: line_number) }
before do
allow(Chef::Audit::ControlData).to receive(:new).
with(name: name, resource_type: resource_type,
- resource_name: resource_name, context: context,
- line_number: line_number).
+ resource_name: resource_name, context: context,
+ line_number: line_number).
and_return(control)
end
end
@@ -433,9 +432,9 @@ describe Chef::Audit::ControlGroupData do
context "with multiple controls added" do
- let(:control_hash_1) { {:line_number => 27} }
- let(:control_hash_2) { {:line_number => 13} }
- let(:control_hash_3) { {:line_number => 35} }
+ let(:control_hash_1) { { :line_number => 27 } }
+ let(:control_hash_2) { { :line_number => 13 } }
+ let(:control_hash_3) { { :line_number => 35 } }
let(:control_1) { double("control 1",
:line_number => control_hash_1[:line_number],
diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb
index 70fff6faf3..4c03cab1d3 100644
--- a/spec/unit/audit/runner_spec.rb
+++ b/spec/unit/audit/runner_spec.rb
@@ -24,7 +24,6 @@ require "chef/audit/rspec_formatter"
require "rspec/support/spec/in_sub_process"
require "rspec/support/spec/stderr_splitter"
-
describe Chef::Audit::Runner do
include RSpec::Support::InSubProcess
@@ -100,8 +99,8 @@ describe Chef::Audit::Runner do
end
context "audits exist" do
- let(:audits) { {"audit_name" => group} }
- let(:group) {Struct.new(:args, :block).new(["group_name"], nil)}
+ let(:audits) { { "audit_name" => group } }
+ let(:group) { Struct.new(:args, :block).new(["group_name"], nil) }
it "sends the audits to the world" do
runner.send(:register_control_groups)
diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb
index c126d05c93..2f65b6db94 100644
--- a/spec/unit/chef_fs/config_spec.rb
+++ b/spec/unit/chef_fs/config_spec.rb
@@ -71,7 +71,7 @@ describe Chef::ChefFS::Config do
},)
end
- let(:chef_fs_config) { Chef::ChefFS::Config.new(chef_config, Dir.pwd) }
+ let(:chef_fs_config) { Chef::ChefFS::Config.new(chef_config, Dir.pwd) }
subject(:local_fs) { chef_fs_config.local_fs }
diff --git a/spec/unit/chef_fs/data_handler/group_handler_spec.rb b/spec/unit/chef_fs/data_handler/group_handler_spec.rb
index a1baabc14f..849bc84f92 100644
--- a/spec/unit/chef_fs/data_handler/group_handler_spec.rb
+++ b/spec/unit/chef_fs/data_handler/group_handler_spec.rb
@@ -45,8 +45,8 @@ describe Chef::ChefFS::DataHandler::GroupDataHandler do
let(:normalized) do
{ "actors" =>
{ "users" => %w{fizz buzz},
- "clients"=> %w{honey sting},
- "groups"=> [],
+ "clients" => %w{honey sting},
+ "groups" => [],
},
"groupname" => "workers",
"name" => "worker_bees",
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index e0e507ce89..c1c9050101 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -98,63 +98,63 @@ describe "diff", :uses_diff => true do
CONTEXT_LINE_NUMBERS
-a
+b
-','diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
+', 'diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
new file
--- /dev/null DATE
+++ b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub DATE
CONTEXT_LINE_NUMBERS
+subsub
-','diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
+', 'diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
deleted file
--- a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-subsub
-',"Only in a/both_dirs: sub_a_only_dir
-",'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
+', "Only in a/both_dirs: sub_a_only_dir
+", 'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
deleted file
--- a/both_dirs/sub_a_only_file DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-sub_a_only_file
-',"File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file
-","File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory
-","Only in b/both_dirs: sub_b_only_dir
-",'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file
+', "File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file
+", "File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory
+", "Only in b/both_dirs: sub_b_only_dir
+", 'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file
new file
--- /dev/null DATE
+++ b/both_dirs/sub_b_only_file DATE
CONTEXT_LINE_NUMBERS
+sub_b_only_file
-','diff --knife a/both_files_different b/both_files_different
+', 'diff --knife a/both_files_different b/both_files_different
--- a/both_files_different DATE
+++ b/both_files_different DATE
CONTEXT_LINE_NUMBERS
-a
+b
-','diff --knife a/dirs_empty_in_a_filled_in_b/subsub b/dirs_empty_in_a_filled_in_b/subsub
+', 'diff --knife a/dirs_empty_in_a_filled_in_b/subsub b/dirs_empty_in_a_filled_in_b/subsub
new file
--- /dev/null DATE
+++ b/dirs_empty_in_a_filled_in_b/subsub DATE
CONTEXT_LINE_NUMBERS
+subsub
-','diff --knife a/dirs_empty_in_b_filled_in_a/subsub b/dirs_empty_in_b_filled_in_a/subsub
+', 'diff --knife a/dirs_empty_in_b_filled_in_a/subsub b/dirs_empty_in_b_filled_in_a/subsub
deleted file
--- a/dirs_empty_in_b_filled_in_a/subsub DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-subsub
-',"Only in a: a_only_dir
-",'diff --knife a/a_only_file b/a_only_file
+', "Only in a: a_only_dir
+", 'diff --knife a/a_only_file b/a_only_file
deleted file
--- a/a_only_file DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-a_only_file
-',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
-","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
-","Only in b: b_only_dir
-",'diff --knife a/b_only_file b/b_only_file
+', "File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
+", "File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
+", "Only in b: b_only_dir
+", 'diff --knife a/b_only_file b/b_only_file
new file
--- /dev/null DATE
+++ b/b_only_file DATE
@@ -174,29 +174,29 @@ CONTEXT_LINE_NUMBERS
CONTEXT_LINE_NUMBERS
-a
+b
-','diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
+', 'diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
new file
--- /dev/null DATE
+++ b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub DATE
CONTEXT_LINE_NUMBERS
+subsub
-','diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
+', 'diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
deleted file
--- a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-subsub
-',"Only in a/both_dirs: sub_a_only_dir
-",'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
+', "Only in a/both_dirs: sub_a_only_dir
+", 'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
deleted file
--- a/both_dirs/sub_a_only_file DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-sub_a_only_file
-',"File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file
-","File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory
-","Only in b/both_dirs: sub_b_only_dir
-",'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file
+', "File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file
+", "File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory
+", "Only in b/both_dirs: sub_b_only_dir
+", 'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file
new file
--- /dev/null DATE
+++ b/both_dirs/sub_b_only_file DATE
@@ -211,26 +211,26 @@ CONTEXT_LINE_NUMBERS
end
expect(results).to match_array([
"Common subdirectories: b/both_dirs
-",'diff --knife a/both_files_different b/both_files_different
+", 'diff --knife a/both_files_different b/both_files_different
--- a/both_files_different DATE
+++ b/both_files_different DATE
CONTEXT_LINE_NUMBERS
-a
+b
-',"Common subdirectories: b/both_dirs_empty
-","Common subdirectories: b/dirs_empty_in_b_filled_in_a
-","Common subdirectories: b/dirs_empty_in_a_filled_in_b
-","Only in a: a_only_dir
-",'diff --knife a/a_only_file b/a_only_file
+', "Common subdirectories: b/both_dirs_empty
+", "Common subdirectories: b/dirs_empty_in_b_filled_in_a
+", "Common subdirectories: b/dirs_empty_in_a_filled_in_b
+", "Only in a: a_only_dir
+", 'diff --knife a/a_only_file b/a_only_file
deleted file
--- a/a_only_file DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-a_only_file
-',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
-","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
-","Only in b: b_only_dir
-",'diff --knife a/b_only_file b/b_only_file
+', "File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
+", "File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
+", "Only in b: b_only_dir
+", 'diff --knife a/b_only_file b/b_only_file
new file
--- /dev/null DATE
+++ b/b_only_file DATE
@@ -245,26 +245,26 @@ CONTEXT_LINE_NUMBERS
end
expect(results).to match_array([
"Common subdirectories: b/both_dirs
-",'diff --knife a/both_files_different b/both_files_different
+", 'diff --knife a/both_files_different b/both_files_different
--- a/both_files_different DATE
+++ b/both_files_different DATE
CONTEXT_LINE_NUMBERS
-a
+b
-',"Common subdirectories: b/both_dirs_empty
-","Common subdirectories: b/dirs_empty_in_b_filled_in_a
-","Common subdirectories: b/dirs_empty_in_a_filled_in_b
-","Only in a: a_only_dir
-",'diff --knife a/a_only_file b/a_only_file
+', "Common subdirectories: b/both_dirs_empty
+", "Common subdirectories: b/dirs_empty_in_b_filled_in_a
+", "Common subdirectories: b/dirs_empty_in_a_filled_in_b
+", "Only in a: a_only_dir
+", 'diff --knife a/a_only_file b/a_only_file
deleted file
--- a/a_only_file DATE
+++ /dev/null DATE
CONTEXT_LINE_NUMBERS
-a_only_file
-',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
-","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
-","Only in b: b_only_dir
-",'diff --knife a/b_only_file b/b_only_file
+', "File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file
+", "File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory
+", "Only in b: b_only_dir
+", 'diff --knife a/b_only_file b/b_only_file
new file
--- /dev/null DATE
+++ b/b_only_file DATE
diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb
index a919c50114..c4d076ef90 100644
--- a/spec/unit/chef_fs/file_pattern_spec.rb
+++ b/spec/unit/chef_fs/file_pattern_spec.rb
@@ -478,7 +478,6 @@ describe Chef::ChefFS::FilePattern do
end
end
-
# match?
# - single element matches (empty, fixed, ?, *, characters, escapes)
# - nested matches
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 8f6f9e71fc..da18117bbd 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -25,7 +25,7 @@ describe Chef::ChefFS::Parallelizer do
it "parallel_do creates unordered output as soon as it is available" do
outputs = []
- parallelizer.parallel_do([0.5,0.3,0.1]) do |val|
+ parallelizer.parallel_do([0.5, 0.3, 0.1]) do |val|
sleep val
outputs << val
end
@@ -50,18 +50,18 @@ describe Chef::ChefFS::Parallelizer do
end
it "The output comes as soon as it is available" do
- enum = parallelize([0.5,0.3,0.1], :ordered => false) do |val|
+ enum = parallelize([0.5, 0.3, 0.1], :ordered => false) do |val|
sleep val
val
end
expect(enum.map do |value|
- expect(elapsed_time).to be < value+0.1
+ expect(elapsed_time).to be < value + 0.1
value
end).to eq([ 0.1, 0.3, 0.5 ])
end
it "An exception in input is passed through but does NOT stop processing" do
- input = TestEnumerable.new(0.5,0.3,0.1) do
+ input = TestEnumerable.new(0.5, 0.3, 0.1) do
raise "hi"
end
enum = parallelize(input, :ordered => false) { |x| sleep(x); x }
@@ -73,7 +73,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions in output are raised after all processing is done" do
processed = 0
- enum = parallelize([1,2,"x",3], :ordered => false) do |x|
+ enum = parallelize([1, 2, "x", 3], :ordered => false) do |x|
if x == "x"
sleep 0.1
raise "hi"
@@ -91,7 +91,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
- parallelized = parallelize([0.3,0.3,"x",0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x|
+ parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x|
if x == "x"
sleep(0.1)
raise "hi"
@@ -122,7 +122,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "Output comes in the order of the input" do
- enum = parallelize([0.5,0.3,0.1]) do |val|
+ enum = parallelize([0.5, 0.3, 0.1]) do |val|
sleep val
val
end.enum_for(:each_with_index)
@@ -133,7 +133,7 @@ describe Chef::ChefFS::Parallelizer do
end
it "Exceptions in input are raised in the correct sequence but do NOT stop processing" do
- input = TestEnumerable.new(0.5,0.3,0.1) do
+ input = TestEnumerable.new(0.5, 0.3, 0.1) do
raise "hi"
end
results = []
@@ -145,7 +145,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions in output are raised in the correct sequence and running processes do NOT stop processing" do
processed = 0
- enum = parallelize([1,2,"x",3]) do |x|
+ enum = parallelize([1, 2, "x", 3]) do |x|
if x == "x"
sleep(0.1)
raise "hi"
@@ -163,7 +163,7 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
- parallelized = parallelize([0.3,0.3,"x",0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x|
+ parallelized = parallelize([0.3, 0.3, "x", 0.3, 0.3, 0.3, 0.3, 0.3], :ordered => false, :stop_on_exception => true) do |x|
if x == "x"
sleep(0.1)
raise "hi"
@@ -188,7 +188,7 @@ describe Chef::ChefFS::Parallelizer do
end
enum = parallelize(input) { |x| x }
expect(enum.map do |value|
- expect(elapsed_time).to be < (value+1)*0.1
+ expect(elapsed_time).to be < (value + 1) * 0.1
value
end).to eq([ 1, 2, 3 ])
end
@@ -233,7 +233,7 @@ describe Chef::ChefFS::Parallelizer do
it "parallelize with :main_thread_processing = false waits for the job to finish" do
expect(parallelizer.parallelize([1], :main_thread_processing => false) do |x|
sleep(0.1)
- x+1
+ x + 1
end.to_a).to eq([ 2 ])
expect(elapsed_time).to be > 0.3
end
@@ -267,7 +267,7 @@ describe Chef::ChefFS::Parallelizer do
context "enumerable methods should run efficiently" do
it ".count does not process anything" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
@@ -280,7 +280,7 @@ describe Chef::ChefFS::Parallelizer do
it ".count with arguments works normally" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,1,1,1,2,2,2,3,3,4)
+ input_mapper = TestEnumerable.new(1, 1, 1, 1, 2, 2, 2, 3, 3, 4)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
x
@@ -293,40 +293,40 @@ describe Chef::ChefFS::Parallelizer do
it ".first does not enumerate anything other than the first result(s)" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
x
end
expect(enum.first).to eq(1)
- expect(enum.first(2)).to eq([1,2])
+ expect(enum.first(2)).to eq([1, 2])
expect(outputs_processed).to eq(3)
expect(input_mapper.num_processed).to eq(3)
end
it ".take does not enumerate anything other than the first result(s)" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
x
end
- expect(enum.take(2)).to eq([1,2])
+ expect(enum.take(2)).to eq([1, 2])
expect(outputs_processed).to eq(2)
expect(input_mapper.num_processed).to eq(2)
end
it ".drop does not process anything other than the last result(s)" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
x
end
- expect(enum.drop(2)).to eq([3,4,5,6])
+ expect(enum.drop(2)).to eq([3, 4, 5, 6])
expect(outputs_processed).to eq(4)
expect(input_mapper.num_processed).to eq(6)
end
@@ -334,33 +334,33 @@ describe Chef::ChefFS::Parallelizer do
if Enumerable.method_defined?(:lazy)
it ".lazy.take does not enumerate anything other than the first result(s)" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
x
end
- expect(enum.lazy.take(2).to_a).to eq([1,2])
+ expect(enum.lazy.take(2).to_a).to eq([1, 2])
expect(outputs_processed).to eq(2)
expect(input_mapper.num_processed).to eq(2)
end
it ".drop does not process anything other than the last result(s)" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
x
end
- expect(enum.lazy.drop(2).to_a).to eq([3,4,5,6])
+ expect(enum.lazy.drop(2).to_a).to eq([3, 4, 5, 6])
expect(outputs_processed).to eq(4)
expect(input_mapper.num_processed).to eq(6)
end
it "lazy enumerable is actually lazy" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3,4,5,6)
+ input_mapper = TestEnumerable.new(1, 2, 3, 4, 5, 6)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
sleep(0.05) # Just enough to yield and get other inputs in the queue
@@ -378,32 +378,32 @@ describe Chef::ChefFS::Parallelizer do
context "running enumerable multiple times should function correctly" do
it ".map twice on the same parallel enumerable returns the correct results and re-processes the input" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3)
+ input_mapper = TestEnumerable.new(1, 2, 3)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
x
end
- expect(enum.map { |x| x }).to eq([1,2,3])
- expect(enum.map { |x| x }).to eq([1,2,3])
+ expect(enum.map { |x| x }).to eq([1, 2, 3])
+ expect(enum.map { |x| x }).to eq([1, 2, 3])
expect(outputs_processed).to eq(6)
expect(input_mapper.num_processed).to eq(6)
end
it ".first and then .map on the same parallel enumerable returns the correct results and re-processes the input" do
outputs_processed = 0
- input_mapper = TestEnumerable.new(1,2,3)
+ input_mapper = TestEnumerable.new(1, 2, 3)
enum = parallelizer.parallelize(input_mapper) do |x|
outputs_processed += 1
x
end
expect(enum.first).to eq(1)
- expect(enum.map { |x| x }).to eq([1,2,3])
+ expect(enum.map { |x| x }).to eq([1, 2, 3])
expect(outputs_processed).to be >= 4
expect(input_mapper.num_processed).to be >= 4
end
it "two simultaneous enumerations throws an exception" do
- enum = parallelizer.parallelize([1,2,3]) { |x| x }
+ enum = parallelizer.parallelize([1, 2, 3]) { |x| x }
a = enum.enum_for(:each)
a.next
expect do
@@ -421,7 +421,7 @@ describe Chef::ChefFS::Parallelizer do
context "And main_thread_processing on" do
it "succeeds in running" do
- expect(parallelizer.parallelize([0.5]) { |x| x*2 }.to_a).to eq([1])
+ expect(parallelizer.parallelize([0.5]) { |x| x * 2 }.to_a).to eq([1])
end
end
end
@@ -432,16 +432,16 @@ describe Chef::ChefFS::Parallelizer do
end
it "does not have contention issues with large numbers of inputs" do
- expect(parallelizer.parallelize(1.upto(500)) { |x| x+1 }.to_a).to eq(2.upto(501).to_a)
+ expect(parallelizer.parallelize(1.upto(500)) { |x| x + 1 }.to_a).to eq(2.upto(501).to_a)
end
it "does not have contention issues with large numbers of inputs with ordering off" do
- expect(parallelizer.parallelize(1.upto(500), :ordered => false) { |x| x+1 }.to_a.sort).to eq(2.upto(501).to_a)
+ expect(parallelizer.parallelize(1.upto(500), :ordered => false) { |x| x + 1 }.to_a.sort).to eq(2.upto(501).to_a)
end
it "does not have contention issues with large numbers of jobs and inputs with ordering off" do
parallelizers = 0.upto(99).map do
- parallelizer.parallelize(1.upto(500)) { |x| x+1 }
+ parallelizer.parallelize(1.upto(500)) { |x| x + 1 }
end
outputs = []
threads = 0.upto(99).map do |i|
diff --git a/spec/unit/chef_fs/path_util_spec.rb b/spec/unit/chef_fs/path_util_spec.rb
index 823f7c393c..93205a1815 100644
--- a/spec/unit/chef_fs/path_util_spec.rb
+++ b/spec/unit/chef_fs/path_util_spec.rb
@@ -69,7 +69,7 @@ describe Chef::ChefFS::PathUtils do
end
it "handles paths with .. and ." do
- expect(Chef::ChefFS::PathUtils.realest_path(good_path+"/../.")).to eq(File.expand_path(parent_path))
+ expect(Chef::ChefFS::PathUtils.realest_path(good_path + "/../.")).to eq(File.expand_path(parent_path))
end
it "handles paths with *" do
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 7431f804b9..fe9b1afe01 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -181,7 +181,7 @@ describe Chef::Client do
describe "calling run" do
include_examples "a successful client run" do
- let(:client_opts) { {:override_runlist => "recipe[override_recipe]"} }
+ let(:client_opts) { { :override_runlist => "recipe[override_recipe]" } }
def stub_for_sync_cookbooks
# --Client#setup_run_context
@@ -190,7 +190,7 @@ describe Chef::Client do
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(http_cookbook_sync)
expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", {:run_list => ["override_recipe"]}).
+ with("environments/_default/cookbook_versions", { :run_list => ["override_recipe"] }).
and_return({})
end
@@ -215,7 +215,7 @@ describe Chef::Client do
include_examples "a successful client run" do
let(:new_runlist) { "recipe[new_run_list_recipe]" }
- let(:client_opts) { {:runlist => new_runlist} }
+ let(:client_opts) { { :runlist => new_runlist } }
def stub_for_sync_cookbooks
# --Client#setup_run_context
@@ -224,7 +224,7 @@ describe Chef::Client do
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(http_cookbook_sync)
expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", {:run_list => ["new_run_list_recipe"]}).
+ with("environments/_default/cookbook_versions", { :run_list => ["new_run_list_recipe"] }).
and_return({})
end
@@ -388,7 +388,7 @@ describe Chef::Client do
expect(node.chef_environment).to eq("_default")
Chef::Config[:environment] = "A"
- test_env = {"name" => "A"}
+ test_env = { "name" => "A" }
mock_chef_rest = double("Chef::ServerAPI")
expect(mock_chef_rest).to receive(:get).with("environments/A").and_return(test_env)
diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb
index 84aad38876..35cf27f2af 100644
--- a/spec/unit/config_fetcher_spec.rb
+++ b/spec/unit/config_fetcher_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
require "chef/config_fetcher"
describe Chef::ConfigFetcher do
- let(:valid_json) { Chef::JSONCompat.to_json({:a=>"b"}) }
+ let(:valid_json) { Chef::JSONCompat.to_json({ :a => "b" }) }
let(:invalid_json) { %q[{"syntax-error": "missing quote}] }
let(:http) { double("Chef::HTTP::Simple") }
@@ -41,20 +41,18 @@ describe Chef::ConfigFetcher do
let(:config_location) { "/etc/chef/first-boot.json" }
-
it "returns the parsed JSON" do
expect(::File).to receive(:read).
with(config_location).
and_return(valid_json)
- expect(fetcher.fetch_json).to eq({"a" => "b"})
+ expect(fetcher.fetch_json).to eq({ "a" => "b" })
end
context "and the JSON is invalid" do
it "reports the JSON error" do
-
expect(::File).to receive(:read).
with(config_location).
and_return(invalid_json)
@@ -86,8 +84,8 @@ describe Chef::ConfigFetcher do
end
it "reads the file over HTTP" do
- expect(http).to receive(:get).
- with("").and_return(config_content)
+ expect(http).to receive(:get).
+ with("").and_return(config_content)
expect(fetcher.read_config).to eq(config_content)
end
@@ -97,7 +95,7 @@ describe Chef::ConfigFetcher do
it "fetches the file and parses it" do
expect(http).to receive(:get).
with("").and_return(valid_json)
- expect(fetcher.fetch_json).to eq({"a" => "b"})
+ expect(fetcher.fetch_json).to eq({ "a" => "b" })
end
context "and the JSON is invalid" do
@@ -124,5 +122,4 @@ describe Chef::ConfigFetcher do
end
end
-
end
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 10495d180a..a32eb052af 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -184,4 +184,3 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
end
-
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb
index ea6f8d010d..139a5932f9 100644
--- a/spec/unit/cookbook/file_vendor_spec.rb
+++ b/spec/unit/cookbook/file_vendor_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Cookbook::FileVendor do
context "with a manifest from a cookbook version" do
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:cookbook_name => "bob", :name => "bob-1.2.3"} }
+ let(:manifest) { { :cookbook_name => "bob", :name => "bob-1.2.3" } }
it "creates a RemoteFileVendor for a given manifest" do
file_vendor = file_vendor_class.create_from_manifest(manifest)
@@ -54,7 +54,7 @@ describe Chef::Cookbook::FileVendor do
context "with a manifest from a cookbook artifact" do
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:name => "bob"} }
+ let(:manifest) { { :name => "bob" } }
it "creates a RemoteFileVendor for a given manifest" do
file_vendor = file_vendor_class.create_from_manifest(manifest)
@@ -71,7 +71,7 @@ describe Chef::Cookbook::FileVendor do
let(:cookbook_path) { %w{/var/chef/cookbooks /var/chef/other_cookbooks} }
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:cookbook_name => "bob"} }
+ let(:manifest) { { :cookbook_name => "bob" } }
before do
file_vendor_class.fetch_from_disk(cookbook_path)
@@ -95,4 +95,3 @@ describe Chef::Cookbook::FileVendor do
end
end
-
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 351792175f..ff18333e70 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -205,7 +205,7 @@ describe Chef::Cookbook::Metadata do
:issues_url => "http://example.com/issues",
:privacy => true,
}
- params.sort { |a,b| a.to_s <=> b.to_s }.each do |field, field_value|
+ params.sort { |a, b| a.to_s <=> b.to_s }.each do |field, field_value|
describe field do
it "should be set-able via #{field}" do
expect(metadata.send(field, field_value)).to eql(field_value)
@@ -239,7 +239,7 @@ describe Chef::Cookbook::Metadata do
:provides => [ :providing, "foo::bar", "<= 0.2" ],
:replaces => [ :replacing, "foo::bar", "= 0.2.1" ],
}
- dep_types.sort { |a,b| a.to_s <=> b.to_s }.each do |dep, dep_args|
+ dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
check_with = dep_args.shift
describe dep do
it "should be set-able via #{dep}" do
@@ -260,7 +260,7 @@ describe Chef::Cookbook::Metadata do
:provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
:replaces => [ :replacing, "foo::bar", "=0.2.1", "= 0.2.1" ],
}
- dep_types.sort { |a,b| a.to_s <=> b.to_s }.each do |dep, dep_args|
+ dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
check_with = dep_args.shift
normalized_version = dep_args.pop
describe dep do
@@ -274,7 +274,6 @@ describe Chef::Cookbook::Metadata do
end
end
-
describe "in the obsoleted format" do
dep_types = {
:depends => [ "foo::bar", "> 0.2", "< 1.0" ],
@@ -287,12 +286,11 @@ describe Chef::Cookbook::Metadata do
dep_types.each do |dep, dep_args|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
- expect {metadata.send(dep, *dep_args)}.to raise_error(Chef::Exceptions::ObsoleteDependencySyntax)
+ expect { metadata.send(dep, *dep_args) }.to raise_error(Chef::Exceptions::ObsoleteDependencySyntax)
end
end
end
-
describe "with obsolete operators" do
dep_types = {
:depends => [ "foo::bar", ">> 0.2"],
@@ -305,7 +303,7 @@ describe Chef::Cookbook::Metadata do
dep_types.each do |dep, dep_args|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
- expect {metadata.send(dep, *dep_args)}.to raise_error(Chef::Exceptions::InvalidVersionConstraint)
+ expect { metadata.send(dep, *dep_args) }.to raise_error(Chef::Exceptions::InvalidVersionConstraint)
end
end
end
@@ -345,11 +343,11 @@ describe Chef::Cookbook::Metadata do
end
it "should work with multiple simple constraints" do
- expect_chef_version_works(["~> 12.5.1"],["~> 11.18.10"])
+ expect_chef_version_works(["~> 12.5.1"], ["~> 11.18.10"])
end
it "should work with multiple complex constraints" do
- expect_chef_version_works([">= 11.14.2", "< 11.18.10"],[">= 12.2.1", "< 12.5.1"])
+ expect_chef_version_works([">= 11.14.2", "< 11.18.10"], [">= 12.2.1", "< 12.5.1"])
end
it "should fail validation on a simple pessimistic constraint" do
@@ -368,12 +366,12 @@ describe Chef::Cookbook::Metadata do
end
it "should fail validation when all ranges fail" do
- expect_chef_version_works([">= 999.0", "< 999.9"],[">= 0.0.1", "< 0.0.9"])
+ expect_chef_version_works([">= 999.0", "< 999.9"], [">= 0.0.1", "< 0.0.9"])
expect { metadata.validate_chef_version! }.to raise_error(Chef::Exceptions::CookbookChefVersionMismatch)
end
it "should pass validation when one constraint passes" do
- expect_chef_version_works([">= 999.0", "< 999.9"],["= #{Chef::VERSION}"])
+ expect_chef_version_works([">= 999.0", "< 999.9"], ["= #{Chef::VERSION}"])
expect { metadata.validate_chef_version! }.not_to raise_error
end
end
@@ -397,11 +395,11 @@ describe Chef::Cookbook::Metadata do
end
it "should work with multiple simple constraints" do
- expect_ohai_version_works(["~> 12.5.1"],["~> 11.18.10"])
+ expect_ohai_version_works(["~> 12.5.1"], ["~> 11.18.10"])
end
it "should work with multiple complex constraints" do
- expect_ohai_version_works([">= 11.14.2", "< 11.18.10"],[">= 12.2.1", "< 12.5.1"])
+ expect_ohai_version_works([">= 11.14.2", "< 11.18.10"], [">= 12.2.1", "< 12.5.1"])
end
it "should fail validation on a simple pessimistic constraint" do
@@ -420,12 +418,12 @@ describe Chef::Cookbook::Metadata do
end
it "should fail validation when all ranges fail" do
- expect_ohai_version_works([">= 999.0", "< 999.9"],[">= 0.0.1", "< 0.0.9"])
+ expect_ohai_version_works([">= 999.0", "< 999.9"], [">= 0.0.1", "< 0.0.9"])
expect { metadata.validate_ohai_version! }.to raise_error(Chef::Exceptions::CookbookOhaiVersionMismatch)
end
it "should pass validation when one constraint passes" do
- expect_ohai_version_works([">= 999.0", "< 999.9"],["= #{Ohai::VERSION}"])
+ expect_ohai_version_works([">= 999.0", "< 999.9"], ["= #{Ohai::VERSION}"])
expect { metadata.validate_ohai_version! }.not_to raise_error
end
end
@@ -540,22 +538,22 @@ describe Chef::Cookbook::Metadata do
expect(metadata.attributes["db/mysql/databases"][:choice]).to eq([])
end
- it "should let calculated be true or false" do
- expect {
- metadata.attribute("db/mysql/databases", :calculated => true)
- }.not_to raise_error
- expect {
- metadata.attribute("db/mysql/databases", :calculated => false)
- }.not_to raise_error
- expect {
- metadata.attribute("db/mysql/databases", :calculated => Hash.new)
- }.to raise_error(ArgumentError)
- end
+ it "should let calculated be true or false" do
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => true)
+ }.not_to raise_error
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => false)
+ }.not_to raise_error
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => Hash.new)
+ }.to raise_error(ArgumentError)
+ end
- it "should set calculated to false by default" do
- metadata.attribute("db/mysql/databases", {})
- expect(metadata.attributes["db/mysql/databases"][:calculated]).to eq(false)
- end
+ it "should set calculated to false by default" do
+ metadata.attribute("db/mysql/databases", {})
+ expect(metadata.attributes["db/mysql/databases"][:calculated]).to eq(false)
+ end
it "accepts String for the attribute type" do
expect {
@@ -578,11 +576,11 @@ describe Chef::Cookbook::Metadata do
}.not_to raise_error
end
- it "should let type be hash (backwards compatibility only)" do
+ it "should let type be hash (backwards compatibility only)" do
expect {
metadata.attribute("db/mysql/databases", :type => "hash")
}.not_to raise_error
- end
+ end
it "should let required be required, recommended or optional" do
expect {
@@ -847,7 +845,6 @@ describe Chef::Cookbook::Metadata do
let(:deserialized_metadata) { Chef::Cookbook::Metadata.from_json(Chef::JSONCompat.to_json(metadata)) }
-
it "should deserialize to a Chef::Cookbook::Metadata object" do
expect(deserialized_metadata).to be_a_kind_of(Chef::Cookbook::Metadata)
end
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index d8f7f7d293..c869ee8ff3 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -93,7 +93,7 @@ describe Chef::CookbookSynchronizer do
let(:cookbook_a_manifest) do
segments = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ]
- cookbook_a_manifest = segments.inject({}) {|h, segment| h[segment.to_s] = []; h}
+ cookbook_a_manifest = segments.inject({}) { |h, segment| h[segment.to_s] = []; h }
cookbook_a_manifest["recipes"] = [ cookbook_a_default_recipe ]
cookbook_a_manifest["attributes"] = [ cookbook_a_default_attrs ]
cookbook_a_manifest["templates"] = [ cookbook_a_template ]
@@ -157,7 +157,7 @@ describe Chef::CookbookSynchronizer do
let(:file_cache) { double("Chef::FileCache with files from unused cookbooks") }
let(:cookbook_manifest) do
- {"valid1"=> {}, "valid2" => {}}
+ { "valid1" => {}, "valid2" => {} }
end
it "removes unneeded cookbooks" do
@@ -175,7 +175,7 @@ describe Chef::CookbookSynchronizer do
let(:file_cache) { double("Chef::FileCache with files from unused cookbooks") }
let(:cookbook_manifest) do
- {"valid1"=> {}, "valid2" => {}}
+ { "valid1" => {}, "valid2" => {} }
end
it "removes only deleted files" do
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index 02762535ce..6d0ce96870 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Cookbook::SyntaxCheck do
recipes/default.rb
recipes/gigantor.rb
recipes/one.rb
- recipes/return.rb }.map{ |f| File.join(cookbook_path, f) }
+ recipes/return.rb }.map { |f| File.join(cookbook_path, f) }
end
before do
@@ -48,7 +48,7 @@ describe Chef::Cookbook::SyntaxCheck do
@attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, "attributes", f) }
@libr_files = %w{openldap.rb openldap/version.rb}.map { |f| File.join(cookbook_path, "libraries", f) }
- @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, "definitions", f)}
+ @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, "definitions", f) }
@recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, "recipes", f) }
@ruby_files = @attr_files + @libr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")]
basenames = %w{ helpers_via_partial_test.erb
@@ -62,7 +62,7 @@ describe Chef::Cookbook::SyntaxCheck do
some_windows_line_endings.erb
all_windows_line_endings.erb
no_windows_line_endings.erb }
- @template_files = basenames.map { |f| File.join(cookbook_path, "templates", "default", f)}
+ @template_files = basenames.map { |f| File.join(cookbook_path, "templates", "default", f) }
end
after do
@@ -171,7 +171,7 @@ describe Chef::Cookbook::SyntaxCheck do
it "does not remove the invalid template from the list of untested templates" do
expect(syntax_check.untested_template_files).to include(File.join(cookbook_path, "templates", "default", "borken.erb"))
- expect {syntax_check.validate_templates}.not_to change(syntax_check, :untested_template_files)
+ expect { syntax_check.validate_templates }.not_to change(syntax_check, :untested_template_files)
end
end
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index df2777ff43..3f4a7486ce 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::CookbookLoader do
before do
- allow(ChefConfig).to receive(:windows?) {false}
+ allow(ChefConfig).to receive(:windows?) { false }
end
let(:repo_paths) do
[
@@ -48,7 +48,6 @@ describe Chef::CookbookLoader do
cookbook_loader.load_cookbooks
end
-
context "after loading all cookbooks" do
before(:each) do
cookbook_loader.load_cookbooks
diff --git a/spec/unit/cookbook_manifest_spec.rb b/spec/unit/cookbook_manifest_spec.rb
index d2a1a83e37..acf0ade9f9 100644
--- a/spec/unit/cookbook_manifest_spec.rb
+++ b/spec/unit/cookbook_manifest_spec.rb
@@ -101,15 +101,15 @@ describe Chef::CookbookManifest do
"frozen?" => false,
- "recipes" =>[],
- "definitions" =>[],
- "libraries" =>[],
- "attributes" =>[],
- "files" =>[],
- "templates" =>[],
- "resources" =>[],
- "providers" =>[],
- "root_files" =>[],
+ "recipes" => [],
+ "definitions" => [],
+ "libraries" => [],
+ "attributes" => [],
+ "files" => [],
+ "templates" => [],
+ "resources" => [],
+ "providers" => [],
+ "root_files" => [],
}
end
@@ -241,4 +241,3 @@ describe Chef::CookbookManifest do
end
end
-
diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb
index 943fbf828d..c30df71e34 100644
--- a/spec/unit/cookbook_uploader_spec.rb
+++ b/spec/unit/cookbook_uploader_spec.rb
@@ -78,7 +78,7 @@ describe Chef::CookbookUploader do
let(:sandbox_response) do
sandbox_checksums = cksums_not_on_remote.inject({}) do |cksum_map, cksum|
- cksum_map[cksum] = { "needs_upload" => true, "url" => url_for(cksum)}
+ cksum_map[cksum] = { "needs_upload" => true, "url" => url_for(cksum) }
cksum_map
end
{ "checksums" => sandbox_checksums, "uri" => sandbox_commit_uri }
@@ -86,7 +86,7 @@ describe Chef::CookbookUploader do
def expect_sandbox_create
expect(http_client).to receive(:post).
- with("sandboxes", {:checksums => checksums_set}).
+ with("sandboxes", { :checksums => checksums_set }).
and_return(sandbox_response)
end
@@ -111,7 +111,7 @@ describe Chef::CookbookUploader do
end
def expect_sandbox_commit
- expect(http_client).to receive(:put).with(sandbox_commit_uri, {:is_completed => true})
+ expect(http_client).to receive(:put).with(sandbox_commit_uri, { :is_completed => true })
end
def expect_cookbook_create
@@ -193,7 +193,6 @@ describe Chef::CookbookUploader do
uploader.upload_cookbooks
end
-
end
end
diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb
index d3fac7256f..13be1c26ec 100644
--- a/spec/unit/cookbook_version_file_specificity_spec.rb
+++ b/spec/unit/cookbook_version_file_specificity_spec.rb
@@ -202,7 +202,6 @@ describe Chef::CookbookVersion, "file specificity" do
end
-
it "should return a manifest record based on priority preference: host" do
node = Chef::Node.new
node.automatic_attrs[:platform] = "ubuntu"
@@ -314,7 +313,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum-host-1", "csum-host-2"])
end
@@ -328,7 +327,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum-platver-full-1", "csum-platver-full-2"])
end
@@ -342,7 +341,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum-platver-partial-1", "csum-platver-partial-2"])
end
@@ -356,7 +355,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum-plat-1", "csum-plat-2"])
end
@@ -370,7 +369,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum-default-1", "csum-default-2"])
end
@@ -384,7 +383,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum2-platver-full-1", "csum2-platver-full-2"])
end
@@ -398,7 +397,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum2-platver-partial-1", "csum2-platver-partial-2"])
end
@@ -412,7 +411,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum3-platver-full-1", "csum3-platver-full-2"])
end
@@ -426,7 +425,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(manifest_records).not_to be_nil
expect(manifest_records.size).to eq(2)
- checksums = manifest_records.map{ |manifest_record| manifest_record[:checksum] }
+ checksums = manifest_records.map { |manifest_record| manifest_record[:checksum] }
expect(checksums.sort).to eq(["csum4-platver-full-1", "csum4-platver-full-2"])
end
end
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index cabfc228ea..0eafe65468 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -233,7 +233,6 @@ describe Chef::CookbookVersion do
end
-
describe "<=>" do
it "should sort based on the version number" do
@@ -270,13 +269,12 @@ describe Chef::CookbookVersion do
expect(a).to eq(b)
end
-
it "should not allow you to sort cookbooks with different names" do
apt = Chef::CookbookVersion.new "apt", "/tmp/blah"
apt.version = "1.0"
god = Chef::CookbookVersion.new "god", "/tmp/blah"
god.version = "2.0"
- expect {apt <=> god}.to raise_error(Chef::Exceptions::CookbookVersionNameMismatch)
+ expect { apt <=> god }.to raise_error(Chef::Exceptions::CookbookVersionNameMismatch)
end
end
@@ -296,7 +294,7 @@ describe Chef::CookbookVersion do
"1 2 3", "1-2-3", "1_2_3", "1.2_3", "1.2-3"]
the_error = Chef::Exceptions::InvalidCookbookVersion
bad_versions.each do |v|
- expect {@cbv.version = v}.to raise_error(the_error)
+ expect { @cbv.version = v }.to raise_error(the_error)
end
end
@@ -335,7 +333,6 @@ describe Chef::CookbookVersion do
expect(cbv.status).to eq(:ready)
end
-
include_examples "to_json equivalent to Chef::JSONCompat.to_json" do
let(:jsonable) { Chef::CookbookVersion.new("tatft", "/tmp/blah") }
end
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 22ed95267a..ac4cf31b18 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -176,7 +176,6 @@ describe Chef::DataBagItem do
let(:deserial) { Chef::DataBagItem.from_hash(Chef::JSONCompat.parse(Chef::JSONCompat.to_json(data_bag_item))) }
-
it "should deserialize to a Chef::DataBagItem object" do
expect(deserial).to be_a_kind_of(Chef::DataBagItem)
end
@@ -205,7 +204,7 @@ describe Chef::DataBagItem do
end
it "inspects as data_bag_item[BAG, ID, RAW_DATA]" do
- raw_data = {"id" => "heart_of_darkness", "author" => "Conrad"}
+ raw_data = { "id" => "heart_of_darkness", "author" => "Conrad" }
data_bag_item.raw_data = raw_data
data_bag_item.data_bag("books")
@@ -219,7 +218,7 @@ describe Chef::DataBagItem do
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
data_bag_item["id"] = "heart of darkness"
- data_bag_item.raw_data = {"id" => "heart_of_darkness", "author" => "Conrad"}
+ data_bag_item.raw_data = { "id" => "heart_of_darkness", "author" => "Conrad" }
data_bag_item.data_bag("books")
data_bag_item
}
@@ -278,7 +277,7 @@ describe Chef::DataBagItem do
describe "when loading" do
before do
- data_bag_item.raw_data = {"id" => "charlie", "shell" => "zsh", "ssh_keys" => %w{key1 key2}}
+ data_bag_item.raw_data = { "id" => "charlie", "shell" => "zsh", "ssh_keys" => %w{key1 key2} }
data_bag_item.data_bag("users")
end
@@ -314,7 +313,7 @@ describe Chef::DataBagItem do
end
it "converts the raw data to a data bag item" do
- expect(Chef::DataBag).to receive(:load).with("users").and_return({"charlie" => data_bag_item.to_hash})
+ expect(Chef::DataBag).to receive(:load).with("users").and_return({ "charlie" => data_bag_item.to_hash })
item = Chef::DataBagItem.load("users", "charlie")
expect(item).to be_a_kind_of(Chef::DataBagItem)
expect(item).to eq(data_bag_item)
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index c2bcff4378..92da4cade1 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -127,9 +127,9 @@ describe Chef::DataBag do
it "should return the data bag" do
allow(Chef::ServerAPI).to receive(:new).and_return(@http_client)
- expect(@http_client).to receive(:get).with("data/foo").and_return({"bar" => "https://myserver.example.com/data/foo/bar"})
+ expect(@http_client).to receive(:get).with("data/foo").and_return({ "bar" => "https://myserver.example.com/data/foo/bar" })
data_bag = Chef::DataBag.load("foo")
- expect(data_bag).to eq({"bar" => "https://myserver.example.com/data/foo/bar"})
+ expect(data_bag).to eq({ "bar" => "https://myserver.example.com/data/foo/bar" })
end
end
@@ -180,7 +180,7 @@ describe Chef::DataBag do
expect(IO).to receive(:read).with(File.join(@paths.first, "foo/bar.json")).and_return('{"id": "bar", "name": "Bob Bar" }')
expect(IO).to receive(:read).with(File.join(@paths.first, "foo/baz.json")).and_return('{"id": "baz", "name": "John Baz" }')
data_bag = Chef::DataBag.load("foo")
- expect(data_bag).to eq({ "bar" => { "id" => "bar", "name" => "Bob Bar" }, "baz" => { "id" => "baz", "name" => "John Baz" }})
+ expect(data_bag).to eq({ "bar" => { "id" => "bar", "name" => "Bob Bar" }, "baz" => { "id" => "baz", "name" => "John Baz" } })
end
it "should raise if data bag has items with similar names but different content" do
@@ -208,7 +208,7 @@ describe Chef::DataBag do
expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(item_with_same_content)
end
data_bag = Chef::DataBag.load("foo")
- test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar"} }
+ test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar" } }
expect(data_bag).to eq(test_data_bag)
end
@@ -222,7 +222,7 @@ describe Chef::DataBag do
expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(test_uniq_item)
end
data_bag = Chef::DataBag.load("foo")
- test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar"} }
+ test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar" } }
@paths.each_with_index do |path, index|
test_data_bag["baz_#{index}"] = { "id" => "baz_#{index}", "name" => "John Baz", "path" => path }
end
diff --git a/spec/unit/digester_spec.rb b/spec/unit/digester_spec.rb
index 9fa0f9235b..2684ac8f7d 100644
--- a/spec/unit/digester_spec.rb
+++ b/spec/unit/digester_spec.rb
@@ -47,4 +47,3 @@ describe Chef::Digester do
end
end
-
diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb
index df8dbc95c0..a8227f6c99 100644
--- a/spec/unit/dsl/audit_spec.rb
+++ b/spec/unit/dsl/audit_spec.rb
@@ -17,15 +17,15 @@ describe Chef::DSL::Audit do
let(:cookbook_collection) { {} }
it "raises an error when a block of audits is not provided" do
- expect{ auditor.control_group "name" }.to raise_error(Chef::Exceptions::NoAuditsProvided)
+ expect { auditor.control_group "name" }.to raise_error(Chef::Exceptions::NoAuditsProvided)
end
it "raises an error when no audit name is given" do
- expect{ auditor.control_group do end }.to raise_error(Chef::Exceptions::AuditNameMissing)
+ expect { auditor.control_group do end }.to raise_error(Chef::Exceptions::AuditNameMissing)
end
context "audits already populated" do
- let(:audits) { {"unique" => {} } }
+ let(:audits) { { "unique" => {} } }
it "raises an error if the audit name is a duplicate" do
expect { auditor.control_group "unique" do end }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 36f9aa13b1..55c6e5f578 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -35,23 +35,23 @@ describe Chef::DSL::DataQuery do
describe "::data_bag" do
it "lists the items in a data bag" do
allow(Chef::DataBag).to receive(:load)
- .with("bag_name")
- .and_return("item_1" => "http://url_for/item_1", "item_2" => "http://url_for/item_2")
+ .with("bag_name")
+ .and_return("item_1" => "http://url_for/item_1", "item_2" => "http://url_for/item_2")
expect( language.data_bag("bag_name").sort ).to eql %w{item_1 item_2}
end
end
shared_examples_for "a data bag item" do
it "validates the name of the data bag you're trying to load an item from" do
- expect{ language.send(method_name, " %%^& ", "item_name") }.to raise_error(Chef::Exceptions::InvalidDataBagName)
+ expect { language.send(method_name, " %%^& ", "item_name") }.to raise_error(Chef::Exceptions::InvalidDataBagName)
end
it "validates the id of the data bag item you're trying to load" do
- expect{ language.send(method_name, "bag_name", " 987 (*&()") }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
+ expect { language.send(method_name, "bag_name", " 987 (*&()") }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
end
it "validates that the id of the data bag item is not nil" do
- expect{ language.send(method_name, "bag_name", nil) }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
+ expect { language.send(method_name, "bag_name", nil) }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
end
end
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 24f63d126b..fd1f9b23b5 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -39,9 +39,9 @@ end
describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
before do
platform_hash = {
- :openbsd => {:default => "free, functional, secure"},
- [:redhat, :centos, :fedora, :scientific] => {:default => '"stable"'},
- :ubuntu => {"10.04" => "using upstart more", :default => "using init more"},
+ :openbsd => { :default => "free, functional, secure" },
+ [:redhat, :centos, :fedora, :scientific] => { :default => '"stable"' },
+ :ubuntu => { "10.04" => "using upstart more", :default => "using init more" },
:default => "bork da bork",
}
@platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(platform_hash)
@@ -60,12 +60,12 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "returns a value for a specific platform version" do
- node = {:platform => "ubuntu", :platform_version => "10.04"}
+ node = { :platform => "ubuntu", :platform_version => "10.04" }
expect(@platform_specific_value.value_for_node(node)).to eq("using upstart more")
end
it "returns a platform-default value if the platform version doesn't match an explicit one" do
- node = {:platform => "ubuntu", :platform_version => "9.10" }
+ node = { :platform => "ubuntu", :platform_version => "9.10" }
expect(@platform_specific_value.value_for_node(node)).to eq("using init more")
end
@@ -77,8 +77,8 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "raises an argument error if the platform hash is not correctly structured" do
- bad_hash = {:ubuntu => :foo} # should be :ubuntu => {:default => 'foo'}
- expect {Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash)}.to raise_error(ArgumentError)
+ bad_hash = { :ubuntu => :foo } # should be :ubuntu => {:default => 'foo'}
+ expect { Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash) }.to raise_error(ArgumentError)
end
end
@@ -101,7 +101,6 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq("default value")
end
-
it "returns a value for the platform family when it was set as a string but fetched as a symbol" do
expect(@platform_family_value.value_for_node(:platform_family => :debian)).to eq("debian value")
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 42891195bf..66f8b76d7f 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -34,22 +34,22 @@ describe Chef::DSL::RebootPending do
allow(recipe).to receive(:registry_key_exists?).and_return(false)
allow(recipe).to receive(:registry_value_exists?).and_return(false)
end
-
+
it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do
allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }).and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
+
it 'should return true if "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" exists' do
allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired').and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
+
it 'should return true if key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired" exists' do
allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending').and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
+
context "version is server 2003" do
before do
allow(Chef::Platform).to receive(:windows_server_2003?).and_return(true)
@@ -58,22 +58,22 @@ describe Chef::DSL::RebootPending do
it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data on 2k3' do
allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
allow(recipe).to receive(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
- [{:name => "Flags", :type => :dword, :data => 3}])
+ [{ :name => "Flags", :type => :dword, :data => 3 }])
expect(recipe.reboot_pending?).to be_truthy
end
end
end
-
+
context "platform is ubuntu" do
before do
allow(recipe).to receive(:platform?).with("ubuntu").and_return(true)
end
-
+
it "should return true if /var/run/reboot-required exists" do
allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
+
it "should return false if /var/run/reboot-required does not exist" do
allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false)
expect(recipe.reboot_pending?).to be_falsey
@@ -85,7 +85,7 @@ describe Chef::DSL::RebootPending do
describe "in a recipe" do
it "responds to reboot_pending?" do
# Chef::Recipe.new(cookbook_name, recipe_name, run_context(node, cookbook_collection, events))
- recipe = Chef::Recipe.new(nil,nil,Chef::RunContext.new(Chef::Node.new, {}, nil))
+ recipe = Chef::Recipe.new(nil, nil, Chef::RunContext.new(Chef::Node.new, {}, nil))
expect(recipe).to respond_to(:reboot_pending?)
end
end # describe in a recipe
diff --git a/spec/unit/dsl/recipe_spec.rb b/spec/unit/dsl/recipe_spec.rb
index 534e430817..cd01079c15 100644
--- a/spec/unit/dsl/recipe_spec.rb
+++ b/spec/unit/dsl/recipe_spec.rb
@@ -19,7 +19,6 @@
require "spec_helper"
require "chef/dsl/recipe"
-
RecipeDSLExampleClass = Struct.new(:cookbook_name, :recipe_name)
class RecipeDSLExampleClass
include Chef::DSL::Recipe
@@ -79,4 +78,3 @@ describe Chef::DSL::Recipe do
end
end
-
diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb
index 9b527ec36c..d6c2257003 100644
--- a/spec/unit/dsl/regsitry_helper_spec.rb
+++ b/spec/unit/dsl/regsitry_helper_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Resource::RegistryKey do
before (:all) do
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
- node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ node.consume_external_attrs(OHAI_SYSTEM.data, {})
run_context = Chef::RunContext.new(node, {}, events)
@resource = Chef::Resource::new("foo", run_context)
end
@@ -50,4 +50,3 @@ describe Chef::Resource::RegistryKey do
end
end
end
-
diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb
index 3952483efc..53cd6fcdb1 100644
--- a/spec/unit/dsl/resources_spec.rb
+++ b/spec/unit/dsl/resources_spec.rb
@@ -44,7 +44,7 @@ describe Chef::DSL::Resources do
end
end
end
- it { is_expected.to eq [[:test_resource, "test_name"]]}
+ it { is_expected.to eq [[:test_resource, "test_name"]] }
end
context "with no resource added" do
@@ -77,9 +77,9 @@ describe Chef::DSL::Resources do
before do
Chef::DSL::Resources.add_resource_dsl(:test_resource)
test_class.new.instance_eval do
- test_resource { }
+ test_resource {}
end
end
- it { is_expected.to eq [[:test_resource, nil]]}
+ it { is_expected.to eq [[:test_resource, nil]] }
end
end
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 f435137061..685c2e738e 100644
--- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
+++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
@@ -32,7 +32,7 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do
end
it "detects the item is not encrypted when the data only contains an id" do
- expect(tester.encrypted?({id: "foo"})).to eq(false)
+ expect(tester.encrypted?({ id: "foo" })).to eq(false)
end
context "when the item is encrypted" do
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb
index 15e4057ec3..14713682e7 100644
--- a/spec/unit/encrypted_data_bag_item_spec.rb
+++ b/spec/unit/encrypted_data_bag_item_spec.rb
@@ -32,10 +32,10 @@ module Version0Encryptor
end
end
-describe Chef::EncryptedDataBagItem::Encryptor do
+describe Chef::EncryptedDataBagItem::Encryptor do
subject(:encryptor) { described_class.new(plaintext_data, key) }
- let(:plaintext_data) { {"foo" => "bar"} }
+ let(:plaintext_data) { { "foo" => "bar" } }
let(:key) { "passwd" }
it "encrypts to format version 1 by default" do
@@ -149,10 +149,10 @@ end
describe Chef::EncryptedDataBagItem::Decryptor do
subject(:decryptor) { described_class.for(encrypted_value, decryption_key) }
- let(:plaintext_data) { {"foo" => "bar"} }
+ let(:plaintext_data) { { "foo" => "bar" } }
let(:encryption_key) { "passwd" }
let(:decryption_key) { encryption_key }
- let(:json_wrapped_data) { Chef::JSONCompat.to_json({"json_wrapper" => plaintext_data}) }
+ let(:json_wrapped_data) { Chef::JSONCompat.to_json({ "json_wrapper" => plaintext_data }) }
shared_examples "decryption examples" do
it "decrypts the encrypted value" do
@@ -290,7 +290,7 @@ describe Chef::EncryptedDataBagItem::Decryptor do
end
- context "when decrypting a version 0 (YAML+aes-256-cbc+no iv) encrypted value", :not_supported_under_fips do
+ context "when decrypting a version 0 (YAML+aes-256-cbc+no iv) encrypted value", :not_supported_under_fips do
let(:encrypted_value) do
Version0Encryptor.encrypt_value(plaintext_data, encryption_key)
end
@@ -323,7 +323,7 @@ describe Chef::EncryptedDataBagItem do
let(:plaintext_data) {{
"id" => "item_name",
"greeting" => "hello",
- "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true }},
+ "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
}}
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 ef8abc3f15..f4026c7e78 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -167,7 +167,7 @@ describe Chef::Environment do
before(:each) do
@environment.name("spec")
@environment.description("Where we run the spec tests")
- @environment.cookbook_versions({:apt => "= 1.2.3"})
+ @environment.cookbook_versions({ :apt => "= 1.2.3" })
@hash = @environment.to_hash
end
@@ -190,7 +190,7 @@ describe Chef::Environment do
before(:each) do
@environment.name("spec")
@environment.description("Where we run the spec tests")
- @environment.cookbook_versions({:apt => "= 1.2.3"})
+ @environment.cookbook_versions({ :apt => "= 1.2.3" })
@json = @environment.to_json
end
@@ -329,13 +329,13 @@ describe Chef::Environment do
# NOTE: I'm only choosing this (admittedly weird) structure for the hash b/c the better more obvious
# one, i.e, {:cookbook_version_constraints => {COOKBOOK_NAME => CONSTRAINT}} is difficult to implement
# the way merb does params
- params = {:name=>"superbowl", :cookbook_version => {"0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0"}}
+ params = { :name => "superbowl", :cookbook_version => { "0" => "apache2 ~> 1.0.0", "1" => "nginx < 2.0.0" } }
@environment.update_from_params(params)
- expect(@environment.cookbook_versions).to eq({"apache2" => "~> 1.0.0", "nginx" => "< 2.0.0"})
+ expect(@environment.cookbook_versions).to eq({ "apache2" => "~> 1.0.0", "nginx" => "< 2.0.0" })
end
it "validates the cookbook constraints" do
- params = {:cookbook_version => {"0" => "apache2 >>> 1.0.0"}}
+ params = { :cookbook_version => { "0" => "apache2 >>> 1.0.0" } }
expect(@environment.update_from_params(params)).to be_falsey
err_msg = @environment.invalid_fields[:cookbook_version]["0"]
expect(err_msg).to eq("apache2 >>> 1.0.0 is not a valid cookbook constraint")
@@ -353,12 +353,12 @@ describe Chef::Environment do
it "updates default attributes from a JSON string in params[:attributes]" do
@environment.update_from_params(:name => "fuuu", :default_attributes => %q|{"fuuu":"RAGE"}|)
- expect(@environment.default_attributes).to eq({"fuuu" => "RAGE"})
+ expect(@environment.default_attributes).to eq({ "fuuu" => "RAGE" })
end
it "updates override attributes from a JSON string in params[:attributes]" do
@environment.update_from_params(:name => "fuuu", :override_attributes => %q|{"foo":"override"}|)
- expect(@environment.override_attributes).to eq({"foo" => "override"})
+ expect(@environment.override_attributes).to eq({ "foo" => "override" })
end
end
@@ -405,7 +405,7 @@ describe Chef::Environment do
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(2).times.and_return(true)
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
- role_dsl="name \"foo\"\ndescription \"desc\"\n"
+ role_dsl = "name \"foo\"\ndescription \"desc\"\n"
expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl)
Chef::Environment.load("foo")
end
@@ -438,7 +438,7 @@ describe Chef::Environment do
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(2).times.and_return(true)
expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
- role_dsl="name \"foo\"\ndescription \"desc\"\n"
+ role_dsl = "name \"foo\"\ndescription \"desc\"\n"
expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl)
environment = Chef::Environment.load("foo")
diff --git a/spec/unit/event_dispatch/dispatcher_spec.rb b/spec/unit/event_dispatch/dispatcher_spec.rb
index 814377a776..2360b2675d 100644
--- a/spec/unit/event_dispatch/dispatcher_spec.rb
+++ b/spec/unit/event_dispatch/dispatcher_spec.rb
@@ -75,7 +75,6 @@ describe Chef::EventDispatch::Dispatcher do
end
end
-
context "when two event sinks have different arguments for an event" do
let(:event_sink_1) do
Class.new(Chef::EventDispatch::Base) do
diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb
index d18234c08a..979b067fb6 100644
--- a/spec/unit/event_dispatch/dsl_spec.rb
+++ b/spec/unit/event_dispatch/dsl_spec.rb
@@ -32,7 +32,7 @@ describe Chef::EventDispatch::DSL do
Chef.set_run_context(run_context)
end
- subject{ described_class.new("test") }
+ subject { described_class.new("test") }
it "set handler name" do
subject.on(:run_started) {}
@@ -46,7 +46,7 @@ describe Chef::EventDispatch::DSL do
end
it "register user hooks against valid event type" do
- subject.on(:run_failed) {"testhook"}
+ subject.on(:run_failed) { "testhook" }
expect(events.subscribers.first.run_failed).to eq("testhook")
end
@@ -61,7 +61,7 @@ describe Chef::EventDispatch::DSL do
end
end
resource = Chef::Resource::RubyBlock.new("foo", run_context)
- resource.block { }
+ resource.block {}
resource.run_action(:run)
expect(calls).to eq([:started, :updated])
end
@@ -76,7 +76,7 @@ describe Chef::EventDispatch::DSL do
end
end
resource = Chef::Resource::RubyBlock.new("foo", run_context)
- resource.block { }
+ resource.block {}
resource.run_action(:run)
expect(events.subscribers.first.instance_variable_get(:@ivar)).to eq([1, 2])
end
diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb
index c834f7dbe1..940edfec2e 100644
--- a/spec/unit/exceptions_spec.rb
+++ b/spec/unit/exceptions_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Exceptions do
exception_to_super_class.each do |exception, expected_super_class|
it "should have an exception class of #{exception} which inherits from #{expected_super_class}" do
- expect{ raise exception }.to raise_error(expected_super_class)
+ expect { raise exception }.to raise_error(expected_super_class)
end
if exception.methods.include?(:to_json)
@@ -95,7 +95,7 @@ describe Chef::Exceptions do
end
context "initialized with nothing" do
- let(:e) { Chef::Exceptions::RunFailedWrappingError.new }
+ let(:e) { Chef::Exceptions::RunFailedWrappingError.new }
let(:num_errors) { 0 }
let(:backtrace) { [] }
@@ -103,7 +103,7 @@ describe Chef::Exceptions do
end
context "initialized with nil" do
- let(:e) { Chef::Exceptions::RunFailedWrappingError.new(nil, nil) }
+ let(:e) { Chef::Exceptions::RunFailedWrappingError.new(nil, nil) }
let(:num_errors) { 0 }
let(:backtrace) { [] }
@@ -111,7 +111,7 @@ describe Chef::Exceptions do
end
context "initialized with 1 error and nil" do
- let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), nil) }
+ let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), nil) }
let(:num_errors) { 1 }
let(:backtrace) { ["1) RuntimeError - foo"] }
@@ -119,7 +119,7 @@ describe Chef::Exceptions do
end
context "initialized with 2 errors" do
- let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), RuntimeError.new("bar")) }
+ let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), RuntimeError.new("bar")) }
let(:num_errors) { 2 }
let(:backtrace) { ["1) RuntimeError - foo", "", "2) RuntimeError - bar"] }
diff --git a/spec/unit/file_cache_spec.rb b/spec/unit/file_cache_spec.rb
index 8486b4517f..388b0e746a 100644
--- a/spec/unit/file_cache_spec.rb
+++ b/spec/unit/file_cache_spec.rb
@@ -36,7 +36,7 @@ describe Chef::FileCache do
end
it "creates the cached file at the correct relative path" do
- expect(File).to receive(:open).with(File.join(@file_cache_path, "whiz", "bang"), "w",416).and_yield(@io)
+ expect(File).to receive(:open).with(File.join(@file_cache_path, "whiz", "bang"), "w", 416).and_yield(@io)
Chef::FileCache.store("whiz/bang", "borkborkbork")
end
diff --git a/spec/unit/file_content_management/deploy/cp_spec.rb b/spec/unit/file_content_management/deploy/cp_spec.rb
index 48df5ca4de..cbdb4f1425 100644
--- a/spec/unit/file_content_management/deploy/cp_spec.rb
+++ b/spec/unit/file_content_management/deploy/cp_spec.rb
@@ -42,5 +42,3 @@ describe Chef::FileContentManagement::Deploy::Cp do
end
end
-
-
diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
index 8c96042a15..569fd898a7 100644
--- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
@@ -99,5 +99,3 @@ describe Chef::FileContentManagement::Deploy::MvUnix do
end
end
-
-
diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
index 8f54226a9d..30a62c4da9 100644
--- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
@@ -72,7 +72,7 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
end
it "errors out with a WindowsNotAdmin error" do
- expect { content_deployer.deploy(staging_file_path, target_file_path)}.to raise_error(Chef::Exceptions::WindowsNotAdmin)
+ expect { content_deployer.deploy(staging_file_path, target_file_path) }.to raise_error(Chef::Exceptions::WindowsNotAdmin)
end
end
@@ -92,7 +92,6 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
double "security descriptor for target file"
end
-
before do
allow(target_file_security_object).to receive(:security_descriptor).and_return(target_file_security_descriptor)
@@ -130,7 +129,6 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
expect(updated_target_security_object).to receive(:set_sacl).with(nil, false)
end
-
it "fixes up permissions and moves the file into place" do
content_deployer.deploy(staging_file_path, target_file_path)
end
@@ -154,7 +152,6 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
with([]).
and_return(empty_dacl)
-
allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true)
allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false)
@@ -164,12 +161,10 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
with([]).
and_return(empty_sacl)
-
expect(updated_target_security_object).to receive(:set_dacl).with(empty_dacl, false)
expect(updated_target_security_object).to receive(:set_sacl).with(empty_sacl, false)
end
-
it "fixes up permissions and moves the file into place" do
content_deployer.deploy(staging_file_path, target_file_path)
end
@@ -235,5 +230,3 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
end
end
-
-
diff --git a/spec/unit/formatters/doc_spec.rb b/spec/unit/formatters/doc_spec.rb
index 34121ab589..e9bff0759d 100644
--- a/spec/unit/formatters/doc_spec.rb
+++ b/spec/unit/formatters/doc_spec.rb
@@ -28,15 +28,15 @@ describe Chef::Formatters::Base do
it "prints a policyfile's name and revision ID" do
minimal_policyfile = {
- "revision_id"=> "613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073",
- "name"=> "jenkins",
- "run_list"=> [
+ "revision_id" => "613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073",
+ "name" => "jenkins",
+ "run_list" => [
"recipe[apt::default]",
"recipe[java::default]",
"recipe[jenkins::master]",
"recipe[policyfile_demo::default]",
],
- "cookbook_locks"=> { },
+ "cookbook_locks" => {},
}
formatter.policyfile_loaded(minimal_policyfile)
diff --git a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
index e1c1419eca..97fa92ca52 100644
--- a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
+++ b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
@@ -27,7 +27,6 @@ describe Chef::Formatters::APIErrorFormatting do
allow(response).to receive(:body)
end
-
context "when describe_406_error is called" do
context "when response['x-ops-server-api-version'] exists" do
let(:min_version) { "2" }
@@ -47,17 +46,17 @@ describe Chef::Formatters::APIErrorFormatting do
end
it "prints an error about client and server API version incompatibility with a min API version" do
- expect(error_description).to receive(:section).with("Incompatible server API version:",/a min API version of #{min_version}/)
+ expect(error_description).to receive(:section).with("Incompatible server API version:", /a min API version of #{min_version}/)
class_instance.describe_406_error(error_description, response)
end
it "prints an error about client and server API version incompatibility with a max API version" do
- expect(error_description).to receive(:section).with("Incompatible server API version:",/a max API version of #{max_version}/)
+ expect(error_description).to receive(:section).with("Incompatible server API version:", /a max API version of #{max_version}/)
class_instance.describe_406_error(error_description, response)
end
it "prints an error describing the request API version" do
- expect(error_description).to receive(:section).with("Incompatible server API version:",/a request with an API version of #{request_version}/)
+ expect(error_description).to receive(:section).with("Incompatible server API version:", /a request with an API version of #{request_version}/)
class_instance.describe_406_error(error_description, response)
end
end
diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
index 9abf27ced2..2c1da7345b 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-BAD_RECIPE=<<-E
+BAD_RECIPE = <<-E
#
# Cookbook Name:: syntax-err
# Recipe:: default
@@ -91,7 +91,7 @@ describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
describe "when explaining an error in the compile phase" do
before do
- recipe_lines = BAD_RECIPE.split("\n").map {|l| l << "\n" }
+ recipe_lines = BAD_RECIPE.split("\n").map { |l| l << "\n" }
expect(IO).to receive(:readlines).with(path_to_failed_file).and_return(recipe_lines)
inspector.add_explanation(description)
end
@@ -209,7 +209,7 @@ describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
before do
allow(Chef::Config).to receive(:cookbook_path).and_return([ "C:/opscode/chef/var/cache/cookbooks" ])
- recipe_lines = BAD_RECIPE.split("\n").map {|l| l << "\n" }
+ recipe_lines = BAD_RECIPE.split("\n").map { |l| l << "\n" }
expect(IO).to receive(:readlines).at_least(1).times.with(full_path_to_failed_file).and_return(recipe_lines)
inspector.add_explanation(description)
end
diff --git a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
index 700d7fa7ed..07643385b4 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
@@ -124,6 +124,3 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
end
end
-
-
-
diff --git a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
index 52432e8fc2..93aac417fa 100644
--- a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
@@ -21,7 +21,6 @@ require "spec_helper"
# spec_helper loads the shared examples already.
#require 'support/shared/unit/api_error_inspector_spec'
-
describe Chef::Formatters::ErrorInspectors::NodeLoadErrorInspector do
it_behaves_like "an api error inspector"
end
diff --git a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
index ed525a2228..cea93888eb 100644
--- a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
@@ -21,7 +21,6 @@ require "spec_helper"
# spec_helper loads the shared examples already.
#require 'support/shared/unit/api_error_inspector_spec'
-
describe Chef::Formatters::ErrorInspectors::RegistrationErrorInspector do
it_behaves_like "an api error inspector"
end
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 57fc4d38e2..072dcfef28 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -95,7 +95,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
@error = begin
@context.render_template_from_string("foo\nbar\nbaz\n<%= this_is_not_defined %>\nquin\nqunx\ndunno")
- rescue Chef::Mixin::Template::TemplateError => e
+ rescue Chef::Mixin::Template::TemplateError => e
e
end
@@ -108,7 +108,6 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
expect(@stdout.string).to include(@error.source_listing)
end
-
end
describe "recipe_snippet" do
@@ -189,5 +188,4 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
end
-
end
diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
index bfa9a30099..3e988c584d 100644
--- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
@@ -39,7 +39,6 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@exception = Chef::Exceptions::MissingRole.new(@run_list_expansion)
-
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
@inspector.add_explanation(@description)
end
@@ -78,8 +77,8 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
allow(@inspector).to receive(:config).and_return(:node_name => "unit-test.example.com",
- :client_key => "/etc/chef/client.pem",
- :chef_server_url => "http://chef.example.com")
+ :client_key => "/etc/chef/client.pem",
+ :chef_server_url => "http://chef.example.com")
@inspector.add_explanation(@description)
end
@@ -90,4 +89,3 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
end
end
-
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index 315e457cb2..e76e69d2cd 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -118,7 +118,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :code" do
- expect(command_opts).to receive(:merge).with({:code => "exit 0"}).and_call_original
+ expect(command_opts).to receive(:merge).with({ :code => "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
@@ -131,7 +131,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :code" do
- expect(command_opts).to receive(:merge).with({:command => "exit 0"}).and_call_original
+ expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
@@ -145,7 +145,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
end
it "merges to :command" do
- expect(command_opts).to receive(:merge).with({:command => "exit 0"}).and_call_original
+ expect(command_opts).to receive(:merge).with({ :command => "exit 0" }).and_call_original
expect(guard_interpreter.evaluate).to eq(true)
end
end
diff --git a/spec/unit/guard_interpreter_spec.rb b/spec/unit/guard_interpreter_spec.rb
index aaa9a9ebf1..1bfc831177 100644
--- a/spec/unit/guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::GuardInterpreter do
describe "#for_resource" do
- let (:resource) { Chef::Resource.new("foo")}
+ let (:resource) { Chef::Resource.new("foo") }
it "returns a DefaultGuardInterpreter if the resource has guard_interpreter set to :default" do
resource.guard_interpreter :default
diff --git a/spec/unit/handler/json_file_spec.rb b/spec/unit/handler/json_file_spec.rb
index fd3438e65e..4be448690a 100644
--- a/spec/unit/handler/json_file_spec.rb
+++ b/spec/unit/handler/json_file_spec.rb
@@ -49,7 +49,6 @@ describe Chef::Handler::JsonFile do
allow(File).to receive(:open).and_yield(@file_mock)
end
-
it "saves run status data to a file as JSON" do
expect(@handler).to receive(:build_report_dir)
@handler.run_report_unsafe(@run_status)
diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb
index f0c78d9bc1..65c3ddc4cb 100644
--- a/spec/unit/handler_spec.rb
+++ b/spec/unit/handler_spec.rb
@@ -100,7 +100,7 @@ describe Chef::Handler do
$report_ran = true
raise Exception, "I died the deth"
end
- expect {@handler.run_report_safely(@run_status)}.not_to raise_error
+ expect { @handler.run_report_safely(@run_status) }.not_to raise_error
expect($report_ran).to be_truthy
end
it "does not fail if the report handler does not raise an exception" do
@@ -108,7 +108,7 @@ describe Chef::Handler do
def @handler.report
$report_ran = true
end
- expect {@handler.run_report_safely(@run_status)}.not_to raise_error
+ expect { @handler.run_report_safely(@run_status) }.not_to raise_error
expect($report_ran).to be_truthy
end
end
diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb
index 3650e99a02..7fd2bdc821 100644
--- a/spec/unit/http/authenticator_spec.rb
+++ b/spec/unit/http/authenticator_spec.rb
@@ -35,15 +35,15 @@ describe Chef::HTTP::Authenticator do
it "merges the default version of X-Ops-Server-API-Version into the headers" do
# headers returned
expect(class_instance.handle_request(method, url, headers, data)[2]).
- to include({"X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION})
+ to include({ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION })
end
context "when api_version is set to something other than the default" do
- let(:class_instance) { Chef::HTTP::Authenticator.new({:api_version => "-10"}) }
+ let(:class_instance) { Chef::HTTP::Authenticator.new({ :api_version => "-10" }) }
it "merges the requested version of X-Ops-Server-API-Version into the headers" do
expect(class_instance.handle_request(method, url, headers, data)[2]).
- to include({"X-Ops-Server-API-Version" => "-10"})
+ to include({ "X-Ops-Server-API-Version" => "-10" })
end
end
end
@@ -72,7 +72,7 @@ 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 e26e030737..a76c8d1dc7 100644
--- a/spec/unit/http/json_input_spec.rb
+++ b/spec/unit/http/json_input_spec.rb
@@ -66,7 +66,7 @@ describe Chef::HTTP::JSONInput do
context "when the request should be serialized" do
let(:http_method) { :put }
- let(:data) { {foo: "bar"} }
+ let(:data) { { foo: "bar" } }
let(:expected_data) { %q[{"foo":"bar"}] }
context "and the request has a ruby object as the body and no explicit content-type" do
@@ -111,7 +111,7 @@ describe Chef::HTTP::JSONInput do
expect(handle_request).to eq([http_method, url, headers, data])
# not normalized
- expect(headers).to eq({"content-type" => "application/x-binary"})
+ expect(headers).to eq({ "content-type" => "application/x-binary" })
end
it "does not serialize the body to json when content type is given in capitalized form" do
@@ -120,7 +120,7 @@ describe Chef::HTTP::JSONInput do
expect(handle_request).to eq([http_method, url, headers, data])
# not normalized
- expect(headers).to eq({"Content-Type" => "application/x-binary"})
+ expect(headers).to eq({ "Content-Type" => "application/x-binary" })
end
end
diff --git a/spec/unit/http/socketless_chef_zero_client_spec.rb b/spec/unit/http/socketless_chef_zero_client_spec.rb
index 4b45582ec4..637e562799 100644
--- a/spec/unit/http/socketless_chef_zero_client_spec.rb
+++ b/spec/unit/http/socketless_chef_zero_client_spec.rb
@@ -110,7 +110,7 @@ describe Chef::HTTP::SocketlessChefZeroClient do
end
it "does not fail when calling read_body with a block" do
- expect(net_http_response.read_body {|chunk| chunk }).to eq("bunch o' JSON")
+ expect(net_http_response.read_body { |chunk| chunk }).to eq("bunch o' JSON")
end
end
@@ -149,7 +149,6 @@ describe Chef::HTTP::SocketlessChefZeroClient do
}
end
-
let(:response_code) { 200 }
let(:response_headers) { { "Content-Type" => "Application/JSON" } }
let(:response_body) { [ "bunch o' JSON" ] }
diff --git a/spec/unit/http/ssl_policies_spec.rb b/spec/unit/http/ssl_policies_spec.rb
index 7dbe06ee8e..df6dee1198 100644
--- a/spec/unit/http/ssl_policies_spec.rb
+++ b/spec/unit/http/ssl_policies_spec.rb
@@ -54,7 +54,7 @@ describe "HTTP SSL Policy" do
it "raises a ConfigurationError if :ssl_ca_path is set to a path that doesn't exist" do
Chef::Config[:ssl_ca_path] = "/dev/null/nothing_here"
- expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError)
+ expect { http_client }.to raise_error(Chef::Exceptions::ConfigurationError)
end
it "should set the CA path if that is set in the configuration" do
@@ -64,7 +64,7 @@ describe "HTTP SSL Policy" do
it "raises a ConfigurationError if :ssl_ca_file is set to a file that does not exist" do
Chef::Config[:ssl_ca_file] = "/dev/null/nothing_here"
- expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError)
+ expect { http_client }.to raise_error(Chef::Exceptions::ConfigurationError)
end
it "should set the CA file if that is set in the configuration" do
@@ -85,24 +85,24 @@ describe "HTTP SSL Policy" do
end
describe "when configured with a client certificate" do
- before {@url = URI.parse("https://chef.example.com:4443/")}
+ before { @url = URI.parse("https://chef.example.com:4443/") }
it "raises ConfigurationError if the certificate file doesn't exist" do
Chef::Config[:ssl_client_cert] = "/dev/null/nothing_here"
Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key"
- expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError)
+ expect { http_client }.to raise_error(Chef::Exceptions::ConfigurationError)
end
it "raises ConfigurationError if the certificate file doesn't exist" do
Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec.cert"
Chef::Config[:ssl_client_key] = "/dev/null/nothing_here"
- expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError)
+ expect { http_client }.to raise_error(Chef::Exceptions::ConfigurationError)
end
it "raises a ConfigurationError if one of :ssl_client_cert and :ssl_client_key is set but not both" do
Chef::Config[:ssl_client_cert] = "/dev/null/nothing_here"
Chef::Config[:ssl_client_key] = nil
- expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError)
+ expect { http_client }.to raise_error(Chef::Exceptions::ConfigurationError)
end
it "configures the HTTP client's cert and private key" do
@@ -167,4 +167,3 @@ describe "HTTP SSL Policy" do
end
end
-
diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb
index 00f69c7e6f..c054529e48 100644
--- a/spec/unit/http/validate_content_length_spec.rb
+++ b/spec/unit/http/validate_content_length_spec.rb
@@ -29,7 +29,7 @@ describe Chef::HTTP::ValidateContentLength do
let(:headers) { {} }
let(:data) { false }
- let(:request) { }
+ let(:request) {}
let(:return_value) { "200" }
# Test Variables
@@ -105,7 +105,7 @@ describe Chef::HTTP::ValidateContentLength do
end
describe "without Content-Length header" do
- let(:response_headers) { { } }
+ let(:response_headers) { {} }
[ "direct", "streaming" ].each do |req_type|
describe "when running #{req_type} request" do
@@ -180,7 +180,7 @@ describe Chef::HTTP::ValidateContentLength do
end
it "should reset internal counter" do
- expect(middleware.instance_variable_get(:@content_length_counter)).to be_nil
+ expect(middleware.instance_variable_get(:@content_length_counter)).to be_nil
end
it "should validate correctly second time" do
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index c31ab05f45..4da29fe4ec 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -58,14 +58,14 @@ describe Chef::JSONCompat do
let(:json) { '{"json_class": "Chef::Sandbox", "arbitrary": "data"}' }
it "returns a Hash, because Chef::Sandbox is a dummy class" do
- expect(Chef::JSONCompat.from_json(json)).to eq({"json_class" => "Chef::Sandbox", "arbitrary" => "data"})
+ expect(Chef::JSONCompat.from_json(json)).to eq({ "json_class" => "Chef::Sandbox", "arbitrary" => "data" })
end
end
describe "when pretty printing an object that defines #to_json" do
class Foo
def to_json(*a)
- Chef::JSONCompat.to_json({"foo" => 1234, "bar" => {"baz" => 5678}}, *a)
+ Chef::JSONCompat.to_json({ "foo" => 1234, "bar" => { "baz" => 5678 } }, *a)
end
end
diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb
index 5912016577..ef8d39bb0d 100644
--- a/spec/unit/key_spec.rb
+++ b/spec/unit/key_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Key do
# whether user or client irrelevent to these tests
let(:key) { Chef::Key.new("original_actor", "user") }
let(:public_key_string) do
- <<EOS
+ <<EOS
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
@@ -71,7 +71,6 @@ EOS
end
end
-
describe "when a new Chef::Key object is initialized with invalid input" do
it "should raise an InvalidKeyArgument" do
expect { Chef::Key.new("original_actor", "not_a_user_or_client") }.to raise_error(Chef::Exceptions::InvalidKeyArgument)
@@ -306,7 +305,7 @@ EOS
"name" => "key_name",
"public_key" => public_key_string,
"private_key" => "some_private_key",
- "expiration_date" => "infinity"}
+ "expiration_date" => "infinity" }
Chef::Key.from_json(o.to_json)
end
let(:key_with_create_key_field) do
@@ -324,7 +323,7 @@ EOS
"name" => "key_name",
"public_key" => public_key_string,
"private_key" => "some_private_key",
- "expiration_date" => "infinity"}
+ "expiration_date" => "infinity" }
Chef::Key.from_json(o.to_json)
end
let(:key_with_create_key_field) do
@@ -336,7 +335,6 @@ EOS
end
end # when deserializing from JSON
-
describe "API Interactions" do
let(:rest) do
Chef::Config[:chef_server_root] = "http://www.example.com"
@@ -358,8 +356,8 @@ EOS
describe "list" do
context "when listing keys for a user" do
- let(:response) { [{"uri" => "http://www.example.com/users/keys/foobar", "name"=>"foobar", "expired"=>false}] }
- let(:inflated_response) { {"foobar" => user_key} }
+ let(:response) { [{ "uri" => "http://www.example.com/users/keys/foobar", "name" => "foobar", "expired" => false }] }
+ let(:inflated_response) { { "foobar" => user_key } }
it "lists all keys" do
expect(rest).to receive(:get).with("users/#{user_key.actor}/keys").and_return(response)
@@ -375,8 +373,8 @@ EOS
end
context "when listing keys for a client" do
- let(:response) { [{"uri" => "http://www.example.com/users/keys/foobar", "name"=>"foobar", "expired"=>false}] }
- let(:inflated_response) { {"foobar" => client_key} }
+ let(:response) { [{ "uri" => "http://www.example.com/users/keys/foobar", "name" => "foobar", "expired" => false }] }
+ let(:inflated_response) { { "foobar" => client_key } }
it "lists all keys" do
expect(rest).to receive(:get).with("clients/#{client_key.actor}/keys").and_return(response)
@@ -392,7 +390,6 @@ EOS
end
end
-
describe "create" do
shared_examples_for "create key" do
context "when a field is missing" do
@@ -409,9 +406,9 @@ EOS
it "creates a new key via the API with the fingerprint as the name" do
expect(rest).to receive(:post).with(url,
- {"name" => "12:3e:33:73:0b:f4:ec:72:dc:f0:4c:51:62:27:08:76:96:24:f4:4a",
- "public_key" => key.public_key,
- "expiration_date" => key.expiration_date}).and_return({})
+ { "name" => "12:3e:33:73:0b:f4:ec:72:dc:f0:4c:51:62:27:08:76:96:24:f4:4a",
+ "public_key" => key.public_key,
+ "expiration_date" => key.expiration_date }).and_return({})
key.create
end
end
@@ -427,9 +424,9 @@ EOS
context "when create_key is false" do
it "creates a new key via the API" do
expect(rest).to receive(:post).with(url,
- {"name" => key.name,
- "public_key" => key.public_key,
- "expiration_date" => key.expiration_date}).and_return({})
+ { "name" => key.name,
+ "public_key" => key.public_key,
+ "expiration_date" => key.expiration_date }).and_return({})
key.create
end
end
@@ -459,11 +456,11 @@ EOS
context "when the server returns the private_key via key.create" do
before do
- allow(rest).to receive(:post).with(url, $expected_input).and_return({"private_key" => "this_private_key"})
+ allow(rest).to receive(:post).with(url, $expected_input).and_return({ "private_key" => "this_private_key" })
end
it "key.create returns the original key plus the private_key" do
- expect(key.create.to_hash).to eq($expected_output.merge({"private_key" => "this_private_key"}))
+ expect(key.create.to_hash).to eq($expected_output.merge({ "private_key" => "this_private_key" }))
end
end
end
@@ -572,7 +569,7 @@ EOS
describe "load" do
shared_examples_for "load" do
it "should load a named key from the API" do
- expect(rest).to receive(:get).with(url).and_return({"user" => "foobar", "name" => "test_key_name", "public_key" => public_key_string, "expiration_date" => "infinity"})
+ expect(rest).to receive(:get).with(url).and_return({ "user" => "foobar", "name" => "test_key_name", "public_key" => public_key_string, "expiration_date" => "infinity" })
key = Chef::Key.send(load_method, "foobar", "test_key_name")
expect(key.actor).to eq("foobar")
expect(key.name).to eq("test_key_name")
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index c509c70872..491d0ca754 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -18,7 +18,6 @@
require "spec_helper"
-
describe Chef::Knife::Bootstrap::ClientBuilder do
let(:stdout) { StringIO.new }
@@ -131,7 +130,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
end
end
- context "#create_node!" do
+ context "#create_node!" do
before do
# mock out the rest of #run
expect(client_builder).to receive(:sanity_check)
@@ -181,8 +180,8 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
end
it "builds a node with first_boot_attributes if they're given" do
- knife_config[:first_boot_attributes] = {:baz => :quux}
- expect(node).to receive(:normal_attrs=).with({:baz=>:quux})
+ knife_config[:first_boot_attributes] = { :baz => :quux }
+ expect(node).to receive(:normal_attrs=).with({ :baz => :quux })
expect(node).to receive(:run_list).with([])
client_builder.run
end
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index e6a78df8ba..e8e75e43b5 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -51,7 +51,7 @@ describe Chef::Knife::Bootstrap do
context "with --bootstrap-vault-item" do
let(:bootstrap_cli_options) { [ "--bootstrap-vault-item", "vault1:item1", "--bootstrap-vault-item", "vault1:item2", "--bootstrap-vault-item", "vault2:item1" ] }
it "sets the knife config cli option correctly" do
- expect(knife.config[:bootstrap_vault_item]).to eq({"vault1"=>["item1", "item2"], "vault2"=>["item1"]})
+ expect(knife.config[:bootstrap_vault_item]).to eq({ "vault1" => ["item1", "item2"], "vault2" => ["item1"] })
end
end
@@ -102,7 +102,7 @@ describe Chef::Knife::Bootstrap do
context "when :bootstrap_template config is set to a template name" do
let(:bootstrap_template) { "example" }
- let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb"))}
+ let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb")) }
let(:chef_config_dir_template_path) { "/knife/chef/config/bootstrap/example.erb" }
@@ -209,7 +209,7 @@ describe Chef::Knife::Bootstrap do
["-d", "--distro", "-t", "--bootstrap-template", "--template-file"].each do |t|
context "when #{t} option is given in the command line" do
it "sets the knife :bootstrap_template config" do
- knife.parse_options([t,"blahblah"])
+ knife.parse_options([t, "blahblah"])
knife.merge_configs
expect(knife.bootstrap_template).to eq("blahblah")
end
@@ -224,7 +224,7 @@ describe Chef::Knife::Bootstrap do
end
it "should have role[base] in the run_list" do
- knife.parse_options(["-r","role[base]"])
+ knife.parse_options(["-r", "role[base]"])
knife.merge_configs
expect(knife.render_template).to eq('{"run_list":["role[base]"]}')
end
@@ -238,7 +238,7 @@ describe Chef::Knife::Bootstrap do
context "with bootstrap_attribute options" do
let(:jsonfile) {
file = Tempfile.new (["node", ".json"])
- File.open(file.path, "w") {|f| f.puts '{"foo":{"bar":"baz"}}' }
+ File.open(file.path, "w") { |f| f.puts '{"foo":{"bar":"baz"}}' }
file
}
@@ -264,7 +264,7 @@ describe Chef::Knife::Bootstrap do
knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
knife.parse_options(["--json-attribute-file", jsonfile.path])
knife.merge_configs
- expect{ knife.run }.to raise_error(Chef::Exceptions::BootstrapCommandInputError)
+ expect { knife.run }.to raise_error(Chef::Exceptions::BootstrapCommandInputError)
jsonfile.close
end
end
@@ -297,7 +297,7 @@ describe Chef::Knife::Bootstrap do
k
end
- let(:options){ ["--bootstrap-no-proxy", setting, "-s", "foo"] }
+ let(:options) { ["--bootstrap-no-proxy", setting, "-s", "foo"] }
let(:template_file) { File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "no_proxy.erb")) }
let(:rendered_template) do
knife.render_template
@@ -339,7 +339,7 @@ describe Chef::Knife::Bootstrap do
let(:options) { ["--node-ssl-verify-mode", "all"] }
it "raises error" do
- expect{ rendered_template }.to raise_error
+ expect { rendered_template }.to raise_error
end
end
@@ -633,7 +633,7 @@ describe Chef::Knife::Bootstrap do
describe "when falling back to password auth when host key auth fails" do
let(:knife_ssh_with_password_auth) do
knife.name_args = ["foo.example.com"]
- knife.config[:ssh_user] = "rooty"
+ knife.config[:ssh_user] = "rooty"
knife.config[:ssh_identity_file] = "~/.ssh/me.rsa"
allow(knife).to receive(:render_template).and_return("")
k = knife.knife_ssh
@@ -662,7 +662,7 @@ describe Chef::Knife::Bootstrap do
let(:knife_ssh) do
knife.name_args = ["foo.example.com"]
knife.config[:chef_node_name] = "foo.example.com"
- knife.config[:ssh_user] = "rooty"
+ knife.config[:ssh_user] = "rooty"
knife.config[:ssh_identity_file] = "~/.ssh/me.rsa"
allow(knife).to receive(:render_template).and_return("")
knife_ssh = knife.knife_ssh
@@ -677,7 +677,6 @@ describe Chef::Knife::Bootstrap do
allow(File).to receive(:exist?).with(File.expand_path(Chef::Config[:validation_key])).and_return(true)
end
-
it "configures the underlying ssh command and then runs it" do
expect(knife_ssh).to receive(:run)
knife.run
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index 42110d8180..096fba632a 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::ClientBulkDelete do
let(:stdout_io) { StringIO.new }
- let(:stdout) {stdout_io.string}
+ let(:stdout) { stdout_io.string }
let(:stderr_io) { StringIO.new }
let(:stderr) { stderr_io.string }
@@ -69,7 +69,7 @@ describe Chef::Knife::ClientBulkDelete do
clients
}
- let(:client_names) { nonvalidator_client_names + validator_client_names}
+ let(:client_names) { nonvalidator_client_names + validator_client_names }
let(:clients) {
nonvalidator_clients.merge(validator_clients)
}
@@ -128,7 +128,7 @@ describe Chef::Knife::ClientBulkDelete do
end
describe "with --delete-validators" do
- let(:option_args) { {:delete_validators => true} }
+ let(:option_args) { { :delete_validators => true } }
it "should mention that validator clients will be deleted" do
knife.run
diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb
index 7c3d837c97..bd9d4a1d63 100644
--- a/spec/unit/knife/client_create_spec.rb
+++ b/spec/unit/knife/client_create_spec.rb
@@ -24,7 +24,6 @@ describe Chef::Knife::ClientCreate do
let(:stderr) { StringIO.new }
let(:stdout) { StringIO.new }
-
let(:default_client_hash) do
{
"name" => "adam",
@@ -53,7 +52,7 @@ describe Chef::Knife::ClientCreate do
end
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
end
describe "run" do
diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb
index eee665a7b4..f1af3c3d4e 100644
--- a/spec/unit/knife/client_delete_spec.rb
+++ b/spec/unit/knife/client_delete_spec.rb
@@ -69,7 +69,7 @@ describe Chef::Knife::ClientDelete do
it "should not delete validator client if --delete-validators is not set" do
@client.validator(true)
expect(@knife.ui).to receive(:fatal)
- expect { @knife.run}.to raise_error(SystemExit)
+ expect { @knife.run }.to raise_error(SystemExit)
end
it "should delete validator client if --delete-validators is set" do
diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb
index 9dfb0666de..47b4b6ccb0 100644
--- a/spec/unit/knife/client_show_spec.rb
+++ b/spec/unit/knife/client_show_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Knife::ClientShow do
@knife.config[:format] = "json"
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
- fake_client_contents = {"foo"=>"bar", "baz"=>"qux"}
+ fake_client_contents = { "foo" => "bar", "baz" => "qux" }
expect(Chef::ApiClientV1).to receive(:load).with("adam").and_return(fake_client_contents)
@knife.run
expect(@stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n")
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index 54fed02ca3..192da862d7 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -44,9 +44,9 @@ describe Chef::Knife::ConfigureClient do
@client_file = StringIO.new
@validation_file = StringIO.new
expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w").
- and_yield(@client_file)
+ and_yield(@client_file)
expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w").
- and_yield(@validation_file)
+ and_yield(@validation_file)
expect(IO).to receive(:read).and_return("foo_bar_baz")
end
@@ -81,4 +81,3 @@ describe Chef::Knife::ConfigureClient do
end
end
-
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 6c1d98c2f5..e96115c056 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -4,7 +4,7 @@ describe Chef::Knife::Configure do
before do
Chef::Log.logger = Logger.new(StringIO.new)
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::Configure.new
@rest_client = double("null rest client", :post => { :result => :true })
allow(@knife).to receive(:rest).and_return(@rest_client)
@@ -22,7 +22,6 @@ describe Chef::Knife::Configure do
allow(Ohai::System).to receive(:new).and_return(ohai)
end
-
let(:fqdn) { "foo.example.org" }
let(:ohai) do
@@ -41,7 +40,6 @@ describe Chef::Knife::Configure do
let(:default_server_url) { "https://#{fqdn}:443" }
-
it "asks the user for the URL of the chef server" do
@knife.ask_user_for_config
expect(@out.string).to match(Regexp.escape("Please enter the chef server URL: [#{default_server_url}]"))
@@ -220,7 +218,7 @@ describe Chef::Knife::Configure do
expect(File).to receive(:expand_path).with("/home/you/.chef/a-new-user.pem").and_return("/home/you/.chef/a-new-user.pem")
expect(File).to receive(:expand_path).with(default_validator_key).and_return(default_validator_key)
expect(File).to receive(:expand_path).with(default_admin_key).and_return(default_admin_key)
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
user_command = Chef::Knife::UserCreate.new
expect(user_command).to receive(:run)
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb
index 72299f4920..62b8c9fe51 100644
--- a/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -22,9 +22,9 @@ describe Chef::Knife::CookbookBulkDelete do
before(:each) do
Chef::Log.logger = Logger.new(StringIO.new)
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::CookbookBulkDelete.new
- @knife.config = {:print_after => nil}
+ @knife.config = { :print_after => nil }
@knife.name_args = ["."]
@stdout = StringIO.new
@stderr = StringIO.new
@@ -44,15 +44,13 @@ describe Chef::Knife::CookbookBulkDelete do
end
-
-
describe "when there are several cookbooks on the server" do
before do
- @cheezburger = {"cheezburger" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-cheez", "version" => "1.0.0"}]}}
+ @cheezburger = { "cheezburger" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-cheez", "version" => "1.0.0" }] } }
allow(@rest).to receive(:get).with("cookbooks/cheezburger").and_return(@cheezburger)
- @pizza = {"pizza" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-pizza", "version" => "2.0.0"}]}}
+ @pizza = { "pizza" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-pizza", "version" => "2.0.0" }] } }
allow(@rest).to receive(:get).with("cookbooks/pizza").and_return(@pizza)
- @lasagna = {"lasagna" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-lasagna", "version" => "3.0.0"}]}}
+ @lasagna = { "lasagna" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-lasagna", "version" => "3.0.0" }] } }
allow(@rest).to receive(:get).with("cookbooks/lasagna").and_return(@lasagna)
end
@@ -68,7 +66,7 @@ describe Chef::Knife::CookbookBulkDelete do
end
it "should delete each cookbook" do
- {"cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => "3.0.0"}.each do |cookbook_name, version|
+ { "cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => "3.0.0" }.each do |cookbook_name, version|
expect(@rest).to receive(:delete).with("cookbooks/#{cookbook_name}/#{version}")
end
@knife.run
diff --git a/spec/unit/knife/cookbook_create_spec.rb b/spec/unit/knife/cookbook_create_spec.rb
index 1989516c1b..a183bef103 100644
--- a/spec/unit/knife/cookbook_create_spec.rb
+++ b/spec/unit/knife/cookbook_create_spec.rb
@@ -21,7 +21,7 @@ require "tmpdir"
describe Chef::Knife::CookbookCreate do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::CookbookCreate.new
@knife.config = {}
@knife.name_args = ["foobar"]
@@ -34,7 +34,7 @@ describe Chef::Knife::CookbookCreate do
# Fixes CHEF-2579
it "should expand the path of the cookbook directory" do
expect(File).to receive(:expand_path).with("~/tmp/monkeypants")
- @knife.config = {:cookbook_path => "~/tmp/monkeypants"}
+ @knife.config = { :cookbook_path => "~/tmp/monkeypants" }
allow(@knife).to receive(:create_cookbook)
allow(@knife).to receive(:create_readme)
allow(@knife).to receive(:create_changelog)
@@ -44,7 +44,7 @@ describe Chef::Knife::CookbookCreate do
it "should create a new cookbook with default values to copyright name, email, readme format and license if those are not supplied" do
@dir = Dir.tmpdir
- @knife.config = {:cookbook_path => @dir}
+ @knife.config = { :cookbook_path => @dir }
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "none")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -58,7 +58,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_path => @dir,
:cookbook_copyright => "Opscode, Inc",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -73,7 +73,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_copyright => "Opscode, Inc",
:cookbook_email => "nuo@opscode.com",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -89,7 +89,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => "apachev2",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "apachev2")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -105,7 +105,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => false,
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -121,7 +121,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => "false",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -137,7 +137,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => "gplv2",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv2")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -153,7 +153,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => "gplv3",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv3")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -169,7 +169,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_email => "nuo@opscode.com",
:cookbook_license => "mit",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -186,7 +186,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_license => "mit",
:readme_format => "rdoc",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "rdoc")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -203,7 +203,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_license => "mit",
:readme_format => "mkd",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "mkd")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -220,7 +220,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_license => "mit",
:readme_format => "txt",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "txt")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -237,7 +237,7 @@ describe Chef::Knife::CookbookCreate do
:cookbook_license => "mit",
:readme_format => "foo",
}
- @knife.name_args=["foobar"]
+ @knife.name_args = ["foobar"]
expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit")
expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "foo")
expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first)
@@ -252,7 +252,7 @@ describe Chef::Knife::CookbookCreate do
it "should throw an argument error" do
@dir = Dir.tmpdir
- expect{@knife.run}.to raise_error(ArgumentError)
+ expect { @knife.run }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index f27bfeaa80..4bca4e06ed 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Knife::CookbookDelete do
it "should prompt to purge the files" do
@knife.config[:purge] = true
expect(@knife).to receive(:confirm).
- with(/.+Are you sure you want to purge files.+/)
+ with(/.+Are you sure you want to purge files.+/)
expect(@knife).to receive(:delete_without_explicit_version)
@knife.run
end
@@ -127,9 +127,9 @@ describe Chef::Knife::CookbookDelete do
before(:each) do
@rest_mock = double("rest")
expect(@knife).to receive(:rest).and_return(@rest_mock)
- @cookbook_data = { "foobar" => { "versions" => [{"version" => "1.0.0"},
- {"version" => "1.1.0"},
- {"version" => "2.0.0"} ]}
+ @cookbook_data = { "foobar" => { "versions" => [{ "version" => "1.0.0" },
+ { "version" => "1.1.0" },
+ { "version" => "2.0.0" } ] }
}
end
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index c515693a53..a8248a80b9 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -49,20 +49,20 @@ describe Chef::Knife::CookbookDownload do
@manifest_data = {
:recipes => [
- {"path" => "recipes/foo.rb",
- "url" => "http://example.org/files/foo.rb"},
- {"path" => "recipes/bar.rb",
- "url" => "http://example.org/files/bar.rb"},
+ { "path" => "recipes/foo.rb",
+ "url" => "http://example.org/files/foo.rb" },
+ { "path" => "recipes/bar.rb",
+ "url" => "http://example.org/files/bar.rb" },
],
:templates => [
- {"path" => "templates/default/foo.erb",
- "url" => "http://example.org/files/foo.erb"},
- {"path" => "templates/default/bar.erb",
- "url" => "http://example.org/files/bar.erb"},
+ { "path" => "templates/default/foo.erb",
+ "url" => "http://example.org/files/foo.erb" },
+ { "path" => "templates/default/bar.erb",
+ "url" => "http://example.org/files/bar.erb" },
],
:attributes => [
- {"path" => "attributes/default.rb",
- "url" => "http://example.org/files/default.rb"},
+ { "path" => "attributes/default.rb",
+ "url" => "http://example.org/files/default.rb" },
],
}
@@ -102,17 +102,17 @@ describe Chef::Knife::CookbookDownload do
before(:each) do
@files.map { |f| File.dirname(f) }.flatten.uniq.each do |dir|
expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}").
- at_least(:once)
+ at_least(:once)
end
@files_mocks.each_pair do |file, mock|
expect(@rest_mock).to receive(:streaming_request).with("http://example.org/files/#{file}").
- and_return(mock)
+ and_return(mock)
end
@files.each do |f|
expect(FileUtils).to receive(:mv).
- with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}")
+ with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}")
end
end
@@ -165,7 +165,7 @@ describe Chef::Knife::CookbookDownload do
it "should return and set the version to the latest version" do
@knife.config[:latest] = true
expect(@knife).to receive(:available_versions).at_least(:once).
- and_return(["1.0.0", "1.1.0", "2.0.0"])
+ and_return(["1.0.0", "1.1.0", "2.0.0"])
@knife.determine_version
expect(@knife.version.to_s).to eq("2.0.0")
end
@@ -179,15 +179,15 @@ describe Chef::Knife::CookbookDownload do
it "should return nil if there are no versions" do
expect(Chef::CookbookVersion).to receive(:available_versions).
- with("foobar").
- and_return(nil)
+ with("foobar").
+ and_return(nil)
expect(@knife.available_versions).to eq(nil)
end
it "should return the available versions" do
expect(Chef::CookbookVersion).to receive(:available_versions).
- with("foobar").
- and_return(["1.1.0", "2.0.0", "1.0.0"])
+ with("foobar").
+ and_return(["1.1.0", "2.0.0", "1.0.0"])
expect(@knife.available_versions).to eq([Chef::Version.new("1.0.0"),
Chef::Version.new("1.1.0"),
Chef::Version.new("2.0.0")])
@@ -195,9 +195,9 @@ describe Chef::Knife::CookbookDownload do
it "should avoid multiple API calls to the server" do
expect(Chef::CookbookVersion).to receive(:available_versions).
- once.
- with("foobar").
- and_return(["1.1.0", "2.0.0", "1.0.0"])
+ once.
+ with("foobar").
+ and_return(["1.1.0", "2.0.0", "1.0.0"])
@knife.available_versions
@knife.available_versions
end
diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb
index cc45970ead..668f9afa4b 100644
--- a/spec/unit/knife/cookbook_list_spec.rb
+++ b/spec/unit/knife/cookbook_list_spec.rb
@@ -27,9 +27,9 @@ describe Chef::Knife::CookbookList do
@base_url = "https://server.example.com/cookbooks"
@cookbook_data = {}
@cookbook_names.each do |item|
- @cookbook_data[item] = {"url" => "#{@base_url}/#{item}",
- "versions" => [{"version" => "1.0.1",
- "url" => "#{@base_url}/#{item}/1.0.1"}]}
+ @cookbook_data[item] = { "url" => "#{@base_url}/#{item}",
+ "versions" => [{ "version" => "1.0.1",
+ "url" => "#{@base_url}/#{item}/1.0.1" }] }
end
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
@@ -38,7 +38,7 @@ describe Chef::Knife::CookbookList do
describe "run" do
it "should display the latest version of the cookbooks" do
expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=1").
- and_return(@cookbook_data)
+ and_return(@cookbook_data)
@knife.run
@cookbook_names.each do |item|
expect(@stdout.string).to match /#{item}\s+1\.0\.1/
@@ -48,8 +48,8 @@ describe Chef::Knife::CookbookList do
it "should query cookbooks for the configured environment" do
@knife.config[:environment] = "production"
expect(@rest_mock).to receive(:get).
- with("/environments/production/cookbooks?num_versions=1").
- and_return(@cookbook_data)
+ with("/environments/production/cookbooks?num_versions=1").
+ and_return(@cookbook_data)
@knife.run
end
@@ -68,15 +68,15 @@ describe Chef::Knife::CookbookList do
describe "with -a or --all" do
before do
@cookbook_names.each do |item|
- @cookbook_data[item]["versions"] << {"version" => "1.0.0",
- "url" => "#{@base_url}/#{item}/1.0.0"}
+ @cookbook_data[item]["versions"] << { "version" => "1.0.0",
+ "url" => "#{@base_url}/#{item}/1.0.0" }
end
end
it "should display all versions of the cookbooks" do
@knife.config[:all_versions] = true
expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all").
- and_return(@cookbook_data)
+ and_return(@cookbook_data)
@knife.run
@cookbook_names.each do |item|
expect(@stdout.string).to match /#{item}\s+1\.0\.1\s+1\.0\.0/
diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
index f09a4fc53c..274eb5e167 100644
--- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
@@ -22,7 +22,7 @@ require "spec_helper"
describe Chef::Knife::CookbookMetadataFromFile do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@src = File.expand_path(File.join(CHEF_SPEC_DATA, "metadata", "quick_start", "metadata.rb"))
@tgt = File.expand_path(File.join(CHEF_SPEC_DATA, "metadata", "quick_start", "metadata.json"))
@knife = Chef::Knife::CookbookMetadataFromFile.new
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index 2f6480a06b..0e3fccfa7e 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -85,19 +85,19 @@ describe Chef::Knife::CookbookMetadata do
before(:each) do
@knife.config[:cookbook_path] = @cookbook_dir
allow(File).to receive(:expand_path).with("#{@cookbook_dir}/foobar/metadata.rb").
- and_return("#{@cookbook_dir}/foobar/metadata.rb")
+ and_return("#{@cookbook_dir}/foobar/metadata.rb")
end
it "should generate the metadata from metadata.rb if it exists" do
expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb").
- and_return(true)
+ and_return(true)
expect(@knife).to receive(:generate_metadata_from_file).with("foobar", "#{@cookbook_dir}/foobar/metadata.rb")
@knife.run
end
it "should validate the metadata json if metadata.rb does not exist" do
expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb").
- and_return(false)
+ and_return(false)
expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, "foobar")
@knife.run
end
@@ -114,10 +114,10 @@ describe Chef::Knife::CookbookMetadata do
expect(@metadata_mock).to receive(:name).with("foobar")
expect(@metadata_mock).to receive(:from_file).with("#{@cookbook_dir}/foobar/metadata.rb")
expect(File).to receive(:open).with("#{@cookbook_dir}/foobar/metadata.json", "w").
- and_yield(@json_file_mock)
+ and_yield(@json_file_mock)
expect(@json_file_mock).to receive(:write).with(@json_data)
expect(Chef::JSONCompat).to receive(:to_json_pretty).with(@metadata_mock).
- and_return(@json_data)
+ and_return(@json_data)
@knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb")
expect(@stderr.string).to match /generating metadata for foobar from #{@cookbook_dir}\/foobar\/metadata\.rb/im
end
@@ -141,16 +141,16 @@ describe Chef::Knife::CookbookMetadata do
describe "validate_metadata_json" do
it "should validate the metadata json" do
expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json").
- and_return(true)
+ and_return(true)
expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json").
- and_return(@json_data)
+ and_return(@json_data)
expect(Chef::Cookbook::Metadata).to receive(:validate_json).with(@json_data)
@knife.validate_metadata_json(@cookbook_dir, "foobar")
end
it "should not try to validate the metadata json if the file does not exist" do
expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json").
- and_return(false)
+ and_return(false)
expect(IO).not_to receive(:read)
expect(Chef::Cookbook::Metadata).not_to receive(:validate_json)
@knife.validate_metadata_json(@cookbook_dir, "foobar")
@@ -161,9 +161,9 @@ describe Chef::Knife::CookbookMetadata do
}.each_pair do |klass, description|
it "should print an error and exit when an #{description} syntax exception is encountered" do
expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json").
- and_return(true)
+ and_return(true)
expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json").
- and_return(@json_data)
+ and_return(@json_data)
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception)
expect {
diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb
index ee9fb1c081..de6d569e1d 100644
--- a/spec/unit/knife/cookbook_show_spec.rb
+++ b/spec/unit/knife/cookbook_show_spec.rb
@@ -21,9 +21,9 @@ require "spec_helper"
describe Chef::Knife::CookbookShow do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::CookbookShow.new
- @knife.config = { }
+ @knife.config = {}
@knife.name_args = [ "cookbook_name" ]
@rest = double(Chef::ServerAPI)
allow(@knife).to receive(:rest).and_return(@rest)
@@ -72,7 +72,7 @@ describe Chef::Knife::CookbookShow do
describe "with 2 arguments: name and version" do
before(:each) do
@knife.name_args << "0.1.0"
- @response = { "0.1.0" => { "recipes" => {"default.rb" => ""} } }
+ @response = { "0.1.0" => { "recipes" => { "default.rb" => "" } } }
end
it "should show the specific part of a cookbook" do
@@ -97,7 +97,7 @@ describe Chef::Knife::CookbookShow do
]
}
@cookbook_response.manifest = @manifest
- @response = {"name"=>"default.rb", "url"=>"http://example.org/files/default.rb", "checksum"=>"1234", "path"=>"recipes/default.rb"}
+ @response = { "name" => "default.rb", "url" => "http://example.org/files/default.rb", "checksum" => "1234", "path" => "recipes/default.rb" }
end
it "should print the json of the part" do
@@ -220,4 +220,3 @@ describe Chef::Knife::CookbookShow do
end
end
end
-
diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb
index 530ac576e0..663ad1af74 100644
--- a/spec/unit/knife/cookbook_site_download_spec.rb
+++ b/spec/unit/knife/cookbook_site_download_spec.rb
@@ -36,8 +36,8 @@ describe Chef::Knife::CookbookSiteDownload do
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
expect(@noauth_rest).to receive(:get).
- with("#{@cookbook_api_url}/apache2").
- and_return(@current_data)
+ with("#{@cookbook_api_url}/apache2").
+ and_return(@current_data)
end
context "when the cookbook is deprecated and not forced" do
@@ -47,9 +47,9 @@ describe Chef::Knife::CookbookSiteDownload do
it "should warn with info about the replacement" do
expect(@knife.ui).to receive(:warn).
- with(/.+deprecated.+replaced by other_apache2.+/i)
+ with(/.+deprecated.+replaced by other_apache2.+/i)
expect(@knife.ui).to receive(:warn).
- with(/use --force.+download.+/i)
+ with(/use --force.+download.+/i)
@knife.run
end
end
@@ -58,7 +58,7 @@ describe Chef::Knife::CookbookSiteDownload do
before do
@cookbook_data = { "version" => @version,
"file" => "http://example.com/apache2_#{@version_us}.tgz" }
- @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" )
+ @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" )
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
expect(@noauth_rest).to receive(:sign_on_redirect=).with(false)
@@ -67,11 +67,11 @@ describe Chef::Knife::CookbookSiteDownload do
context "downloading the latest version" do
before do
expect(@noauth_rest).to receive(:get).
- with(@current_data["latest_version"]).
- and_return(@cookbook_data)
+ with(@current_data["latest_version"]).
+ and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data["file"], true).
- and_return(@temp_file)
+ with(@cookbook_data["file"], true).
+ and_return(@temp_file)
end
context "and it is deprecated and with --force" do
@@ -82,7 +82,7 @@ describe Chef::Knife::CookbookSiteDownload do
it "should download the latest version" do
expect(@knife.ui).to receive(:warn).
- with(/.+deprecated.+replaced by other_apache2.+/i)
+ with(/.+deprecated.+replaced by other_apache2.+/i)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
@@ -132,11 +132,11 @@ describe Chef::Knife::CookbookSiteDownload do
it "should download the desired version" do
expect(@noauth_rest).to receive(:get).
- with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
- and_return(@cookbook_data)
+ with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
+ and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data["file"], true).
- and_return(@temp_file)
+ with(@cookbook_data["file"], true).
+ and_return(@temp_file)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb
index 051a3ed168..662b53dd29 100644
--- a/spec/unit/knife/cookbook_site_share_spec.rb
+++ b/spec/unit/knife/cookbook_site_share_spec.rb
@@ -145,8 +145,8 @@ describe Chef::Knife::CookbookSiteShare do
it "should list files in the tarball" do
allow(@knife).to receive(:tar_cmd).and_return("footar")
- expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", {:cwd => "/var/tmp/dummy"})
- expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", {:cwd => "/var/tmp/dummy"})
+ expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { :cwd => "/var/tmp/dummy" })
+ expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { :cwd => "/var/tmp/dummy" })
@knife.run
end
@@ -172,7 +172,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it 'should post the cookbook to "https://supermarket.chef.io"' do
- response_text = Chef::JSONCompat.to_json({:uri => "https://supermarket.chef.io/cookbooks/cookbook_name"})
+ response_text = Chef::JSONCompat.to_json({ :uri => "https://supermarket.chef.io/cookbooks/cookbook_name" })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(201)
expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything())
@@ -180,7 +180,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should alert the user when a version already exists" do
- response_text = Chef::JSONCompat.to_json({:error_messages => ["Version already exists"]})
+ response_text = Chef::JSONCompat.to_json({ :error_messages => ["Version already exists"] })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(409)
expect { @knife.run }.to raise_error(SystemExit)
@@ -188,7 +188,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should pass any errors on to the user" do
- response_text = Chef::JSONCompat.to_json({:error_messages => ["You're holding it wrong"]})
+ response_text = Chef::JSONCompat.to_json({ :error_messages => ["You're holding it wrong"] })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(403)
expect { @knife.run }.to raise_error(SystemExit)
@@ -196,7 +196,7 @@ describe Chef::Knife::CookbookSiteShare do
end
it "should print the body if no errors are exposed on failure" do
- response_text = Chef::JSONCompat.to_json({:system_error => "Your call was dropped", :reason => "There's a map for that"})
+ response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(500)
expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered
diff --git a/spec/unit/knife/cookbook_test_spec.rb b/spec/unit/knife/cookbook_test_spec.rb
index 841ebe5f6f..abb88fe739 100644
--- a/spec/unit/knife/cookbook_test_spec.rb
+++ b/spec/unit/knife/cookbook_test_spec.rb
@@ -23,9 +23,9 @@ Chef::Knife::CookbookTest.load_deps
describe Chef::Knife::CookbookTest do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::CookbookTest.new
- @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA,"cookbooks")
+ @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA, "cookbooks")
allow(@knife.cookbook_loader).to receive(:cookbook_exists?).and_return(true)
@cookbooks = []
%w{tats central_market jimmy_johns pho}.each do |cookbook_name|
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index 1445f8c086..dc55a709b7 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Knife::CookbookUpload do
let(:cookbook) { Chef::CookbookVersion.new("test_cookbook", "/tmp/blah.txt") }
let(:cookbooks_by_name) do
- {cookbook.name => cookbook}
+ { cookbook.name => cookbook }
end
let(:cookbook_loader) do
@@ -62,8 +62,8 @@ describe Chef::Knife::CookbookUpload do
allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook)
allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"])
expect(Chef::CookbookUploader).to receive(:new).
- with( kind_of(Array), { :force => nil, :concurrency => 3}).
- and_return(double("Chef::CookbookUploader", :upload_cookbooks=> true))
+ with( kind_of(Array), { :force => nil, :concurrency => 3 }).
+ and_return(double("Chef::CookbookUploader", :upload_cookbooks => true))
knife.run
end
end
@@ -107,12 +107,12 @@ describe Chef::Knife::CookbookUpload do
before do
allow(cookbook_loader).to receive(:merged_cookbooks).and_return(["test_cookbook"])
allow(cookbook_loader).to receive(:merged_cookbook_paths).
- and_return({"test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook}})
+ and_return({ "test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook} })
end
it "emits a warning" do
knife.run
- expected_message=<<-E
+ expected_message = <<-E
WARNING: The cookbooks: test_cookbook exist in multiple places in your cookbook_path.
A composite version of these cookbooks has been compiled for uploading.
@@ -196,9 +196,9 @@ E
before(:each) do
cookbook.metadata.depends("dependency")
- allow(cookbook_loader).to receive(:[]) do |ckbk|
+ allow(cookbook_loader).to receive(:[]) do |ckbk|
{ "test_cookbook" => cookbook,
- "dependency" => cookbook_dependency}[ckbk]
+ "dependency" => cookbook_dependency }[ckbk]
end
allow(knife).to receive(:cookbook_names).and_return(["cookbook_dependency", "test_cookbook"])
@stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new
@@ -209,11 +209,11 @@ E
expect(cookbook_loader).to receive(:[]).once.with("test_cookbook")
expect(cookbook_loader).not_to receive(:load_cookbooks)
expect(cookbook_uploader).not_to receive(:upload_cookbooks)
- expect {knife.run}.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "should output a message for a single missing dependency" do
- expect {knife.run}.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently")
expect(@stderr.string).to include("being uploaded and cannot be found on the server.")
expect(@stderr.string).to include("The missing cookbook(s) are: 'dependency' version '>= 0.0.0'")
@@ -222,13 +222,13 @@ E
it "should output a message for a multiple missing dependencies which are concatenated" do
cookbook_dependency2 = Chef::CookbookVersion.new("dependency2")
cookbook.metadata.depends("dependency2")
- allow(cookbook_loader).to receive(:[]) do |ckbk|
+ allow(cookbook_loader).to receive(:[]) do |ckbk|
{ "test_cookbook" => cookbook,
"dependency" => cookbook_dependency,
- "dependency2" => cookbook_dependency2}[ckbk]
+ "dependency2" => cookbook_dependency2 }[ckbk]
end
allow(knife).to receive(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"])
- expect {knife.run}.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently")
expect(@stderr.string).to include("being uploaded and cannot be found on the server.")
expect(@stderr.string).to include("The missing cookbook(s) are:")
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 16c0867610..efcc2659dd 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Knife::Core::BootstrapContext do
Chef::Config[:fips] = false
end
- let(:config) { {:foo => :bar, :color => true} }
+ let(:config) { { :foo => :bar, :color => true } }
let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") }
let(:chef_config) do
{
@@ -41,7 +41,7 @@ describe Chef::Knife::Core::BootstrapContext do
subject(:bootstrap_context) { described_class.new(config, run_list, chef_config, secret) }
it "initializes with Chef 11 parameters" do
- expect{described_class.new(config, run_list, chef_config)}.not_to raise_error
+ expect { described_class.new(config, run_list, chef_config) }.not_to raise_error
end
it "runs chef with the first-boot.json with no environment specified" do
@@ -49,14 +49,14 @@ describe Chef::Knife::Core::BootstrapContext do
end
describe "when in verbosity mode" do
- let(:config) { {:verbosity => 2, :color => true} }
+ let(:config) { { :verbosity => 2, :color => true } }
it "adds '-l debug' when verbosity is >= 2" do
expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug"
end
end
describe "when no color value has been set in config" do
- let(:config) { {:color => false } }
+ let(:config) { { :color => false } }
it "adds '--no-color' when color is false" do
expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json --no-color"
end
@@ -67,7 +67,7 @@ describe Chef::Knife::Core::BootstrapContext do
end
it "generates the config file data" do
- expected=<<-EXPECTED
+ expected = <<-EXPECTED
log_location STDOUT
chef_server_url "http://chef.example.com:4444"
validation_client_name "chef-validator-testing"
@@ -81,14 +81,14 @@ EXPECTED
end
describe "alternate chef-client path" do
- let(:chef_config){ {:chef_client_path => "/usr/local/bin/chef-client"} }
+ let(:chef_config) { { :chef_client_path => "/usr/local/bin/chef-client" } }
it "runs chef-client from another path when specified" do
expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json"
end
end
describe "validation key path that contains a ~" do
- let(:chef_config){ {:validation_key => "~/my.key"} }
+ let(:chef_config) { { :validation_key => "~/my.key" } }
it "reads the validation key when it contains a ~" do
expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV["HOME"])).and_return(true)
expect(IO).to receive(:read).with(File.expand_path("my.key", ENV["HOME"]))
@@ -97,36 +97,36 @@ EXPECTED
end
describe "when an explicit node name is given" do
- let(:config){ {:chef_node_name => "foobar.example.com" }}
+ let(:config) { { :chef_node_name => "foobar.example.com" } }
it "sets the node name in the client.rb" do
expect(bootstrap_context.config_content).to match(/node_name "foobar\.example\.com"/)
end
end
describe "when bootstrapping into a specific environment" do
- let(:config){ {:environment => "prodtastic", :color => true} }
+ let(:config) { { :environment => "prodtastic", :color => true } }
it "starts chef in the configured environment" do
expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic")
end
end
describe "when tags are given" do
- let(:config) { {:tags => [ "unicorn" ] } }
+ let(:config) { { :tags => [ "unicorn" ] } }
it "adds the attributes to first_boot" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:run_list => run_list, :tags => ["unicorn"]}))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list, :tags => ["unicorn"] }))
end
end
describe "when JSON attributes are given" do
- let(:config) { {:first_boot_attributes => {:baz => :quux}} }
+ let(:config) { { :first_boot_attributes => { :baz => :quux } } }
it "adds the attributes to first_boot" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list}))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :baz => :quux, :run_list => run_list }))
end
end
describe "when JSON attributes are NOT given" do
it "sets first_boot equal to run_list" do
- expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:run_list => run_list}))
+ expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list }))
end
end
@@ -160,7 +160,7 @@ EXPECTED
describe "when a bootstrap_version is specified" do
let(:chef_config) do
{
- :knife => {:bootstrap_version => "11.12.4" }
+ :knife => { :bootstrap_version => "11.12.4" }
}
end
@@ -172,7 +172,7 @@ EXPECTED
describe "when a pre-release bootstrap_version is specified" do
let(:chef_config) do
{
- :knife => {:bootstrap_version => "11.12.4.rc.0" }
+ :knife => { :bootstrap_version => "11.12.4.rc.0" }
}
end
@@ -196,7 +196,7 @@ EXPECTED
describe "when configured in config" do
let(:chef_config) do
{
- :knife => {:ssl_verify_mode => :verify_peer}
+ :knife => { :ssl_verify_mode => :verify_peer }
}
end
@@ -205,7 +205,7 @@ EXPECTED
end
describe "when configured via CLI" do
- let(:config) {{:node_ssl_verify_mode => "none"}}
+ let(:config) { { :node_ssl_verify_mode => "none" } }
it "uses CLI value" do
expect(bootstrap_context.config_content).to include("ssl_verify_mode :verify_none")
@@ -222,7 +222,7 @@ EXPECTED
describe "when configured in config" do
let(:chef_config) do
{
- :knife => {:verify_api_cert => :false}
+ :knife => { :verify_api_cert => :false }
}
end
@@ -231,7 +231,7 @@ EXPECTED
end
describe "when configured via CLI" do
- let(:config) {{:node_verify_api_cert => true}}
+ let(:config) { { :node_verify_api_cert => true } }
it "uses CLI value" do
expect(bootstrap_context.config_content).to include("verify_api_cert true")
@@ -246,7 +246,7 @@ EXPECTED
end
describe "when configured via cli" do
- let(:config) {{:prerelease => true}}
+ let(:config) { { :prerelease => true } }
it "uses CLI value" do
expect(bootstrap_context.latest_current_chef_version_string).to eq("-p")
diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
index d1f5aeef85..137bdddafb 100644
--- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb
+++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
@@ -49,7 +49,7 @@ BRANCHES
describe "when sanity checking the repo" do
it "exits when the directory does not exist" do
expect(::File).to receive(:directory?).with(@repo_path).and_return(false)
- expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
+ expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
describe "and the repo dir exists" do
@@ -59,7 +59,7 @@ BRANCHES
it "exits when there is no git repo" do
allow(::File).to receive(:directory?).with(/.*\.git/).and_return(false)
- expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
+ expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
describe "and the repo is a git repo" do
@@ -68,9 +68,9 @@ BRANCHES
end
it "exits when the default branch doesn't exist" do
- @nobranches = Mixlib::ShellOut.new.tap {|s|s.stdout.replace "\n"}
+ @nobranches = Mixlib::ShellOut.new.tap { |s| s.stdout.replace "\n" }
expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches)
- expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
+ expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
describe "and the default branch exists" do
@@ -86,12 +86,12 @@ BRANCHES
M chef/lib/chef/knife/cookbook_site_vendor.rb
DIRTY
expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status)
- expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
+ expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit)
end
describe "and the repo is clean" do
before do
- @clean_status = Mixlib::ShellOut.new.tap {|s| s.stdout.replace("\n")}
+ @clean_status = Mixlib::ShellOut.new.tap { |s| s.stdout.replace("\n") }
allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status)
end
diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb
index 9fd880a810..69a40ebaed 100644
--- a/spec/unit/knife/core/gem_glob_loader_spec.rb
+++ b/spec/unit/knife/core/gem_glob_loader_spec.rb
@@ -18,14 +18,14 @@
require "spec_helper"
describe Chef::Knife::SubcommandLoader::GemGlobLoader do
- let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) }
- let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") }
- let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
+ let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) }
+ let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") }
+ let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
- before do
- allow(ChefConfig).to receive(:windows?) { false }
- Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
- end
+ before do
+ allow(ChefConfig).to receive(:windows?) { false }
+ Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
+ end
after do
Chef::Util::PathHelper.class_variable_set(:@@home_dir, nil)
@@ -40,7 +40,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
it "finds files installed via rubygems" do
expect(loader.find_subcommands_via_rubygems).to include("chef/knife/node_create")
- loader.find_subcommands_via_rubygems.each {|rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+})}
+ loader.find_subcommands_via_rubygems.each { |rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+}) }
end
it "finds files from latest version of installed gems" do
@@ -65,7 +65,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
it "finds files using a dirglob when rubygems is not available" do
expect(loader.find_subcommands_via_dirglob).to include("chef/knife/node_create")
- loader.find_subcommands_via_dirglob.each {|rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+})}
+ loader.find_subcommands_via_dirglob.each { |rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+}) }
end
it "finds user-specific subcommands in the user's ~/.chef directory" do
@@ -178,7 +178,6 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
allow(ENV).to receive(:[]).with("HOME").and_return(env_home)
end
-
it "searches rubygems for plugins" do
if Gem::Specification.respond_to?(:latest_specs)
expect(Gem::Specification).to receive(:latest_specs).and_call_original
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index ca9aeec60c..d9f5e5761c 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -47,11 +47,11 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
describe "#list_commands" do
it "lists all commands by category when no argument is given" do
- expect(loader.list_commands).to eq({"cool" => ["cool_a"], "cooler" => ["cooler_b"]})
+ expect(loader.list_commands).to eq({ "cool" => ["cool_a"], "cooler" => ["cooler_b"] })
end
it "lists only commands in the given category when a category is given" do
- expect(loader.list_commands("cool")).to eq({"cool" => ["cool_a"]})
+ expect(loader.list_commands("cool")).to eq({ "cool" => ["cool_a"] })
end
end
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index e64faebf6b..32ce402e19 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -43,7 +43,7 @@ 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
+ "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)
@@ -74,7 +74,7 @@ describe Chef::Knife::NodeEditor do
expect(ui).to have_received(:warn)
.with "Changing the name of a node results in a new node being " +
- "created, test_node will not be modified or removed."
+ "created, test_node will not be modified or removed."
expect(ui).to have_received(:confirm)
.with("Proceed with creation of new node")
@@ -189,7 +189,7 @@ describe Chef::Knife::NodeEditor do
end
it 'returns an array of property names that doesn\'t include ' +
- "the non-editable properties" do
+ "the non-editable properties" do
expect(subject.updated?).to eql %w{ normal policy_name policy_group run_list }
end
end
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 13fd304a2e..d2381f60cb 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Knife::UI do
context "when editing is disabled" do
before do
@ui.config[:disable_editing] = true
- stub_const("Tempfile", double) # Tempfiles should never be invoked
+ stub_const("Tempfile", double) # Tempfiles should never be invoked
end
context "when parse_output is false" do
it "returns pretty json string" do
@@ -97,7 +97,7 @@ describe Chef::Knife::UI do
expect(IO).not_to receive(:read)
end
it "throws an exception" do
- expect{ subject }.to raise_error(RuntimeError)
+ expect { subject }.to raise_error(RuntimeError)
end
end
context "when running the editor fails with false" do
@@ -106,7 +106,7 @@ describe Chef::Knife::UI do
expect(IO).not_to receive(:read)
end
it "throws an exception" do
- expect{ subject }.to raise_error(RuntimeError)
+ expect { subject }.to raise_error(RuntimeError)
end
end
end
@@ -166,20 +166,20 @@ describe Chef::Knife::UI do
it "should throw Errno::EIO exceptions" do
allow(@out).to receive(:puts).and_raise(Errno::EIO)
allow(@err).to receive(:puts).and_raise(Errno::EIO)
- expect {@ui.send(method, "hi")}.to raise_error(Errno::EIO)
+ expect { @ui.send(method, "hi") }.to raise_error(Errno::EIO)
end
it "should ignore Errno::EPIPE exceptions (CHEF-3516)" do
allow(@out).to receive(:puts).and_raise(Errno::EPIPE)
allow(@err).to receive(:puts).and_raise(Errno::EPIPE)
- expect {@ui.send(method, "hi")}.to raise_error(SystemExit)
+ expect { @ui.send(method, "hi") }.to raise_error(SystemExit)
end
it "should throw Errno::EPIPE exceptions with -VV (CHEF-3516)" do
@config[:verbosity] = 2
allow(@out).to receive(:puts).and_raise(Errno::EPIPE)
allow(@err).to receive(:puts).and_raise(Errno::EPIPE)
- expect {@ui.send(method, "hi")}.to raise_error(Errno::EPIPE)
+ expect { @ui.send(method, "hi") }.to raise_error(Errno::EPIPE)
end
end
@@ -192,7 +192,7 @@ describe Chef::Knife::UI do
end
it "formats hashes appropriately" do
- @ui.output({"hi" => "a", "lo" => "b" })
+ @ui.output({ "hi" => "a", "lo" => "b" })
expect(@out.string).to eq <<EOM
hi: a
lo: b
@@ -318,7 +318,7 @@ EOM
end
it "formats hashes with empty hash values appropriately" do
- @ui.output({ "a" => { }, "b" => "c" })
+ @ui.output({ "a" => {}, "b" => "c" })
expect(@out.string).to eq <<EOM
a:
b: c
@@ -354,7 +354,7 @@ EOM
it "should return multiple attributes" do
input = { "gi" => "go", "hi" => "ho", "id" => "sample-data-bag-item" }
@ui.config[:attribute] = ["gi", "hi"]
- expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi"=> "ho" } })
+ expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi" => "ho" } })
end
it "should handle attributes named the same as methods" do
@@ -364,7 +364,7 @@ EOM
end
it "should handle nested attributes named the same as methods" do
- input = { "keys" => {"keys" => "values"}, "hi" => "ho", "id" => "sample-data-bag-item" }
+ input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" }
@ui.config[:attribute] = "keys.keys"
expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "keys.keys" => "values" } })
end
@@ -373,11 +373,11 @@ EOM
allow_any_instance_of(Chef::Node).to receive(:name).and_return("chef.localdomain")
input = Chef::Node.new
@ui.config[:attribute] = "name"
- expect(@ui.format_for_display(input)).to eq( {"chef.localdomain"=>{"name"=>"chef.localdomain"} })
+ expect(@ui.format_for_display(input)).to eq( { "chef.localdomain" => { "name" => "chef.localdomain" } })
end
it "returns nil when given an attribute path that isn't a name or attribute" do
- input = { "keys" => {"keys" => "values"}, "hi" => "ho", "id" => "sample-data-bag-item" }
+ input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" }
non_existing_path = "nope.nada.nothingtoseehere"
@ui.config[:attribute] = non_existing_path
expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { non_existing_path => nil } })
@@ -420,10 +420,10 @@ EOM
describe "with --with-uri" do
it "should return the URIs" do
response = {
- "cookbook_name"=>{
+ "cookbook_name" => {
"1.0.0" => "http://url/cookbooks/1.0.0",
"2.0.0" => "http://url/cookbooks/2.0.0",
- "3.0.0" => "http://url/cookbooks/3.0.0"}
+ "3.0.0" => "http://url/cookbooks/3.0.0" }
}
@ui.config[:with_uri] = true
expect(@ui.format_cookbook_list_for_display(@item)).to eq(response)
@@ -460,8 +460,8 @@ EOM
end
describe "confirm" do
- let(:stdout) {StringIO.new}
- let(:output) {stdout.string}
+ let(:stdout) { StringIO.new }
+ let(:output) { stdout.string }
let(:question) { "monkeys rule" }
let(:answer) { "y" }
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index 9356974735..b852c30401 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Knife::DataBagCreate do
let(:secret) { "abc123SECRET" }
- let(:raw_hash) {{ "login_name" => "alphaomega", "id" => item_name }}
+ let(:raw_hash) { { "login_name" => "alphaomega", "id" => item_name } }
let(:config) { {} }
@@ -49,7 +49,7 @@ describe Chef::Knife::DataBagCreate do
it "tries to create a data bag with an invalid name when given one argument" do
knife.name_args = ["invalid&char"]
expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName)
- expect {knife.run}.to exit_with_code(1)
+ expect { knife.run }.to exit_with_code(1)
end
context "when given one argument" do
@@ -58,7 +58,7 @@ describe Chef::Knife::DataBagCreate do
end
it "creates a data bag" do
- expect(rest).to receive(:post).with("data", {"name" => bag_name})
+ expect(rest).to receive(:post).with("data", { "name" => bag_name })
expect(knife.ui).to receive(:info).with("Created data_bag[#{bag_name}]")
knife.run
@@ -75,7 +75,7 @@ describe Chef::Knife::DataBagCreate do
it "creates a data bag item" do
expect(knife).to receive(:create_object).and_yield(raw_hash)
expect(knife).to receive(:encryption_secret_provided?).and_return(false)
- expect(rest).to receive(:post).with("data", {"name" => bag_name}).ordered
+ expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered
expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered
knife.run
@@ -99,7 +99,7 @@ describe Chef::Knife::DataBagCreate do
.to receive(:encrypt_data_bag_item)
.with(raw_hash, secret)
.and_return(encoded_data)
- expect(rest).to receive(:post).with("data", {"name" => bag_name}).ordered
+ expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered
expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered
knife.run
diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb
index 42558c5cbd..1001e68ce4 100644
--- a/spec/unit/knife/data_bag_edit_spec.rb
+++ b/spec/unit/knife/data_bag_edit_spec.rb
@@ -33,9 +33,9 @@ describe Chef::Knife::DataBagEdit do
k
end
- let(:raw_hash) { {"login_name" => "alphaomega", "id" => "item_name"} }
- let(:db) { Chef::DataBagItem.from_hash(raw_hash)}
- let(:raw_edited_hash) { {"login_name" => "rho", "id" => "item_name", "new_key" => "new_value"} }
+ let(:raw_hash) { { "login_name" => "alphaomega", "id" => "item_name" } }
+ let(:db) { Chef::DataBagItem.from_hash(raw_hash) }
+ let(:raw_edited_hash) { { "login_name" => "rho", "id" => "item_name", "new_key" => "new_value" } }
let(:rest) { double("Chef::ServerAPI") }
let(:stdout) { StringIO.new }
@@ -65,7 +65,7 @@ describe Chef::Knife::DataBagEdit do
it "requires data bag and item arguments" do
knife.name_args = []
expect(stdout).to receive(:puts).twice.with(anything)
- expect {knife.run}.to exit_with_code(1)
+ expect { knife.run }.to exit_with_code(1)
expect(stdout.string).to eq("")
end
@@ -74,7 +74,7 @@ describe Chef::Knife::DataBagEdit do
end
context "when config[:print_after] is set" do
- let(:config) { {:print_after => true} }
+ let(:config) { { :print_after => true } }
before do
expect(knife.ui).to receive(:output).with(raw_edited_hash)
end
@@ -121,7 +121,7 @@ describe Chef::Knife::DataBagEdit do
expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(false)
expect(knife.ui).to receive(:fatal).with("You cannot edit an encrypted data bag without providing the secret.")
- expect {knife.run}.to exit_with_code(1)
+ expect { knife.run }.to exit_with_code(1)
end
end
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index 4a31c480c0..0b6f389e87 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -75,7 +75,7 @@ describe Chef::Knife::DataBagFromFile do
let(:plain_data) { {
"id" => "item_name",
"greeting" => "hello",
- "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true }},
+ "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
} }
let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) }
@@ -164,7 +164,7 @@ describe Chef::Knife::DataBagFromFile do
describe "command line parsing" do
it "prints help if given no arguments" do
knife.name_args = [bag_name]
- expect {knife.run}.to exit_with_code(1)
+ expect { knife.run }.to exit_with_code(1)
expect(stdout.string).to start_with("knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)")
end
end
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 489949a0e9..4637e34ba1 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -45,10 +45,10 @@ describe Chef::Knife::DataBagShow do
let(:bag_name) { "sudoing_admins" }
let(:item_name) { "ME" }
- let(:data_bag_contents) { { "id" => "id", "baz"=>"http://localhost:4000/data/bag_o_data/baz",
- "qux"=>"http://localhost:4000/data/bag_o_data/qux"} }
- 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_contents) { { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
+ "qux" => "http://localhost:4000/data/bag_o_data/qux" } }
+ 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) }
let(:enc_data_bag) { Chef::EncryptedDataBagItem.new(enc_hash, secret) }
@@ -56,7 +56,7 @@ describe Chef::Knife::DataBagShow do
#
# let(:raw_hash) {{ "login_name" => "alphaomega", "id" => item_name }}
#
- let(:config) { {format: "json"} }
+ let(:config) { { format: "json" } }
context "Data bag to show is encrypted" do
before do
@@ -116,7 +116,7 @@ qux: http://localhost:4000/data/bag_o_data/qux}
it "raises an error when no @name_args are provided" do
knife.name_args = []
- expect {knife.run}.to exit_with_code(1)
+ expect { knife.run }.to exit_with_code(1)
expect(stdout.string).to start_with("knife data bag show BAG [ITEM] (options)")
end
diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb
index 5d4a71d3a4..7a341192be 100644
--- a/spec/unit/knife/environment_compare_spec.rb
+++ b/spec/unit/knife/environment_compare_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::EnvironmentCompare do
before(:each) do
@knife = Chef::Knife::EnvironmentCompare.new
-
+
@environments = {
"cita" => "http://localhost:4000/environments/cita",
"citm" => "http://localhost:4000/environments/citm",
@@ -33,10 +33,10 @@ describe Chef::Knife::EnvironmentCompare do
"cita" => { "foo" => "= 1.0.1", "bar" => "= 0.0.4" },
"citm" => { "foo" => "= 1.0.1", "bar" => "= 0.0.2" },
}
-
+
allow(@knife).to receive(:constraint_list).and_return(@constraints)
- @cookbooks = { "foo"=>"= 1.0.1", "bar"=>"= 0.0.1" }
+ @cookbooks = { "foo" => "= 1.0.1", "bar" => "= 0.0.1" }
allow(@knife).to receive(:cookbook_list).and_return(@cookbooks)
@@ -46,10 +46,10 @@ describe Chef::Knife::EnvironmentCompare do
@base_url = "https://server.example.com/cookbooks"
@cookbook_data = {}
@cookbook_names.each do |item|
- @cookbook_data[item] = {"url" => "#{@base_url}/#{item}",
- "versions" => [{"version" => "1.0.1",
- "url" => "#{@base_url}/#{item}/1.0.1"}]}
- end
+ @cookbook_data[item] = { "url" => "#{@base_url}/#{item}",
+ "versions" => [{ "version" => "1.0.1",
+ "url" => "#{@base_url}/#{item}/1.0.1" }] }
+ end
allow(@rest_double).to receive(:get).with("/cookbooks?num_versions=1").and_return(@cookbook_data)
@@ -65,7 +65,7 @@ describe Chef::Knife::EnvironmentCompare do
expect(@stdout.string).to match /#{item}/ and expect(@stdout.string.lines.count).to be 4
end
end
-
+
it "should display 4 number of lines" do
@knife.config[:format] = "summary"
@knife.run
@@ -90,7 +90,7 @@ describe Chef::Knife::EnvironmentCompare do
expect(@stdout.string.lines.count).to be 3
end
end
-
+
describe "with -a or --all" do
it "should display all cookbooks" do
@knife.config[:format] = "summary"
diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb
index afabc0051f..4505da3637 100644
--- a/spec/unit/knife/environment_from_file_spec.rb
+++ b/spec/unit/knife/environment_from_file_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Knife::EnvironmentFromFile do
@environment = Chef::Environment.new
@environment.name("spec")
@environment.description("runs the unit tests")
- @environment.cookbook_versions({"apt" => "= 1.2.3"})
+ @environment.cookbook_versions({ "apt" => "= 1.2.3" })
allow(@environment).to receive(:save).and_return true
allow(@knife.loader).to receive(:load_from).and_return @environment
end
@@ -61,7 +61,7 @@ describe Chef::Knife::EnvironmentFromFile do
allow(File).to receive(:expand_path).with("./environments/").and_return("/tmp/environments")
allow(Dir).to receive(:glob).with("/tmp/environments/*.{json,rb}").and_return(["spec.rb", "apple.rb"])
@knife.name_args = []
- allow(@knife).to receive(:config).and_return({:all => true})
+ allow(@knife).to receive(:config).and_return({ :all => true })
expect(@environment).to receive(:save).twice
@knife.run
end
diff --git a/spec/unit/knife/environment_list_spec.rb b/spec/unit/knife/environment_list_spec.rb
index 2ee11e91dc..636b32273e 100644
--- a/spec/unit/knife/environment_list_spec.rb
+++ b/spec/unit/knife/environment_list_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentList do
end
it "should print the environment names in a sorted list" do
- names = @environments.keys.sort { |a,b| a <=> b }
+ names = @environments.keys.sort { |a, b| a <=> b }
expect(@knife).to receive(:output).with(names)
@knife.run
end
diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb
index 1e9803c4b7..97a3a69155 100644
--- a/spec/unit/knife/index_rebuild_spec.rb
+++ b/spec/unit/knife/index_rebuild_spec.rb
@@ -20,8 +20,8 @@ require "spec_helper"
describe Chef::Knife::IndexRebuild do
- let(:knife){Chef::Knife::IndexRebuild.new}
- let(:rest_client){double(Chef::ServerAPI)}
+ let(:knife) { Chef::Knife::IndexRebuild.new }
+ let(:rest_client) { double(Chef::ServerAPI) }
let(:stub_rest!) do
expect(knife).to receive(:rest).and_return(rest_client)
@@ -49,14 +49,14 @@ describe Chef::Knife::IndexRebuild do
end
context "against a Chef 11 server" do
- let(:api_header_value){"flavor=osc;version=11.0.0;erchef=1.2.3"}
+ let(:api_header_value) { "flavor=osc;version=11.0.0;erchef=1.2.3" }
it "retrieves API information" do
- expect(knife.grab_api_info).to eq({"flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3"})
+ expect(knife.grab_api_info).to eq({ "flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3" })
end
end # Chef 11
context "against a Chef 10 server" do
- let(:api_header_value){nil}
+ let(:api_header_value) { nil }
it "finds no API information" do
expect(knife.grab_api_info).to eq({})
end
@@ -66,11 +66,11 @@ describe Chef::Knife::IndexRebuild do
context "#unsupported_version?" do
context "with Chef 11 API metadata" do
it "is unsupported" do
- expect(knife.unsupported_version?({"version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy
+ expect(knife.unsupported_version?({ "version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3" })).to be_truthy
end
it "only truly relies on the version being non-nil" do
- expect(knife.unsupported_version?({"version" => "1", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy
+ expect(knife.unsupported_version?({ "version" => "1", "flavor" => "osc", "erchef" => "1.2.3" })).to be_truthy
end
end
@@ -91,7 +91,7 @@ describe Chef::Knife::IndexRebuild do
context "against a Chef 11 server" do
let(:api_info) do
- {"flavor" => "osc",
+ { "flavor" => "osc",
"version" => "11.0.0",
"erchef" => "1.2.3",
}
@@ -107,7 +107,7 @@ describe Chef::Knife::IndexRebuild do
end
context "against a Chef 10 server" do
- let(:api_info){ {} }
+ let(:api_info) { {} }
let(:server_specific_stubs!) do
stub_rest!
expect(rest_client).to receive(:post).with("/search/reindex", {}).and_return("representative output")
@@ -123,6 +123,3 @@ describe Chef::Knife::IndexRebuild do
end
end
-
-
-
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 1b9e551df7..1647b14dc2 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -95,7 +95,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
context "when public_key and key_name weren't passed" do
it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do
- expect{ key_create_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_create_object.public_key_or_key_name_error_msg)
+ expect { key_create_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_create_object.public_key_or_key_name_error_msg)
end
end
@@ -221,4 +221,3 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
end
end
-
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index 0f09ec9c3d..3da5a9762a 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -45,8 +45,8 @@ describe "key delete commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyDelete with the correct args" do
expect(Chef::Knife::KeyDelete).to receive(:new).
- with("charmander-key", "charmander", command.actor_field_name, command.ui).
- and_return(service_object)
+ with("charmander-key", "charmander", command.actor_field_name, command.ui).
+ and_return(service_object)
command.service_object
end
end # when the service object is called
@@ -117,7 +117,6 @@ describe Chef::Knife::KeyDelete do
end
end # when the command is run
-
end # key delete run command
context "when actor_field_name is 'user'" do
@@ -132,4 +131,3 @@ describe Chef::Knife::KeyDelete do
end
end
end
-
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 3a9689d4d1..0fc7208139 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -45,8 +45,8 @@ describe "key edit commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyEdit with the correct args" do
expect(Chef::Knife::KeyEdit).to receive(:new).
- with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config).
- and_return(service_object)
+ with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config).
+ and_return(service_object)
command.service_object
end
end # when the service object is called
@@ -114,7 +114,6 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
allow(key_edit_object).to receive(:display_info)
end
-
context "when public_key and create_key are passed" do
before do
key_edit_object.config[:public_key] = "public_key_path"
@@ -122,7 +121,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do
- expect{ key_edit_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_edit_object.public_key_and_create_key_error_msg)
+ expect { key_edit_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_edit_object.public_key_and_create_key_error_msg)
end
end
@@ -249,8 +248,6 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end # when the command is run
-
-
end # key edit run command
context "when actor_field_name is 'user'" do
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 989deac76e..2d4f0a07bb 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -98,7 +98,7 @@ describe Chef::Knife::KeyList do
end
it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do
- expect{ key_list_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_list_object.expired_and_non_expired_msg)
+ expect { key_list_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_list_object.expired_and_non_expired_msg)
end
end
@@ -193,9 +193,9 @@ describe Chef::Knife::KeyList do
let(:list_method) { :list_by_user }
let(:http_response) {
[
- {"uri"=>"https://api.opscode.piab/users/charmander/keys/non-expired1", "name"=>"non-expired1", "expired"=>false},
- {"uri"=>"https://api.opscode.piab/users/charmander/keys/non-expired2", "name"=>"non-expired2", "expired"=>false},
- {"uri"=>"https://api.opscode.piab/users/mary/keys/out-of-date", "name"=>"out-of-date", "expired"=>true},
+ { "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
+ { "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
+ { "uri" => "https://api.opscode.piab/users/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
}
end
@@ -206,9 +206,9 @@ describe Chef::Knife::KeyList do
let(:list_method) { :list_by_client }
let(:http_response) {
[
- {"uri"=>"https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired1", "name"=>"non-expired1", "expired"=>false},
- {"uri"=>"https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired2", "name"=>"non-expired2", "expired"=>false},
- {"uri"=>"https://api.opscode.piab/organizations/pokemon/clients/mary/keys/out-of-date", "name"=>"out-of-date", "expired"=>true},
+ { "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
+ { "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
+ { "uri" => "https://api.opscode.piab/organizations/pokemon/clients/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
}
end
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index 0681ad8b72..c161efbe0d 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -45,8 +45,8 @@ describe "key show commands that inherit knife" do
context "when the service object is called" do
it "creates a new instance of Chef::Knife::KeyShow with the correct args" do
expect(Chef::Knife::KeyShow).to receive(:new).
- with("charmander-key", "charmander", command.load_method, command.ui).
- and_return(service_object)
+ with("charmander-key", "charmander", command.load_method, command.ui).
+ and_return(service_object)
command.service_object
end
end # when the service object is called
diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb
index 8744787ef6..2a3563e563 100644
--- a/spec/unit/knife/node_bulk_delete_spec.rb
+++ b/spec/unit/knife/node_bulk_delete_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Knife::NodeBulkDelete do
before(:each) do
Chef::Log.logger = Logger.new(StringIO.new)
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeBulkDelete.new
@knife.name_args = ["."]
@stdout = StringIO.new
@@ -37,14 +37,14 @@ describe Chef::Knife::NodeBulkDelete do
describe "when creating the list of nodes" do
it "fetches the node list" do
expected = @nodes.inject({}) do |inflatedish, (name, uri)|
- inflatedish[name] = Chef::Node.new.tap {|n| n.name(name)}
+ inflatedish[name] = Chef::Node.new.tap { |n| n.name(name) }
inflatedish
end
expect(Chef::Node).to receive(:list).and_return(@nodes)
# 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 { |n| n.name }).to match_array(%w{adam brent jacob})
end
end
@@ -92,6 +92,3 @@ describe Chef::Knife::NodeBulkDelete do
end
end
-
-
-
diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb
index da4c44a651..e2cda8751f 100644
--- a/spec/unit/knife/node_delete_spec.rb
+++ b/spec/unit/knife/node_delete_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeDelete do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeDelete.new
@knife.config = {
:print_after => nil
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index 2cf6633574..dedb5c949d 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::NodeEdit do
end
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeEdit.new
@knife.config = {
:editor => "cat",
@@ -46,10 +46,10 @@ describe Chef::Knife::NodeEdit do
describe "after loading the node" do
before do
allow(@knife).to receive(:node).and_return(@node)
- @node.automatic_attrs = {:go => :away}
- @node.default_attrs = {:hide => :me}
- @node.override_attrs = {:dont => :show}
- @node.normal_attrs = {:do_show => :these}
+ @node.automatic_attrs = { :go => :away }
+ @node.default_attrs = { :hide => :me }
+ @node.override_attrs = { :dont => :show }
+ @node.normal_attrs = { :do_show => :these }
@node.chef_environment("prod")
@node.run_list("recipe[foo]")
end
@@ -59,7 +59,7 @@ describe Chef::Knife::NodeEdit do
expect(actual).not_to have_key("automatic")
expect(actual).not_to have_key("override")
expect(actual).not_to have_key("default")
- expect(actual["normal"]).to eq({"do_show" => "these"})
+ expect(actual["normal"]).to eq({ "do_show" => "these" })
expect(actual["run_list"]).to eq(["recipe[foo]"])
expect(actual["chef_environment"]).to eq("prod")
end
@@ -68,10 +68,10 @@ describe Chef::Knife::NodeEdit do
@knife.config[:all_attributes] = true
actual = deserialized_json_view
- expect(actual["automatic"]).to eq({"go" => "away"})
- expect(actual["override"]).to eq({"dont" => "show"})
- expect(actual["default"]).to eq({"hide" => "me"})
- expect(actual["normal"]).to eq({"do_show" => "these"})
+ expect(actual["automatic"]).to eq({ "go" => "away" })
+ expect(actual["override"]).to eq({ "dont" => "show" })
+ expect(actual["default"]).to eq({ "hide" => "me" })
+ expect(actual["normal"]).to eq({ "do_show" => "these" })
expect(actual["run_list"]).to eq(["recipe[foo]"])
expect(actual["chef_environment"]).to eq("prod")
end
@@ -101,15 +101,14 @@ describe Chef::Knife::NodeEdit do
it "raises an exception when editing is disabled" do
@knife.config[:disable_editing] = true
- expect{ subject }.to raise_error(SystemExit)
+ expect { subject }.to raise_error(SystemExit)
end
it "raises an exception when the editor is not set" do
@knife.config[:editor] = nil
- expect{ subject }.to raise_error(SystemExit)
+ expect { subject }.to raise_error(SystemExit)
end
end
end
-
diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index 7fba0cf841..13dd3762a2 100644
--- a/spec/unit/knife/node_environment_set_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeEnvironmentSet do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeEnvironmentSet.new
@knife.name_args = [ "adam", "bar" ]
allow(@knife).to receive(:output).and_return(true)
diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb
index 728483e22d..89b2b8156f 100644
--- a/spec/unit/knife/node_from_file_spec.rb
+++ b/spec/unit/knife/node_from_file_spec.rb
@@ -22,7 +22,7 @@ Chef::Knife::NodeFromFile.load_deps
describe Chef::Knife::NodeFromFile do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeFromFile.new
@knife.config = {
:print_after => nil
diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb
index 3112e0b804..ab17a45795 100644
--- a/spec/unit/knife/node_list_spec.rb
+++ b/spec/unit/knife/node_list_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeList do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
Chef::Config[:environment] = nil # reset this value each time, as it is not reloaded
@knife = Chef::Knife::NodeList.new
allow(@knife).to receive(:output).and_return(true)
@@ -60,4 +60,3 @@ describe Chef::Knife::NodeList do
end
end
end
-
diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb
index 6bdaee6915..eb897c146b 100644
--- a/spec/unit/knife/node_run_list_add_spec.rb
+++ b/spec/unit/knife/node_run_list_add_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeRunListAdd do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeRunListAdd.new
@knife.config = {
:after => nil
@@ -143,6 +143,3 @@ describe Chef::Knife::NodeRunListAdd do
end
end
end
-
-
-
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index 54f8625898..e741f513eb 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeRunListRemove do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeRunListRemove.new
@knife.config[:print_after] = nil
@knife.name_args = [ "adam", "role[monkey]" ]
diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb
index 11d3be7e84..1bbaa7d9a5 100644
--- a/spec/unit/knife/node_run_list_set_spec.rb
+++ b/spec/unit/knife/node_run_list_set_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::NodeRunListSet do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeRunListSet.new
@knife.config = {}
@knife.name_args = [ "adam", "role[monkey]" ]
diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb
index a69c133a0e..9202998fb9 100644
--- a/spec/unit/knife/raw_spec.rb
+++ b/spec/unit/knife/raw_spec.rb
@@ -36,7 +36,7 @@ describe Chef::Knife::Raw do
knife.config[:proxy_auth] = true
expect(rest).to receive(:request).with(:GET, "/nodes",
{ "Content-Type" => "application/json",
- "x-ops-request-source" => "web"}, false)
+ "x-ops-request-source" => "web" }, false)
knife.run
end
end
diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb
index 75edab8aa9..9a4a1a0bc7 100644
--- a/spec/unit/knife/role_bulk_delete_spec.rb
+++ b/spec/unit/knife/role_bulk_delete_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::RoleBulkDelete do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleBulkDelete.new
@knife.config = {
:print_after => nil
diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb
index 765cec7882..d414e5a18d 100644
--- a/spec/unit/knife/role_create_spec.rb
+++ b/spec/unit/knife/role_create_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::RoleCreate do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleCreate.new
@knife.config = {
:description => nil
diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb
index 3251ddd81c..cc65674a08 100644
--- a/spec/unit/knife/role_delete_spec.rb
+++ b/spec/unit/knife/role_delete_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::RoleDelete do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleDelete.new
@knife.config = {
:print_after => nil
diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb
index 5f4ed1eb8e..71d6980670 100644
--- a/spec/unit/knife/role_edit_spec.rb
+++ b/spec/unit/knife/role_edit_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::RoleEdit do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleEdit.new
@knife.config[:print_after] = nil
@knife.name_args = [ "adam" ]
@@ -75,5 +75,3 @@ describe Chef::Knife::RoleEdit do
end
end
end
-
-
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 0831abd845..fe4cb6d057 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -7,9 +7,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -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
@@ -180,7 +180,7 @@ describe Chef::Knife::RoleEnvRunListAdd do
expect(@role.run_list[1]).to be_nil
end
end
-
+
describe "with more than one command" do
it "should be able to the environment run list by running multiple knife commands" do
@knife.name_args = [ "will", "QA", "role[blue]," ]
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 831a23b71b..1fb2f1f1c7 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -21,8 +21,8 @@ require "spec_helper"
describe Chef::Knife::RoleEnvRunListClear do
before(:each) do
- Chef::Config[:role_name] = "will"
- Chef::Config[:env_name] = "QA"
+ Chef::Config[:role_name] = "will"
+ Chef::Config[:env_name] = "QA"
@setup = Chef::Knife::RoleEnvRunListAdd.new
@setup.name_args = [ "will", "QA", "role[monkey]", "role[person]" ]
@@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListClear do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -57,44 +54,41 @@ describe Chef::Knife::RoleEnvRunListClear do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list_for("QA")[0]).to be_nil
- expect(@role.run_list[0]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list_for("QA")[0]).to be_nil
+ expect(@role.run_list[0]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "should clear an environmental run list of roles and recipes" do
- it "should remove the items from the run list" do
- @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will", "QA" ]
- @knife.run
- expect(@role.run_list_for("QA")[0]).to be_nil
- expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
- expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
- expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
- expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
- expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
- end
- end
+ describe "should clear an environmental run list of roles and recipes" do
+ it "should remove the items from the run list" do
+ @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will", "QA" ]
+ @knife.run
+ expect(@role.run_list_for("QA")[0]).to be_nil
+ expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
+ expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
+ expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
+ expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
+ expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
+ end
+ end
end
end
-
-
-
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 39f4a78e28..180dbf1d43 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -21,8 +21,8 @@ require "spec_helper"
describe Chef::Knife::RoleEnvRunListRemove do
before(:each) do
- Chef::Config[:role_name] = "will"
- Chef::Config[:env_name] = "QA"
+ Chef::Config[:role_name] = "will"
+ Chef::Config[:env_name] = "QA"
@setup = Chef::Knife::RoleEnvRunListAdd.new
@setup.name_args = [ "will", "QA", "role[monkey]", "role[person]" ]
@@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListRemove do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -57,52 +54,49 @@ describe Chef::Knife::RoleEnvRunListRemove do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list_for("QA")[0]).not_to eq("role[monkey]")
- expect(@role.run_list_for("QA")[0]).to eq("role[person]")
- expect(@role.run_list[0]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list_for("QA")[0]).not_to eq("role[monkey]")
+ expect(@role.run_list_for("QA")[0]).to eq("role[person]")
+ expect(@role.run_list[0]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "run with a list of roles and recipes" do
- it "should remove the items from the run list" do
- @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will", "QA", "role[monkey]" ]
- @knife.run
- @knife.name_args = [ "will", "QA", "recipe[duck::type]" ]
- @knife.run
- expect(@role.run_list_for("QA")).not_to include("role[monkey]")
- expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]")
- expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list_for("QA")[1]).to eq("role[person]")
- expect(@role.run_list_for("QA")[2]).to eq("role[bird]")
- expect(@role.run_list_for("QA")[3]).to eq("role[town]")
- expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
- expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
- expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
- expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
- expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
- end
- end
+ describe "run with a list of roles and recipes" do
+ it "should remove the items from the run list" do
+ @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will", "QA", "role[monkey]" ]
+ @knife.run
+ @knife.name_args = [ "will", "QA", "recipe[duck::type]" ]
+ @knife.run
+ expect(@role.run_list_for("QA")).not_to include("role[monkey]")
+ expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]")
+ expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[person]")
+ expect(@role.run_list_for("QA")[2]).to eq("role[bird]")
+ expect(@role.run_list_for("QA")[3]).to eq("role[town]")
+ expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
+ expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
+ expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
+ expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
+ expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
+ end
+ end
end
end
-
-
-
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 537ede29ce..fcfbe99e7c 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -21,8 +21,8 @@ require "spec_helper"
describe Chef::Knife::RoleEnvRunListReplace do
before(:each) do
- Chef::Config[:role_name] = "will"
- Chef::Config[:env_name] = "QA"
+ Chef::Config[:role_name] = "will"
+ Chef::Config[:env_name] = "QA"
@setup = Chef::Knife::RoleEnvRunListAdd.new
@setup.name_args = [ "will", "QA", "role[monkey]", "role[dude]", "role[fixer]" ]
@@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListReplace do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -57,52 +54,52 @@ describe Chef::Knife::RoleEnvRunListReplace do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list_for("QA")[1]).not_to eq("role[dude]")
- expect(@role.run_list_for("QA")[1]).to eq("role[person]")
- expect(@role.run_list[0]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list_for("QA")[1]).not_to eq("role[dude]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[person]")
+ expect(@role.run_list[0]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "run with a list of roles and recipes" do
- it "should replace the items from the run list" do
- @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ]
- @knife.run
- @knife.name_args = [ "will", "QA", "recipe[duck::type]", "recipe[duck::mallard]" ]
- @knife.run
- expect(@role.run_list_for("QA")).not_to include("role[monkey]")
- expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]")
- expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list_for("QA")[1]).to eq("role[gibbon]")
- expect(@role.run_list_for("QA")[2]).to eq("recipe[duck::mallard]")
- expect(@role.run_list_for("QA")[3]).to eq("role[person]")
- expect(@role.run_list_for("QA")[4]).to eq("role[bird]")
- expect(@role.run_list_for("QA")[5]).to eq("role[town]")
- expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
- expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
- expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
- expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
- expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
- expect(@role.run_list[0]).to be_nil
- end
- end
+ describe "run with a list of roles and recipes" do
+ it "should replace the items from the run list" do
+ @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ]
+ @knife.run
+ @knife.name_args = [ "will", "QA", "recipe[duck::type]", "recipe[duck::mallard]" ]
+ @knife.run
+ expect(@role.run_list_for("QA")).not_to include("role[monkey]")
+ expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]")
+ expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[gibbon]")
+ expect(@role.run_list_for("QA")[2]).to eq("recipe[duck::mallard]")
+ expect(@role.run_list_for("QA")[3]).to eq("role[person]")
+ expect(@role.run_list_for("QA")[4]).to eq("role[bird]")
+ expect(@role.run_list_for("QA")[5]).to eq("role[town]")
+ expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]")
+ expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]")
+ expect(@role.run_list_for("PRD")[3]).to eq("role[person]")
+ expect(@role.run_list_for("PRD")[4]).to eq("role[bird]")
+ expect(@role.run_list_for("PRD")[5]).to eq("role[town]")
+ expect(@role.run_list[0]).to be_nil
+ end
+ end
end
end
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 83a665c34f..6fb187447d 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -21,8 +21,8 @@ require "spec_helper"
describe Chef::Knife::RoleEnvRunListSet do
before(:each) do
- Chef::Config[:role_name] = "will"
- Chef::Config[:env_name] = "QA"
+ Chef::Config[:role_name] = "will"
+ Chef::Config[:env_name] = "QA"
@setup = Chef::Knife::RoleEnvRunListAdd.new
@setup.name_args = [ "will", "QA", "role[monkey]", "role[person]", "role[bucket]" ]
@@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListSet do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -60,8 +57,8 @@ describe Chef::Knife::RoleEnvRunListSet do
it "should replace all the items in the runlist with what is specified" do
@setup.run
@knife.run
- expect(@role.run_list_for("QA")[0]).to eq("role[owen]")
- expect(@role.run_list_for("QA")[1]).to eq("role[mauntel]")
+ expect(@role.run_list_for("QA")[0]).to eq("role[owen]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[mauntel]")
expect(@role.run_list_for("QA")[2]).to be_nil
expect(@role.run_list[0]).to be_nil
end
diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb
index 1660026b1a..741ff99741 100644
--- a/spec/unit/knife/role_from_file_spec.rb
+++ b/spec/unit/knife/role_from_file_spec.rb
@@ -22,7 +22,7 @@ Chef::Knife::RoleFromFile.load_deps
describe Chef::Knife::RoleFromFile do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleFromFile.new
@knife.config = {
:print_after => nil
diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb
index daf2645aef..bfbba30288 100644
--- a/spec/unit/knife/role_list_spec.rb
+++ b/spec/unit/knife/role_list_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Knife::RoleList do
before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::RoleList.new
allow(@knife).to receive(:output).and_return(true)
@list = {
@@ -52,5 +52,3 @@ describe Chef::Knife::RoleList do
end
end
end
-
-
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index ac5202da22..419fbdfedb 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -7,9 +7,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -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
@@ -162,7 +162,7 @@ describe Chef::Knife::RoleRunListAdd do
expect(@role.run_list[2]).to be_nil
end
end
-
+
describe "with more than one command" do
it "should be able to the environment run list by running multiple knife commands" do
@knife.name_args = [ "will", "role[blue]," ]
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index 5e1a388c75..61dfc8fa89 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::RoleRunListClear do
before(:each) do
- Chef::Config[:role_name] = "will"
+ Chef::Config[:role_name] = "will"
@setup = Chef::Knife::RoleRunListAdd.new
@setup.name_args = [ "will", "role[monkey]", "role[person]" ]
@@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListClear do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -56,35 +53,32 @@ describe Chef::Knife::RoleRunListClear do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list[0]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list[0]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "should clear an environmental run list of roles and recipes" do
- it "should remove the items from the run list" do
- @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will" ]
- @knife.run
- expect(@role.run_list[0]).to be_nil
- end
- end
+ describe "should clear an environmental run list of roles and recipes" do
+ it "should remove the items from the run list" do
+ @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will" ]
+ @knife.run
+ expect(@role.run_list[0]).to be_nil
+ end
+ end
end
end
-
-
-
diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb
index f3cc38e616..704c3d3cb4 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::RoleRunListRemove do
before(:each) do
- Chef::Config[:role_name] = "will"
+ Chef::Config[:role_name] = "will"
@setup = Chef::Knife::RoleRunListAdd.new
@setup.name_args = [ "will", "role[monkey]", "role[person]" ]
@@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListRemove do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -56,43 +53,40 @@ describe Chef::Knife::RoleRunListRemove do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list[0]).to eq("role[person]")
- expect(@role.run_list[1]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list[0]).to eq("role[person]")
+ expect(@role.run_list[1]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "run with a list of roles and recipes" do
- it "should remove the items from the run list" do
- @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will", "role[monkey]" ]
- @knife.run
- @knife.name_args = [ "will", "recipe[duck::type]" ]
- @knife.run
- expect(@role.run_list).not_to include("role[monkey]")
- expect(@role.run_list).not_to include("recipe[duck::type]")
- expect(@role.run_list[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list[1]).to eq("role[person]")
- expect(@role.run_list[2]).to eq("role[bird]")
- expect(@role.run_list[3]).to eq("role[town]")
- end
- end
+ describe "run with a list of roles and recipes" do
+ it "should remove the items from the run list" do
+ @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will", "role[monkey]" ]
+ @knife.run
+ @knife.name_args = [ "will", "recipe[duck::type]" ]
+ @knife.run
+ expect(@role.run_list).not_to include("role[monkey]")
+ expect(@role.run_list).not_to include("recipe[duck::type]")
+ expect(@role.run_list[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list[1]).to eq("role[person]")
+ expect(@role.run_list[2]).to eq("role[bird]")
+ expect(@role.run_list[3]).to eq("role[town]")
+ end
+ end
end
end
-
-
-
diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb
index 74f648a372..91e4993630 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::RoleRunListReplace do
before(:each) do
- Chef::Config[:role_name] = "will"
+ Chef::Config[:role_name] = "will"
@setup = Chef::Knife::RoleRunListAdd.new
@setup.name_args = [ "will", "role[monkey]", "role[dude]", "role[fixer]" ]
@@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListReplace do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -56,46 +53,46 @@ describe Chef::Knife::RoleRunListReplace do
@knife.run
end
- it "should remove the item from the run list" do
- @setup.run
- @knife.run
- expect(@role.run_list[0]).to eq("role[monkey]")
- expect(@role.run_list[1]).not_to eq("role[dude]")
- expect(@role.run_list[1]).to eq("role[person]")
- expect(@role.run_list[2]).to eq("role[fixer]")
- expect(@role.run_list[3]).to be_nil
- end
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ expect(@role.run_list[0]).to eq("role[monkey]")
+ expect(@role.run_list[1]).not_to eq("role[dude]")
+ expect(@role.run_list[1]).to eq("role[person]")
+ expect(@role.run_list[2]).to eq("role[fixer]")
+ expect(@role.run_list[3]).to be_nil
+ end
- it "should save the node" do
- expect(@role).to receive(:save).and_return(true)
- @knife.run
- end
+ it "should save the node" do
+ expect(@role).to receive(:save).and_return(true)
+ @knife.run
+ end
- it "should print the run list" do
- expect(@knife).to receive(:output).and_return(true)
- @knife.config[:print_after] = true
- @setup.run
- @knife.run
- end
+ it "should print the run list" do
+ expect(@knife).to receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
- describe "run with a list of roles and recipes" do
- it "should replace the items from the run list" do
- @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
- @setup.run
- @knife.name_args = [ "will", "role[monkey]", "role[gibbon]" ]
- @knife.run
- @knife.name_args = [ "will", "recipe[duck::type]", "recipe[duck::mallard]" ]
- @knife.run
- expect(@role.run_list).not_to include("role[monkey]")
- expect(@role.run_list).not_to include("recipe[duck::type]")
- expect(@role.run_list[0]).to eq("recipe[orange::chicken]")
- expect(@role.run_list[1]).to eq("role[gibbon]")
- expect(@role.run_list[2]).to eq("recipe[duck::mallard]")
- expect(@role.run_list[3]).to eq("role[person]")
- expect(@role.run_list[4]).to eq("role[bird]")
- expect(@role.run_list[5]).to eq("role[town]")
- expect(@role.run_list[6]).to be_nil
- end
- end
+ describe "run with a list of roles and recipes" do
+ it "should replace the items from the run list" do
+ @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ "will", "role[monkey]", "role[gibbon]" ]
+ @knife.run
+ @knife.name_args = [ "will", "recipe[duck::type]", "recipe[duck::mallard]" ]
+ @knife.run
+ expect(@role.run_list).not_to include("role[monkey]")
+ expect(@role.run_list).not_to include("recipe[duck::type]")
+ expect(@role.run_list[0]).to eq("recipe[orange::chicken]")
+ expect(@role.run_list[1]).to eq("role[gibbon]")
+ expect(@role.run_list[2]).to eq("recipe[duck::mallard]")
+ expect(@role.run_list[3]).to eq("role[person]")
+ expect(@role.run_list[4]).to eq("role[bird]")
+ expect(@role.run_list[5]).to eq("role[town]")
+ expect(@role.run_list[6]).to be_nil
+ end
+ end
end
end
diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb
index 5207f631d4..ad088e5d0f 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Knife::RoleRunListSet do
before(:each) do
- Chef::Config[:role_name] = "will"
+ Chef::Config[:role_name] = "will"
@setup = Chef::Knife::RoleRunListAdd.new
@setup.name_args = [ "will", "role[monkey]", "role[person]", "role[bucket]" ]
@@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListSet do
end
-
-
describe "run" do
-
# it "should display all the things" do
# @knife.run
# @role.to_json.should == 'show all the things'
@@ -59,8 +56,8 @@ describe Chef::Knife::RoleRunListSet do
it "should replace all the items in the runlist with what is specified" do
@setup.run
@knife.run
- expect(@role.run_list[0]).to eq("role[owen]")
- expect(@role.run_list[1]).to eq("role[mauntel]")
+ expect(@role.run_list[0]).to eq("role[owen]")
+ expect(@role.run_list[1]).to eq("role[mauntel]")
expect(@role.run_list[2]).to be_nil
end
diff --git a/spec/unit/knife/role_show_spec.rb b/spec/unit/knife/role_show_spec.rb
index 657c508f10..fe48e2f940 100644
--- a/spec/unit/knife/role_show_spec.rb
+++ b/spec/unit/knife/role_show_spec.rb
@@ -40,14 +40,14 @@ describe Chef::Knife::RoleShow do
knife.config[:format] = "json"
stdout = StringIO.new
allow(knife.ui).to receive(:stdout).and_return(stdout)
- fake_role_contents = {"foo"=>"bar", "baz"=>"qux"}
+ fake_role_contents = { "foo" => "bar", "baz" => "qux" }
expect(Chef::Role).to receive(:load).with("base").and_return(fake_role_contents)
knife.run
expect(stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n")
end
context "without a role name" do
- let(:role) { }
+ let(:role) {}
it "should print usage and exit when a role name is not provided" do
expect(knife).to receive(:show_usage)
diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb
index 5fed92ffa5..3a8728515d 100644
--- a/spec/unit/knife/ssh_spec.rb
+++ b/spec/unit/knife/ssh_spec.rb
@@ -114,10 +114,10 @@ describe Chef::Knife::Ssh do
end
it "should raise an error if no host are found" do
- configure_query([ ])
- expect(@knife.ui).to receive(:fatal)
- expect(@knife).to receive(:exit).with(10)
- @knife.configure_session
+ configure_query([ ])
+ expect(@knife.ui).to receive(:fatal)
+ expect(@knife).to receive(:exit).with(10)
+ @knife.configure_session
end
context "when there are some hosts found but they do not have an attribute to connect with" do
@@ -170,26 +170,26 @@ describe Chef::Knife::Ssh do
expect(@knife.get_ssh_attribute(@node_foo)).to eq("cloud.public_hostname")
end
- it "should favor to attribute_from_cli over config file and cloud" do
+ it "should favor to attribute_from_cli over config file and cloud" do
@knife.config[:attribute] = "command_line"
Chef::Config[:knife][:ssh_attribute] = "config_file"
expect( @knife.get_ssh_attribute(@node_foo)).to eq("command_line")
end
- it "should favor config file over cloud and default" do
+ it "should favor config file over cloud and default" do
Chef::Config[:knife][:ssh_attribute] = "config_file"
expect( @knife.get_ssh_attribute(@node_foo)).to eq("config_file")
end
it "should return fqdn if cloud.hostname is empty" do
- expect( @knife.get_ssh_attribute(@node_bar)).to eq("fqdn")
+ expect( @knife.get_ssh_attribute(@node_bar)).to eq("fqdn")
end
end
describe "#session_from_list" do
before :each do
@knife.instance_variable_set(:@longest, 0)
- ssh_config = {:timeout => 50, :user => "locutus", :port => 23 }
+ ssh_config = { :timeout => 50, :user => "locutus", :port => 23 }
allow(Net::SSH).to receive(:configuration_for).with("the.b.org").and_return(ssh_config)
end
@@ -211,10 +211,10 @@ describe Chef::Knife::Ssh do
describe "#ssh_command" do
let(:execution_channel) { double(:execution_channel, :on_data => nil) }
- let(:session_channel) { double(:session_channel, :request_pty => nil)}
+ let(:session_channel) { double(:session_channel, :request_pty => nil) }
let(:execution_channel2) { double(:execution_channel, :on_data => nil) }
- let(:session_channel2) { double(:session_channel, :request_pty => nil)}
+ let(:session_channel2) { double(:session_channel, :request_pty => nil) }
let(:session) { double(:session, :loop => nil) }
@@ -309,14 +309,14 @@ describe Chef::Knife::Ssh do
context "when setting ssh_password_ng from knife ssh" do
# in this case ssh_password_ng exists, but ssh_password does not
- it "should prompt for a password when ssh_passsword_ng is nil" do
+ it "should prompt for a password when ssh_passsword_ng is nil" do
@knife.config[:ssh_password_ng] = nil
expect(@knife).to receive(:get_password).and_return("mysekretpassw0rd")
@knife.configure_password
expect(@knife.config[:ssh_password]).to eq("mysekretpassw0rd")
end
- it "should set ssh_password to false if ssh_password_ng is false" do
+ it "should set ssh_password to false if ssh_password_ng is false" do
@knife.config[:ssh_password_ng] = false
expect(@knife).not_to receive(:get_password)
@knife.configure_password
@@ -360,14 +360,14 @@ describe Chef::Knife::Ssh do
end
context "when setting ssh_password_ng from knife ssh" do
# in this case ssh_password_ng exists, but ssh_password does not
- it "should prompt for a password when ssh_passsword_ng is nil" do
+ it "should prompt for a password when ssh_passsword_ng is nil" do
@knife.config[:ssh_password_ng] = nil
expect(@knife).to receive(:get_password).and_return("mysekretpassw0rd")
@knife.configure_password
expect(@knife.config[:ssh_password]).to eq("mysekretpassw0rd")
end
- it "should set ssh_password to the configured knife.rb value if ssh_password_ng is false" do
+ it "should set ssh_password to the configured knife.rb value if ssh_password_ng is false" do
@knife.config[:ssh_password_ng] = false
expect(@knife).not_to receive(:get_password)
@knife.configure_password
diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb
index c7ca98d2dc..180d798d5b 100644
--- a/spec/unit/knife/ssl_check_spec.rb
+++ b/spec/unit/knife/ssl_check_spec.rb
@@ -67,10 +67,10 @@ describe Chef::Knife::SslCheck do
it "prints an error and exits" do
expect { ssl_check.run }.to raise_error(SystemExit)
- expected_stdout=<<-E
+ expected_stdout = <<-E
USAGE: knife ssl check [URL] (options)
E
- expected_stderr=<<-E
+ expected_stderr = <<-E
ERROR: Given URI: `foo.test' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
@@ -83,10 +83,10 @@ E
it "prints an error and exits" do
expect { ssl_check.run }.to raise_error(SystemExit)
- expected_stdout=<<-E
+ expected_stdout = <<-E
USAGE: knife ssl check [URL] (options)
E
- expected_stderr=<<-E
+ expected_stderr = <<-E
ERROR: Given URI: `#{name_args[0]}' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb
index 4f31285fca..8bb4810b88 100644
--- a/spec/unit/knife/ssl_fetch_spec.rb
+++ b/spec/unit/knife/ssl_fetch_spec.rb
@@ -68,10 +68,10 @@ describe Chef::Knife::SslFetch do
it "prints an error and exits" do
expect { ssl_fetch.run }.to raise_error(SystemExit)
- expected_stdout=<<-E
+ expected_stdout = <<-E
USAGE: knife ssl fetch [URL] (options)
E
- expected_stderr=<<-E
+ expected_stderr = <<-E
ERROR: Given URI: `foo.test' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
@@ -84,10 +84,10 @@ E
it "prints an error and exits" do
expect { ssl_fetch.run }.to raise_error(SystemExit)
- expected_stdout=<<-E
+ expected_stdout = <<-E
USAGE: knife ssl fetch [URL] (options)
E
- expected_stderr=<<-E
+ expected_stderr = <<-E
ERROR: Given URI: `#{name_args[0]}' is invalid
E
expect(stdout_io.string).to eq(expected_stdout)
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 536a5c317a..473598fd85 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -34,10 +34,10 @@ describe Chef::Knife::Status do
end
describe "run" do
- let(:opts) {{filter_result:
+ let(:opts) {{ 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"]}}}
+ ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
+ platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }}
it "should default to searching for everything" do
expect(@query).to receive(:search).with(:node, "*:*", opts)
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index 7983df8b41..5ab77d2df6 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -47,12 +47,12 @@ describe Chef::Knife::UserCreate do
it "displays the osc warning" do
expect(knife.ui).to receive(:warn).with(knife.osc_11_warning)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "calls knife osc_user create" do
expect(knife).to receive(:run_osc_11_user_create)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
end
@@ -186,7 +186,7 @@ describe Chef::Knife::UserCreate do
context "when a private_key is returned" do
before do
- allow(knife).to receive(:create_user_from_hash).and_return(Chef::UserV1.from_hash(knife.user.to_hash.merge({"private_key" => "some_private_key"})))
+ allow(knife).to receive(:create_user_from_hash).and_return(Chef::UserV1.from_hash(knife.user.to_hash.merge({ "private_key" => "some_private_key" })))
end
context "when --file is passed" do
diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb
index de37797d3c..0f71b39a41 100644
--- a/spec/unit/knife/user_delete_spec.rb
+++ b/spec/unit/knife/user_delete_spec.rb
@@ -41,12 +41,12 @@ describe Chef::Knife::UserDelete do
it "displays the osc warning" do
expect(knife.ui).to receive(:warn).with(knife.osc_11_warning)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "forwards the command to knife osc_user edit" do
expect(knife).to receive(:run_osc_11_user_delete)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
end
diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb
index d7db1aac29..ec118ed181 100644
--- a/spec/unit/knife/user_edit_spec.rb
+++ b/spec/unit/knife/user_edit_spec.rb
@@ -36,17 +36,17 @@ describe Chef::Knife::UserEdit do
context "when the username field is not supported by the server" do
before do
allow(knife).to receive(:run_osc_11_user_edit).and_raise(SystemExit)
- allow(Chef::UserV1).to receive(:load).and_return({"username" => nil})
+ allow(Chef::UserV1).to receive(:load).and_return({ "username" => nil })
end
it "displays the osc warning" do
expect(knife.ui).to receive(:warn).with(knife.osc_11_warning)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "forwards the command to knife osc_user edit" do
expect(knife).to receive(:run_osc_11_user_edit)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
end
diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb
index cc85578bf6..d650ff9fb8 100644
--- a/spec/unit/knife/user_reregister_spec.rb
+++ b/spec/unit/knife/user_reregister_spec.rb
@@ -41,12 +41,12 @@ describe Chef::Knife::UserReregister do
it "displays the osc warning" do
expect(knife.ui).to receive(:warn).with(knife.osc_11_warning)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "forwards the command to knife osc_user edit" do
expect(knife).to receive(:run_osc_11_user_reregister)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
end
diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb
index b82e3e2640..3a38161b34 100644
--- a/spec/unit/knife/user_show_spec.rb
+++ b/spec/unit/knife/user_show_spec.rb
@@ -41,12 +41,12 @@ describe Chef::Knife::UserShow do
it "displays the osc warning" do
expect(knife.ui).to receive(:warn).with(knife.osc_11_warning)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
it "forwards the command to knife osc_user edit" do
expect(knife).to receive(:run_osc_11_user_show)
- expect{ knife.run }.to raise_error(SystemExit)
+ expect { knife.run }.to raise_error(SystemExit)
end
end
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 62c1b4c4eb..698ae205f1 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Knife do
before(:each) do
Chef::Log.logger = Logger.new(StringIO.new)
- Chef::Config[:node_name] = "webmonkey.example.com"
+ Chef::Config[:node_name] = "webmonkey.example.com"
allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
allow(config_loader).to receive(:explicit_config_file=)
@@ -152,14 +152,14 @@ describe Chef::Knife do
describe "the headers include X-Remote-Request-Id" do
- let(:headers) {{"Accept"=>"application/json",
- "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
- "X-Chef-Version" => Chef::VERSION,
- "Host"=>"api.opscode.piab",
- "X-REMOTE-REQUEST-ID"=>request_id,
+ let(:headers) {{ "Accept" => "application/json",
+ "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
+ "X-Chef-Version" => Chef::VERSION,
+ "Host" => "api.opscode.piab",
+ "X-REMOTE-REQUEST-ID" => request_id,
}}
- let(:request_id) {"1234"}
+ let(:request_id) { "1234" }
let(:request_mock) { {} }
@@ -216,10 +216,10 @@ describe Chef::Knife do
it "merges the global knife CLI options" do
extra_opts = {}
- extra_opts[:editor] = {:long=>"--editor EDITOR",
- :description=>"Set the editor to use for interactive commands",
- :short=>"-e EDITOR",
- :default=>"/usr/bin/vim"}
+ extra_opts[:editor] = { :long => "--editor EDITOR",
+ :description => "Set the editor to use for interactive commands",
+ :short => "-e EDITOR",
+ :default => "/usr/bin/vim" }
# there is special hackery to return the subcommand instance going on here.
command = Chef::Knife.run(%w{test yourself}, extra_opts)
@@ -252,7 +252,7 @@ describe Chef::Knife do
allow(Chef::Knife.ui).to receive(:stderr).and_return(stderr)
allow(Chef::Knife.ui).to receive(:stdout).and_return(stdout)
expect(Chef::Knife.ui).to receive(:fatal)
- expect {Chef::Knife.run(%w{fuuu uuuu fuuuu})}.to raise_error(SystemExit) { |e| expect(e.status).not_to eq(0) }
+ expect { Chef::Knife.run(%w{fuuu uuuu fuuuu}) }.to raise_error(SystemExit) { |e| expect(e.status).not_to eq(0) }
end
it "loads lazy dependencies" do
@@ -508,7 +508,7 @@ describe Chef::Knife do
knife.run_with_pretty_exceptions
- expected_message=<<-MSG
+ expected_message = <<-MSG
ERROR: Could not establish a secure connection to the server.
Use `knife ssl check` to troubleshoot your SSL configuration.
If your Chef Server uses a self-signed certificate, you can use
diff --git a/spec/unit/log/winevt_spec.rb b/spec/unit/log/winevt_spec.rb
index 288962863c..d5d452159b 100644
--- a/spec/unit/log/winevt_spec.rb
+++ b/spec/unit/log/winevt_spec.rb
@@ -20,7 +20,7 @@
require "spec_helper"
describe Chef::Log::WinEvt do
- let(:evtlog) { instance_double("Win32::EventLog")}
+ let(:evtlog) { instance_double("Win32::EventLog") }
let(:winevt) { Chef::Log::WinEvt.new(evtlog) }
let(:app) { Chef::Application.new }
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index e18ab135a5..5afd838551 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -202,7 +202,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 { |m| m.to_sym }).to include(:monkey)
end
it "should build attribute methods that respect validation rules" do
@@ -246,8 +246,8 @@ describe "LWRP" do
let(:klass) do
Class.new(Chef::Resource::LWRPBase) do
self.resource_name = :sample_resource
- attribute :food, :default => lazy { "BACON!"*3 }
- attribute :drink, :default => lazy { |r| "Drink after #{r.food}!"}
+ attribute :food, :default => lazy { "BACON!" * 3 }
+ attribute :drink, :default => lazy { |r| "Drink after #{r.food}!" }
end
end
@@ -718,5 +718,3 @@ describe "LWRP" do
end
end
end
-
-
diff --git a/spec/unit/mash_spec.rb b/spec/unit/mash_spec.rb
index 838aabbd73..e58f6b85a1 100644
--- a/spec/unit/mash_spec.rb
+++ b/spec/unit/mash_spec.rb
@@ -21,7 +21,7 @@ require "chef/mash"
describe Mash do
it "should duplicate a simple key/value mash to a new mash" do
- data = {:x=>"one", :y=>"two", :z=>"three"}
+ data = { :x => "one", :y => "two", :z => "three" }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
@@ -30,21 +30,21 @@ describe Mash do
end
it "should duplicate a mash with an array to a new mash" do
- data = {:x=>"one", :y=>"two", :z=>[1,2,3]}
+ data = { :x => "one", :y => "two", :z => [1, 2, 3] }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
@copy[:z] << 4
- expect(@orig[:z]).to eq([1,2,3])
+ expect(@orig[:z]).to eq([1, 2, 3])
end
it "should duplicate a nested mash to a new mash" do
- data = {:x=>"one", :y=>"two", :z=>Mash.new({:a=>[1,2,3]})}
+ data = { :x => "one", :y => "two", :z => Mash.new({ :a => [1, 2, 3] }) }
@orig = Mash.new(data)
@copy = @orig.dup
expect(@copy.to_hash).to eq(Mash.new(data).to_hash)
@copy[:z][:a] << 4
- expect(@orig[:z][:a]).to eq([1,2,3])
+ expect(@orig[:z][:a]).to eq([1, 2, 3])
end
# add more!
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index 0768072814..13b729538c 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -23,8 +23,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:object) { dummy_class.new }
describe ".server_client_api_version_intersection" do
- let(:default_supported_client_versions) { [0,1,2] }
-
+ let(:default_supported_client_versions) { [0, 1, 2] }
context "when the response code is not 406" do
let(:response) { OpenStruct.new(:code => "405") }
@@ -78,13 +77,13 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when all the versions are higher than the max" do
it_should_behave_like "no intersection between client and server versions" do
- let(:supported_client_versions) { [5,6,7] }
+ let(:supported_client_versions) { [5, 6, 7] }
end
end
context "when all the versions are lower than the min" do
it_should_behave_like "no intersection between client and server versions" do
- let(:supported_client_versions) { [0,1] }
+ let(:supported_client_versions) { [0, 1] }
end
end
@@ -92,16 +91,16 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when there is an intersection between client and server versions" do
context "when multiple versions intersect" do
- let(:supported_client_versions) { [1,2,3,4,5] }
+ let(:supported_client_versions) { [1, 2, 3, 4, 5] }
it "includes all of the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to eq([2,3,4])
+ to eq([2, 3, 4])
end
end # when multiple versions intersect
context "when only the min client version intersects" do
- let(:supported_client_versions) { [0,1,2] }
+ let(:supported_client_versions) { [0, 1, 2] }
it "includes the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
@@ -110,7 +109,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
end # when only the min client version intersects
context "when only the max client version intersects" do
- let(:supported_client_versions) { [4,5,6] }
+ let(:supported_client_versions) { [4, 5, 6] }
it "includes the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index 8b8284a867..997dcd523e 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -38,4 +38,3 @@ describe Chef::Mixin::Checksum do
end
end
-
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb
index dfe7b148ec..0c2f6da188 100644
--- a/spec/unit/mixin/command_spec.rb
+++ b/spec/unit/mixin/command_spec.rb
@@ -43,16 +43,16 @@ describe Chef::Mixin::Command, :volatile do
end
it "should respect locale when specified explicitly" do
- popen4("echo $LC_ALL", :environment => {"LC_ALL" => "es"}) do |pid, stdin, stdout, stderr|
+ popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr|
expect(stdout.read.strip).to eq("es")
end
end
it "should end when the child process reads from STDIN and a block is given" do
expect {Timeout.timeout(10) do
- popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
- (1..5).each { |i| stdin.puts "#{i}" }
- end
+ popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
+ (1..5).each { |i| stdin.puts "#{i}" }
+ end
end
}.not_to raise_error
end
@@ -61,8 +61,8 @@ describe Chef::Mixin::Command, :volatile do
it "returns immediately after the first child process exits" do
expect {Timeout.timeout(10) do
- evil_forker="exit if fork; 10.times { sleep 1}"
- popen4("ruby -e '#{evil_forker}'") do |pid,stdin,stdout,stderr|
+ evil_forker = "exit if fork; 10.times { sleep 1}"
+ popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr|
end
end}.not_to raise_error
end
@@ -93,7 +93,7 @@ describe Chef::Mixin::Command, :volatile do
# Serdar - During Solaris tests, we've seen that processes
# are taking a long time to exit. Bumping timeout now to 10.
expect {Timeout.timeout(10) do
- evil_forker="exit if fork; 10.times { sleep 1}"
+ evil_forker = "exit if fork; 10.times { sleep 1}"
run_command(:command => "ruby -e '#{evil_forker}'")
end}.not_to raise_error
end
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb
index 6ce9a1cb2d..2850193eb6 100644
--- a/spec/unit/mixin/deep_merge_spec.rb
+++ b/spec/unit/mixin/deep_merge_spec.rb
@@ -34,14 +34,14 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do
# deep_merge core tests - moving from basic to more complex
it "tests merging an hash w/array into blank hash" do
- hash_src = {"id" => "2"}
+ hash_src = { "id" => "2" }
hash_dst = {}
@dm.deep_merge!(hash_src.dup, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests merging an hash w/array into blank hash" do
- hash_src = {"region" => {"id" => ["227", "2"]}}
+ hash_src = { "region" => { "id" => ["227", "2"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
@@ -49,192 +49,192 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do
it "tests merge from empty hash" do
hash_src = {}
- hash_dst = {"property" => ["2","4"]}
+ hash_dst = { "property" => ["2", "4"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4"] })
end
it "tests merge to empty hash" do
- hash_src = {"property" => ["2","4"]}
+ hash_src = { "property" => ["2", "4"] }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4"] })
end
it "tests simple string overwrite" do
- hash_src = {"name" => "value"}
- hash_dst = {"name" => "value1"}
+ hash_src = { "name" => "value" }
+ hash_dst = { "name" => "value1" }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"name" => "value"})
+ expect(hash_dst).to eq({ "name" => "value" })
end
it "tests simple string overwrite of empty hash" do
- hash_src = {"name" => "value"}
+ hash_src = { "name" => "value" }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests hashes holding array" do
- hash_src = {"property" => ["1","3"]}
- hash_dst = {"property" => ["2","4"]}
+ hash_src = { "property" => ["1", "3"] }
+ hash_dst = { "property" => ["2", "4"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4","1","3"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4", "1", "3"] })
end
it "tests hashes holding hashes holding arrays (array with duplicate elements is merged with dest then src" do
- hash_src = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["3", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["3", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["3","2","1"], "bathroom_count" => ["2", "1", "4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["3", "2", "1"], "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding array v string (string is overwritten by array)" do
- hash_src = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => "3", "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding string v array (array is overwritten by string)" do
- hash_src = {"property" => {"bedroom_count" => "3", "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => "3", "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => "3", "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding hash v array (array is overwritten by hash)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 3 hash layers holding integers (integers are overwritten by source)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => 2, "queen_bed" => 4}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => 2, "queen_bed" => 4 }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 3 hash layers holding arrays of int (arrays are merged)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3], "queen_bed" => [1]}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3], "queen_bed" => [1] }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4,1]}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4, 1] }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 1 hash overwriting 3 hash layers holding arrays of int" do
- hash_src = {"property" => "1"}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => "1" }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => "1"})
+ expect(hash_dst).to eq({ "property" => "1" })
end
it "tests 3 hash layers holding arrays of int (arrays are merged) but second hash's array is overwritten" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3], "queen_bed" => [1]}, "bathroom_count" => "1"}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3], "queen_bed" => [1] }, "bathroom_count" => "1" } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4,1]}, "bathroom_count" => "1"}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4, 1] }, "bathroom_count" => "1" } })
end
it "tests 3 hash layers holding arrays of int, but one holds int. This one overwrites, but the rest merge" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => [1]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [1] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => [4,1]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [4, 1] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is incomplete." do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is shorter and has new 2nd level ints." do
- hash_src = {"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {2=>3, "king_bed" => [2,3], "queen_bed" => [4]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is empty" do
hash_src = {}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } })
end
it "tests 3 hash layers holding arrays of int, but dest is empty" do
- hash_src = {"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}}
+ hash_src = { "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } })
end
it "tests hash holding arrays of arrays" do
- hash_src = {["1", "2", "3"] => ["1", "2"]}
- hash_dst = {["4", "5"] => ["3"]}
+ hash_src = { ["1", "2", "3"] => ["1", "2"] }
+ hash_dst = { ["4", "5"] => ["3"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({["1","2","3"] => ["1", "2"], ["4", "5"] => ["3"]})
+ expect(hash_dst).to eq({ ["1", "2", "3"] => ["1", "2"], ["4", "5"] => ["3"] })
end
it "tests merging of hash with blank hash, and make sure that source array split does not function when turned off" do
- hash_src = {"property" => {"bedroom_count" => ["1","2,3"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2,3"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["1","2,3"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["1", "2,3"] } })
end
it "tests merging into a blank hash" do
- hash_src = {"action"=>"browse", "controller"=>"results"}
+ hash_src = { "action" => "browse", "controller" => "results" }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests are unmerged hashes passed unmodified w/out :unpack_arrays?" do
- hash_src = {"amenity"=>{"id"=>["26,27"]}}
+ hash_src = { "amenity" => { "id" => ["26,27"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"amenity"=>{"id"=>["26,27"]}})
+ expect(hash_dst).to eq({ "amenity" => { "id" => ["26,27"] } })
end
it "tests hash of array of hashes" do
- hash_src = {"item" => [{"1" => "3"}, {"2" => "4"}]}
- hash_dst = {"item" => [{"3" => "5"}]}
+ hash_src = { "item" => [{ "1" => "3" }, { "2" => "4" }] }
+ hash_dst = { "item" => [{ "3" => "5" }] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => [{"3" => "5"}, {"1" => "3"}, {"2" => "4"}]})
+ expect(hash_dst).to eq({ "item" => [{ "3" => "5" }, { "1" => "3" }, { "2" => "4" }] })
end
# Additions since import
it "should overwrite true with false when merging boolean values" do
- hash_src = {"valid" => false}
- hash_dst = {"valid" => true}
+ hash_src = { "valid" => false }
+ hash_dst = { "valid" => true }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"valid" => false})
+ expect(hash_dst).to eq({ "valid" => false })
end
it "should overwrite false with true when merging boolean values" do
- hash_src = {"valid" => true}
- hash_dst = {"valid" => false}
+ hash_src = { "valid" => true }
+ hash_dst = { "valid" => false }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"valid" => true})
+ expect(hash_dst).to eq({ "valid" => true })
end
it "should overwrite a string with an empty string when merging string values" do
- hash_src = {"item" => " "}
- hash_dst = {"item" => "orange"}
+ hash_src = { "item" => " " }
+ hash_dst = { "item" => "orange" }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => " "})
+ expect(hash_dst).to eq({ "item" => " " })
end
it "should overwrite an empty string with a string when merging string values" do
- hash_src = {"item" => "orange"}
- hash_dst = {"item" => " "}
+ hash_src = { "item" => "orange" }
+ hash_dst = { "item" => " " }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => "orange"})
+ expect(hash_dst).to eq({ "item" => "orange" })
end
end # deep_merge!
@@ -247,41 +247,41 @@ describe Chef::Mixin::DeepMerge do
describe "merge" do
it "should merge a hash into an empty hash" do
hash_dst = {}
- hash_src = {"id" => "2"}
+ hash_src = { "id" => "2" }
expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src)
end
it "should merge a nested hash into an empty hash" do
hash_dst = {}
- hash_src = {"region" => {"id" => ["227", "2"]}}
+ hash_src = { "region" => { "id" => ["227", "2"] } }
expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src)
end
it "should overwrite as string value when merging hashes" do
- hash_dst = {"name" => "value1"}
- hash_src = {"name" => "value"}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"name" => "value"})
+ hash_dst = { "name" => "value1" }
+ hash_src = { "name" => "value" }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "name" => "value" })
end
it "should merge arrays within hashes" do
- hash_dst = {"property" => ["2","4"]}
- hash_src = {"property" => ["1","3"]}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"property" => ["2","4","1","3"]})
+ hash_dst = { "property" => ["2", "4"] }
+ hash_src = { "property" => ["1", "3"] }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => ["2", "4", "1", "3"] })
end
it "should merge deeply nested hashes" do
- hash_dst = {"property" => {"values" => {"are" => "falling", "can" => "change"}}}
- hash_src = {"property" => {"values" => {"are" => "stable", "may" => "rise"}}}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"property" => {"values" => {"are" => "stable", "can" => "change", "may" => "rise"}}})
+ hash_dst = { "property" => { "values" => { "are" => "falling", "can" => "change" } } }
+ hash_src = { "property" => { "values" => { "are" => "stable", "may" => "rise" } } }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => { "values" => { "are" => "stable", "can" => "change", "may" => "rise" } } })
end
it "should not modify the source or destination during the merge" do
- hash_dst = {"property" => ["1","2","3"]}
- hash_src = {"property" => ["4","5","6"]}
+ hash_dst = { "property" => ["1", "2", "3"] }
+ hash_src = { "property" => ["4", "5", "6"] }
ret = @dm.merge(hash_dst, hash_src)
- expect(hash_dst).to eq({"property" => ["1","2","3"]})
- expect(hash_src).to eq({"property" => ["4","5","6"]})
- expect(ret).to eq({"property" => ["1","2","3","4","5","6"]})
+ expect(hash_dst).to eq({ "property" => ["1", "2", "3"] })
+ expect(hash_src).to eq({ "property" => ["4", "5", "6"] })
+ expect(ret).to eq({ "property" => ["1", "2", "3", "4", "5", "6"] })
end
it "should not error merging un-dupable objects" do
@@ -292,8 +292,8 @@ describe Chef::Mixin::DeepMerge do
describe "hash-only merging" do
it "merges Hashes like normal deep merge" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => "1-a-merge-ee", "1_deep_b" => "1-deep-b-merge-ee"}, "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => "1-deep-b-merged-onto", "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => "1-a-merge-ee", "1_deep_b" => "1-deep-b-merge-ee" }, "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => "1-deep-b-merged-onto", "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -304,8 +304,8 @@ describe Chef::Mixin::DeepMerge do
end
it "replaces arrays rather than merging them" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => "1-a-merge-ee", "1_deep_b" => %w{A A A}}, "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => "1-a-merge-ee", "1_deep_b" => %w{A A A} }, "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -315,8 +315,8 @@ describe Chef::Mixin::DeepMerge do
end
it "replaces non-hash items with hashes when there's a conflict" do
- merge_ee_hash = {"top_level_a" => "top-level-a-mergee", "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => "top-level-a-mergee", "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -326,16 +326,16 @@ describe Chef::Mixin::DeepMerge do
end
it "does not mutate deeply-nested original hashes by default" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" }}}}
- merge_with_hash = {"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" }}}}
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" } } } }
+ merge_with_hash = { "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" } } } }
@dm.hash_only_merge(merge_ee_hash, merge_with_hash)
- expect(merge_ee_hash).to eq({"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" }}}})
- expect(merge_with_hash).to eq({"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" }}}})
+ expect(merge_ee_hash).to eq({ "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" } } } })
+ expect(merge_with_hash).to eq({ "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" } } } })
end
it "does not error merging un-dupable items" do
- merge_ee_hash = {"top_level_a" => 1, "top_level_b" => false}
- merge_with_hash = {"top_level_a" => 2, "top_level_b" => true }
+ merge_ee_hash = { "top_level_a" => 1, "top_level_b" => false }
+ merge_with_hash = { "top_level_a" => 2, "top_level_b" => true }
@dm.hash_only_merge(merge_ee_hash, merge_with_hash)
end
end
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index a08584baf9..259b89032e 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -23,18 +23,18 @@ class TinyClass
attr_reader :name
- def music(is_good=true)
+ def music(is_good = true)
is_good
end
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
- expect { @vo.validate({:one => "two"}, {}) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, {}) }.not_to raise_error
end
it "should raise an argument error if validate is called incorrectly" do
@@ -42,23 +42,23 @@ describe Chef::Mixin::ParamsValidate do
end
it "should require validation map keys to be symbols or strings" do
- expect { @vo.validate({:one => "two"}, { :one => true }) }.not_to raise_error
- expect { @vo.validate({:one => "two"}, { "one" => true }) }.not_to raise_error
- expect { @vo.validate({:one => "two"}, { Hash.new => true }) }.to raise_error(ArgumentError)
+ expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { "one" => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { Hash.new => true }) }.to raise_error(ArgumentError)
end
it "should allow options to be required with true" do
- expect { @vo.validate({:one => "two"}, { :one => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
end
it "should allow options to be optional with false" do
- expect { @vo.validate({}, {:one => false})}.not_to raise_error
+ expect { @vo.validate({}, { :one => false }) }.not_to raise_error
end
it "should allow you to check what kind_of? thing an argument is with kind_of" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => String
@@ -69,7 +69,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => Array
@@ -82,7 +82,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify an argument is required with required" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:required => true
@@ -93,7 +93,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:two => "string"},
+ { :two => "string" },
{
:one => {
:required => true
@@ -104,7 +104,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:two => "string"},
+ { :two => "string" },
{
:one => {
:required => false
@@ -117,7 +117,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has a method with respond_to" do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => "validate"
@@ -128,7 +128,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => "monkey"
@@ -141,7 +141,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has all the given methods with respond_to and an array" do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => ["validate", "music"]
@@ -152,7 +152,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => ["monkey", "validate"]
@@ -293,14 +293,14 @@ describe Chef::Mixin::ParamsValidate do
it "should accept keys that are strings in the options" do
expect {
- @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ }})
+ @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } })
}.not_to raise_error
end
it "should allow an array to kind_of" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => [ String, Array ]
@@ -310,7 +310,7 @@ describe Chef::Mixin::ParamsValidate do
}.not_to raise_error
expect {
@vo.validate(
- {:one => ["string"]},
+ { :one => ["string"] },
{
:one => {
:kind_of => [ String, Array ]
@@ -320,7 +320,7 @@ describe Chef::Mixin::ParamsValidate do
}.not_to raise_error
expect {
@vo.validate(
- {:one => Hash.new},
+ { :one => Hash.new },
{
:one => {
:kind_of => [ String, Array ]
@@ -332,12 +332,12 @@ describe Chef::Mixin::ParamsValidate do
it "asserts that a value returns false from a predicate method" do
expect do
- @vo.validate({:not_blank => "should pass"},
- {:not_blank => {:cannot_be => [ :nil, :empty ]}})
+ @vo.validate({ :not_blank => "should pass" },
+ { :not_blank => { :cannot_be => [ :nil, :empty ] } })
end.not_to raise_error
expect do
- @vo.validate({:not_blank => ""},
- {:not_blank => {:cannot_be => [ :nil, :empty ]}})
+ @vo.validate({ :not_blank => "" },
+ { :not_blank => { :cannot_be => [ :nil, :empty ] } })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
@@ -367,31 +367,31 @@ describe Chef::Mixin::ParamsValidate do
it "should set and return @name, then return @name for foo when argument is nil" do
value = "meow"
- expect(@vo.set_or_return(:name, value, { }).object_id).to eq(value.object_id)
+ expect(@vo.set_or_return(:name, value, {}).object_id).to eq(value.object_id)
expect(@vo.set_or_return(:foo, nil, { :name_attribute => true }).object_id).to eq(value.object_id)
end
it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do
- value = Chef::DelayedEvaluator.new{ "test" }
- @vo.set_or_return(:test, value, {:kind_of => Numeric})
+ value = Chef::DelayedEvaluator.new { "test" }
+ @vo.set_or_return(:test, value, { :kind_of => Numeric })
end
it "should raise an error when delayed evaluated attribute is not valid" do
- value = Chef::DelayedEvaluator.new{ "test" }
- @vo.set_or_return(:test, value, {:kind_of => Numeric})
+ value = Chef::DelayedEvaluator.new { "test" }
+ @vo.set_or_return(:test, value, { :kind_of => Numeric })
expect do
- @vo.set_or_return(:test, nil, {:kind_of => Numeric})
+ @vo.set_or_return(:test, nil, { :kind_of => Numeric })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should create DelayedEvaluator instance when #lazy is used" do
- @vo.set_or_return(:delayed, @vo.lazy{ "test" }, {})
+ @vo.set_or_return(:delayed, @vo.lazy { "test" }, {})
expect(@vo.instance_variable_get(:@delayed)).to be_a(Chef::DelayedEvaluator)
end
it "should execute block on each call when DelayedEvaluator" do
value = "fubar"
- @vo.set_or_return(:test, @vo.lazy{ value }, {})
+ @vo.set_or_return(:test, @vo.lazy { value }, {})
expect(@vo.set_or_return(:test, nil, {})).to eq("fubar")
value = "foobar"
expect(@vo.set_or_return(:test, nil, {})).to eq("foobar")
@@ -400,7 +400,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should not evaluate non DelayedEvaluator instances" do
- value = lambda{ "test" }
+ value = lambda { "test" }
@vo.set_or_return(:test, value, {})
expect(@vo.set_or_return(:test, nil, {}).object_id).to eq(value.object_id)
expect(@vo.set_or_return(:test, nil, {})).to be_a(Proc)
diff --git a/spec/unit/mixin/path_sanity_spec.rb b/spec/unit/mixin/path_sanity_spec.rb
index 2679780c76..e410f034d5 100644
--- a/spec/unit/mixin/path_sanity_spec.rb
+++ b/spec/unit/mixin/path_sanity_spec.rb
@@ -39,25 +39,25 @@ describe Chef::Mixin::PathSanity do
end
it "adds all useful PATHs even if environment is an empty hash" do
- env={}
+ env = {}
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
it "adds all useful PATHs that are not yet in PATH to PATH" do
- env = {"PATH" => ""}
+ env = { "PATH" => "" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
it "does not re-add paths that already exist in PATH" do
- env = {"PATH" => "/usr/bin:/sbin:/bin"}
+ env = { "PATH" => "/usr/bin:/sbin:/bin" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("/usr/bin:/sbin:/bin:#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin")
end
it "adds the current executing Ruby's bindir and Gem bindir to the PATH" do
- env = {"PATH" => ""}
+ env = { "PATH" => "" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
@@ -67,7 +67,7 @@ describe Chef::Mixin::PathSanity do
gem_bindir = "/yo/gabba/gabba"
allow(Gem).to receive(:bindir).and_return(gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
- env = {"PATH" => gem_bindir}
+ env = { "PATH" => gem_bindir }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("/yo/gabba/gabba:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
@@ -78,7 +78,7 @@ describe Chef::Mixin::PathSanity do
allow(Gem).to receive(:bindir).and_return(gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
allow(ChefConfig).to receive(:windows?).and_return(true)
- env = {"PATH" => 'C:\Windows\system32;C:\mr\softie'}
+ env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("C:\\Windows\\system32;C:\\mr\\softie;#{ruby_bindir};#{gem_bindir}")
end
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index 8e2e4e2b45..b586be7fdc 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -21,9 +21,9 @@ require "chef/mixin/powershell_out"
describe Chef::Mixin::PowershellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } }
subject(:object) { shell_out_class.new }
- let(:architecture) { "something" }
+ let(:architecture) { "something" }
let(:flags) {
- "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None"
+ "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None"
}
describe "#powershell_out" do
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index f7b4fcd723..7f2ecb94e2 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -55,17 +55,17 @@ describe Chef::Mixin::PowershellTypeCoercions do
end
it "translates all members of a hash and wrap them in @{} separated by ;" do
- expect(test_class.translate_type({"a" => 1, "b" => 1.2, "c" => false, "d" => true
+ expect(test_class.translate_type({ "a" => 1, "b" => 1.2, "c" => false, "d" => true
})).to eq("@{a=1;b=1.2;c=$false;d=$true}")
end
it "translates all members of an array and them by a ," do
expect(test_class.translate_type([true, false])).to eq("@($true,$false)")
end
-
+
it "translates a Chef::Node::ImmutableMash like a hash" do
- test_mash = Chef::Node::ImmutableMash.new({"a" => 1, "b" => 1.2,
- "c" => false, "d" => true})
+ test_mash = Chef::Node::ImmutableMash.new({ "a" => 1, "b" => 1.2,
+ "c" => false, "d" => true })
expect(test_class.translate_type(test_mash)).to eq("@{a=1;b=1.2;c=$false;d=$true}")
end
diff --git a/spec/unit/mixin/proxified_socket_spec.rb b/spec/unit/mixin/proxified_socket_spec.rb
index d8cc762210..1d752bb600 100644
--- a/spec/unit/mixin/proxified_socket_spec.rb
+++ b/spec/unit/mixin/proxified_socket_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Mixin::ProxifiedSocket do
let(:host) { "host" }
let(:port) { 7979 }
let(:test_instance) { TestProxifiedSocket.new }
- let(:socket_double) { instance_double(TCPSocket)}
+ let(:socket_double) { instance_double(TCPSocket) }
let(:proxifier_double) { instance_double(Proxifier::Proxy) }
let(:http_uri) { "http://somehost:1" }
let(:https_uri) { "https://somehost:1" }
diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb
index 50bfe84b27..6f50ce853f 100644
--- a/spec/unit/mixin/securable_spec.rb
+++ b/spec/unit/mixin/securable_spec.rb
@@ -253,7 +253,7 @@ describe Chef::Mixin::Securable do
it "should accept a principal as a string or an array" do
expect { @securable.rights :read, "The Dude" }.not_to raise_error
- expect { @securable.rights :read, ["The Dude","Donny"] }.not_to raise_error
+ expect { @securable.rights :read, ["The Dude", "Donny"] }.not_to raise_error
expect { @securable.rights :read, 3 }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 6d7e12af4b..12336b1dbb 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Mixin::ShellOut do
let(:cmd) { "echo '#{rand(1000)}'" }
let(:output) { StringIO.new }
- let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
+ let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) }
context "without options" do
@@ -171,7 +171,7 @@ describe Chef::Mixin::ShellOut do
end
it "should not change env when language options are set to non-nil" do
- options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8" }}
+ options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
@@ -266,7 +266,7 @@ describe Chef::Mixin::ShellOut do
end
it "should not change env when set to non-nil" do
- options = { :env => { "LC_ALL" => "en_US.UTF-8"}}
+ options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 41e2174eb0..48150f7198 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -172,7 +172,7 @@ describe Chef::Mixin::Template, "render_template" do
expect(output).to eq("before {super secret is } after")
output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb' %>} after")
- expect(output).to eq("before {super secret is } after")
+ expect(output).to eq("before {super secret is } after")
end
it "should render nested partials" do
@@ -199,10 +199,13 @@ describe Chef::Mixin::Template, "render_template" do
mod = Module.new do
def render
end
+
def node
end
+
def render_template
end
+
def render_template_from_string
end
end
@@ -225,7 +228,7 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should raise an error if an attempt is made to access node but it is nil" do
- expect {@context.render_template_from_string("<%= node %>") {|r| r}}.to raise_error(Chef::Mixin::Template::TemplateError)
+ expect { @context.render_template_from_string("<%= node %>") { |r| r } }.to raise_error(Chef::Mixin::Template::TemplateError)
end
describe "the raised TemplateError" do
diff --git a/spec/unit/mixin/uris_spec.rb b/spec/unit/mixin/uris_spec.rb
index 13012617bc..9005edd7b4 100644
--- a/spec/unit/mixin/uris_spec.rb
+++ b/spec/unit/mixin/uris_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Mixin::Uris do
describe "#as_uri" do
it "parses a file scheme uri with spaces" do
- expect{ uris.as_uri("file:///c:/foo bar.txt") }.not_to raise_exception
+ expect { uris.as_uri("file:///c:/foo bar.txt") }.not_to raise_exception
end
it "returns a URI object" do
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 25064678fa..aaf9fa4b2b 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -16,12 +16,9 @@
# limitations under the License.
#
-
require "spec_helper"
require "chef/mixin/windows_architecture_helper"
-
-
describe Chef::Mixin::WindowsArchitectureHelper do
include Chef::Mixin::WindowsArchitectureHelper
@@ -34,25 +31,25 @@ describe Chef::Mixin::WindowsArchitectureHelper do
end
it "returns true when valid architectures are passed to valid_windows_architecture?" do
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
expect(valid_windows_architecture?(architecture)).to eq(true)
end
end
it "returns false when invalid architectures are passed to valid_windows_architecture?" do
- @invalid_architectures.each do | architecture |
+ @invalid_architectures.each do |architecture|
expect(valid_windows_architecture?(architecture)).to eq(false)
end
end
it "does not raise an exception when a valid architecture is passed to assert_valid_windows_architecture!" do
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
assert_valid_windows_architecture!(architecture)
end
end
it "raises an error if an invalid architecture is passed to assert_valid_windows_architecture!" do
- @invalid_architectures.each do | architecture |
+ @invalid_architectures.each do |architecture|
begin
expect(assert_valid_windows_architecture!(architecture)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
rescue Chef::Exceptions::Win32ArchitectureIncorrect
@@ -61,26 +58,26 @@ describe Chef::Mixin::WindowsArchitectureHelper do
end
it "returns true only for supported desired architecture passed to node_supports_windows_architecture" do
- with_node_architecture_combinations do | node, desired_arch |
- expect(node_supports_windows_architecture?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64 || desired_arch == :i386 )
- expect(node_supports_windows_architecture?(node, desired_arch)).to be false if (node_windows_architecture(node) == :i386 && desired_arch == :x86_64 )
+ with_node_architecture_combinations do |node, desired_arch|
+ expect(node_supports_windows_architecture?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64 || desired_arch == :i386 )
+ expect(node_supports_windows_architecture?(node, desired_arch)).to be false if (node_windows_architecture(node) == :i386 && desired_arch == :x86_64 )
end
end
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 |
+ 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))
end
end
def with_node_architecture_combinations
- @valid_architectures.each do | node_architecture |
+ @valid_architectures.each do |node_architecture|
new_node = Chef::Node.new
new_node.default["kernel"] = Hash.new
new_node.default["kernel"][:machine] = node_architecture.to_s
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
yield new_node, architecture if block_given?
end
end
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 79ef2bf7d7..c69748ac49 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -23,172 +23,128 @@ require "chef/node/attribute"
describe Chef::Node::Attribute do
before(:each) do
@attribute_hash =
- {"dmi"=>{},
- "command"=>{"ps"=>"ps -ef"},
- "platform_version"=>"10.5.7",
- "platform"=>"mac_os_x",
- "ipaddress"=>"192.168.0.117",
- "network"=>
- {"default_interface"=>"en1",
- "interfaces"=>
- {"vmnet1"=>
- {"flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"1",
- "addresses"=>
- {"00:50:56:c0:00:01"=>{"family"=>"lladdr"},
- "192.168.110.1"=>
- {"broadcast"=>"192.168.110.255",
- "netmask"=>"255.255.255.0",
- "family"=>"inet"}},
- "mtu"=>"1500",
- "type"=>"vmnet",
- "arp"=>{"192.168.110.255"=>"ff:ff:ff:ff:ff:ff"},
- "encapsulation"=>"Ethernet"},
- "stf0"=>
- {"flags"=>[],
- "number"=>"0",
- "addresses"=>{},
- "mtu"=>"1280",
- "type"=>"stf",
- "encapsulation"=>"6to4"},
- "lo0"=>
- {"flags"=>["UP", "LOOPBACK", "RUNNING", "MULTICAST"],
- "number"=>"0",
- "addresses"=>
- {"::1"=>{"scope"=>"Node", "prefixlen"=>"128", "family"=>"inet6"},
- "127.0.0.1"=>{"netmask"=>"255.0.0.0", "family"=>"inet"},
- "fe80::1"=>{"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"}},
- "mtu"=>"16384",
- "type"=>"lo",
- "encapsulation"=>"Loopback"},
- "gif0"=>
- {"flags"=>["POINTOPOINT", "MULTICAST"],
- "number"=>"0",
- "addresses"=>{},
- "mtu"=>"1280",
- "type"=>"gif",
- "encapsulation"=>"IPIP"},
- "vmnet8"=>
- {"flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"8",
- "addresses"=>
- {"192.168.4.1"=>
- {"broadcast"=>"192.168.4.255",
- "netmask"=>"255.255.255.0",
- "family"=>"inet"},
- "00:50:56:c0:00:08"=>{"family"=>"lladdr"}},
- "mtu"=>"1500",
- "type"=>"vmnet",
- "arp"=>{"192.168.4.255"=>"ff:ff:ff:ff:ff:ff"},
- "encapsulation"=>"Ethernet"},
- "en0"=>
- {"status"=>"inactive",
- "flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"0",
- "addresses"=>{"00:23:32:b0:32:f2"=>{"family"=>"lladdr"}},
- "mtu"=>"1500",
- "media"=>
- {"supported"=>
- {"autoselect"=>{"options"=>[]},
- "none"=>{"options"=>[]},
- "1000baseT"=>
- {"options"=>["full-duplex", "flow-control", "hw-loopback"]},
- "10baseT/UTP"=>
- {"options"=>
- ["half-duplex", "full-duplex", "flow-control", "hw-loopback"]},
- "100baseTX"=>
- {"options"=>
- ["half-duplex", "full-duplex", "flow-control", "hw-loopback"]}},
- "selected"=>{"autoselect"=>{"options"=>[]}}},
- "type"=>"en",
- "encapsulation"=>"Ethernet"},
- "en1"=>
- {"status"=>"active",
- "flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"1",
- "addresses"=>
- {"fe80::223:6cff:fe7f:676c"=>
- {"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
- "00:23:6c:7f:67:6c"=>{"family"=>"lladdr"},
- "192.168.0.117"=>
- {"broadcast"=>"192.168.0.255",
- "netmask"=>"255.255.255.0",
- "family"=>"inet"}},
- "mtu"=>"1500",
- "media"=>
- {"supported"=>{"autoselect"=>{"options"=>[]}},
- "selected"=>{"autoselect"=>{"options"=>[]}}},
- "type"=>"en",
- "arp"=>
- {"192.168.0.72"=>"0:f:ea:39:fa:d5",
- "192.168.0.1"=>"0:1c:fb:fc:6f:20",
- "192.168.0.255"=>"ff:ff:ff:ff:ff:ff",
- "192.168.0.3"=>"0:1f:33:ea:26:9b",
- "192.168.0.77"=>"0:23:12:70:f8:cf",
- "192.168.0.152"=>"0:26:8:7d:2:4c"},
- "encapsulation"=>"Ethernet"},
- "en2"=>
- {"status"=>"active",
- "flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"2",
- "addresses"=>
- {"169.254.206.152"=>
- {"broadcast"=>"169.254.255.255",
- "netmask"=>"255.255.0.0",
- "family"=>"inet"},
- "00:1c:42:00:00:01"=>{"family"=>"lladdr"},
- "fe80::21c:42ff:fe00:1"=>
- {"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"}},
- "mtu"=>"1500",
- "media"=>
- {"supported"=>{"autoselect"=>{"options"=>[]}},
- "selected"=>{"autoselect"=>{"options"=>[]}}},
- "type"=>"en",
- "encapsulation"=>"Ethernet"},
- "fw0"=>
- {"status"=>"inactive",
- "flags"=>["BROADCAST", "SIMPLEX", "MULTICAST"],
- "number"=>"0",
- "addresses"=>{"00:23:32:ff:fe:b0:32:f2"=>{"family"=>"lladdr"}},
- "mtu"=>"4078",
- "media"=>
- {"supported"=>{"autoselect"=>{"options"=>["full-duplex"]}},
- "selected"=>{"autoselect"=>{"options"=>["full-duplex"]}}},
- "type"=>"fw",
- "encapsulation"=>"1394"},
- "en3"=>
- {"status"=>"active",
- "flags"=>
- ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
- "number"=>"3",
- "addresses"=>
- {"169.254.206.152"=>
- {"broadcast"=>"169.254.255.255",
- "netmask"=>"255.255.0.0",
- "family"=>"inet"},
- "00:1c:42:00:00:00"=>{"family"=>"lladdr"},
- "fe80::21c:42ff:fe00:0"=>
- {"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"}},
- "mtu"=>"1500",
- "media"=>
- {"supported"=>{"autoselect"=>{"options"=>[]}},
- "selected"=>{"autoselect"=>{"options"=>[]}}},
- "type"=>"en",
- "encapsulation"=>"Ethernet"}}},
- "fqdn"=>"latte.local",
- "ohai_time"=>1249065590.90391,
- "domain"=>"local",
- "os"=>"darwin",
- "platform_build"=>"9J61",
- "os_version"=>"9.7.0",
- "hostname"=>"latte",
- "macaddress"=>"00:23:6c:7f:67:6c",
- "music" => { "jimmy_eat_world" => "nice", "apophis" => false },
+ { "dmi" => {},
+ "command" => { "ps" => "ps -ef" },
+ "platform_version" => "10.5.7",
+ "platform" => "mac_os_x",
+ "ipaddress" => "192.168.0.117",
+ "network" => { "default_interface" => "en1",
+ "interfaces" => { "vmnet1" => { "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "1",
+ "addresses" => { "00:50:56:c0:00:01" => { "family" => "lladdr" },
+ "192.168.110.1" => { "broadcast" => "192.168.110.255",
+ "netmask" => "255.255.255.0",
+ "family" => "inet" } },
+ "mtu" => "1500",
+ "type" => "vmnet",
+ "arp" => { "192.168.110.255" => "ff:ff:ff:ff:ff:ff" },
+ "encapsulation" => "Ethernet" },
+ "stf0" => { "flags" => [],
+ "number" => "0",
+ "addresses" => {},
+ "mtu" => "1280",
+ "type" => "stf",
+ "encapsulation" => "6to4" },
+ "lo0" => { "flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"],
+ "number" => "0",
+ "addresses" => { "::1" => { "scope" => "Node", "prefixlen" => "128", "family" => "inet6" },
+ "127.0.0.1" => { "netmask" => "255.0.0.0", "family" => "inet" },
+ "fe80::1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } },
+ "mtu" => "16384",
+ "type" => "lo",
+ "encapsulation" => "Loopback" },
+ "gif0" => { "flags" => ["POINTOPOINT", "MULTICAST"],
+ "number" => "0",
+ "addresses" => {},
+ "mtu" => "1280",
+ "type" => "gif",
+ "encapsulation" => "IPIP" },
+ "vmnet8" => { "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "8",
+ "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255",
+ "netmask" => "255.255.255.0",
+ "family" => "inet" },
+ "00:50:56:c0:00:08" => { "family" => "lladdr" } },
+ "mtu" => "1500",
+ "type" => "vmnet",
+ "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" },
+ "encapsulation" => "Ethernet" },
+ "en0" => { "status" => "inactive",
+ "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "0",
+ "addresses" => { "00:23:32:b0:32:f2" => { "family" => "lladdr" } },
+ "mtu" => "1500",
+ "media" => { "supported" => { "autoselect" => { "options" => [] },
+ "none" => { "options" => [] },
+ "1000baseT" => { "options" => ["full-duplex", "flow-control", "hw-loopback"] },
+ "10baseT/UTP" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] },
+ "100baseTX" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] } },
+ "selected" => { "autoselect" => { "options" => [] } } },
+ "type" => "en",
+ "encapsulation" => "Ethernet" },
+ "en1" => { "status" => "active",
+ "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "1",
+ "addresses" => { "fe80::223:6cff:fe7f:676c" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" },
+ "00:23:6c:7f:67:6c" => { "family" => "lladdr" },
+ "192.168.0.117" => { "broadcast" => "192.168.0.255",
+ "netmask" => "255.255.255.0",
+ "family" => "inet" } },
+ "mtu" => "1500",
+ "media" => { "supported" => { "autoselect" => { "options" => [] } },
+ "selected" => { "autoselect" => { "options" => [] } } },
+ "type" => "en",
+ "arp" => { "192.168.0.72" => "0:f:ea:39:fa:d5",
+ "192.168.0.1" => "0:1c:fb:fc:6f:20",
+ "192.168.0.255" => "ff:ff:ff:ff:ff:ff",
+ "192.168.0.3" => "0:1f:33:ea:26:9b",
+ "192.168.0.77" => "0:23:12:70:f8:cf",
+ "192.168.0.152" => "0:26:8:7d:2:4c" },
+ "encapsulation" => "Ethernet" },
+ "en2" => { "status" => "active",
+ "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "2",
+ "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255",
+ "netmask" => "255.255.0.0",
+ "family" => "inet" },
+ "00:1c:42:00:00:01" => { "family" => "lladdr" },
+ "fe80::21c:42ff:fe00:1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } },
+ "mtu" => "1500",
+ "media" => { "supported" => { "autoselect" => { "options" => [] } },
+ "selected" => { "autoselect" => { "options" => [] } } },
+ "type" => "en",
+ "encapsulation" => "Ethernet" },
+ "fw0" => { "status" => "inactive",
+ "flags" => ["BROADCAST", "SIMPLEX", "MULTICAST"],
+ "number" => "0",
+ "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } },
+ "mtu" => "4078",
+ "media" => { "supported" => { "autoselect" => { "options" => ["full-duplex"] } },
+ "selected" => { "autoselect" => { "options" => ["full-duplex"] } } },
+ "type" => "fw",
+ "encapsulation" => "1394" },
+ "en3" => { "status" => "active",
+ "flags" => ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"],
+ "number" => "3",
+ "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255",
+ "netmask" => "255.255.0.0",
+ "family" => "inet" },
+ "00:1c:42:00:00:00" => { "family" => "lladdr" },
+ "fe80::21c:42ff:fe00:0" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } },
+ "mtu" => "1500",
+ "media" => { "supported" => { "autoselect" => { "options" => [] } },
+ "selected" => { "autoselect" => { "options" => [] } } },
+ "type" => "en",
+ "encapsulation" => "Ethernet" } } },
+ "fqdn" => "latte.local",
+ "ohai_time" => 1249065590.90391,
+ "domain" => "local",
+ "os" => "darwin",
+ "platform_build" => "9J61",
+ "os_version" => "9.7.0",
+ "hostname" => "latte",
+ "macaddress" => "00:23:6c:7f:67:6c",
+ "music" => { "jimmy_eat_world" => "nice", "apophis" => false },
}
@default_hash = {
"domain" => "opscode.com",
@@ -198,7 +154,7 @@ describe Chef::Node::Attribute do
"mastodon" => "rocks",
"mars_volta" => "is loud and nutty",
"deeper" => { "gates_of_ishtar" => nil },
- "this" => {"apparatus" => {"must" => "be unearthed"}},
+ "this" => { "apparatus" => { "must" => "be unearthed" } },
},
}
@override_hash = {
@@ -209,7 +165,7 @@ describe Chef::Node::Attribute do
"mars_volta" => "cicatriz"
},
}
- @automatic_hash = {"week" => "friday"}
+ @automatic_hash = { "week" => "friday" }
@attributes = Chef::Node::Attribute.new(@attribute_hash, @default_hash, @override_hash, @automatic_hash)
end
@@ -354,13 +310,13 @@ describe Chef::Node::Attribute do
it "merges nested hashes between precedence levels" do
@attributes = Chef::Node::Attribute.new({}, {}, {}, {})
- @attributes.env_default = {"a" => {"b" => {"default" => "default"}}}
- @attributes.normal = {"a" => {"b" => {"normal" => "normal"}}}
- @attributes.override = {"a" => {"override" => "role"}}
- @attributes.automatic = {"a" => {"automatic" => "auto"}}
- expect(@attributes["a"]).to eq({"b"=>{"default"=>"default", "normal"=>"normal"},
- "override"=>"role",
- "automatic"=>"auto"})
+ @attributes.env_default = { "a" => { "b" => { "default" => "default" } } }
+ @attributes.normal = { "a" => { "b" => { "normal" => "normal" } } }
+ @attributes.override = { "a" => { "override" => "role" } }
+ @attributes.automatic = { "a" => { "automatic" => "auto" } }
+ expect(@attributes["a"]).to eq({ "b" => { "default" => "default", "normal" => "normal" },
+ "override" => "role",
+ "automatic" => "auto" })
end
end
@@ -431,7 +387,7 @@ describe Chef::Node::Attribute do
describe "[]=" do
it "should error out when the type of attribute to set has not been specified" do
- @attributes.normal["the_ghost"] = { }
+ @attributes.normal["the_ghost"] = {}
expect { @attributes["the_ghost"]["exterminate"] = false }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
end
@@ -490,29 +446,29 @@ describe Chef::Node::Attribute do
it "should create a deep copy of the node attribute" do
@attributes.default["foo"]["bar"]["baz"] = "fizz"
hash = @attributes["foo"].to_hash
- expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
+ expect(hash).to eql({ "bar" => { "baz" => "fizz" } })
hash["bar"]["baz"] = "buzz"
- expect(hash).to eql({"bar"=>{"baz"=>"buzz"}})
- expect(@attributes.default["foo"]).to eql({"bar"=>{"baz"=>"fizz"}})
+ expect(hash).to eql({ "bar" => { "baz" => "buzz" } })
+ expect(@attributes.default["foo"]).to eql({ "bar" => { "baz" => "fizz" } })
end
it "should create a deep copy of arrays in the node attribute" do
@attributes.default["foo"]["bar"] = ["fizz"]
hash = @attributes["foo"].to_hash
- expect(hash).to eql({"bar"=>[ "fizz" ]})
+ expect(hash).to eql({ "bar" => [ "fizz" ] })
hash["bar"].push("buzz")
- expect(hash).to eql({"bar"=>[ "fizz", "buzz" ]})
- expect(@attributes.default["foo"]).to eql({"bar"=>[ "fizz" ]})
+ expect(hash).to eql({ "bar" => [ "fizz", "buzz" ] })
+ expect(@attributes.default["foo"]).to eql({ "bar" => [ "fizz" ] })
end
it "mutating strings should not mutate the attributes" do
pending "this is a bug that should be fixed"
@attributes.default["foo"]["bar"]["baz"] = "fizz"
hash = @attributes["foo"].to_hash
- expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
+ expect(hash).to eql({ "bar" => { "baz" => "fizz" } })
hash["bar"]["baz"] << "buzz"
- expect(hash).to eql({"bar"=>{"baz"=>"fizzbuzz"}})
- expect(@attributes.default["foo"]).to eql({"bar"=>{"baz"=>"fizz"}})
+ expect(hash).to eql({ "bar" => { "baz" => "fizzbuzz" } })
+ expect(@attributes.default["foo"]).to eql({ "bar" => { "baz" => "fizz" } })
end
end
@@ -592,7 +548,7 @@ describe Chef::Node::Attribute do
{
"one" => { "two" => "three" },
"hut" => { "two" => "three" },
- "place" => { },
+ "place" => {},
},
{
"one" => { "four" => "five" },
@@ -853,7 +809,7 @@ describe Chef::Node::Attribute do
"hut" => "three",
"snakes" => "on a plane",
"snack" => "cookies",
- }.each do |k,v|
+ }.each do |k, v|
expect(@attributes.fetch(k)).to eq(v)
end
end
@@ -1031,7 +987,7 @@ describe Chef::Node::Attribute do
end
else
it "should raise a LocalJumpError if no block is given" do
- expect{ @attributes.select }.to raise_error(LocalJumpError)
+ expect { @attributes.select }.to raise_error(LocalJumpError)
end
end
@@ -1070,7 +1026,7 @@ describe Chef::Node::Attribute do
{},
)
- @empty = Chef::Node::Attribute.new({},{},{},{})
+ @empty = Chef::Node::Attribute.new({}, {}, {}, {})
end
it "should respond to size" do
@@ -1138,7 +1094,6 @@ describe Chef::Node::Attribute do
end
end
-
describe "when not mutated" do
it "does not reset the cache when dup'd [CHEF-3680]" do
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index 2a0884f4b2..170e6d927a 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.rb
@@ -21,10 +21,10 @@ require "chef/node/immutable_collections"
describe Chef::Node::ImmutableMash do
before do
- @data_in = {:top => {:second_level => "some value"},
- "top_level_2" => %w{array of values},
- :top_level_3 => [{:hash_array => 1, :hash_array_b => 2}],
- :top_level_4 => {:level2 => {:key => "value"}},
+ @data_in = { :top => { :second_level => "some value" },
+ "top_level_2" => %w{array of values},
+ :top_level_3 => [{ :hash_array => 1, :hash_array_b => 2 }],
+ :top_level_4 => { :level2 => { :key => "value" } },
}
@immutable_mash = Chef::Node::ImmutableMash.new(@data_in)
end
@@ -113,8 +113,8 @@ describe Chef::Node::ImmutableArray do
before do
@immutable_array = Chef::Node::ImmutableArray.new(%w{foo bar baz} + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ])
- immutable_mash = Chef::Node::ImmutableMash.new({:m => "m"})
- @immutable_nested_array = Chef::Node::ImmutableArray.new(["level1",@immutable_array, immutable_mash])
+ immutable_mash = Chef::Node::ImmutableMash.new({ :m => "m" })
+ @immutable_nested_array = Chef::Node::ImmutableArray.new(["level1", @immutable_array, immutable_mash])
end
##
@@ -154,7 +154,7 @@ describe Chef::Node::ImmutableArray do
:unshift,
].each do |mutator|
it "does not allow mutation via `#{mutator}" do
- expect { @immutable_array.send(mutator)}.to raise_error
+ expect { @immutable_array.send(mutator) }.to raise_error
end
end
@@ -195,4 +195,3 @@ describe Chef::Node::ImmutableArray do
end
end
-
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 7d9a85bbb4..0eb251ac8d 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -27,7 +27,7 @@ describe Chef::NodeMap do
describe "with a bad filter name" do
it "should raise an error" do
- expect{ node_map.set(node, :thing, on_platform_family: "rhel") }.to raise_error
+ expect { node_map.set(node, :thing, on_platform_family: "rhel") }.to raise_error
end
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 234955cc27..d3c58c6f6a 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Node do
end
it "should validate the name of the node" do
- expect{Chef::Node.build("solo node")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { Chef::Node.build("solo node") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should be sortable" do
@@ -107,11 +107,11 @@ describe Chef::Node do
end
it "cannot be blank" do
- expect { node.name("")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.name("") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should not accept name doesn't match /^[\-[:alnum:]_:.]+$/" do
- expect { node.name("space in it")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.name("space in it") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
@@ -131,7 +131,7 @@ describe Chef::Node do
end
it "cannot be blank" do
- expect { node.chef_environment("")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.chef_environment("") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
@@ -167,7 +167,7 @@ describe Chef::Node do
end
it "cannot be blank" do
- expect { node.policy_name("")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.policy_name("") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
@@ -203,7 +203,7 @@ describe Chef::Node do
end
it "cannot be blank" do
- expect { node.policy_group("")}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { node.policy_group("") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
@@ -223,7 +223,7 @@ describe Chef::Node do
end
it "does not allow you to set an attribute via node[]=" do
- expect { node["secret"] = "shush" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
+ expect { node["secret"] = "shush" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
end
it "should allow you to query whether an attribute exists with attribute?" do
@@ -239,7 +239,7 @@ describe Chef::Node do
end
it "does not allow you to set an attribute via method_missing" do
- expect { node.sunshine = "is bright"}.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
+ expect { node.sunshine = "is bright" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
end
it "should allow you get get an attribute via method_missing" do
@@ -389,7 +389,7 @@ describe Chef::Node do
it "deletes nested things correctly" do
node.default["mysql"]["client"]["client_setting"] = "foo"
- expect( node.rm("mysql", "server") ).to eql( {"port" => 3456} )
+ expect( node.rm("mysql", "server") ).to eql( { "port" => 3456 } )
expect( node["mysql"] ).to eql( { "client" => { "client_setting" => "foo" } } )
end
@@ -398,7 +398,7 @@ describe Chef::Node do
end
it "can delete the entire tree" do
- expect( node.rm("mysql") ).to eql({"server"=>{"port"=>3456}})
+ expect( node.rm("mysql") ).to eql({ "server" => { "port" => 3456 } })
end
end
@@ -736,7 +736,7 @@ describe Chef::Node do
node.default.sunshine = "is bright"
node.default.canada = "is a nice place"
seen_attributes = Hash.new
- node.each_attribute do |a,v|
+ node.each_attribute do |a, v|
seen_attributes[a] = v
end
expect(seen_attributes).to have_key("sunshine")
@@ -749,12 +749,12 @@ describe Chef::Node do
describe "consuming json" do
before do
- @ohai_data = {:platform => "foo", :platform_version => "bar"}
+ @ohai_data = { :platform => "foo", :platform_version => "bar" }
end
it "consumes the run list portion of a collection of attributes and returns the remainder" do
- attrs = {"run_list" => [ "role[base]", "recipe[chef::server]" ], "foo" => "bar"}
- expect(node.consume_run_list(attrs)).to eq({"foo" => "bar"})
+ attrs = { "run_list" => [ "role[base]", "recipe[chef::server]" ], "foo" => "bar" }
+ expect(node.consume_run_list(attrs)).to eq({ "foo" => "bar" })
expect(node.run_list).to eq([ "role[base]", "recipe[chef::server]" ])
end
@@ -774,7 +774,7 @@ describe Chef::Node do
it "should not add duplicate recipes from the json attributes" do
node.run_list << "one"
node.consume_run_list "recipes" => [ "one", "two", "three" ]
- expect(node.run_list).to eq([ "one", "two", "three" ])
+ expect(node.run_list).to eq([ "one", "two", "three" ])
end
it "doesn't change the run list if no run_list is specified in the json" do
@@ -788,7 +788,7 @@ describe Chef::Node do
end
it "should add json attributes to the node" do
- node.consume_external_attrs(@ohai_data, {"one" => "two", "three" => "four"})
+ node.consume_external_attrs(@ohai_data, { "one" => "two", "three" => "four" })
expect(node.one).to eql("two")
expect(node.three).to eql("four")
end
@@ -823,25 +823,25 @@ describe Chef::Node do
end
it "deep merges attributes instead of overwriting them" do
- node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
- expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})
- node.consume_external_attrs(@ohai_data, "one" => {"abc" => "123"})
- node.consume_external_attrs(@ohai_data, "one" => {"two" => {"foo" => "bar"}})
- expect(node.one.to_hash).to eq({"two" => {"three" => "four", "foo" => "bar"}, "abc" => "123"})
+ node.consume_external_attrs(@ohai_data, "one" => { "two" => { "three" => "four" } })
+ expect(node.one.to_hash).to eq({ "two" => { "three" => "four" } })
+ node.consume_external_attrs(@ohai_data, "one" => { "abc" => "123" })
+ node.consume_external_attrs(@ohai_data, "one" => { "two" => { "foo" => "bar" } })
+ expect(node.one.to_hash).to eq({ "two" => { "three" => "four", "foo" => "bar" }, "abc" => "123" })
end
it "gives attributes from JSON priority when deep merging" do
- node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
- expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})
- node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "forty-two"}})
- expect(node.one.to_hash).to eq({"two" => {"three" => "forty-two"}})
+ node.consume_external_attrs(@ohai_data, "one" => { "two" => { "three" => "four" } })
+ expect(node.one.to_hash).to eq({ "two" => { "three" => "four" } })
+ node.consume_external_attrs(@ohai_data, "one" => { "two" => { "three" => "forty-two" } })
+ expect(node.one.to_hash).to eq({ "two" => { "three" => "forty-two" } })
end
end
describe "preparing for a chef client run" do
before do
- @ohai_data = {:platform => "foobuntu", :platform_version => "23.42"}
+ @ohai_data = { :platform => "foobuntu", :platform_version => "23.42" }
end
it "sets its platform according to platform detection" do
@@ -851,16 +851,16 @@ describe Chef::Node do
end
it "consumes the run list from provided json attributes" do
- node.consume_external_attrs(@ohai_data, {"run_list" => ["recipe[unicorn]"]})
+ node.consume_external_attrs(@ohai_data, { "run_list" => ["recipe[unicorn]"] })
expect(node.run_list).to eq(["recipe[unicorn]"])
end
it "saves non-runlist json attrs for later" do
expansion = Chef::RunList::RunListExpansion.new("_default", [])
allow(node.run_list).to receive(:expand).and_return(expansion)
- node.consume_external_attrs(@ohai_data, {"foo" => "bar"})
+ node.consume_external_attrs(@ohai_data, { "foo" => "bar" })
node.expand!
- expect(node.normal_attrs).to eq({"foo" => "bar", "tags" => []})
+ expect(node.normal_attrs).to eq({ "foo" => "bar", "tags" => [] })
end
end
@@ -885,7 +885,7 @@ describe Chef::Node do
end
it "sets the 'roles' automatic attribute to the expanded role list" do
- @expansion.instance_variable_set(:@applied_roles, {"arf" => nil, "countersnark" => nil})
+ @expansion.instance_variable_set(:@applied_roles, { "arf" => nil, "countersnark" => nil })
node.expand!
expect(node.automatic_attrs[:roles].sort).to eq(["arf", "countersnark"])
end
@@ -985,12 +985,12 @@ describe Chef::Node do
before do
node.chef_environment = "rspec"
@expansion = Chef::RunList::RunListExpansion.new("rspec", [])
- @expansion.default_attrs.replace({:default => "from role", :d_role => "role only"})
- @expansion.override_attrs.replace({:override => "from role", :o_role => "role only"})
+ @expansion.default_attrs.replace({ :default => "from role", :d_role => "role only" })
+ @expansion.override_attrs.replace({ :override => "from role", :o_role => "role only" })
@environment = Chef::Environment.new
- @environment.default_attributes = {:default => "from env", :d_env => "env only" }
- @environment.override_attributes = {:override => "from env", :o_env => "env only"}
+ @environment.default_attributes = { :default => "from env", :d_env => "env only" }
+ @environment.override_attributes = { :override => "from env", :o_env => "env only" }
allow(Chef::Environment).to receive(:load).and_return(@environment)
node.apply_expansion_attributes(@expansion)
end
@@ -1173,8 +1173,8 @@ describe Chef::Node do
it "should serialize valid json with a run list", :json => true do
#This test came about because activesupport mucks with Chef json serialization
#Test should pass with and without Activesupport
- node.run_list << {"type" => "role", "name" => "Cthulu"}
- node.run_list << {"type" => "role", "name" => "Hastur"}
+ node.run_list << { "type" => "role", "name" => "Cthulu" }
+ node.run_list << { "type" => "role", "name" => "Hastur" }
json = Chef::JSONCompat.to_json(node)
expect(json).to match(/\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/)
end
@@ -1211,7 +1211,7 @@ describe Chef::Node do
expect(serialized_node).to be_a_kind_of(Chef::Node)
expect(serialized_node.name).to eql(node.name)
expect(serialized_node.chef_environment).to eql(node.chef_environment)
- node.each_attribute do |k,v|
+ node.each_attribute do |k, v|
expect(serialized_node[k]).to eql(v)
end
expect(serialized_node.run_list).to eq(node.run_list)
diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb
index 7c6fcc9e6c..49557417a5 100644
--- a/spec/unit/org_spec.rb
+++ b/spec/unit/org_spec.rb
@@ -110,8 +110,8 @@ describe Chef::Org do
describe "when deserializing from JSON" do
let(:org) do
o = { "name" => "turtle",
- "full_name" => "turtle_club",
- "private_key" => "pandas" }
+ "full_name" => "turtle_club",
+ "private_key" => "pandas" }
Chef::Org.from_json(o.to_json)
end
@@ -147,8 +147,8 @@ describe Chef::Org do
end
describe "list" do
- let(:response) { {"foobar" => "http://www.example.com/organizations/foobar"} }
- let(:inflated_response) { {"foobar" => org } }
+ let(:response) { { "foobar" => "http://www.example.com/organizations/foobar" } }
+ let(:inflated_response) { { "foobar" => org } }
it "lists all orgs" do
expect(rest).to receive(:get).with("organizations").and_return(response)
@@ -164,14 +164,14 @@ describe Chef::Org do
describe "create" do
it "creates a new org via the API" do
- expect(rest).to receive(:post).with("organizations", {:name => "foobar", :full_name => "foo bar bat"}).and_return({})
+ expect(rest).to receive(:post).with("organizations", { :name => "foobar", :full_name => "foo bar bat" }).and_return({})
org.create
end
end
describe "read" do
it "loads a named org from the API" do
- expect(rest).to receive(:get).with("organizations/foobar").and_return({"name" => "foobar", "full_name" => "foo bar bat", "private_key" => "private"})
+ expect(rest).to receive(:get).with("organizations/foobar").and_return({ "name" => "foobar", "full_name" => "foo bar bat", "private_key" => "private" })
org = Chef::Org.load("foobar")
expect(org.name).to eq("foobar")
expect(org.full_name).to eq("foo bar bat")
@@ -181,7 +181,7 @@ describe Chef::Org do
describe "update" do
it "updates an existing org on via the API" do
- expect(rest).to receive(:put).with("organizations/foobar", {:name => "foobar", :full_name => "foo bar bat"}).and_return({})
+ expect(rest).to receive(:put).with("organizations/foobar", { :name => "foobar", :full_name => "foo bar bat" }).and_return({})
org.update
end
end
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index 7eeeb696eb..49da6a95f0 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -103,7 +103,7 @@ describe "Chef::Platform#windows_nano_server?" do
end
describe "Chef::Platform#supports_msi?" do
- include_context "Win32" # clear and restore Win32:: namespace
+ include_context "Win32" # clear and restore Win32:: namespace
let(:key) { "System\\CurrentControlSet\\Services\\msiserver" }
let(:key_query_value) { 0x0001 }
@@ -198,7 +198,7 @@ end
describe 'Chef::Platform#dsc_refresh_mode_disabled?' do
let(:node) { instance_double("Chef::Node") }
let(:cmdlet) { instance_double("Chef::Util::Powershell::Cmdlet") }
- let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult")}
+ let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult") }
it "returns true when RefreshMode is Disabled" do
expect(Chef::Util::Powershell::Cmdlet).to receive(:new).
diff --git a/spec/unit/platform_spec.rb b/spec/unit/platform_spec.rb
index 4ad2b3e9c0..e37e00bc43 100644
--- a/spec/unit/platform_spec.rb
+++ b/spec/unit/platform_spec.rb
@@ -171,11 +171,11 @@ describe Chef::Platform do
it "raises an error when trying to find the provider for a resource with no run context" do
file = Chef::Resource::File.new("whateva")
- expect {Chef::Platform.provider_for_resource(file)}.to raise_error(ArgumentError)
+ expect { Chef::Platform.provider_for_resource(file) }.to raise_error(ArgumentError)
end
it "does not support finding a provider by resource and node -- a run context is required" do
- expect {Chef::Platform.provider_for_node("node", "resource")}.to raise_error(NotImplementedError)
+ expect { Chef::Platform.provider_for_node("node", "resource") }.to raise_error(NotImplementedError)
end
it "should update the provider map with map" do
diff --git a/spec/unit/policy_builder/dynamic_spec.rb b/spec/unit/policy_builder/dynamic_spec.rb
index 19ad057863..f91b0ba7d2 100644
--- a/spec/unit/policy_builder/dynamic_spec.rb
+++ b/spec/unit/policy_builder/dynamic_spec.rb
@@ -22,8 +22,8 @@ require "chef/policy_builder"
describe Chef::PolicyBuilder::Dynamic do
let(:node_name) { "joe_node" }
- let(:ohai_data) { {"platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com"} }
- let(:json_attribs) { {"custom_attr" => "custom_attr_value"} }
+ let(:ohai_data) { { "platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com" } }
+ let(:json_attribs) { { "custom_attr" => "custom_attr_value" } }
let(:override_runlist) { nil }
let(:events) { Chef::EventDispatch::Dispatcher.new }
@@ -123,7 +123,7 @@ describe Chef::PolicyBuilder::Dynamic do
context "and no policyfile attributes are present in json_attribs" do
- let(:json_attribs) { {"foo" => "bar"} }
+ let(:json_attribs) { { "foo" => "bar" } }
it "uses the ExpandNodeObject implementation" do
expect(implementation).to be_a(Chef::PolicyBuilder::ExpandNodeObject)
@@ -171,7 +171,7 @@ describe Chef::PolicyBuilder::Dynamic do
context "and policyfile attributes are present in json_attribs" do
- let(:json_attribs) { {"policy_name" => "example-policy", "policy_group" => "testing"} }
+ let(:json_attribs) { { "policy_name" => "example-policy", "policy_group" => "testing" } }
it "uses the Policyfile implementation" do
expect(implementation).to be_a(Chef::PolicyBuilder::Policyfile)
@@ -207,7 +207,6 @@ describe Chef::PolicyBuilder::Dynamic do
context "when not running chef solo" do
-
context "when successful" do
before do
@@ -243,7 +242,6 @@ describe Chef::PolicyBuilder::Dynamic do
expect(implementation).to receive(:finish_load_node).and_raise("oops")
end
-
it "sends a node_load_failed event and re-raises" do
expect(events).to receive(:node_load_failed)
expect { policy_builder.load_node }.to raise_error("oops")
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb
index 2a1a85e605..8667532d72 100644
--- a/spec/unit/policy_builder/expand_node_object_spec.rb
+++ b/spec/unit/policy_builder/expand_node_object_spec.rb
@@ -22,8 +22,8 @@ require "chef/policy_builder"
describe Chef::PolicyBuilder::ExpandNodeObject do
let(:node_name) { "joe_node" }
- let(:ohai_data) { {"platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com"} }
- let(:json_attribs) { {"run_list" => []} }
+ let(:ohai_data) { { "platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com" } }
+ let(:json_attribs) { { "run_list" => [] } }
let(:override_runlist) { "recipe[foo::default]" }
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:policy_builder) { Chef::PolicyBuilder::ExpandNodeObject.new(node_name, ohai_data, json_attribs, override_runlist, events) }
@@ -155,8 +155,8 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
let(:override_runlist) { nil }
let(:primary_runlist) { ["recipe[primary::default]"] }
- let(:original_default_attrs) { {"default_key" => "default_value"} }
- let(:original_override_attrs) { {"override_key" => "override_value"} }
+ let(:original_default_attrs) { { "default_key" => "default_value" } }
+ let(:original_override_attrs) { { "override_key" => "override_value" } }
let(:node) do
node = Chef::Node.new
@@ -227,7 +227,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
context "when JSON attributes are given on the command line" do
- let(:json_attribs) { {"run_list" => ["recipe[json_attribs::default]"], "json_attribs_key" => "json_attribs_value" } }
+ let(:json_attribs) { { "run_list" => ["recipe[json_attribs::default]"], "json_attribs_key" => "json_attribs_value" } }
it "sets the run list according to the given JSON" do
expect(node.run_list).to eq(["recipe[json_attribs::default]"])
@@ -267,7 +267,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
let(:configured_environment) { environment.name }
let(:environment) do
- environment = Chef::Environment.new.tap {|e| e.name("prod") }
+ environment = Chef::Environment.new.tap { |e| e.name("prod") }
expect(Chef::Environment).to receive(:load).with("prod").and_return(environment)
environment
end
@@ -293,7 +293,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do
let(:chef_http) { double("Chef::ServerAPI") }
let(:cookbook_resolve_url) { "environments/#{node.chef_environment}/cookbook_versions" }
- let(:cookbook_resolve_post_data) { {:run_list=>["first::default", "second::default"]} }
+ let(:cookbook_resolve_post_data) { { :run_list => ["first::default", "second::default"] } }
# cookbook_hash is just a hash, but since we're passing it between mock
# objects, we get a little better test strictness by using a double (which
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 1425fe2b70..6b71b4d43e 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -22,8 +22,8 @@ require "chef/policy_builder"
describe Chef::PolicyBuilder::Policyfile do
let(:node_name) { "joe_node" }
- let(:ohai_data) { {"platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com"} }
- let(:json_attribs) { {"custom_attr" => "custom_attr_value"} }
+ let(:ohai_data) { { "platform" => "ubuntu", "platform_version" => "13.04", "fqdn" => "joenode.example.com" } }
+ let(:json_attribs) { { "custom_attr" => "custom_attr_value" } }
let(:override_runlist) { nil }
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:policy_builder) { Chef::PolicyBuilder::Policyfile.new(node_name, ohai_data, json_attribs, override_runlist, events) }
@@ -40,11 +40,10 @@ describe Chef::PolicyBuilder::Policyfile do
major = sha1_id[0...14]
minor = sha1_id[14...28]
patch = sha1_id[28..40]
- decimal_integers =[major, minor, patch].map {|hex| hex.to_i(16) }
+ decimal_integers = [major, minor, patch].map { |hex| hex.to_i(16) }
decimal_integers.join(".")
end
-
let(:example1_lock_data) do
# based on https://github.com/danielsdeleo/chef-workflow2-prototype/blob/master/skeletons/basic_policy/Policyfile.lock.json
{
@@ -53,10 +52,10 @@ describe Chef::PolicyBuilder::Policyfile do
# NOTE: for compatibility mode we include the dotted id in the policyfile to enhance discoverability.
"dotted_decimal_identifier" => id_to_dotted("168d2102fb11c9617cd8a981166c8adc30a6e915"),
"source" => { "path" => "./cookbooks/demo" },
- "scm_identifier"=> {
- "vcs"=> "git",
- "rev_id"=> "9d5b09026470c322c3cb5ca8a4157c4d2f16cef3",
- "remote"=> nil,
+ "scm_identifier" => {
+ "vcs" => "git",
+ "rev_id" => "9d5b09026470c322c3cb5ca8a4157c4d2f16cef3",
+ "remote" => nil,
},
}
end
@@ -71,8 +70,8 @@ describe Chef::PolicyBuilder::Policyfile do
}
end
- let(:policyfile_default_attributes) { {"policyfile_default_attr" => "policyfile_default_value"} }
- let(:policyfile_override_attributes) { {"policyfile_override_attr" => "policyfile_override_value"} }
+ let(:policyfile_default_attributes) { { "policyfile_default_attr" => "policyfile_default_value" } }
+ let(:policyfile_override_attributes) { { "policyfile_override_attr" => "policyfile_override_value" } }
let(:policyfile_run_list) { ["recipe[example1::default]", "recipe[example2::server]"] }
@@ -132,7 +131,7 @@ describe Chef::PolicyBuilder::Policyfile do
end
context "when json_attribs contains a run_list" do
- let(:json_attribs) { {"run_list" => []} }
+ let(:json_attribs) { { "run_list" => [] } }
it "errors on create" do
expect { initialize_pb }.to raise_error(err_namespace::UnsupportedFeature)
@@ -158,8 +157,8 @@ describe Chef::PolicyBuilder::Policyfile do
let(:override_runlist) { nil }
let(:primary_runlist) { nil }
- let(:original_default_attrs) { {"default_key" => "default_value"} }
- let(:original_override_attrs) { {"override_key" => "override_value"} }
+ let(:original_default_attrs) { { "default_key" => "default_value" } }
+ let(:original_override_attrs) { { "override_key" => "override_value" } }
let(:node) do
node = Chef::Node.new
@@ -268,7 +267,6 @@ describe Chef::PolicyBuilder::Policyfile do
end
-
describe "building policy from the policyfile" do
before do
@@ -304,7 +302,6 @@ describe Chef::PolicyBuilder::Policyfile do
expect(policy_builder.expand_run_list.roles).to eq([])
end
-
describe "validating the Policyfile.lock" do
it "errors if the policyfile json contains any non-recipe items" do
@@ -447,7 +444,6 @@ describe Chef::PolicyBuilder::Policyfile do
node
end
-
it "prefers the policy_name and policy_group from the node json" do
expect(policy_builder.policy_name).to eq("policy_name_from_node_json")
expect(policy_builder.policy_group).to eq("policy_group_from_node_json")
@@ -592,7 +588,6 @@ describe Chef::PolicyBuilder::Policyfile do
end
end
-
describe "fetching the desired cookbook set" do
let(:example1_cookbook_data) { double("CookbookVersion Hash for example1 cookbook") }
@@ -716,7 +711,6 @@ describe Chef::PolicyBuilder::Policyfile do
include_examples "fetching cookbooks when they don't exist"
end
-
context "when the cookbooks exist on the server" do
before do
@@ -735,7 +729,6 @@ describe Chef::PolicyBuilder::Policyfile do
end
-
end
end
diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb
index 3dce632570..f553991903 100644
--- a/spec/unit/property/state_spec.rb
+++ b/spec/unit/property/state_spec.rb
@@ -32,9 +32,9 @@ describe "Chef::Resource#identity and #state" do
end
def self.with_property(*properties, &block)
- tags_index = properties.find_index { |p| !p.is_a?(String)}
+ tags_index = properties.find_index { |p| !p.is_a?(String) }
if tags_index
- properties, tags = properties[0..tags_index-1], properties[tags_index..-1]
+ properties, tags = properties[0..tags_index - 1], properties[tags_index..-1]
else
tags = []
end
@@ -203,10 +203,11 @@ describe "Chef::Resource#identity and #state" do
before do
resource_class.class_eval do
def custom_property
- @blarghle ? @blarghle*3 : nil
+ @blarghle ? @blarghle * 3 : nil
end
+
def custom_property=(x)
- @blarghle = x*2
+ @blarghle = x * 2
end
end
end
@@ -353,10 +354,11 @@ describe "Chef::Resource#identity and #state" do
before do
resource_class.class_eval do
def x
- @blah*3
+ @blah * 3
end
+
def x=(value)
- @blah = value*2
+ @blah = value * 2
end
end
end
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb
index 5a40cce145..0b2a8e0bc9 100644
--- a/spec/unit/property/validation_spec.rb
+++ b/spec/unit/property/validation_spec.rb
@@ -8,12 +8,15 @@ describe "Chef::Resource.property validation" do
def self.next_resource_name
"chef_resource_property_spec_#{@i += 1}"
end
+
def self.reset_index
@current_index = 0
end
+
def self.current_index
@current_index
end
+
def self.next_index
@current_index += 1
end
@@ -38,6 +41,7 @@ describe "Chef::Resource.property validation" do
def blah
Namer.next_index
end
+
def self.blah
"class#{Namer.next_index}"
end
@@ -55,9 +59,9 @@ describe "Chef::Resource.property validation" do
end
def self.with_property(*properties, &block)
- tags_index = properties.find_index { |p| !p.is_a?(String)}
+ tags_index = properties.find_index { |p| !p.is_a?(String) }
if tags_index
- properties, tags = properties[0..tags_index-1], properties[tags_index..-1]
+ properties, tags = properties[0..tags_index - 1], properties[tags_index..-1]
else
tags = []
end
@@ -516,32 +520,32 @@ describe "Chef::Resource.property validation" do
context "cannot_be" do
validation_test "cannot_be: :empty",
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
validation_test 'cannot_be: "empty"',
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
validation_test "cannot_be: [ :empty, :nil ]",
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
validation_test 'cannot_be: [ "empty", "nil" ]',
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
validation_test "cannot_be: [ :nil, :empty ]",
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
validation_test "cannot_be: [ :empty, :nil, :blahblah ]",
- [ 1, [1,2], { a: 10 } ],
+ [ 1, [1, 2], { a: 10 } ],
[ [] ],
:nil_is_valid
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index dc969ebde2..ecea666072 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -8,12 +8,15 @@ describe "Chef::Resource.property" do
def self.next_resource_name
"chef_resource_property_spec_#{@i += 1}"
end
+
def self.reset_index
@current_index = 0
end
+
def self.current_index
@current_index
end
+
def self.next_index
@current_index += 1
end
@@ -52,9 +55,9 @@ describe "Chef::Resource.property" do
end
def self.with_property(*properties, &block)
- tags_index = properties.find_index { |p| !p.is_a?(String)}
+ tags_index = properties.find_index { |p| !p.is_a?(String) }
if tags_index
- properties, tags = properties[0..tags_index-1], properties[tags_index..-1]
+ properties, tags = properties[0..tags_index - 1], properties[tags_index..-1]
else
tags = []
end
@@ -551,6 +554,7 @@ describe "Chef::Resource.property" do
def self.blah
"class"
end
+
def blah
"#{name}#{next_index}"
end
@@ -800,6 +804,7 @@ describe "Chef::Resource.property" do
def self.blah
"class"
end
+
def blah
"#{name}#{Namer.next_index}"
end
diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb
index 5986083410..ffe8c8261f 100644
--- a/spec/unit/provider/breakpoint_spec.rb
+++ b/spec/unit/provider/breakpoint_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
describe Chef::Provider::Breakpoint do
diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb
index b4116bda12..096ac85b64 100644
--- a/spec/unit/provider/cookbook_file/content_spec.rb
+++ b/spec/unit/provider/cookbook_file/content_spec.rb
@@ -37,4 +37,3 @@ describe Chef::Provider::CookbookFile::Content do
end
end
-
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index 810adb52f9..b375784d00 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -24,7 +24,7 @@ require "support/shared/unit/provider/file"
describe Chef::Provider::CookbookFile do
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 107e4b9645..010b1b09f3 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -94,7 +94,7 @@ CRONTAB
cron = @provider.load_current_resource
expect(cron.mailto).to eq("warn@example.com")
- expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
+ expect(cron.environment).to eq({ "TEST" => "lol", "FLAG" => "1" })
end
it "should not break with variables that match the cron resource internals" do
@@ -109,7 +109,7 @@ CRONTAB
cron = @provider.load_current_resource
expect(cron.time).to eq(:reboot)
- expect(cron.environment).to eq({"MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
+ expect(cron.environment).to eq({ "MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production" })
end
it "should report the match" do
@@ -276,7 +276,7 @@ CRONTAB
cron = @provider.load_current_resource
expect(cron.mailto).to eq("warn@example.com")
- expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
+ expect(cron.environment).to eq({ "TEST" => "lol", "FLAG" => "1" })
end
it "should not break with variabels that match the cron resource internals" do
@@ -292,7 +292,7 @@ CRONTAB
expect(cron.minute).to eq("*")
expect(cron.hour).to eq("5")
- expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
+ expect(cron.environment).to eq({ "MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production" })
end
it "should report the match" do
diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb
index 5fe0f26a6b..8f8280e11d 100644
--- a/spec/unit/provider/deploy/revision_spec.rb
+++ b/spec/unit/provider/deploy/revision_spec.rb
@@ -41,7 +41,6 @@ describe Chef::Provider::Deploy::Revision do
FileUtils.rm_rf @temp_dir if File.directory?( @temp_dir )
end
-
it "uses the resolved revision from the SCM as the release slug" do
allow(@provider.scm_provider).to receive(:revision_slug).and_return("uglySlugly")
expect(@provider.send(:release_slug)).to eq("uglySlugly")
@@ -60,7 +59,7 @@ describe Chef::Provider::Deploy::Revision do
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
- expect(@provider.all_releases).to eq([@expected_release_dir,second_release])
+ expect(@provider.all_releases).to eq([@expected_release_dir, second_release])
end
it "removes a release from the file cache when it's used again in another release and append it to the end" do
@@ -71,7 +70,7 @@ describe Chef::Provider::Deploy::Revision do
@provider.load_current_resource
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
- expect(@provider.all_releases).to eq([@expected_release_dir,second_release])
+ expect(@provider.all_releases).to eq([@expected_release_dir, second_release])
@provider.cleanup!
allow(@provider).to receive(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
@@ -82,7 +81,7 @@ describe Chef::Provider::Deploy::Revision do
it "removes a release from the file cache when it's deleted by :cleanup!" do
release_paths = %w{first second third fourth fifth}.map do |release_name|
- "/my/deploy/dir/releases/#{release_name}"
+ "/my/deploy/dir/releases/#{release_name}"
end
release_paths.each do |release_path|
@provider.send(:release_created, release_path)
@@ -93,7 +92,7 @@ describe Chef::Provider::Deploy::Revision do
@provider.cleanup!
expected_release_paths = (%w{second third fourth fifth} << @resource.revision).map do |release_name|
- "/my/deploy/dir/releases/#{release_name}"
+ "/my/deploy/dir/releases/#{release_name}"
end
expect(@provider.all_releases).to eq(expected_release_paths)
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index 7a3c208c9c..da5a69ac1b 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -164,7 +164,7 @@ describe Chef::Provider::Deploy do
it "dont care by default if error happens on deploy" do
allow(@provider).to receive(:all_releases).and_return(["previous_release"])
- allow(@provider).to receive(:deploy){ raise "Unexpected error" }
+ allow(@provider).to receive(:deploy) { raise "Unexpected error" }
allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).not_to receive(:rollback)
expect {
@@ -175,7 +175,7 @@ describe Chef::Provider::Deploy do
it "rollbacks to previous release if error happens on deploy" do
@resource.rollback_on_error true
allow(@provider).to receive(:all_releases).and_return(["previous_release"])
- allow(@provider).to receive(:deploy){ raise "Unexpected error" }
+ allow(@provider).to receive(:deploy) { raise "Unexpected error" }
allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).to receive(:rollback)
expect {
@@ -266,7 +266,7 @@ describe Chef::Provider::Deploy do
it "raises a runtime error when there's no release to rollback to" do
all_releases = []
allow(Dir).to receive(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
- expect {@provider.run_action(:rollback)}.to raise_error(RuntimeError)
+ expect { @provider.run_action(:rollback) }.to raise_error(RuntimeError)
end
it "runs the new resource collection in the runner during a callback" do
@@ -286,12 +286,12 @@ describe Chef::Provider::Deploy do
end
it "raises a runtime error if a callback file is explicitly specified but does not exist" do
- baz_callback = "/deploy/baz.rb"
+ baz_callback = "/deploy/baz.rb"
expect(::File).to receive(:exist?).with("#{@expected_release_dir}/#{baz_callback}").and_return(false)
- @resource.before_migrate baz_callback
+ @resource.before_migrate baz_callback
@provider.define_resource_requirements
@provider.action = :deploy
- expect {@provider.process_resource_requirements}.to raise_error(RuntimeError)
+ expect { @provider.process_resource_requirements }.to raise_error(RuntimeError)
end
it "runs a default callback if the callback code is nil" do
@@ -378,11 +378,11 @@ describe Chef::Provider::Deploy do
allow(STDOUT).to receive(:tty?).and_return(true)
allow(Chef::Log).to receive(:info?).and_return(true)
- expect(@provider).to receive(:shell_out!).with("migration_foo",:cwd => @expected_release_dir,
- :user => "deployNinja", :group => "deployNinjas",
- :log_level => :info, :live_stream => STDOUT,
- :log_tag => "deploy[/my/deploy/dir]",
- :environment => {"RAILS_ENV"=>"production"})
+ expect(@provider).to receive(:shell_out!).with("migration_foo", :cwd => @expected_release_dir,
+ :user => "deployNinja", :group => "deployNinjas",
+ :log_level => :info, :live_stream => STDOUT,
+ :log_tag => "deploy[/my/deploy/dir]",
+ :environment => { "RAILS_ENV" => "production" })
@provider.migrate
end
@@ -518,7 +518,7 @@ describe Chef::Provider::Deploy do
it "runs an inline recipe with the provided block for :callback_name == {:recipe => &block} " do
snitch = nil
- recipe_code = Proc.new {snitch = 42}
+ recipe_code = Proc.new { snitch = 42 }
#@provider.should_receive(:instance_eval).with(&recipe_code)
@provider.callback(:whateverz, recipe_code)
expect(snitch).to eq(42)
@@ -533,7 +533,7 @@ describe Chef::Provider::Deploy do
it "instance_evals a block/proc for restart command" do
snitch = nil
- restart_cmd = Proc.new {snitch = 42}
+ restart_cmd = Proc.new { snitch = 42 }
@resource.restart(&restart_cmd)
@provider.restart
expect(snitch).to eq(42)
@@ -569,7 +569,7 @@ describe Chef::Provider::Deploy do
nil
else
expect(args.size).to eq(1)
- expect(args.first).to eq({"APP_ENV" => "staging"})
+ expect(args.first).to eq({ "APP_ENV" => "staging" })
end
}.twice
@provider.run("iGoToHell4this")
@@ -586,7 +586,6 @@ describe Chef::Provider::Deploy do
@provider.run("iGoToHell4this")
end
-
it "converts sudo and run to exec resources in hooks" do
runner = double("tehRunner")
allow(Chef::Runner).to receive(:new).and_return(runner)
@@ -613,7 +612,7 @@ describe Chef::Provider::Deploy do
before do
allow(::File).to receive(:exist?).with("#{@expected_release_dir}/gems.yml").and_return(true)
- @gem_list = [{:name=>"eventmachine", :version=>"0.12.9"}]
+ @gem_list = [{ :name => "eventmachine", :version => "0.12.9" }]
end
it "reads a gems.yml file, creating gem providers for each with action :upgrade" do
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb
index c4cf070246..c8bec3e8ce 100644
--- a/spec/unit/provider/directory_spec.rb
+++ b/spec/unit/provider/directory_spec.rb
@@ -191,7 +191,7 @@ describe Chef::Provider::Directory do
end
it "raises the right exception when the parent directory is a file and recursive is true" do
- pending "this seems to return the wrong error" # FIXME
+ pending "this seems to return the wrong error" # FIXME
FileUtils.touch tmp_dir
new_resource.recursive true
expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
@@ -219,7 +219,7 @@ describe Chef::Provider::Directory do
allow(node).to receive(:[]).with("platform_version").and_return("10.11")
allow(::File).to receive(:directory?).and_return(true)
allow(Chef::FileAccessControl).to receive(:writable?).and_return(false)
- expect {directory.run_action(:create) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
+ expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
end
it "os x 10.11 can write to sip exlcusions" do
@@ -269,7 +269,7 @@ describe Chef::Provider::Directory do
end
it "cannot delete it and raises an exception" do
- expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
+ expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
end
end
@@ -280,7 +280,7 @@ describe Chef::Provider::Directory do
end
it "cannot delete it and raises an exception" do
- expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
+ expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
end
end
end
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 6a5063ac60..c0b412951d 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -35,7 +35,7 @@ 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(
+ expect { provider.run_action(:run) }.to raise_error(
Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/)
end
end
@@ -70,7 +70,7 @@ describe Chef::Provider::DscResource do
end
end
end
-
+
context "when the LCM supports Invoke-DscResource" do
let (:node) {
node = Chef::Node.new
@@ -92,27 +92,27 @@ describe Chef::Provider::DscResource do
provider.run_action(:run)
expect(resource).to be_updated
end
-
+
it "flags the resource as reboot required when required" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value =>nil))
+ and_return(double(:stdout => "", :return_value => nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
expect(provider).to receive(:create_reboot_resource)
provider.run_action(:run)
end
-
+
it "does not flag the resource as reboot required when not required" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
expect(provider).to receive(:test_resource).and_return(false)
expect(provider).to receive(:invoke_resource).
- and_return(double(:stdout => "", :return_value =>nil))
+ and_return(double(:stdout => "", :return_value => nil))
expect(provider).to receive(:add_dsc_verbose_log)
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
expect(provider).to_not receive(:create_reboot_resource)
provider.run_action(:run)
end
end
-end \ No newline at end of file
+end
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index 0bea0e596d..3877a37e61 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -117,7 +117,7 @@ describe Chef::Provider::DscScript do
it "should not converge if the script is already converged" do
allow(provider).to receive(:run_configuration).with(:test).and_return([])
-
+
provider.run_action(:run)
expect(resource).not_to be_updated
end
@@ -171,4 +171,3 @@ describe Chef::Provider::DscScript do
end
end
end
-
diff --git a/spec/unit/provider/env/windows_spec.rb b/spec/unit/provider/env/windows_spec.rb
index 0eeac3dba5..abe2344443 100644
--- a/spec/unit/provider/env/windows_spec.rb
+++ b/spec/unit/provider/env/windows_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::Env::Windows, :windows_only do
let(:node) { Chef::Node.new }
- let(:events) {Chef::EventDispatch::Dispatcher.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
context "when environment variable is not PATH" do
@@ -29,8 +29,8 @@ describe Chef::Provider::Env::Windows, :windows_only do
new_resource.value("foo")
new_resource
}
- let(:provider) {
- provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
+ let(:provider) {
+ provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object)
provider
}
@@ -74,21 +74,21 @@ describe Chef::Provider::Env::Windows, :windows_only do
context "when environment is PATH" do
describe "for PATH" do
- let(:system_root) {"%SystemRoot%"}
+ let(:system_root) { "%SystemRoot%" }
let(:system_root_value) { 'D:\Windows' }
let(:new_resource) {
new_resource = Chef::Resource::Env.new("PATH")
new_resource.value(system_root)
new_resource
}
- let(:provider) {
- provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
+ let(:provider) {
+ provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object)
provider
}
before do
- stub_const("ENV", {"PATH" => ""})
+ stub_const("ENV", { "PATH" => "" })
end
it "replaces Windows system variables" do
diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb
index a5ea9f1259..e99aee5ad1 100644
--- a/spec/unit/provider/env_spec.rb
+++ b/spec/unit/provider/env_spec.rb
@@ -199,12 +199,12 @@ describe Chef::Provider::Env do
expect(@new_resource).to be_updated
end
- context "when new_resource's value contains the delimiter" do
+ context "when new_resource's value contains the delimiter" do
it "should return false if all the elements are deleted" do
# This indicates that the entire key needs to be deleted
@new_resource.value("C:/foo/bin;C:/bar/bin")
expect(@provider.delete_element).to eql(false)
- expect(@new_resource).not_to be_updated # This will be updated in action_delete
+ expect(@new_resource).not_to be_updated # This will be updated in action_delete
end
it "should return true if any, but not all, of the elements are deleted" do
@@ -251,7 +251,7 @@ describe Chef::Provider::Env do
expect(@provider.requires_modify_or_create?).to be_truthy
end
- context "when new_resource's value contains the delimiter" do
+ context "when new_resource's value contains the delimiter" do
it "should return false if all the current values are contained in specified order" do
@new_resource.value("C:/biz;C:/baz")
@new_resource.delim(";")
diff --git a/spec/unit/provider/erl_call_spec.rb b/spec/unit/provider/erl_call_spec.rb
index 946d5384d1..f1c229028a 100644
--- a/spec/unit/provider/erl_call_spec.rb
+++ b/spec/unit/provider/erl_call_spec.rb
@@ -83,4 +83,3 @@ describe Chef::Provider::ErlCall do
end
end
-
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 4cc27ef105..c0646f2999 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -130,7 +130,7 @@ describe Chef::Provider::Execute do
expect(Chef::Log).to receive(:warn).with(/relative path/)
expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
expect(provider).not_to receive(:shell_out!)
- expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13
+ expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13
end
end
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index 5179b5ce4d..ebef4faa09 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -89,7 +89,7 @@ describe Chef::Provider::File::Content do
it "fails when :file_desployment_uses_destdir is set" do
Chef::Config[:file_staging_uses_destdir] = true
- expect{content.tempfile}.to raise_error
+ expect { content.tempfile }.to raise_error
end
it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index 83cdf21050..11bef8a44d 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::File do
end
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
@@ -54,4 +54,3 @@ describe Chef::Provider::File do
it_behaves_like "a file provider with content field"
end
-
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 8c55875ce7..97f04a5a77 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
describe Chef::Provider::Git do
@@ -59,7 +58,7 @@ describe Chef::Provider::Git do
it "determines the current revision when there is one" do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n"
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", {:cwd => "/my/deploy/dir", :returns => [0,128]}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128] }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13")
end
@@ -67,7 +66,7 @@ describe Chef::Provider::Git do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
@stderr = "fatal: Not a git repository (or any of the parent directories): .git"
@stdout = ""
- expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0,128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr))
+ expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr))
expect(@provider.find_current_revision).to be_nil
end
end
@@ -98,7 +97,7 @@ describe Chef::Provider::Git do
@resource.revision "v1.0"
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -107,7 +106,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -116,7 +115,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -125,7 +124,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -134,7 +133,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -144,7 +143,7 @@ describe Chef::Provider::Git do
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -153,7 +152,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -162,7 +161,7 @@ describe Chef::Provider::Git do
@provider.action = :checkout
@provider.define_resource_requirements
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- expect {@provider.process_resource_requirements}.to raise_error(Chef::Exceptions::InvalidRemoteGitReference)
+ expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::InvalidRemoteGitReference)
end
it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do
@@ -182,7 +181,7 @@ describe Chef::Provider::Git do
it "does not raise an error when the revision is valid and assertions are run." do
@resource.revision "0.8-alpha"
@stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
@provider.action = :checkout
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
@provider.define_resource_requirements
@@ -190,7 +189,7 @@ describe Chef::Provider::Git do
end
it "gives the latest HEAD revision SHA if nothing is specified" do
- @stdout =<<-SHAS
+ @stdout = <<-SHAS
28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD
503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha
28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master
@@ -207,7 +206,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
SHAS
@resource.revision ""
- expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout))
expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
end
end
@@ -248,7 +247,7 @@ SHAS
end
context "with a specific home" do
let (:override_home) do
- {"HOME" => "/home/masterNinja"}
+ { "HOME" => "/home/masterNinja" }
end
let(:overrided_options) do
{
@@ -275,9 +274,9 @@ SHAS
@resource.ssh_wrapper "do_it_this_way.sh"
expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\""
expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja",
- :environment =>{"GIT_SSH"=>"do_it_this_way.sh",
- "HOME" => "/home/deployNinja"},
- :log_tag => "git[web2.0 app]")
+ :environment => { "GIT_SSH" => "do_it_this_way.sh",
+ "HOME" => "/home/deployNinja" },
+ :log_tag => "git[web2.0 app]")
@provider.clone
end
@@ -312,9 +311,9 @@ SHAS
it "runs a checkout command with default options" do
expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
+ :log_tag => "git[web2.0 app]").ordered
expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]").ordered
+ :log_tag => "git[web2.0 app]").ordered
@provider.checkout
end
@@ -322,7 +321,7 @@ SHAS
@resource.enable_submodules true
expected_cmd = "git submodule sync"
expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
- :log_tag => "git[web2.0 app]")
+ :log_tag => "git[web2.0 app]")
expected_cmd = "git submodule update --init --recursive"
expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
@provider.enable_submodules
@@ -336,7 +335,7 @@ SHAS
it "runs a sync command with default options" do
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :log_tag => "git[web2.0 app]")
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]")
@provider.fetch_updates
end
@@ -347,9 +346,9 @@ SHAS
expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository)
expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
- :user => "whois", :group => "thisis",
- :log_tag => "git[web2.0 app]",
- :environment=>{"HOME"=>"/home/whois"})
+ :user => "whois", :group => "thisis",
+ :log_tag => "git[web2.0 app]",
+ :environment => { "HOME" => "/home/whois" })
@provider.fetch_updates
end
@@ -378,7 +377,7 @@ SHAS
expect(@provider).to receive(:shell_out!).with(expected_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
- :returns => [0,1,2]).and_return(command_response)
+ :returns => [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
:cwd => "/my/deploy/dir",
@@ -398,15 +397,15 @@ SHAS
:log_tag => "git[web2.0 app]",
:user => "whois",
:group => "thisis",
- :environment=>{"HOME"=>"/home/whois"},
- :returns => [0,1,2]).and_return(command_response)
+ :environment => { "HOME" => "/home/whois" },
+ :returns => [0, 1, 2]).and_return(command_response)
add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(add_remote_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
:user => "whois",
:group => "thisis",
- :environment=>{"HOME"=>"/home/whois"})
+ :environment => { "HOME" => "/home/whois" })
@provider.setup_remote_tracking_branches(@resource.remote, @resource.repository)
end
@@ -418,7 +417,7 @@ SHAS
expect(@provider).to receive(:shell_out!).with(check_remote_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
- :returns => [0,1,2]).and_return(command_response)
+ :returns => [0, 1, 2]).and_return(command_response)
expected_command = "git remote add #{@resource.remote} #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(expected_command,
:cwd => "/my/deploy/dir",
@@ -436,7 +435,7 @@ SHAS
expect(@provider).to receive(:shell_out!).with(check_remote_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
- :returns => [0,1,2]).and_return(command_response)
+ :returns => [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(expected_command,
:cwd => "/my/deploy/dir",
@@ -452,7 +451,7 @@ SHAS
expect(@provider).to receive(:shell_out!).with(check_remote_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
- :returns => [0,1,2]).and_return(command_response)
+ :returns => [0, 1, 2]).and_return(command_response)
unexpected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}"
expect(@provider).not_to receive(:shell_out!).with(unexpected_command,
:cwd => "/my/deploy/dir",
@@ -467,7 +466,7 @@ SHAS
expect(@provider).to receive(:shell_out!).with(check_remote_command,
:cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]",
- :returns => [0,1,2]).and_return(command_response)
+ :returns => [0, 1, 2]).and_return(command_response)
expected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}"
expect(@provider).to receive(:shell_out!).with(expected_command,
:cwd => "/my/deploy/dir",
@@ -479,7 +478,7 @@ SHAS
it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do
allow(@provider).to receive(:shell_out!)
- expect {@provider.run_action(:sync)}.to raise_error(Chef::Exceptions::MissingParentDirectory)
+ expect { @provider.run_action(:sync) }.to raise_error(Chef::Exceptions::MissingParentDirectory)
end
it "does a checkout by cloning the repo and then enabling submodules" do
@@ -488,7 +487,7 @@ SHAS
allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."])
+ allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."])
expect(@provider).to receive(:clone)
expect(@provider).to receive(:checkout)
expect(@provider).to receive(:enable_submodules)
@@ -504,7 +503,7 @@ SHAS
allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."])
+ allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."])
@resource.enable_checkout false
expect(@provider).to receive(:clone)
@@ -519,7 +518,7 @@ SHAS
allow(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(false)
allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(false)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..","."])
+ allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..", "."])
expect(@provider).to receive(:clone)
expect(@provider).to receive(:checkout)
expect(@provider).to receive(:enable_submodules)
@@ -534,7 +533,7 @@ SHAS
allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"])
+ allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", "..", "foo", "bar"])
expect(@provider).not_to receive(:clone)
expect(@provider).not_to receive(:checkout)
expect(@provider).not_to receive(:enable_submodules)
@@ -606,8 +605,8 @@ SHAS
describe "calling add_remotes" do
it "adds a new remote for each entry in additional remotes hash" do
- @resource.additional_remotes({:opscode => "opscode_repo_url",
- :another_repo => "some_other_repo_url"})
+ @resource.additional_remotes({ :opscode => "opscode_repo_url",
+ :another_repo => "some_other_repo_url" })
allow(STDOUT).to receive(:tty?).and_return(false)
command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index 44619f891b..52aff87dc5 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Provider::Group::Dscl do
it "should return an array of four elements - cmd, status, stdout, stderr" do
dscl_retval = @provider.dscl("cmd /Path args")
expect(dscl_retval).to be_a_kind_of(Array)
- expect(dscl_retval).to eq(["dscl . -cmd /Path args",@status,"\n",""])
+ expect(dscl_retval).to eq(["dscl . -cmd /Path args", @status, "\n", ""])
end
describe "safe_dscl" do
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index ad9e16ea94..b4295c9dff 100644
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -43,9 +43,9 @@ describe Chef::Provider::Group::Groupadd, "set_options" do
field_list.each do |attribute, option|
it "should check for differences in #{attribute} between the current and new resources" do
- expect(@new_resource).to receive(attribute)
- expect(@current_resource).to receive(attribute)
- @provider.set_options
+ expect(@new_resource).to receive(attribute)
+ expect(@current_resource).to receive(attribute)
+ @provider.set_options
end
it "should set the option for #{attribute} if the new resources #{attribute} is not null" do
allow(@new_resource).to receive(attribute).and_return("wowaweea")
@@ -55,7 +55,7 @@ describe Chef::Provider::Group::Groupadd, "set_options" do
it "should combine all the possible options" do
match_string = ""
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
allow(@new_resource).to receive(attribute).and_return("hola")
match_string << " #{option} 'hola'"
end
diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb
index 1cb39ad0c3..21d026409e 100644
--- a/spec/unit/provider/group/groupmod_spec.rb
+++ b/spec/unit/provider/group/groupmod_spec.rb
@@ -19,16 +19,16 @@
require "spec_helper"
describe Chef::Provider::Group::Groupmod do
- before do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::Group.new("wheel")
- @new_resource.gid 123
- @new_resource.members %w{lobster rage fist}
- @new_resource.append false
- @provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context)
- end
+ before do
+ @node = Chef::Node.new
+ @events = Chef::EventDispatch::Dispatcher.new
+ @run_context = Chef::RunContext.new(@node, {}, @events)
+ @new_resource = Chef::Resource::Group.new("wheel")
+ @new_resource.gid 123
+ @new_resource.members %w{lobster rage fist}
+ @new_resource.append false
+ @provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context)
+ end
describe "manage_group" do
describe "when determining the current group state" do
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index d5512b32cd..d41b0689ee 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -120,7 +120,7 @@ describe Chef::Provider::User do
end
it "should return true if the append is true and excluded_members include an existing user" do
- @new_resource.members.each {|m| @new_resource.excluded_members << m }
+ @new_resource.members.each { |m| @new_resource.excluded_members << m }
@new_resource.members.clear
allow(@new_resource).to receive(:append).and_return(true)
expect(@provider.compare_group).to be_truthy
@@ -256,18 +256,18 @@ describe Chef::Provider::User do
describe "when determining the reason for a change" do
it "should report which group members are missing if members are missing and appending to the group" do
- @new_resource.members << "user1"
- @new_resource.members << "user2"
- allow(@new_resource).to receive(:append).and_return true
- expect(@provider.compare_group).to be_truthy
- expect(@provider.change_desc).to eq([ "add missing member(s): user1, user2" ])
+ @new_resource.members << "user1"
+ @new_resource.members << "user2"
+ allow(@new_resource).to receive(:append).and_return true
+ expect(@provider.compare_group).to be_truthy
+ expect(@provider.change_desc).to eq([ "add missing member(s): user1, user2" ])
end
it "should report that the group members will be overwritten if not appending" do
- @new_resource.members << "user1"
- allow(@new_resource).to receive(:append).and_return false
- expect(@provider.compare_group).to be_truthy
- expect(@provider.change_desc).to eq([ "replace group members with new list of members" ])
+ @new_resource.members << "user1"
+ allow(@new_resource).to receive(:append).and_return false
+ expect(@provider.compare_group).to be_truthy
+ expect(@provider.change_desc).to eq([ "replace group members with new list of members" ])
end
it "should report the gid will be changed when it does not match" do
diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb
index f4d415be4d..9a3519a95a 100644
--- a/spec/unit/provider/http_request_spec.rb
+++ b/spec/unit/provider/http_request_spec.rb
@@ -138,7 +138,7 @@ describe Chef::Provider::HttpRequest do
it "should not update a HEAD request if a not modified response (CHEF-4762)" do
if_modified_since = File.mtime(__FILE__).httpdate
@new_resource.headers "If-Modified-Since" => if_modified_since
- expect(@http).to receive(:head).with("http://www.opscode.com/", {"If-Modified-Since" => if_modified_since}).and_return(false)
+ expect(@http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false)
@provider.run_action(:head)
expect(@new_resource).not_to be_updated
end
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 264ef1d205..7847fc9a5f 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -35,7 +35,6 @@ lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64
IFCONFIG
end
-
before(:each) do
@node = Chef::Node.new
@cookbook_collection = Chef::CookbookCollection.new([])
@@ -87,7 +86,7 @@ IFCONFIG
@provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
end
- expect{@provider.run_action(:add)}.to raise_error(Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action")
+ expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric attribute cannot be set for :add action")
end
end
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index d0ae988344..1f61957721 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::Ifconfig::Debian do
new_resource
end
- let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) }
+ let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) }
let(:provider) do
status = double("Status", :exitstatus => 0)
@@ -120,7 +120,7 @@ iface eth0 inet static
netmask 255.255.254.0
EOF
)
- expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
+ expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
end
context "when the /etc/network/interfaces file has the source line" do
@@ -253,7 +253,7 @@ iface eth0 inet static
EOF
)
expect(File).not_to receive(:new).with(config_filename_ifcfg, "w")
- expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
+ expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
end
context "when the /etc/network/interfaces file has the source line" do
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index cf49d651c2..421dd0c2dd 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Mdadm do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Mdadm.new("/dev/md1")
- @new_resource.devices ["/dev/sdz1","/dev/sdz2","/dev/sdz3"]
+ @new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"]
@provider = Chef::Provider::Mdadm.new(@new_resource, @run_context)
end
@@ -39,13 +39,13 @@ describe Chef::Provider::Mdadm do
end
it "determines that the metadevice exists when mdadm exit code is zero" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_truthy
end
it "determines that the metadevice does not exist when mdadm exit code is 4" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 4))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_falsey
end
@@ -102,12 +102,12 @@ describe Chef::Provider::Mdadm do
expect(@new_resource).to be_updated_by_last_action
end
- it "should not assemble the raid device if it doesnt exist" do
+ it "should not assemble the raid device if it doesnt exist" do
@current_resource.exists(true)
expect(@provider).not_to receive(:shell_out!)
@provider.run_action(:assemble)
expect(@new_resource).not_to be_updated_by_last_action
- end
+ end
end
describe "when stopping the metadevice" do
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index 3bd05073ea..9a34a6d21d 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -40,7 +40,7 @@ UNMOUNTED
/dev/sdz3 /tmp/foo jfs2 Jul 17 13:22 rw,log=/dev/hd8
MOUNT
- @enabled_output = <<-ENABLED
+ @enabled_output = <<-ENABLED
#MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct
/tmp/foo:/dev/sdz1:jfs2::bootfs:10485760:rw:yes:no
ENABLED
@@ -156,7 +156,7 @@ ENABLED
describe "remount_fs" do
it "should remount resource if it is already mounted and it supports remounting" do
- @new_resource.supports({:remount => true})
+ @new_resource.supports({ :remount => true })
stub_mounted_enabled(@provider, @mounted_output, "")
expect(@provider).to receive(:shell_out!).with("mount -o remount #{@new_resource.device} #{@new_resource.mount_point}")
@@ -165,7 +165,7 @@ ENABLED
end
it "should remount with new mount options if it is already mounted and it supports remounting" do
- @new_resource.supports({:remount => true})
+ @new_resource.supports({ :remount => true })
@new_resource.options("nodev,rw")
stub_mounted_enabled(@provider, @mounted_output, "")
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 1fbe0c5c89..50ed356049 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -239,11 +239,11 @@ describe Chef::Provider::Mount::Mount do
end
it "should ignore commented lines in fstab " do
- fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
- allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab
+ fstab = "\# #{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n"
+ allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab
- @provider.load_current_resource
- expect(@provider.current_resource.enabled).to be_falsey
+ @provider.load_current_resource
+ expect(@provider.current_resource.enabled).to be_falsey
end
it "should set enabled to false if the mount point is not last in fstab" do
@@ -347,14 +347,14 @@ describe Chef::Provider::Mount::Mount do
describe "remount_fs" do
it "should use mount -o remount if remount is supported" do
- @new_resource.supports({:remount => true})
+ @new_resource.supports({ :remount => true })
@current_resource.mounted(true)
expect(@provider).to receive(:shell_out!).with("mount -o remount,defaults #{@new_resource.mount_point}")
@provider.remount_fs
end
it "should use mount -o remount with new mount options if remount is supported" do
- @new_resource.supports({:remount => true})
+ @new_resource.supports({ :remount => true })
options = "rw,noexec,noauto"
@new_resource.options(%w{rw noexec noauto})
@current_resource.mounted(true)
@@ -363,7 +363,7 @@ describe Chef::Provider::Mount::Mount do
end
it "should umount and mount if remount is not supported" do
- @new_resource.supports({:remount => false})
+ @new_resource.supports({ :remount => false })
@current_resource.mounted(true)
expect(@provider).to receive(:umount_fs)
expect(@provider).to receive(:sleep).with(1)
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 7304c4290f..a6d0620df6 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) }
+ [: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
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index df7479fd46..ab7a161c08 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -100,9 +100,9 @@ describe Chef::Provider::Mount::Windows do
it "should mount the filesystem if it is not mounted" do
expect(@vol).to receive(:add).with(:remote => @new_resource.device,
- :username => @new_resource.username,
- :domainname => @new_resource.domain,
- :password => @new_resource.password)
+ :username => @new_resource.username,
+ :domainname => @new_resource.domain,
+ :password => @new_resource.password)
@provider.mount_fs
end
@@ -114,9 +114,9 @@ describe Chef::Provider::Mount::Windows do
it "should remount the filesystem if it is mounted and the options have changed" do
expect(@vol).to receive(:add).with(:remote => @new_resource.device,
- :username => @new_resource.username,
- :domainname => @new_resource.domain,
- :password => @new_resource.password)
+ :username => @new_resource.username,
+ :domainname => @new_resource.domain,
+ :password => @new_resource.password)
@provider.mount_fs
end
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index 5aa247a30f..fa168e571e 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -135,7 +135,7 @@ describe Chef::Provider::Mount do
provider.unmount_retries = 1
expect(provider).to receive(:umount_fs)
expect(provider).to receive(:mounted?).and_return(true, true)
- expect{ provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount)
+ expect { provider.run_action(:remount) }.to raise_error(Chef::Exceptions::Mount)
end
end
@@ -181,7 +181,6 @@ describe Chef::Provider::Mount do
end
end
-
it "should delegates the mount implementation to subclasses" do
expect { provider.mount_fs }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb
index d04bef146e..100eee59a4 100644
--- a/spec/unit/provider/ohai_spec.rb
+++ b/spec/unit/provider/ohai_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Provider::Ohai do
mock_ohai[:data2])
allow(Ohai::System).to receive(:new).and_return(mock_ohai)
allow(Chef::Platform).to receive(:find_platform_and_version).and_return({ "platform" => @platform,
- "platform_version" => @platform_version})
+ "platform_version" => @platform_version })
# Fake node with a dummy save
@node = Chef::Node.new
@node.name(@fqdn)
@@ -56,7 +56,7 @@ describe Chef::Provider::Ohai do
@new_resource = Chef::Resource::Ohai.new("ohai_reload")
ohai = Ohai::System.new
ohai.all_plugins
- @node.consume_external_attrs(ohai.data,{})
+ @node.consume_external_attrs(ohai.data, {})
@provider = Chef::Provider::Ohai.new(@new_resource, @run_context)
end
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index 13b65e8cc7..260204f98b 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -23,56 +23,47 @@ describe Chef::Provider::OsxProfile do
double("shell_out", :exitstatus => 0, :error? => false)
end
describe "action_create" do
- let(:node) { Chef::Node.new }
- let(:events) { Chef::EventDispatch::Dispatcher.new }
- let(:run_context) { Chef::RunContext.new(node, {}, events) }
- let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) }
- let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) }
- let(:all_profiles) do
- {"_computerlevel"=>
- [{"ProfileDisplayName"=>"Finder Settings",
- "ProfileIdentifier"=>"com.apple.finder",
- "ProfileInstallDate"=>"2015-11-08 23:15:21 +0000",
- "ProfileItems"=>
- [{"PayloadContent"=>
- {"PayloadContentManagedPreferences"=>
- {"com.apple.finder"=>
- {"Forced"=>[{"mcx_preference_settings"=>{"ShowExternalHardDrivesOnDesktop"=>false}}]}}},
- "PayloadDisplayName"=>"Custom: (com.apple.finder)",
- "PayloadIdentifier"=>"com.apple.finder",
- "PayloadType"=>"com.apple.ManagedClient.preferences",
- "PayloadUUID"=>"a017048f-684b-4e81-baa3-43afe316d739",
- "PayloadVersion"=>1}],
- "ProfileOrganization"=>"Chef",
- "ProfileRemovalDisallowed"=>"false",
- "ProfileType"=>"Configuration",
- "ProfileUUID"=>"e2e09bef-e673-44a6-bcbe-ecb5f1c1b740",
- "ProfileVerificationState"=>"unsigned",
- "ProfileVersion"=>1},
- {"ProfileDisplayName"=>"ScreenSaver Settings",
- "ProfileIdentifier"=>"com.testprofile.screensaver",
- "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000",
- "ProfileItems"=>
- [{"PayloadContent"=>
- {"PayloadContentManagedPreferences"=>
- {"com.apple.screensaver"=>
- {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}},
- "PayloadDisplayName"=>"Custom: (com.apple.screensaver)",
- "PayloadIdentifier"=>"com.apple.screensaver",
- "PayloadType"=>"com.apple.ManagedClient.preferences",
- "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c110",
- "PayloadVersion"=>1}],
- "ProfileOrganization"=>"Chef",
- "ProfileRemovalDisallowed"=>"false",
- "ProfileType"=>"Configuration",
- "ProfileUUID"=>"6e95927c-f200-54b4-85c7-52ab99b61c47",
- "ProfileVerificationState"=>"unsigned",
- "ProfileVersion"=>1}]
- }
- end
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) }
+ let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) }
+ let(:all_profiles) do
+ { "_computerlevel" => [{ "ProfileDisplayName" => "Finder Settings",
+ "ProfileIdentifier" => "com.apple.finder",
+ "ProfileInstallDate" => "2015-11-08 23:15:21 +0000",
+ "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.finder" => { "Forced" => [{ "mcx_preference_settings" => { "ShowExternalHardDrivesOnDesktop" => false } }] } } },
+ "PayloadDisplayName" => "Custom: (com.apple.finder)",
+ "PayloadIdentifier" => "com.apple.finder",
+ "PayloadType" => "com.apple.ManagedClient.preferences",
+ "PayloadUUID" => "a017048f-684b-4e81-baa3-43afe316d739",
+ "PayloadVersion" => 1 }],
+ "ProfileOrganization" => "Chef",
+ "ProfileRemovalDisallowed" => "false",
+ "ProfileType" => "Configuration",
+ "ProfileUUID" => "e2e09bef-e673-44a6-bcbe-ecb5f1c1b740",
+ "ProfileVerificationState" => "unsigned",
+ "ProfileVersion" => 1 },
+ { "ProfileDisplayName" => "ScreenSaver Settings",
+ "ProfileIdentifier" => "com.testprofile.screensaver",
+ "ProfileInstallDate" => "2015-10-05 23:15:21 +0000",
+ "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } },
+ "PayloadDisplayName" => "Custom: (com.apple.screensaver)",
+ "PayloadIdentifier" => "com.apple.screensaver",
+ "PayloadType" => "com.apple.ManagedClient.preferences",
+ "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110",
+ "PayloadVersion" => 1 }],
+ "ProfileOrganization" => "Chef",
+ "ProfileRemovalDisallowed" => "false",
+ "ProfileType" => "Configuration",
+ "ProfileUUID" => "6e95927c-f200-54b4-85c7-52ab99b61c47",
+ "ProfileVerificationState" => "unsigned",
+ "ProfileVersion" => 1 }]
+ }
+ end
# If anything is changed within this profile, be sure to update the
# ProfileUUID in all_profiles to match the new config specific UUID
- let(:test_profile) do
+ let(:test_profile) do
{
"PayloadIdentifier" => "com.testprofile.screensaver",
"PayloadRemovalDisallowed" => false,
@@ -82,7 +73,7 @@ describe Chef::Provider::OsxProfile do
"PayloadOrganization" => "Chef",
"PayloadVersion" => 1,
"PayloadDisplayName" => "Screensaver Settings",
- "PayloadContent"=> [
+ "PayloadContent" => [
{
"PayloadType" => "com.apple.ManagedClient.preferences",
"PayloadVersion" => 1,
@@ -104,10 +95,10 @@ describe Chef::Provider::OsxProfile do
},
],
}
- end
- let(:no_profiles) do
- { }
- end
+ end
+ let(:no_profiles) do
+ {}
+ end
before(:each) do
allow(provider).to receive(:cookbook_file_available?).and_return(true)
@@ -181,7 +172,7 @@ describe Chef::Provider::OsxProfile do
test_profile.delete("PayloadIdentifier")
new_resource.profile test_profile
error_message = "The specified profile does not seem to be valid"
- expect{provider.run_action(:install)}.to raise_error(RuntimeError, error_message)
+ expect { provider.run_action(:install) }.to raise_error(RuntimeError, error_message)
end
end
@@ -194,45 +185,36 @@ describe Chef::Provider::OsxProfile do
let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) }
let(:current_resource) { Chef::Resource::OsxProfile.new("Profile Test") }
let(:all_profiles) do
- {"_computerlevel"=>
- [{"ProfileDisplayName"=>"ScreenSaver Settings",
- "ProfileIdentifier"=>"com.apple.screensaver",
- "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000",
- "ProfileItems"=>
- [{"PayloadContent"=>
- {"PayloadContentManagedPreferences"=>
- {"com.apple.screensaver"=>
- {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}},
- "PayloadDisplayName"=>"Custom: (com.apple.screensaver)",
- "PayloadIdentifier"=>"com.apple.screensaver",
- "PayloadType"=>"com.apple.ManagedClient.preferences",
- "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c108",
- "PayloadVersion"=>1}],
- "ProfileOrganization"=>"Chef",
- "ProfileRemovalDisallowed"=>"false",
- "ProfileType"=>"Configuration",
- "ProfileUUID"=>"1781fbec-3325-565f-9022-8aa28135c3cc",
- "ProfileVerificationState"=>"unsigned",
- "ProfileVersion"=>1},
- {"ProfileDisplayName"=>"ScreenSaver Settings",
- "ProfileIdentifier"=>"com.testprofile.screensaver",
- "ProfileInstallDate"=>"2015-10-05 23:15:21 +0000",
- "ProfileItems"=>
- [{"PayloadContent"=>
- {"PayloadContentManagedPreferences"=>
- {"com.apple.screensaver"=>
- {"Forced"=>[{"mcx_preference_settings"=>{"idleTime"=>0}}]}}},
- "PayloadDisplayName"=>"Custom: (com.apple.screensaver)",
- "PayloadIdentifier"=>"com.apple.screensaver",
- "PayloadType"=>"com.apple.ManagedClient.preferences",
- "PayloadUUID"=>"73fc30e0-1e57-0131-c32d-000c2944c110",
- "PayloadVersion"=>1}],
- "ProfileOrganization"=>"Chef",
- "ProfileRemovalDisallowed"=>"false",
- "ProfileType"=>"Configuration",
- "ProfileUUID"=>"1781fbec-3325-565f-9022-8aa28135c3cc",
- "ProfileVerificationState"=>"unsigned",
- "ProfileVersion"=>1}]
+ { "_computerlevel" => [{ "ProfileDisplayName" => "ScreenSaver Settings",
+ "ProfileIdentifier" => "com.apple.screensaver",
+ "ProfileInstallDate" => "2015-10-05 23:15:21 +0000",
+ "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } },
+ "PayloadDisplayName" => "Custom: (com.apple.screensaver)",
+ "PayloadIdentifier" => "com.apple.screensaver",
+ "PayloadType" => "com.apple.ManagedClient.preferences",
+ "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108",
+ "PayloadVersion" => 1 }],
+ "ProfileOrganization" => "Chef",
+ "ProfileRemovalDisallowed" => "false",
+ "ProfileType" => "Configuration",
+ "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc",
+ "ProfileVerificationState" => "unsigned",
+ "ProfileVersion" => 1 },
+ { "ProfileDisplayName" => "ScreenSaver Settings",
+ "ProfileIdentifier" => "com.testprofile.screensaver",
+ "ProfileInstallDate" => "2015-10-05 23:15:21 +0000",
+ "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } },
+ "PayloadDisplayName" => "Custom: (com.apple.screensaver)",
+ "PayloadIdentifier" => "com.apple.screensaver",
+ "PayloadType" => "com.apple.ManagedClient.preferences",
+ "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110",
+ "PayloadVersion" => 1 }],
+ "ProfileOrganization" => "Chef",
+ "ProfileRemovalDisallowed" => "false",
+ "ProfileType" => "Configuration",
+ "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc",
+ "ProfileVerificationState" => "unsigned",
+ "ProfileVersion" => 1 }]
}
end
before(:each) do
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb
index b319d87929..6940874a43 100644
--- a/spec/unit/provider/package/aix_spec.rb
+++ b/spec/unit/provider/package/aix_spec.rb
@@ -33,10 +33,10 @@ describe Chef::Provider::Package::Aix do
describe "assessing the current package status" do
before do
- @bffinfo ="/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:
- /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
+ @bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:
+ /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:"
- @empty_status = double("Status", :stdout => "", :exitstatus => 0)
+ @empty_status = double("Status", :stdout => "", :exitstatus => 0)
end
it "should create a current resource with the name of new_resource" do
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index abf128d086..f87c1e86bc 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -34,7 +34,7 @@ describe Chef::Provider::Package::Apt do
@status = double("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
@stdin = StringIO.new
- @stdout =<<-PKG_STATUS
+ @stdout = <<-PKG_STATUS
irssi:
Installed: (none)
Candidate: 0.8.14-1ubuntu4
@@ -43,7 +43,7 @@ irssi:
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
PKG_STATUS
@stderr = ""
- @shell_out = OpenStruct.new(:stdout => @stdout,:stdin => @stdin,:stderr => @stderr,:status => @status,:exitstatus => 0)
+ @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
@timeout = 900
end
@@ -86,18 +86,18 @@ sudo:
# list of virtual packages: http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt
it "should not install the virtual package there is a single provider package and it is installed" do
@new_resource.package_name("libmysqlclient15-dev")
- virtual_package_out=<<-VPKG_STDOUT
+ virtual_package_out = <<-VPKG_STDOUT
libmysqlclient15-dev:
Installed: (none)
Candidate: (none)
Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
+ virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with(
"apt-cache policy libmysqlclient15-dev",
:timeout => @timeout,
).and_return(virtual_package)
- showpkg_out =<<-SHOWPKG_STDOUT
+ showpkg_out = <<-SHOWPKG_STDOUT
Package: libmysqlclient15-dev
Versions:
@@ -115,12 +115,12 @@ libmysqlclient-dev 5.1.41-3ubuntu12.7
libmysqlclient-dev 5.1.41-3ubuntu12.10
libmysqlclient-dev 5.1.41-3ubuntu12
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
+ showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with(
"apt-cache showpkg libmysqlclient15-dev",
:timeout => @timeout,
).and_return(showpkg)
- real_package_out=<<-RPKG_STDOUT
+ real_package_out = <<-RPKG_STDOUT
libmysqlclient-dev:
Installed: 5.1.41-3ubuntu12.10
Candidate: 5.1.41-3ubuntu12.10
@@ -133,7 +133,7 @@ libmysqlclient-dev:
5.1.41-3ubuntu12 0
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
RPKG_STDOUT
- real_package = double(:stdout => real_package_out,:exitstatus => 0)
+ real_package = double(:stdout => real_package_out, :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with(
"apt-cache policy libmysqlclient-dev",
:timeout => @timeout,
@@ -143,18 +143,18 @@ libmysqlclient-dev:
it "should raise an exception if you specify a virtual package with multiple provider packages" do
@new_resource.package_name("mp3-decoder")
- virtual_package_out=<<-VPKG_STDOUT
+ virtual_package_out = <<-VPKG_STDOUT
mp3-decoder:
Installed: (none)
Candidate: (none)
Version table:
VPKG_STDOUT
- virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
+ virtual_package = double(:stdout => virtual_package_out, :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with(
"apt-cache policy mp3-decoder",
:timeout => @timeout,
).and_return(virtual_package)
- showpkg_out=<<-SHOWPKG_STDOUT
+ showpkg_out = <<-SHOWPKG_STDOUT
Package: mp3-decoder
Versions:
@@ -175,7 +175,7 @@ opencubicplayer 1:0.1.17-2
mpg321 0.2.10.6
mpg123 1.12.1-0ubuntu1
SHOWPKG_STDOUT
- showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
+ showpkg = double(:stdout => showpkg_out, :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with(
"apt-cache showpkg mp3-decoder",
:timeout => @timeout,
@@ -204,7 +204,7 @@ mpg123 1.12.1-0ubuntu1
).and_return(@shell_out)
@provider.load_current_resource
@provider.define_resource_requirements
- expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", {:timeout=>900}).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", { :timeout => 900 }).and_return(@shell_out)
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
end
@@ -219,7 +219,7 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version" do
expect(@provider).to receive(:shell_out!). with(
"apt-get -q -y install irssi=0.8.12-7",
- :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@provider.install_package("irssi", "0.8.12-7")
@@ -228,7 +228,7 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get install with the package name and version and options if specified" do
expect(@provider).to receive(:shell_out!).with(
"apt-get -q -y --force-yes install irssi=0.8.12-7",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@new_resource.options("--force-yes")
@@ -244,7 +244,7 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out!).with(
"apt-get -q -y -o APT::Default-Release=lenny-backports install irssi=0.8.12-7",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@@ -265,7 +265,7 @@ mpg123 1.12.1-0ubuntu1
it "should run apt-get remove with the package name" do
expect(@provider).to receive(:shell_out!).with(
"apt-get -q -y remove irssi",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@provider.remove_package("irssi", "0.8.12-7")
@@ -316,7 +316,7 @@ mpg123 1.12.1-0ubuntu1
expect(@provider).to receive(:shell_out!).with(
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@@ -326,7 +326,7 @@ mpg123 1.12.1-0ubuntu1
it "should run debconf-set-selections on the preseed file if it has changed" do
expect(@provider).to receive(:shell_out!).with(
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
file = @provider.get_preseed_file("irssi", "0.8.12-7")
@@ -347,7 +347,7 @@ mpg123 1.12.1-0ubuntu1
it "should run dpkg-reconfigure package" do
expect(@provider).to receive(:shell_out!).with(
"dpkg-reconfigure irssi",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@provider.reconfig_package("irssi", "0.8.12-7")
@@ -359,7 +359,7 @@ mpg123 1.12.1-0ubuntu1
@provider.is_virtual_package["libmysqlclient-dev"] = true
expect(@provider).to receive(:shell_out!).with(
"apt-get -q -y install libmysqlclient-dev",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@provider.install_package("libmysqlclient-dev", "not_a_real_version")
@@ -373,7 +373,7 @@ mpg123 1.12.1-0ubuntu1
@provider.is_virtual_package["irssi"] = false
expect(@provider).to receive(:shell_out!).with(
"apt-get -q -y install libmysqlclient-dev irssi=0.8.12-7",
- :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
+ :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
:timeout => @timeout,
)
@provider.install_package(["libmysqlclient-dev", "irssi"], ["not_a_real_version", "0.8.12-7"])
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index d550e55445..aeb420fa7a 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -45,7 +45,7 @@ ConEmu|15.10.25.0
allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
allow(provider).to receive(:choco_exe).and_return(choco_exe)
local_list_obj = double(:stdout => local_list_stdout)
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", {:timeout => timeout}).and_return(local_list_obj)
+ allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", { :timeout => timeout }).and_return(local_list_obj)
end
def allow_remote_list(package_names, args = nil)
@@ -57,7 +57,7 @@ Git|2.6.2
munin-node|1.6.1.20130823
EOF
remote_list_obj = double(stdout: remote_list_stdout)
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -ar #{package_names.join ' '}#{args}", {timeout: timeout}).and_return(remote_list_obj)
+ allow(provider).to receive(:shell_out!).with("#{choco_exe} list -ar #{package_names.join ' '}#{args}", { timeout: timeout }).and_return(remote_list_obj)
end
describe "#initialize" do
@@ -86,7 +86,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.version("2.5.0")
expect(provider.candidate_version).to eql([nil])
- end
+ end
it "should set the candidate_version to nil if there is no candidate" do
allow_remote_list(["vim"])
@@ -132,7 +132,7 @@ munin-node|1.6.1.20130823
it "should load and downcase names in the installed_packages hash" do
provider.load_current_resource
expect(provider.send(:installed_packages)).to eql(
- {"chocolatey"=>"0.9.9.11", "conemu"=>"15.10.25.0"}
+ { "chocolatey" => "0.9.9.11", "conemu" => "15.10.25.0" }
)
end
@@ -140,7 +140,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
provider.load_current_resource
expect(provider.send(:available_packages)).to eql(
- {"chocolatey"=>"0.9.9.11", "conemu"=>"15.10.25.1", "git"=>"2.6.2", "munin-node" => "1.6.1.20130823"}
+ { "chocolatey" => "0.9.9.11", "conemu" => "15.10.25.1", "git" => "2.6.2", "munin-node" => "1.6.1.20130823" }
)
end
@@ -184,7 +184,7 @@ munin-node|1.6.1.20130823
it "should install a single package" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -195,7 +195,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.timeout(timeout)
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -224,7 +224,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("ConEmu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -237,7 +237,7 @@ munin-node|1.6.1.20130823
new_resource.package_name(["chocolatey", "ConEmu"])
new_resource.version([nil, "15.10.25.1"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -247,7 +247,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("conemu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -257,8 +257,8 @@ munin-node|1.6.1.20130823
new_resource.package_name(["ConEmu", "git"])
new_resource.version(["15.10.25.1", nil])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -267,7 +267,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git", "munin-node"])
new_resource.package_name(["git", "munin-node"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git munin-node", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git munin-node", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -277,7 +277,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"], " -source localpackages")
new_resource.source("localpackages")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -source localpackages git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -source localpackages git", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -287,7 +287,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.options("-force")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -force git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -force git", { :timeout => timeout }).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -329,7 +329,7 @@ munin-node|1.6.1.20130823
it "should install a package that is not installed" do
allow_remote_list(["git"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y git", { :timeout => timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -338,7 +338,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -347,7 +347,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -356,7 +356,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["chocolatey"])
new_resource.package_name("chocolatey")
provider.load_current_resource
- expect(provider).not_to receive(:shell_out!).with("#{choco_exe} upgrade -y chocolatey", {:timeout=>timeout})
+ expect(provider).not_to receive(:shell_out!).with("#{choco_exe} upgrade -y chocolatey", { :timeout => timeout })
provider.run_action(:upgrade)
expect(new_resource).not_to be_updated_by_last_action
end
@@ -365,7 +365,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git"])
new_resource.version("2.6.2")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y -version 2.6.2 git", {:timeout=>timeout})
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y -version 2.6.2 git", { :timeout => timeout })
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -373,7 +373,7 @@ munin-node|1.6.1.20130823
it "upgrading multiple packages uses a single command" do
allow_remote_list(["conemu", "git"])
new_resource.package_name(["conemu", "git"])
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :timeout => timeout }).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -425,7 +425,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y ConEmu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y ConEmu", { :timeout => timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -434,7 +434,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["conemu"])
new_resource.package_name("conemu")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -444,7 +444,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["git", "conemu"])
new_resource.package_name(["git", "conemu"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double)
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index a249f24793..613f7a326e 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -52,7 +52,7 @@ Conflicts: wget-ssl
before(:each) do
allow(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(dpkg_deb_status)
- allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(double(stdout: "", exitstatus: 1))
+ allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0, 1]).and_return(double(stdout: "", exitstatus: 1))
allow(::File).to receive(:exist?).with(source).and_return(true)
end
@@ -160,12 +160,12 @@ Conflicts: wget-ssl
let(:source) { nil }
it "should raise an exception if the source is not set but we are installing" do
- expect { provider.run_action(:install)}.to raise_error(Chef::Exceptions::Package)
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
end
it "should return the current version installed if found by dpkg" do
- allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(dpkg_s_status)
+ allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0, 1]).and_return(dpkg_s_status)
provider.load_current_resource
expect(provider.current_resource.version).to eq(["1.11.4-1ubuntu1"])
end
diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb
index 7c17177bec..8890f62f73 100644
--- a/spec/unit/provider/package/freebsd/pkg_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkg_spec.rb
@@ -77,7 +77,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the version number when it is installed" do
pkg_info = OpenStruct.new(:stdout => "zsh-4.3.6_7")
- expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
#@provider.should_receive(:popen4).with('pkg_info -E "zsh*"').and_yield(@pid, @stdin, ["zsh-4.3.6_7"], @stderr).and_return(@status)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to eq("4.3.6_7")
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "does not set the current version number when the package is not installed" do
pkg_info = OpenStruct.new(:stdout => "")
- expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("zsh")
expect(@provider.current_installed_version).to be_nil
end
@@ -102,7 +102,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the ports candidate version when given a valid port path" do
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "4.3.6\n", :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", {cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900}).and_return(make_v)
+ expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v)
expect(@provider.ports_candidate_version).to eq("4.3.6")
end
@@ -110,7 +110,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh")
make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0)
- expect(@provider).to receive(:shell_out!).with("make -V PKGNAME", {cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900}).and_return(make_v)
+ expect(@provider).to receive(:shell_out!).with("make -V PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v)
#@provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7")
expect(@provider.package_name).to eq("zsh")
end
@@ -220,7 +220,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
it "should return the version number when it is installed" do
pkg_info = OpenStruct.new(:stdout => "bonnie++-1.96")
- expect(@provider).to receive(:shell_out!).with('pkg_info -E "bonnie++*"', env: nil, returns: [0,1], timeout: 900).and_return(pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg_info -E "bonnie++*"', env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info)
allow(@provider).to receive(:package_name).and_return("bonnie++")
expect(@provider.current_installed_version).to eq("1.96")
end
diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb
index d89bf24eb8..a2bd833d9e 100644
--- a/spec/unit/provider/package/freebsd/pkgng_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
require "ostruct"
@@ -30,7 +29,6 @@ describe Chef::Provider::Package::Freebsd::Port do
@provider = Chef::Provider::Package::Freebsd::Pkgng.new(@new_resource, @run_context)
end
-
describe "initialization" do
it "should create a current resource with the name of the new resource" do
expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy
@@ -38,7 +36,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "loading current resource" do
before(:each) do
allow(@provider).to receive(:current_installed_version)
@@ -63,7 +60,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "determining current installed version" do
before(:each) do
allow(@provider).to receive(:supports_pkgng?)
@@ -71,12 +67,11 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should query pkg database" do
- expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
-
describe "determining candidate version" do
it "should query repository" do
pkg_query = OpenStruct.new(:stdout => "5.0.5\n", :exitstatus => 0)
@@ -97,7 +92,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "installing a binary package" do
before(:each) do
@install_result = OpenStruct.new(:status => true)
@@ -133,7 +127,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "removing a binary package" do
before(:each) do
@install_result = OpenStruct.new(:status => true)
diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb
index b12d4eb063..b593da4ff1 100644
--- a/spec/unit/provider/package/freebsd/port_spec.rb
+++ b/spec/unit/provider/package/freebsd/port_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
require "ostruct"
@@ -30,7 +29,6 @@ describe Chef::Provider::Package::Freebsd::Port do
@provider = Chef::Provider::Package::Freebsd::Port.new(@new_resource, @run_context)
end
-
describe "initialization" do
it "should create a current resource with the name of the new resource" do
expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy
@@ -38,7 +36,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "loading current resource" do
before(:each) do
allow(@provider).to receive(:current_installed_version)
@@ -63,7 +60,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "determining current installed version" do
before(:each) do
@pkg_info = OpenStruct.new(:stdout => "zsh-3.1.7\n")
@@ -72,7 +68,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should check 'pkg_info' if system uses pkg_* tools" do
allow(@new_resource).to receive(:supports_pkgng?)
expect(@new_resource).to receive(:supports_pkgng?).and_return(false)
- expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0,1], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg_info -E "zsh*"', env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
@@ -81,7 +77,7 @@ describe Chef::Provider::Package::Freebsd::Port do
[1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version|
@node.automatic_attrs[:os_version] = __freebsd_version
expect(@new_resource).to receive(:shell_out!).with("make -V WITH_PKGNG", env: nil).and_return(pkg_enabled)
- expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
@@ -89,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do
__freebsd_version = 1000017
@node.automatic_attrs[:os_version] = __freebsd_version
- expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info)
+ expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
expect(@provider.current_installed_version).to eq("3.1.7")
end
end
@@ -102,7 +98,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should return candidate version if port exists" do
allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true)
allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh")
- expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0,1], timeout: 900).
+ expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900).
and_return(@port_version)
expect(@provider.candidate_version).to eq("5.0.5")
end
@@ -113,7 +109,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "determining port directory" do
it "should return name if package name is absolute path" do
allow(@provider.new_resource).to receive(:package_name).and_return("/var/ports/shells/zsh")
@@ -138,7 +133,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "building a binary package" do
before(:each) do
@install_result = OpenStruct.new(:status => true)
@@ -153,7 +147,6 @@ describe Chef::Provider::Package::Freebsd::Port do
end
end
-
describe "removing a binary package" do
before(:each) do
@install_result = OpenStruct.new(:status => true)
diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb
index ab842eea60..17ed5ccc41 100644
--- a/spec/unit/provider/package/homebrew_spec.rb
+++ b/spec/unit/provider/package/homebrew_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Provider::Package::Homebrew do
let(:events) { double("Chef::Events").as_null_object }
let(:run_context) { double("Chef::RunContext", node: node, events: events) }
let(:new_resource) { Chef::Resource::HomebrewPackage.new("emacs") }
- let(:current_resource) { Chef::Resource::HomebrewPackage.new("emacs")}
+ let(:current_resource) { Chef::Resource::HomebrewPackage.new("emacs") }
let(:provider) do
Chef::Provider::Package::Homebrew.new(new_resource, run_context)
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index 732e42a7bc..f47385da09 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -35,17 +35,16 @@ describe Chef::Provider::Package::Ips do
def local_output
stdin = StringIO.new
stdout = ""
- stderr =<<-PKG_STATUS
+ stderr = <<-PKG_STATUS
pkg: info: no packages matching the following patterns you specified are
installed on the system. Try specifying -r to query remotely:
crypto/gnupg
PKG_STATUS
- return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 1)
+ return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
end
def remote_output
-
stdout = <<-PKG_STATUS
Name: security/sudo
Summary: sudo - authority delegation tool
@@ -58,9 +57,9 @@ Packaging Date: April 1, 2012 05:55:52 PM
Size: 2.57 MB
FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
- stdin = StringIO.new
- stderr = ""
- return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 0)
+ stdin = StringIO.new
+ stderr = ""
+ return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
end
context "when loading current resource" do
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index ff9e669aa8..b90cf89047 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -70,7 +70,7 @@ describe Chef::Provider::Package::Macports do
describe "current_installed_version" do
it "should return the current version if the package is installed" do
- stdout = <<EOF
+ stdout = <<EOF
The following ports are currently installed:
openssl @0.9.8k_0 (active)
EOF
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 3a7aab55ac..3e1c1c90b6 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Provider::Package::Openbsd do
let(:node) do
node = Chef::Node.new
- node.default["kernel"] = {"name" => "OpenBSD", "release" => "5.5", "machine" => "amd64"}
+ node.default["kernel"] = { "name" => "OpenBSD", "release" => "5.5", "machine" => "amd64" }
node
end
@@ -33,7 +33,7 @@ describe Chef::Provider::Package::Openbsd do
Chef::Provider::Package::Openbsd.new(new_resource, run_context)
end
- let(:new_resource) { Chef::Resource::Package.new(name)}
+ let(:new_resource) { Chef::Resource::Package.new(name) }
before(:each) do
ENV["PKG_PATH"] = nil
@@ -41,7 +41,7 @@ describe Chef::Provider::Package::Openbsd do
describe "install a package" do
let(:name) { "ihavetoes" }
- let(:version) {"0.0"}
+ let(:version) { "0.0" }
context "when not already installed" do
before do
@@ -56,8 +56,8 @@ describe Chef::Provider::Package::Openbsd do
instance_double("shellout", :stdout => "#{name}-#{version}\n"))
expect(provider).to receive(:shell_out!).with(
"pkg_add -r #{name}-#{version}",
- {:env => {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900}
- ) {OpenStruct.new :status => true}
+ { :env => { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
+ ) { OpenStruct.new :status => true }
provider.run_action(:install)
end
end
@@ -78,7 +78,7 @@ describe Chef::Provider::Package::Openbsd do
context "if a flavor is specified" do
let(:flavor) { "flavora" }
- let(:package_name) {"ihavetoes" }
+ let(:package_name) { "ihavetoes" }
let(:name) { "#{package_name}--#{flavor}" }
context "if no version is specified" do
@@ -88,8 +88,8 @@ describe Chef::Provider::Package::Openbsd do
instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n"))
expect(provider).to receive(:shell_out!).with(
"pkg_add -r #{name}-#{version}-#{flavor}",
- {env: {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900}
- ) {OpenStruct.new :status => true}
+ { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
+ ) { OpenStruct.new :status => true }
provider.run_action(:install)
end
end
@@ -104,8 +104,8 @@ describe Chef::Provider::Package::Openbsd do
new_resource.version("#{version}-#{flavor_b}")
expect(provider).to receive(:shell_out!).with(
"pkg_add -r #{name}-#{version}-#{flavor_b}",
- {env: {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900}
- ) {OpenStruct.new :status => true}
+ { env: { "PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/" }, timeout: 900 }
+ ) { OpenStruct.new :status => true }
provider.run_action(:install)
end
end
@@ -124,7 +124,7 @@ describe Chef::Provider::Package::Openbsd do
it "should run the command to delete the installed package" do
expect(@provider).to receive(:shell_out!).with(
"pkg_delete #{@name}", env: nil, timeout: 900
- ) {OpenStruct.new :status => true}
+ ) { OpenStruct.new :status => true }
@provider.remove_package(@name, nil)
end
end
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index 4d3339767c..ce9107f31b 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -51,7 +51,7 @@ ERR
end
it "should run pacman query with the package name" do
- expect(@provider).to receive(:shell_out).with("pacman -Qi #{@new_resource.package_name}", {timeout: 900}).and_return(@status)
+ expect(@provider).to receive(:shell_out).with("pacman -Qi #{@new_resource.package_name}", { timeout: 900 }).and_return(@status)
@provider.load_current_resource
end
@@ -102,7 +102,7 @@ PACMAN
end
it "should use pacman.conf to determine valid repo names for package versions" do
- @pacman_conf = <<-PACMAN_CONF
+ @pacman_conf = <<-PACMAN_CONF
[options]
HoldPkg = pacman glibc
Architecture = auto
@@ -151,12 +151,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "install_package" do
it "should run pacman install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar nano", {timeout: 900})
+ expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar nano", { timeout: 900 })
@provider.install_package("nano", "1.0")
end
it "should run pacman install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar --debug nano", {timeout: 900})
+ expect(@provider).to receive(:shell_out!).with("pacman --sync --noconfirm --noprogressbar --debug nano", { timeout: 900 })
allow(@new_resource).to receive(:options).and_return("--debug")
@provider.install_package("nano", "1.0")
@@ -172,12 +172,12 @@ PACMAN_CONF
describe Chef::Provider::Package::Pacman, "remove_package" do
it "should run pacman remove with the package name" do
- expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar nano", {timeout: 900})
+ expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar nano", { timeout: 900 })
@provider.remove_package("nano", "1.0")
end
it "should run pacman remove with the package name and options if specified" do
- expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar --debug nano", {timeout: 900})
+ expect(@provider).to receive(:shell_out!).with("pacman --remove --noconfirm --noprogressbar --debug nano", { timeout: 900 })
allow(@new_resource).to receive(:options).and_return("--debug")
@provider.remove_package("nano", "1.0")
diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb
index 8ca6a881e1..b984aeb83f 100644
--- a/spec/unit/provider/package/paludis_spec.rb
+++ b/spec/unit/provider/package/paludis_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::Package::Paludis do
@stdin = StringIO.new
@stderr = StringIO.new
- @stdout =<<-PKG_STATUS
+ @stdout = <<-PKG_STATUS
group/ntp 0 accounts
group/ntp 0 installed-accounts
net/ntp 4.2.6_p5-r2 arbor
@@ -42,7 +42,7 @@ user/ntp 0 installed-accounts
net/ntp 4.2.6_p5-r1 installed
PKG_STATUS
@pid = 12345
- @shell_out = OpenStruct.new(:stdout => @stdout,:stdin => @stdin,:stderr => @stderr,:status => @status,:exitstatus => 0)
+ @shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
end
context "when loading current resource" do
@@ -86,13 +86,12 @@ INSTALLED
context "when installing a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout})
+ expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout })
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
-
it "should run pkg install with the package name and version and options if specified" do
- expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x --preserve-world \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout})
+ expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x --preserve-world \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout })
allow(@new_resource).to receive(:options).and_return("--preserve-world")
@provider.install_package("net/ntp", "4.2.6_p5-r2")
end
@@ -102,7 +101,7 @@ INSTALLED
sys-process/lsof 4.87 arbor
sys-process/lsof 4.87 x86_64
PKG_STATUS
- expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=sys-process/lsof-4.87\"", {:timeout=>@new_resource.timeout})
+ expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=sys-process/lsof-4.87\"", { :timeout => @new_resource.timeout })
@provider.install_package("sys-process/lsof", "4.87")
end
@@ -120,7 +119,7 @@ PKG_STATUS
context "when upgrading a package" do
it "should run pkg install with the package name and version" do
- expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", {:timeout=>@new_resource.timeout})
+ expect(@provider).to receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"", { :timeout => @new_resource.timeout })
@provider.upgrade_package("net/ntp", "4.2.6_p5-r2")
end
end
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index 2f2c44a5d5..1d179edf76 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -116,7 +116,6 @@ describe Chef::Provider::Package::Rpm do
end
end
-
context "when the package is installed" do
let(:rpm_qp_stdout) { "ImageMagick-c++ 6.5.4.7-7.el6_5" }
@@ -237,7 +236,6 @@ describe Chef::Provider::Package::Rpm do
end
end
-
context "when the package name contains a tilde (chef#3503)" do
let(:package_name) { "supermarket" }
@@ -396,7 +394,6 @@ describe Chef::Provider::Package::Rpm do
end
-
end
end
@@ -429,5 +426,4 @@ describe Chef::Provider::Package::Rpm do
end
end
-
end
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 7f81656eb3..141e2bd383 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -192,7 +192,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
it "uses the cached result for gem paths when available" do
expect(@gem_env).not_to receive(:shell_out!)
expected = ["/path/to/gems", "/another/path/to/gems"]
- Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]= expected
+ Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"] = expected
expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
end
@@ -235,7 +235,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
end
it "detects when the target gem environment is the jruby platform" do
- gem_env_out=<<-JRUBY_GEM_ENV
+ gem_env_out = <<-JRUBY_GEM_ENV
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-05-12 patchlevel 249) [java]
@@ -272,12 +272,12 @@ RubyGems Environment:
it "uses the cached result for gem platforms if available" do
expect(@gem_env).not_to receive(:shell_out!)
expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
- Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]= expected
+ Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"] = expected
expect(@gem_env.gem_platforms).to eq(expected)
end
it "uses the current gem platforms when the target env is not jruby" do
- gem_env_out=<<-RBX_GEM_ENV
+ gem_env_out = <<-RBX_GEM_ENV
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-05-14 patchlevel 174) [x86_64-apple-darwin10.3.0]
@@ -394,10 +394,10 @@ describe Chef::Provider::Package::Rubygems do
end
context "when you try to use a hash of install options" do
- let(:options) { {:fail => :burger } }
+ let(:options) { { :fail => :burger } }
it "smites you" do
- expect {provider}.to raise_error(ArgumentError)
+ expect { provider }.to raise_error(ArgumentError)
end
end
end
@@ -473,8 +473,8 @@ describe Chef::Provider::Package::Rubygems do
expect(provider.current_resource.version).to eq(current_version)
end
- context "if the requested version is not installed" do
- let(:target_version) { "9000.0.2" }
+ context "if the requested version is not installed" do
+ let(:target_version) { "9000.0.2" }
it "sets the current version to the highest installed version if the requested version is not installed" do
expect(provider.current_resource.version).to eq(current_version)
@@ -539,8 +539,8 @@ describe Chef::Provider::Package::Rubygems do
args = [gem_dep]
args << source if source
allow(provider.gem_env).to receive(:candidate_version_from_remote).
- with(*args).
- and_return(version)
+ with(*args).
+ and_return(version)
end
describe "in the current gem environment" do
@@ -594,7 +594,7 @@ describe Chef::Provider::Package::Rubygems do
let(:options) { "-i /alt/install/location" }
it "installs the gem by shelling out when options are provided as a String" do
- expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" #{options}"
+ expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" #{options}"
expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -606,7 +606,7 @@ describe Chef::Provider::Package::Rubygems do
let(:gem_binary) { "/foo/bar" }
it "installs the gem with rubygems.org as an added source" do
- expected ="#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source} --source=https://rubygems.org"
+ expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --source=#{source} --source=https://rubygems.org"
expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -619,7 +619,7 @@ describe Chef::Provider::Package::Rubygems do
it "installs the gem" do
new_resource.clear_sources(true)
- expected ="#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --clear-sources --source=#{source}"
+ expected = "#{gem_binary} install rspec-core -q --no-rdoc --no-ri -v \"#{target_version}\" --clear-sources --source=#{source}"
expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -631,7 +631,7 @@ describe Chef::Provider::Package::Rubygems do
let(:options) { "-i /alt/install/location" }
it "installs the gem by shelling out when options are provided but no version is given" do
- expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{candidate_version}\" #{options}"
+ expected = "gem install rspec-core -q --no-rdoc --no-ri -v \"#{candidate_version}\" #{options}"
expect(provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index 6746395dd2..51bffa17b6 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -28,7 +28,6 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
@new_resource = Chef::Resource::Package.new("varnish")
@current_resource = Chef::Resource::Package.new("varnish")
-
@status = double("Status", :exitstatus => 0)
@provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context)
allow(Chef::Resource::Package).to receive(:new).and_return(@current_resource)
@@ -66,7 +65,6 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
expect(@current_resource.version).to eq(nil)
end
-
end
describe "candidate_version" do
@@ -82,7 +80,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
and_yield("something-varnish-1.1.1 something varnish like\n").
and_yield("varnish-2.3.4 actual varnish\n")
@shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
@@ -92,7 +90,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
and_yield("something-varnish-1.1.1;;something varnish like\n").
and_yield("varnish-2.3.4;;actual varnish\n")
@shell_out = double("shell_out!", :stdout => search)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0, 1], :timeout => 900).and_return(@shell_out)
expect(@provider.candidate_version).to eq("2.3.4")
end
end
@@ -101,8 +99,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
it "run pkgin and install the package" do
out = OpenStruct.new(:stdout => nil)
- expect(@provider).to receive(:shell_out!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", {:env => nil, :returns=>[0,1], :timeout=>900}).and_return(@shell_out)
- expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", {:env=>nil, :timeout=>900}).and_return(out)
+ expect(@provider).to receive(:shell_out!).with("/opt/local/sbin/pkg_info", "-E", "varnish*", { :env => nil, :returns => [0, 1], :timeout => 900 }).and_return(@shell_out)
+ expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "-y", "install", "varnish-2.1.5nb2", { :env => nil, :timeout => 900 }).and_return(out)
@provider.load_current_resource
@provider.install_package("varnish", "2.1.5nb2")
end
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index b0a007b0cf..9cc8deeb2a 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -32,7 +32,7 @@ describe Chef::Provider::Package::Solaris do
describe "assessing the current package status" do
before do
- @pkginfo =<<-PKGINFO
+ @pkginfo = <<-PKGINFO
PKGINST: SUNWbash
NAME: GNU Bourne-Again shell (bash)
CATEGORY: system
@@ -46,7 +46,7 @@ INSTDATE: Nov 04 2009 01:02
HOTLINE: Please contact your local service provider
PKGINFO
- @status = double("Status",:stdout => "", :exitstatus => 0)
+ @status = double("Status", :stdout => "", :exitstatus => 0)
end
it "should create a current resource with the name of new_resource" do
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index 22be2d3497..e29508ca7b 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -21,7 +21,7 @@ require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows::MSI do
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:package_name) { "calculator" }
let(:resource_source) { "calculator.msi" }
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::Windows::MSI do
context "version is explicitly provided" do
let(:resource_version) { "given_version" }
-
+
it "returns the given version" do
expect(provider.package_version).to eql("given_version")
end
@@ -95,7 +95,7 @@ describe Chef::Provider::Package::Windows::MSI do
before do
allow(::File).to receive(:exist?).with(Chef::Util::PathHelper.canonical_path(resource_source, false)).and_return(false)
end
-
+
it "returns nil" do
expect(provider.package_version).to eql(nil)
end
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index 948e138ae2..62e40e7b6a 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
end
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:resource_source) { "calculator.msi" }
let(:resource_name) { "calculator" }
@@ -327,7 +327,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return([ ["5.5.5", "4.3.0", "1.1.1"] ])
end
-
+
it "does not install" do
expect(provider).not_to receive(:install_package)
provider.run_action(:install)
@@ -339,7 +339,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return([ ["5.5.0", "4.3.0", "1.1.1"] ])
end
-
+
it "installs given version" do
expect(provider).to receive(:install_package).with("blah", "5.5.5")
provider.run_action(:install)
@@ -353,7 +353,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return(["5.5.5"])
end
-
+
it "does not install" do
expect(provider).not_to receive(:install_package)
provider.run_action(:install)
@@ -365,7 +365,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return(["5.5.0"])
end
-
+
it "installs given version" do
expect(provider).to receive(:install_package).with("blah", "5.5.5")
provider.run_action(:install)
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index f60bcd1405..98fe9551a6 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -258,10 +258,10 @@ describe Chef::Provider::Package::Yum do
@yum_cache = double(
"Chef::Provider::Yum::YumCache"
)
- allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
- # nothing installed for package_name/new_package_name
- nil
- end
+ allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
+ # nothing installed for package_name/new_package_name
+ nil
+ end
allow(@yum_cache).to receive(:candidate_version) do |package_name, arch|
if package_name == "testing.noarch"
nil
@@ -282,13 +282,13 @@ describe Chef::Provider::Package::Yum do
end
it "should flush the cache if :before is true" do
- allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => true})
+ allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => true })
expect(@yum_cache).to receive(:reload).once
@provider.load_current_resource
end
it "should flush the cache if :before is false" do
- allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => false})
+ allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false })
expect(@yum_cache).not_to receive(:reload)
@provider.load_current_resource
end
@@ -346,7 +346,6 @@ describe Chef::Provider::Package::Yum do
expect(@new_resource.version).to eq("2.0.1.el5")
end
-
it "should search provides then set version to match if a requirement was passed in the version" do
@new_resource = Chef::Resource::YumPackage.new("test-package")
@new_resource.version("= 2.0.1.el5")
@@ -356,7 +355,6 @@ describe Chef::Provider::Package::Yum do
expect(@new_resource.version).to eq("2.0.1.el5")
end
-
it "should search provides and not set the version to match if a specific version was requested" do
@new_resource = Chef::Resource::YumPackage.new("test-package")
@new_resource.version("3.0.1.el5")
@@ -398,7 +396,7 @@ describe Chef::Provider::Package::Yum do
:disable_extra_repo_control => true,
)
allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache)
- allow(@yum_cache).to receive(:yum_binary=).with("yum")
+ allow(@yum_cache).to receive(:yum_binary=).with("yum")
pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", [])
expect(@yum_cache).to receive(:packages_from_require).and_return([pkg])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -420,7 +418,7 @@ describe Chef::Provider::Package::Yum do
:disable_extra_repo_control => true,
)
allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache)
- allow(@yum_cache).to receive(:yum_binary=).with("yum")
+ allow(@yum_cache).to receive(:yum_binary=).with("yum")
pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", [])
expect(@yum_cache).to receive(:packages_from_require).and_return([pkg])
@new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5")
@@ -448,12 +446,12 @@ describe Chef::Provider::Package::Yum do
expect(@yum_cache).to receive(:packages_from_require).exactly(4).times.and_return([])
expect(@yum_cache).to receive(:reload_provides).twice
- @new_resource = Chef::Resource::YumPackage.new(["test-package","test-package2"])
- @new_resource.version(["2.0.1.el5","3.0.1.el5"])
+ @new_resource = Chef::Resource::YumPackage.new(["test-package", "test-package2"])
+ @new_resource.version(["2.0.1.el5", "3.0.1.el5"])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
- expect(@new_resource.package_name).to eq(["test-package","test-package2"])
- expect(@new_resource.version).to eq(["2.0.1.el5","3.0.1.el5"])
+ expect(@new_resource.package_name).to eq(["test-package", "test-package2"])
+ expect(@new_resource.version).to eq(["2.0.1.el5", "3.0.1.el5"])
end
it "should search provides if no package is available - if no match in installed provides then load the complete set" do
@@ -656,7 +654,7 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum install then flush the cache if :after is true" do
- allow(@new_resource).to receive(:flush_cache).and_return({:after => true, :before => false})
+ allow(@new_resource).to receive(:flush_cache).and_return({ :after => true, :before => false })
@provider.load_current_resource
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
@@ -667,7 +665,7 @@ describe Chef::Provider::Package::Yum do
end
it "should run yum install then not flush the cache if :after is false" do
- allow(@new_resource).to receive(:flush_cache).and_return({:after => false, :before => false})
+ allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false })
@provider.load_current_resource
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
@@ -792,7 +790,7 @@ describe Chef::Provider::Package::Yum do
allow(@provider).to receive(:shell_out).and_return(@status)
expect(@provider).to receive(:shell_out).once.with(
"yum -d0 -e0 -y install emacs-1.0",
- {:timeout => Chef::Config[:yum_timeout]},
+ { :timeout => Chef::Config[:yum_timeout] },
)
@provider.yum_command("-d0 -e0 -y install emacs-1.0")
end
@@ -802,18 +800,18 @@ describe Chef::Provider::Package::Yum do
allow(@provider).to receive(:shell_out).and_return(@status)
expect(@provider).to receive(:shell_out).once.with(
"yum -d0 -e0 -y install emacs-1.0",
- {:timeout => Chef::Config[:yum_timeout]},
+ { :timeout => Chef::Config[:yum_timeout] },
)
expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec)
end
it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do
@status = double("Status", :exitstatus => 1, :stdout => "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2",
- :stderr => "")
+ :stderr => "")
allow(@provider).to receive(:shell_out).and_return(@status)
expect(@provider).to receive(:shell_out).once.with(
"yum -d0 -e0 -y install emacs-1.0",
- {:timeout => Chef::Config[:yum_timeout]},
+ { :timeout => Chef::Config[:yum_timeout] },
)
# will still raise an exception, can't stub out the subsequent call
expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec)
@@ -821,11 +819,11 @@ describe Chef::Provider::Package::Yum do
it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do
@status = double("Status", :exitstatus => 1, :stdout => "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2",
- :stderr => "")
+ :stderr => "")
allow(@provider).to receive(:shell_out).and_return(@status)
expect(@provider).to receive(:shell_out).twice.with(
"yum -d0 -e0 -y install emacs-1.0",
- {:timeout => Chef::Config[:yum_timeout]},
+ { :timeout => Chef::Config[:yum_timeout] },
)
# will still raise an exception, can't stub out the subsequent call
expect { @provider.yum_command("-d0 -e0 -y install emacs-1.0") }.to raise_error(Chef::Exceptions::Exec)
@@ -839,7 +837,7 @@ describe Chef::Provider::Package::Yum do
allow(@provider).to receive(:shell_out).and_return(@status)
expect(@provider).to receive(:shell_out).once.with(
"yum-deprecated -d0 -e0 -y install emacs-1.0",
- {:timeout => Chef::Config[:yum_timeout]},
+ { :timeout => Chef::Config[:yum_timeout] },
)
@provider.yum_command("-d0 -e0 -y install emacs-1.0")
end
@@ -965,7 +963,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do
[ "0.0.1aa", "0.0.1aa", 0 ],
[ "0.0.1a", "0.0.1aa", -1 ],
].each do |x, y, result|
- expect(@rpmutils.rpmvercmp(x,y)).to eq(result)
+ expect(@rpmutils.rpmvercmp(x, y)).to eq(result)
end
end
@@ -984,7 +982,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do
[ "", "", 0 ],
[ "", "1.0.1", -1 ],
].each do |x, y, result|
- expect(@rpmutils.rpmvercmp(x,y)).to eq(result)
+ expect(@rpmutils.rpmvercmp(x, y)).to eq(result)
end
end
@@ -1840,19 +1838,19 @@ EOF
end
it "should return the default python if the yum-executable doesn't start with #!" do
- allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(bin_exe); bin_exe.rewind; r}
+ allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(bin_exe); bin_exe.rewind; r }
expect(@yc.python_bin).to eq("/usr/bin/python")
end
it "should return /usr/bin/python if the interpreter is /bin/bash" do
other = StringIO.new("#!/bin/bash\n# The yum executable redirecting to dnf from dnf-yum compatible package.")
- allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
+ allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r }
expect(@yc.python_bin).to eq("/usr/bin/python")
end
it "should return the interpreter for yum" do
other = StringIO.new("#!/usr/bin/super_python\n\nlasjdfdsaljf\nlasdjfs")
- allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r}
+ allow(::File).to receive(:open).with("/usr/bin/yum", "r") { |&b| r = b.call(other); other.rewind; r }
expect(@yc.python_bin).to eq("/usr/bin/super_python")
end
end
@@ -1867,32 +1865,32 @@ EOF
it "should run yum-dump.py using the system python when next_refresh is for :all" do
@yc.reload
- expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
+ expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout])
@yc.refresh
end
it "should run yum-dump.py with the installed flag when next_refresh is for :installed" do
@yc.reload_installed
- expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
+ expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout])
@yc.refresh
end
it "should run yum-dump.py with the all-provides flag when next_refresh is for :provides" do
@yc.reload_provides
- expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
+ expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout])
@yc.refresh
end
it "should pass extra_repo_control args to yum-dump.py" do
@yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
- expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
+ expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 30$}, :timeout => Chef::Config[:yum_timeout])
@yc.refresh
end
it "should pass extra_repo_control args and configured yum lock timeout to yum-dump.py" do
Chef::Config[:yum_lock_timeout] = 999
@yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
- expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 999$}, :timeout=>Chef::Config[:yum_timeout])
+ expect(@yc).to receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 999$}, :timeout => Chef::Config[:yum_timeout])
@yc.refresh
end
@@ -1920,7 +1918,7 @@ EOF
it "should raise exception yum-dump.py exits with a non zero status" do
@status = double("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr)
allow(@yc).to receive(:shell_out!).and_return(@status)
- expect { @yc.refresh}.to raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12})
+ expect { @yc.refresh }.to raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12})
end
it "should parse type 'i' into an installed state for a package" do
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index f5e2c5e8a5..c998c93d6e 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -38,12 +38,12 @@ describe Chef::Provider::Package::Zypper do
allow(provider).to receive(:`).and_return("2.0")
end
- def shell_out_expectation(command, options=nil)
+ def shell_out_expectation(command, options = nil)
options ||= { timeout: 900 }
expect(provider).to receive(:shell_out).with(command, options)
end
- def shell_out_expectation!(command, options=nil)
+ def shell_out_expectation!(command, options = nil)
options ||= { timeout: 900 }
expect(provider).to receive(:shell_out!).with(command, options)
end
@@ -104,8 +104,7 @@ describe Chef::Provider::Package::Zypper do
it "should run zypper install without gpg checks" do
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0"
)
provider.install_package(["emacs"], ["1.0"])
end
@@ -114,8 +113,7 @@ describe Chef::Provider::Package::Zypper do
/All packages will be installed without gpg signature checks/
)
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0"
)
provider.install_package(["emacs"], ["1.0"])
end
@@ -132,8 +130,7 @@ describe Chef::Provider::Package::Zypper do
it "should run zypper update without gpg checks" do
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0"
)
provider.upgrade_package(["emacs"], ["1.0"])
end
@@ -142,15 +139,13 @@ describe Chef::Provider::Package::Zypper do
/All packages will be installed without gpg signature checks/
)
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0"
)
provider.upgrade_package(["emacs"], ["1.0"])
end
it "should run zypper upgrade without gpg checks" do
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0"
)
provider.upgrade_package(["emacs"], ["1.0"])
end
@@ -257,8 +252,7 @@ describe Chef::Provider::Package::Zypper do
it "should install an array of package names and versions" do
allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false)
shell_out_expectation!(
- "zypper --non-interactive --no-gpg-checks install "+
- "--auto-agree-with-licenses emacs=1.0 vim=2.0"
+ "zypper --non-interactive --no-gpg-checks install " + "--auto-agree-with-licenses emacs=1.0 vim=2.0"
)
provider.install_package(["emacs", "vim"], ["1.0", "2.0"])
end
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index c0361eaea1..c44c445fd8 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
provider_flags = provider.flags.split(" ")
execution_policy_specified = false
- provider_flags.find do | value |
+ provider_flags.find do |value|
execution_policy_index += 1
execution_policy_specified = value.downcase == "-ExecutionPolicy".downcase
end
@@ -92,7 +92,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
"3.0" => "Bypass",
"3.6" => "Bypass",
"4.0" => "Bypass",
- "5.0" => "Bypass" }.each do | version_policy |
+ "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 }
diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb
index e91bd22739..710d6613fc 100644
--- a/spec/unit/provider/remote_directory_spec.rb
+++ b/spec/unit/provider/remote_directory_spec.rb
@@ -110,7 +110,7 @@ describe Chef::Provider::RemoteDirectory do
@resource.path(@destination_dir)
end
- after {FileUtils.rm_rf(@destination_dir)}
+ after { FileUtils.rm_rf(@destination_dir) }
# CHEF-3552
it "creates the toplevel directory without error " do
@@ -134,8 +134,8 @@ describe Chef::Provider::RemoteDirectory do
@resource.overwrite(true)
@provider.run_action(:create)
- File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" }
- File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ File.open(@destination_dir + "/remote_dir_file1.txt", "a") { |f| f.puts "blah blah blah" }
+ File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") { |f| f.puts "blah blah blah" }
file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt"))
subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt"))
@@ -147,7 +147,7 @@ describe Chef::Provider::RemoteDirectory do
end
describe "with purging enabled" do
- before {@resource.purge(true)}
+ before { @resource.purge(true) }
it "removes existing files if purge is true" do
@provider.run_action(:create)
@@ -202,13 +202,13 @@ describe Chef::Provider::RemoteDirectory do
end
describe "with overwrite disabled" do
- before {@resource.purge(false)}
- before {@resource.overwrite(false)}
+ before { @resource.purge(false) }
+ before { @resource.overwrite(false) }
it "leaves modifications alone" do
@provider.run_action(:create)
- ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" }
- ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" }
+ ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") { |f| f.puts "blah blah blah" }
+ ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") { |f| f.puts "blah blah blah" }
file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt"))
subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt"))
@provider.run_action(:create)
diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb
index 5d31863274..a80aa38e77 100644
--- a/spec/unit/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb
@@ -214,7 +214,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
# local file system path limits resulting in exceptions from
# file system API's on both Windows and Unix systems.
context "and the URI results in a file cache path that exceeds #{CACHE_FILE_PATH_LIMIT} characters in length" do
- let(:long_remote_path) { "http://www.bing.com/" + ("0" * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) }
+ let(:long_remote_path) { "http://www.bing.com/" + ("0" * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) }
let(:uri) { URI.parse(long_remote_path) }
let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) }
let(:truncated_file_cache_path) do
@@ -243,4 +243,3 @@ describe Chef::Provider::RemoteFile::CacheControlData do
end
end
-
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index a562c1c742..c6a560b123 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -141,7 +141,6 @@ describe Chef::Provider::RemoteFile::Content do
it_behaves_like "the resource needs fetching"
end
-
describe "when the fetcher throws an exception" do
before do
allow(new_resource).to receive(:checksum).and_return(nil)
@@ -163,7 +162,7 @@ describe Chef::Provider::RemoteFile::Content do
# https://github.com/opscode/chef/pull/1358#issuecomment-40853299
def create_exception(exception_class)
if [ Net::HTTPServerException, Net::HTTPFatalError ].include? exception_class
- exception_class.new("message", {"something" => 1})
+ exception_class.new("message", { "something" => 1 })
else
exception_class.new
end
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index a8d65b0156..c044621ed4 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Provider::RemoteFile::FTP do
end
let(:ftp) do
- ftp = double(Net::FTP, { })
+ ftp = double(Net::FTP, {})
allow(ftp).to receive(:connect)
allow(ftp).to receive(:login)
allow(ftp).to receive(:voidcmd)
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index 89f2964076..60ecd45dbb 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -61,7 +61,7 @@ describe Chef::Provider::RemoteFile::HTTP do
end
it "has the user-specified custom headers" do
- expect(fetcher.headers).to eq({"x-myapp-header" => "custom-header-value"})
+ expect(fetcher.headers).to eq({ "x-myapp-header" => "custom-header-value" })
end
end
@@ -178,7 +178,6 @@ describe Chef::Provider::RemoteFile::HTTP do
expect(Chef::HTTP::Simple).to receive(:new).with(*expected_http_args).and_return(rest)
end
-
describe "and the request does not return new content" do
it "should return a nil tempfile for a 304 HTTPNotModifed" do
@@ -207,7 +206,7 @@ describe Chef::Provider::RemoteFile::HTTP do
end
context "and the response does not contain an etag" do
- let(:last_response) { {"etag" => nil} }
+ let(:last_response) { { "etag" => nil } }
it "does not include an etag in the result" do
fetcher.fetch
expect(cache_control_data.etag).to be_nil
@@ -217,7 +216,7 @@ describe Chef::Provider::RemoteFile::HTTP do
end
context "and the response has an etag header" do
- let(:last_response) { {"etag" => "abc123"} }
+ let(:last_response) { { "etag" => "abc123" } }
it "includes the etag value in the response" do
fetcher.fetch
@@ -229,7 +228,7 @@ describe Chef::Provider::RemoteFile::HTTP do
end
context "and the response has no Date or Last-Modified header" do
- let(:last_response) { {"date" => nil, "last_modified" => nil} }
+ let(:last_response) { { "date" => nil, "last_modified" => nil } }
it "does not set an mtime in the result" do
# RFC 2616 suggests that servers that do not set a Date header do not
# have a reliable clock, so no use in making them deal with dates.
@@ -243,7 +242,7 @@ describe Chef::Provider::RemoteFile::HTTP do
context "and the response has a Last-Modified header" do
let(:last_response) do
# Last-Modified should be preferred to Date if both are set
- {"date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => "Fri, 17 May 2013 11:11:11 GMT"}
+ { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => "Fri, 17 May 2013 11:11:11 GMT" }
end
it "sets the mtime to the Last-Modified time in the response" do
@@ -255,7 +254,7 @@ describe Chef::Provider::RemoteFile::HTTP do
context "and the response has a Date header but no Last-Modified header" do
let(:last_response) do
- {"date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => nil}
+ { "date" => "Fri, 17 May 2013 23:23:23 GMT", "last_modified" => nil }
end
it "sets the mtime to the Date in the response" do
@@ -270,7 +269,7 @@ describe Chef::Provider::RemoteFile::HTTP do
context "and the target file is a tarball [CHEF-3140]" do
let(:uri) { URI.parse("http://opscode.com/tarball.tgz") }
- let(:expected_http_opts) { {:disable_gzip => true} }
+ let(:expected_http_opts) { { :disable_gzip => true } }
# CHEF-3140
# Some servers return tarballs as content type tar and encoding gzip, which
@@ -300,4 +299,3 @@ describe Chef::Provider::RemoteFile::HTTP do
end
end
-
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index de5036eb41..6107f93c41 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -21,7 +21,6 @@ require "spec_helper"
require "support/shared/unit/provider/file"
-
describe Chef::Provider::RemoteFile do
let(:resource) do
resource = Chef::Resource::RemoteFile.new("seattle", @run_context)
@@ -36,7 +35,7 @@ describe Chef::Provider::RemoteFile do
end
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
@@ -60,4 +59,3 @@ describe Chef::Provider::RemoteFile do
it_behaves_like "a file provider with source field"
end
-
diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb
index 3ef3affde2..bd1e637570 100644
--- a/spec/unit/provider/route_spec.rb
+++ b/spec/unit/provider/route_spec.rb
@@ -47,7 +47,6 @@ describe Chef::Provider::Route do
end
end
-
describe Chef::Provider::Route, "load_current_resource" do
context "on linux" do
before do
@@ -188,15 +187,15 @@ 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
allow(@new_resource).to receive(:netmask).and_return("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(/\/\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(/\/\d{1,2}.*\n$/)
end
it "should include ' via $gateway ' when a gateway is specified" do
- expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :gateway => @new_resource.gateway})).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/)
+ expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :gateway => @new_resource.gateway })).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/)
end
it "should not include ' via $gateway ' when a gateway is not specified" do
diff --git a/spec/unit/provider/ruby_block_spec.rb b/spec/unit/provider/ruby_block_spec.rb
index d9fd3e2548..b49aef9243 100644
--- a/spec/unit/provider/ruby_block_spec.rb
+++ b/spec/unit/provider/ruby_block_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Provider::RubyBlock, "initialize" do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::RubyBlock.new("bloc party")
- @new_resource.block { $evil_global_evil_laugh = :mwahahaha}
+ @new_resource.block { $evil_global_evil_laugh = :mwahahaha }
@provider = Chef::Provider::RubyBlock.new(@new_resource, @run_context)
end
@@ -43,4 +43,3 @@ describe Chef::Provider::RubyBlock, "initialize" do
expect(@new_resource).to be_updated
end
end
-
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index ef1ccf4ea5..4e8d8bdf59 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Provider::Script, "action_run" do
describe "when writing the script to the file" do
it "should put the contents of the script in the temp file" do
- allow(provider).to receive(:unlink_script_file) # stub to avoid remove
+ allow(provider).to receive(:unlink_script_file) # stub to avoid remove
provider.action_run
expect(IO.read(tempfile.path)).to eq("$| = 1; print 'i like beans'\n")
provider.unlink_script_file
diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb
index 78c0ed3bb3..802ccee2c7 100644
--- a/spec/unit/provider/service/aix_service_spec.rb
+++ b/spec/unit/provider/service/aix_service_spec.rb
@@ -193,4 +193,3 @@ describe Chef::Provider::Service::Aix do
end
end
end
-
diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb
index 085652a6a4..09c177903b 100644
--- a/spec/unit/provider/service/aixinit_service_spec.rb
+++ b/spec/unit/provider/service/aixinit_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::AixInit do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "fuuuu"}
+ @node.automatic_attrs[:command] = { :ps => "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -102,7 +102,7 @@ describe Chef::Provider::Service::AixInit do
context "when the service doesn't set a priority" do
it "creates symlink with status S" do
- expect(@provider).to receive(:create_symlink).with(2,"S","")
+ expect(@provider).to receive(:create_symlink).with(2, "S", "")
@provider.enable_service
end
@@ -114,7 +114,7 @@ describe Chef::Provider::Service::AixInit do
end
it "creates a symlink with status S and a priority" do
- expect(@provider).to receive(:create_symlink).with(2,"S",75)
+ expect(@provider).to receive(:create_symlink).with(2, "S", 75)
@provider.enable_service
end
@@ -122,13 +122,13 @@ describe Chef::Provider::Service::AixInit do
context "when the service sets complex priorities (hash)" do
before do
- priority = {2 => [:start, 20], 3 => [:stop, 10]}
+ priority = { 2 => [:start, 20], 3 => [:stop, 10] }
@new_resource.priority(priority)
end
it "create symlink with status start (S) or stop (K) and a priority " do
- expect(@provider).to receive(:create_symlink).with(2,"S",20)
- expect(@provider).to receive(:create_symlink).with(3,"K",10)
+ expect(@provider).to receive(:create_symlink).with(2, "S", 20)
+ expect(@provider).to receive(:create_symlink).with(3, "K", 10)
@provider.enable_service
end
@@ -142,7 +142,7 @@ describe Chef::Provider::Service::AixInit do
context "when the service doesn't set a priority" do
it "creates symlinks with status stop (K)" do
- expect(@provider).to receive(:create_symlink).with(2,"K","")
+ expect(@provider).to receive(:create_symlink).with(2, "K", "")
@provider.disable_service
end
@@ -154,7 +154,7 @@ describe Chef::Provider::Service::AixInit do
end
it "create symlink with status stop (k) and a priority " do
- expect(@provider).to receive(:create_symlink).with(2,"K",25)
+ expect(@provider).to receive(:create_symlink).with(2, "K", 25)
@provider.disable_service
end
@@ -162,12 +162,12 @@ describe Chef::Provider::Service::AixInit do
context "when the service sets complex priorities (hash)" do
before do
- @priority = {2 => [:start, 20], 3 => [:stop, 10]}
+ @priority = { 2 => [:start, 20], 3 => [:stop, 10] }
@new_resource.priority(@priority)
end
it "create symlink with status stop (k) and a priority " do
- expect(@provider).to receive(:create_symlink).with(3,"K",90)
+ expect(@provider).to receive(:create_symlink).with(3, "K", 90)
@provider.disable_service
end
@@ -183,17 +183,17 @@ describe Chef::Provider::Service::AixInit do
end
it "the service is enabled" do
- expect(@provider.current_resource).to receive(:enabled).with(true)
- expect(@provider.current_resource).to receive(:priority).with(20)
+ expect(@provider.current_resource).to receive(:enabled).with(true)
+ expect(@provider.current_resource).to receive(:priority).with(20)
- @provider.set_current_resource_attributes
+ @provider.set_current_resource_attributes
end
end
context "when rc2.d contains only stop script" do
before do
files = ["/etc/rc.d/rc2.d/K20apache"]
- @priority = {2 => [:stop, 20]}
+ @priority = { 2 => [:stop, 20] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]chef"]).and_return(files)
end
@@ -210,7 +210,7 @@ describe Chef::Provider::Service::AixInit do
@files = ["/etc/rc.d/rc2.d/S20apache", "/etc/rc.d/rc2.d/K80apache"]
# FIXME: this is clearly buggy the duplicated keys do not work
#@priority = {2 => [:start, 20], 2 => [:stop, 80]}
- @priority = {2 => [:stop, 80]}
+ @priority = { 2 => [:stop, 80] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]chef"]).and_return(@files)
end
@@ -230,17 +230,17 @@ describe Chef::Provider::Service::AixInit do
end
it "the service is enabled" do
- expect(@provider.current_resource).to receive(:enabled).with(true)
- expect(@provider.current_resource).to receive(:priority).with("")
+ expect(@provider.current_resource).to receive(:enabled).with(true)
+ expect(@provider.current_resource).to receive(:priority).with("")
- @provider.set_current_resource_attributes
+ @provider.set_current_resource_attributes
end
end
context "when rc2.d contains only stop script (without priority)" do
before do
files = ["/etc/rc.d/rc2.d/Kapache"]
- @priority = {2 => [:stop, ""]}
+ @priority = { 2 => [:stop, ""] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files)
end
@@ -257,7 +257,7 @@ describe Chef::Provider::Service::AixInit do
files = ["/etc/rc.d/rc2.d/Sapache", "/etc/rc.d/rc2.d/Kapache"]
# FIXME: this is clearly buggy the duplicated keys do not work
#@priority = {2 => [:start, ''], 2 => [:stop, '']}
- @priority = {2 => [:stop, ""]}
+ @priority = { 2 => [:stop, ""] }
allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files)
end
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index 9272a8bd96..47f874cc0e 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -26,14 +26,14 @@ require "ostruct"
describe Chef::Provider::Service::Arch, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Service.new("chef")
@new_resource.pattern("chef")
- @new_resource.supports({:status => false})
+ @new_resource.supports({ :status => false })
@provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
@@ -51,7 +51,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when the service supports status" do
before do
- @new_resource.supports({:status => true})
+ @new_resource.supports({ :status => true })
end
it "should run '/etc/rc.d/service_name status'" do
@@ -92,14 +92,14 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => nil}
+ @node.automatic_attrs[:command] = { :ps => nil }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => ""}
+ @node.automatic_attrs[:command] = { :ps => "" }
@provider.define_resource_requirements
@provider.action = :start
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -125,7 +125,7 @@ DEFAULT_PS
@status = double("Status", :exitstatus => 0, :stdout => @stdout)
allow(@provider).to receive(:shell_out!).and_return(@status)
- @node.automatic_attrs[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ef" }
end
it "determines the service is running when it appears in ps" do
@@ -274,7 +274,7 @@ RUNNING_PS
# end
it "should call 'restart' on the service_name if the resource supports it" do
- allow(@new_resource).to receive(:supports).and_return({:restart => true})
+ allow(@new_resource).to receive(:supports).and_return({ :restart => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restart")
@provider.restart_service()
end
@@ -309,7 +309,7 @@ RUNNING_PS
# end
it "should call 'reload' on the service if it supports it" do
- allow(@new_resource).to receive(:supports).and_return({:reload => true})
+ allow(@new_resource).to receive(:supports).and_return({ :reload => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} reload")
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 2400676b84..2192671370 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Debian do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "fuuuu"}
+ @node.automatic_attrs[:command] = { :ps => "fuuuu" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -114,7 +114,7 @@ describe Chef::Provider::Service::Debian do
end
end
- {"Debian/Lenny and older" => {
+ { "Debian/Lenny and older" => {
"linked" => {
"stdout" => <<-STDOUT,
Removing any system startup links for /etc/init.d/chef ...
@@ -128,13 +128,13 @@ describe Chef::Provider::Service::Debian do
STDOUT
"stderr" => "",
"priorities" => {
- "0"=>[:stop, "20"],
- "1"=>[:stop, "20"],
- "2"=>[:start, "20"],
- "3"=>[:start, "20"],
- "4"=>[:start, "20"],
- "5"=>[:start, "20"],
- "6"=>[:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"],
+ "6" => [:stop, "20"],
},
},
"not linked" => {
@@ -156,13 +156,13 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
STDERR
"priorities" => {
- "0"=>[:stop, "20"],
- "1"=>[:stop, "20"],
- "2"=>[:start, "20"],
- "3"=>[:start, "20"],
- "4"=>[:start, "20"],
- "5"=>[:start, "20"],
- "6"=>[:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"],
+ "6" => [:stop, "20"],
},
},
"not linked" => {
@@ -181,10 +181,10 @@ insserv: remove service /etc/init.d/../rcS.d/S13rpcbind
insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
STDERR
"priorities" => {
- "0"=>[:stop, "06"],
- "1"=>[:stop, "06"],
- "6"=>[:stop, "06"],
- "S"=>[:start, "13"],
+ "0" => [:stop, "06"],
+ "1" => [:stop, "06"],
+ "6" => [:stop, "06"],
+ "S" => [:start, "13"],
},
},
"not linked" => {
@@ -276,7 +276,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
context "when the service is enabled" do
before do
@current_resource.enabled(true)
- @current_resource.priority(80)
+ @current_resource.priority(80)
end
context "and the service sets no priority" do
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 9729c1ddbc..e64aa517e2 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -27,14 +27,14 @@ end
describe Chef::Provider::Service::Freebsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = {:ps => "ps -ax"}
+ node.automatic_attrs[:command] = { :ps => "ps -ax" }
node
end
let(:new_resource) do
new_resource = Chef::Resource::Service.new("apache22")
new_resource.pattern("httpd")
- new_resource.supports({:status => false})
+ new_resource.supports({ :status => false })
new_resource
end
@@ -46,7 +46,7 @@ describe Chef::Provider::Service::Freebsd do
let(:provider) do
events = Chef::EventDispatch::Dispatcher.new
run_context = Chef::RunContext.new(node, {}, events)
- provider = Chef::Provider::Service::Freebsd.new(new_resource,run_context)
+ provider = Chef::Provider::Service::Freebsd.new(new_resource, run_context)
provider.action = :start
provider
end
@@ -115,7 +115,7 @@ describe Chef::Provider::Service::Freebsd do
let(:status) { double(:stdout => "", :exitstatus => 0) }
before do
- new_resource.supports({:status => true})
+ new_resource.supports({ :status => true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -147,7 +147,7 @@ PS_SAMPLE
let(:status) { double(:stdout => stdout, :exitstatus => 0) }
before do
- node.automatic_attrs[:command] = {:ps => "ps -ax"}
+ node.automatic_attrs[:command] = { :ps => "ps -ax" }
end
it "should shell_out! the node's ps command" do
@@ -191,7 +191,7 @@ PS_SAMPLE
context "when ps is empty string" do
before do
- node.automatic_attrs[:command] = {:ps => ""}
+ node.automatic_attrs[:command] = { :ps => "" }
end
it "should set running to nil" do
@@ -465,7 +465,7 @@ EOF
describe Chef::Provider::Service::Freebsd, "restart_service" do
it "should call 'restart' on the service_name if the resource supports it" do
- new_resource.supports({:restart => true})
+ new_resource.supports({ :restart => true })
expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart")
provider.restart_service()
end
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index 47c1aa7215..4b31e9c399 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Init, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({:status => true})
+ @new_resource.supports({ :status => true })
end
it "should run '/etc/init.d/service_name status'" do
@@ -109,7 +109,7 @@ PS
describe "when the node has not specified a ps command" do
it "should raise an error if the node has a nil ps attribute" do
- @node.automatic_attrs[:command] = {:ps => nil}
+ @node.automatic_attrs[:command] = { :ps => nil }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -117,7 +117,7 @@ PS
end
it "should raise an error if the node has an empty ps attribute" do
- @node.automatic_attrs[:command] = {:ps => ""}
+ @node.automatic_attrs[:command] = { :ps => "" }
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
@@ -189,7 +189,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({:restart => true})
+ @new_resource.supports({ :restart => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restart")
@provider.restart_service()
end
@@ -210,7 +210,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({:reload => true})
+ @new_resource.supports({ :reload => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef reload")
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index de0c546ff1..3b2b19c432 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Provider::Service::Insserv do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @node.automatic_attrs[:command] = {:ps => "ps -ax"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ax" }
@new_resource = Chef::Resource::Service.new("initgrediant")
@current_resource = Chef::Resource::Service.new("initgrediant")
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index 6503e542f9..57b13d0c51 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Invokercd, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -53,7 +53,7 @@ PS
describe "when the service supports status" do
before do
- @new_resource.supports({:status => true})
+ @new_resource.supports({ :status => true })
end
it "should run '/usr/sbin/invoke-rc.d service_name status'" do
@@ -95,14 +95,14 @@ PS
describe "when the node has not specified a ps command" do
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => nil}
+ @node.automatic_attrs[:command] = { :ps => nil }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => ""}
+ @node.automatic_attrs[:command] = { :ps => "" }
@provider.action = :start
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -176,7 +176,7 @@ RUNNING_PS
describe "when restarting a service" do
it "should call 'restart' on the service_name if the resource supports it" do
- @new_resource.supports({:restart => true})
+ @new_resource.supports({ :restart => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart")
@provider.restart_service()
end
@@ -197,7 +197,7 @@ RUNNING_PS
describe "when reloading a service" do
it "should call 'reload' on the service if it supports it" do
- @new_resource.supports({:reload => true})
+ @new_resource.supports({ :reload => true })
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef reload")
@provider.reload_service()
end
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index fab7a11248..29ebf2da11 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -43,7 +43,7 @@ describe Chef::Provider::Service::Macosx do
context "when service name is given as" do
let(:node) { Chef::Node.new }
- let(:events) {Chef::EventDispatch::Dispatcher.new}
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:provider) { described_class.new(new_resource, run_context) }
let(:launchctl_stdout) { StringIO.new }
@@ -61,30 +61,30 @@ XML
["Daemon", "Agent"].each do |service_type|
["redis-server", "io.redis.redis-server"].each do |service_name|
["10.9", "10.10", "10.11"].each do |platform_version|
- let(:plist) {"/Library/LaunchDaemons/io.redis.redis-server.plist"}
+ let(:plist) { "/Library/LaunchDaemons/io.redis.redis-server.plist" }
let(:session) { StringIO.new }
if service_type == "Agent"
- let(:plist) {"/Library/LaunchAgents/io.redis.redis-server.plist"}
- let(:session) {"-S Aqua "}
- let(:su_cmd) {"su -l igor -c"}
+ let(:plist) { "/Library/LaunchAgents/io.redis.redis-server.plist" }
+ let(:session) { "-S Aqua " }
+ let(:su_cmd) { "su -l igor -c" }
if platform_version == "10.9"
- let(:su_cmd) {"su igor -c"}
+ let(:su_cmd) { "su igor -c" }
end
end
- let(:service_label) {"io.redis.redis-server"}
+ let(:service_label) { "io.redis.redis-server" }
before do
allow(Dir).to receive(:glob).and_return([plist], [])
allow(Etc).to receive(:getlogin).and_return("igor")
allow(node).to receive(:[]).with("platform_version").and_return(platform_version)
cmd = "launchctl list #{service_label}"
allow(provider).to receive(:shell_out_with_systems_locale).
- with(/(#{su_cmd} '#{cmd}'|#{cmd})/).
- and_return(double("Status",
+ with(/(#{su_cmd} '#{cmd}'|#{cmd})/).
+ and_return(double("Status",
:stdout => launchctl_stdout, :exitstatus => 0))
allow(File).to receive(:exists?).and_return([true], [])
allow(provider).to receive(:shell_out_with_systems_locale!).
- with(/plutil -convert xml1 -o/).
- and_return(double("Status", :stdout => plutil_stdout))
+ with(/plutil -convert xml1 -o/).
+ and_return(double("Status", :stdout => plutil_stdout))
end
context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do
@@ -109,8 +109,8 @@ XML
allow(Dir).to receive(:glob).and_return([])
allow(File).to receive(:exists?).and_return([true], [])
allow(provider).to receive(:shell_out!).
- with(/plutil -convert xml1 -o/).
- and_raise(Mixlib::ShellOut::ShellCommandFailed)
+ with(/plutil -convert xml1 -o/).
+ and_raise(Mixlib::ShellOut::ShellCommandFailed)
end
it "works for action :nothing" do
@@ -166,7 +166,7 @@ SVC_LIST
allow(File).to receive(:exists?).and_return([true], [])
end
it "should throw an exception when reload action is attempted" do
- expect {provider.run_action(:reload)}.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
end
context "when launchctl returns empty service pid" do
@@ -265,8 +265,8 @@ SVC_LIST
it "starts service via launchctl if service found" do
cmd = "launchctl load -w " + session + plist
expect(provider).to receive(:shell_out_with_systems_locale).
- with(/(#{su_cmd} .#{cmd}.|#{cmd})/).
- and_return(0)
+ with(/(#{su_cmd} .#{cmd}.|#{cmd})/).
+ and_return(0)
provider.start_service
end
@@ -295,10 +295,10 @@ SVC_LIST
end
it "stops the service via launchctl if service found" do
- cmd = "launchctl unload -w "+ plist
+ cmd = "launchctl unload -w " + plist
expect(provider).to receive(:shell_out_with_systems_locale).
- with(/(#{su_cmd} .#{cmd}.|#{cmd})/).
- and_return(0)
+ with(/(#{su_cmd} .#{cmd}.|#{cmd})/).
+ and_return(0)
provider.stop_service
end
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index 73e0960901..7b64214e65 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -31,11 +31,11 @@ end
describe Chef::Provider::Service::Openbsd do
let(:node) do
node = Chef::Node.new
- node.automatic_attrs[:command] = {:ps => "ps -ax"}
+ node.automatic_attrs[:command] = { :ps => "ps -ax" }
node
end
- let(:supports) { {:status => false} }
+ let(:supports) { { :status => false } }
let(:new_resource) do
new_resource = Chef::Resource::Service.new("sndiod")
@@ -54,7 +54,7 @@ describe Chef::Provider::Service::Openbsd do
run_context = Chef::RunContext.new(node, {}, events)
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("")
allow(::File).to receive(:read).with("/etc/rc.conf.local").and_return("")
- provider = Chef::Provider::Service::Openbsd.new(new_resource,run_context)
+ provider = Chef::Provider::Service::Openbsd.new(new_resource, run_context)
provider.action = :start
provider
end
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 110a38d04b..5d03c688fc 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -23,7 +23,7 @@ shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false)
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
- allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_raise(Errno::ENOENT)
+ allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_raise(Errno::ENOENT)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
@@ -33,7 +33,7 @@ shared_examples_for "define_resource_requirements_common" do
status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
@@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "foo"}
+ @node.automatic_attrs[:command] = { :ps => "foo" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -71,7 +71,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets supports[:status] to true by default" do
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@provider.supports[:status]).to be true
@@ -81,7 +81,7 @@ describe "Chef::Provider::Service::Redhat" do
@new_resource.supports( { status: false } )
@new_resource.pattern "myservice"
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "")
expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out)
expect(@provider.service_missing).to be false
@@ -92,7 +92,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to true if the service is enabled for any run level" do
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
@@ -100,7 +100,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the regex does not match" do
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
expect(@provider.load_current_resource).to eql(@current_resource)
expect(@current_resource.enabled).to be false
@@ -109,7 +109,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to true if the service is enabled at specified run levels" do
@new_resource.run_levels([1, 2])
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be true
@@ -119,7 +119,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is enabled at a run level it should not" do
@new_resource.run_levels([1, 2])
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -129,7 +129,7 @@ describe "Chef::Provider::Service::Redhat" do
it "sets the current enabled status to false if the service is not enabled at specified run levels" do
@new_resource.run_levels([ 2 ])
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
expect(@provider.service_missing).to be false
@provider.load_current_resource
expect(@current_resource.enabled).to be false
@@ -144,8 +144,8 @@ describe "Chef::Provider::Service::Redhat" do
before do
status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
end
@@ -182,8 +182,8 @@ describe "Chef::Provider::Service::Redhat" do
it "should not raise an error if the service does not exist" do
status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service")
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
- chkconfig = double("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
- expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
+ chkconfig = double("Chkconfig", :existatus => 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory")
+ expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0, 1]).and_return(chkconfig)
@provider.load_current_resource
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.not_to raise_error
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 2318bed95a..499e0cc2d3 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Simple, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node.automatic_attrs[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ef" }
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ
end
it "should raise error if the node has a nil ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => nil}
+ @node.automatic_attrs[:command] = { :ps => nil }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
it "should raise error if the node has an empty ps attribute and no other means to get status" do
- @node.automatic_attrs[:command] = {:ps => ""}
+ @node.automatic_attrs[:command] = { :ps => "" }
@provider.define_resource_requirements
expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
end
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index 94d123ef1a..c6835bed64 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::Service::Solaris do
before(:each) do
- @node =Chef::Node.new
+ @node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -116,18 +116,18 @@ describe Chef::Provider::Service::Solaris do
describe "when discovering the current service state" do
it "should create a current resource with the name of the new resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@provider.load_current_resource
end
it "should return the current resource" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
expect(@provider.load_current_resource).to eql(@current_resource)
end
it "should call '/bin/svcs -l service_name'" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
end
@@ -162,7 +162,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -172,7 +172,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm enable -s chef for start_service" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@provider.load_current_resource
@@ -182,7 +182,7 @@ describe Chef::Provider::Service::Solaris do
it "should call svcadm clear chef for start_service when state maintenance" do
# we are in maint mode
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@maintenance_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
@@ -191,7 +191,7 @@ describe Chef::Provider::Service::Solaris do
expect(@provider.enable_service).to be_truthy
# now we are enabled
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
@provider.load_current_resource
expect(@current_resource.enabled).to be_truthy
@@ -204,7 +204,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.disable_service).to be_truthy
@@ -212,7 +212,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef for stop_service" do
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
expect(@provider.stop_service).to be_truthy
@@ -224,7 +224,7 @@ describe Chef::Provider::Service::Solaris do
describe "when reloading the service" do
before(:each) do
@provider.current_resource = @current_resource
- allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@enabled_svc_status)
+ allow(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
end
it "should call svcadm refresh chef" do
@@ -237,7 +237,7 @@ describe Chef::Provider::Service::Solaris do
describe "when the service doesn't exist" do
before(:each) do
@provider.current_resource = @current_resource
- expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", {:returns=>[0, 1]}).and_return(@no_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@no_svc_status)
end
it "should be marked not running" do
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index e98284a8fd..fd9ea0573c 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Provider::Service::Upstart do
end
before(:each) do
- @node =Chef::Node.new
+ @node = Chef::Node.new
@node.name("upstarter")
@node.automatic_attrs[:platform] = "ubuntu"
@node.automatic_attrs[:platform_version] = "9.10"
@@ -66,7 +66,7 @@ describe Chef::Provider::Service::Upstart do
describe "load_current_resource" do
before(:each) do
- @node.automatic_attrs[:command] = {:ps => "ps -ax"}
+ @node.automatic_attrs[:command] = { :ps => "ps -ax" }
@current_resource = Chef::Resource::Service.new("rsyslog")
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index cbda70c9bb..f944d8f6c6 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -369,7 +369,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
describe Chef::Provider::Service::Windows, "action_configure_startup" do
- { :automatic => "auto start", :manual => "demand start", :disabled => "disabled" }.each do |type,win32|
+ { :automatic => "auto start", :manual => "demand start", :disabled => "disabled" }.each do |type, win32|
it "sets the startup type to #{type} if it is something else" do
new_resource.startup_type(type)
allow(provider).to receive(:current_start_type).and_return("fire")
diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb
index 5746bcde89..d775297658 100644
--- a/spec/unit/provider/service_spec.rb
+++ b/spec/unit/provider/service_spec.rb
@@ -49,7 +49,6 @@ describe Chef::Provider::Service do
end
end
-
describe "when disabling the service" do
it "should disable the service if enabled and set the resource as updated" do
allow(@current_resource).to receive(:enabled).and_return(true)
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index 1a92c40ab1..372f3499c4 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::Subversion do
it "converts resource attributes to options for run_command and popen4" do
expect(@provider.run_options).to eq({})
@resource.user "deployninja"
- expect(@provider.run_options).to eq({:user => "deployninja"})
+ expect(@provider.run_options).to eq({ :user => "deployninja" })
end
context "determining the revision of the currently deployed code" do
@@ -64,18 +64,18 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", {:cwd => "/my/deploy/dir", :returns => [0,1]}]
+ expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
expect(@provider.find_current_revision).to eql("11410")
end
it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do
example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n"
expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- expected_command = ["svn info", {:cwd => "/my/deploy/dir", :returns => [0,1]}]
+ expected_command = ["svn info", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
expect(@provider.find_current_revision).to be_nil
end
@@ -119,19 +119,19 @@ describe Chef::Provider::Subversion do
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => "/my/deploy/dir", :returns => [0,1]}]
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
expect(@provider.revision_int).to eql("11410")
end
it "returns a helpful message if data from `svn info` can't be parsed" do
example_svn_info = "some random text from an error message\n"
@resource.revision "HEAD"
- expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => "/my/deploy/dir", :returns => [0,1]}]
+ expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", { :cwd => "/my/deploy/dir", :returns => [0, 1] }]
expect(@provider).to receive(:shell_out!).with(*expected_command).
- and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
- expect {@provider.revision_int}.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n")
+ and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
+ expect { @provider.revision_int }.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n")
end
@@ -154,8 +154,7 @@ describe Chef::Provider::Subversion do
it "generates a checkout command with arbitrary options" do
@resource.svn_arguments "--no-auth-cache"
- expect(@provider.checkout_command).to eql("svn checkout --no-auth-cache -q -r12345 "+
- "http://svn.example.org/trunk/ /my/deploy/dir")
+ expect(@provider.checkout_command).to eql("svn checkout --no-auth-cache -q -r12345 " + "http://svn.example.org/trunk/ /my/deploy/dir")
end
it "generates a sync command with default options" do
@@ -195,14 +194,14 @@ describe Chef::Provider::Subversion do
end
it "raises an error if the svn checkout command would fail because the enclosing directory doesn't exist" do
- expect {@provider.run_action(:sync)}.to raise_error(Chef::Exceptions::MissingParentDirectory)
+ expect { @provider.run_action(:sync) }.to raise_error(Chef::Exceptions::MissingParentDirectory)
end
it "should not checkout if the destination exists or is a non empty directory" do
allow(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(false)
allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"])
+ allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", "..", "foo", "bar"])
expect(@provider).not_to receive(:checkout_command)
@provider.run_action(:checkout)
expect(@resource).not_to be_updated
@@ -213,7 +212,7 @@ describe Chef::Provider::Subversion do
@resource.user "whois"
@resource.group "thisis"
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
- expect(@provider).to receive(:shell_out!).with(expected_cmd, {user: "whois", group: "thisis"})
+ expect(@provider).to receive(:shell_out!).with(expected_cmd, { user: "whois", group: "thisis" })
@provider.run_action(:checkout)
expect(@resource).to be_updated
end
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 5d885267c7..4f7b4c256c 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -113,7 +113,7 @@ describe Chef::Provider::Template::Content do
it "fails when :file_desployment_uses_destdir is set" do
Chef::Config[:file_staging_uses_destdir] = true
- expect{content.tempfile}.to raise_error(Chef::Exceptions::FileContentStagingError)
+ expect { content.tempfile }.to raise_error(Chef::Exceptions::FileContentStagingError)
end
it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index bf1fcd1cc3..488039ad18 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -23,10 +23,9 @@ require "etc"
require "ostruct"
require "support/shared/unit/provider/file"
-
describe Chef::Provider::Template do
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
@@ -60,7 +59,7 @@ describe Chef::Provider::Template do
context "when creating the template" do
let(:node) { double("Chef::Node") }
- let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index 5465e3b225..712fbfc76c 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -230,7 +230,6 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
provider.dscl_set_home
end
-
it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do
new_resource.home("epic-fail")
expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::InvalidHomeDirectory)
@@ -248,16 +247,16 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
expect(FileUtils).to receive(:mkdir_p).with("/Users/toor").and_return(true)
expect(FileUtils).to receive(:rmdir).with(current_home)
- expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*",::File::FNM_DOTMATCH).and_return(current_home_files)
+ expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*", ::File::FNM_DOTMATCH).and_return(current_home_files)
expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", :force => true)
- expect(FileUtils).to receive(:chown_R).with("toor","23","/Users/toor")
+ expect(FileUtils).to receive(:chown_R).with("toor", "23", "/Users/toor")
expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory '/Users/toor'")
provider.dscl_set_home
end
it "should raise an exception when the systems user template dir (skel) cannot be found" do
- allow(::File).to receive(:exists?).and_return(false,false,false)
+ allow(::File).to receive(:exists?).and_return(false, false, false)
expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::User)
end
@@ -720,7 +719,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
end
it "should sleep and flush the dscl cache before saving the password" do
- expect(provider).to receive(:prepare_password_shadow_info).and_return({ })
+ expect(provider).to receive(:prepare_password_shadow_info).and_return({})
mock_shellout = double("Mock::Shellout")
allow(mock_shellout).to receive(:run_command)
expect(Mixlib::ShellOut).to receive(:new).and_return(mock_shellout)
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index dd9564ff1a..1e9fda9f7e 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -67,7 +67,7 @@ describe Chef::Provider::User::Pw do
end
it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do
- allow(@new_resource).to receive(:supports).and_return({:manage_home => false})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => false })
allow(@new_resource).to receive(attribute).and_return("hola")
expect(@provider.set_options).to eql(" #{@new_resource.username} #{option} '#{@new_resource.send(attribute)}'")
end
@@ -75,7 +75,7 @@ describe Chef::Provider::User::Pw do
it "should combine all the possible options" do
match_string = " adam"
- field_list.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
+ field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
allow(@new_resource).to receive(attribute).and_return("hola")
match_string << " #{option} 'hola'"
end
@@ -126,7 +126,7 @@ describe Chef::Provider::User::Pw do
end
it "should run pw userdel with the new resources user name and -r if manage_home is true" do
- expect(@provider).to receive(:run_command).with({ :command => "pw userdel #{@new_resource.username} -r"}).and_return(true)
+ expect(@provider).to receive(:run_command).with({ :command => "pw userdel #{@new_resource.username} -r" }).and_return(true)
@provider.remove_user
end
end
@@ -145,14 +145,14 @@ describe Chef::Provider::User::Pw do
describe "when locking the user" do
it "should run pw lock with the new resources username" do
- expect(@provider).to receive(:run_command).with({ :command => "pw lock #{@new_resource.username}"})
+ expect(@provider).to receive(:run_command).with({ :command => "pw lock #{@new_resource.username}" })
@provider.lock_user
end
end
describe "when unlocking the user" do
it "should run pw unlock with the new resources username" do
- expect(@provider).to receive(:run_command).with({ :command => "pw unlock #{@new_resource.username}"})
+ expect(@provider).to receive(:run_command).with({ :command => "pw unlock #{@new_resource.username}" })
@provider.unlock_user
end
end
diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb
index 37c8655416..4a62e6ec9d 100644
--- a/spec/unit/provider/user/windows_spec.rb
+++ b/spec/unit/provider/user/windows_spec.rb
@@ -127,19 +127,19 @@ describe Chef::Provider::User::Windows do
describe "when creating the user" do
it "should call @net_user.add with the return of set_options" do
- allow(@provider).to receive(:set_options).and_return(:name=> "monkey")
- expect(@net_user).to receive(:add).with(:name=> "monkey")
+ allow(@provider).to receive(:set_options).and_return(:name => "monkey")
+ expect(@net_user).to receive(:add).with(:name => "monkey")
@provider.create_user
end
end
describe "manage_user" do
before(:each) do
- allow(@provider).to receive(:set_options).and_return(:name=> "monkey")
+ allow(@provider).to receive(:set_options).and_return(:name => "monkey")
end
it "should call @net_user.update with the return of set_options" do
- expect(@net_user).to receive(:update).with(:name=> "monkey")
+ expect(@net_user).to receive(:update).with(:name => "monkey")
@provider.manage_user
end
end
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb
index ce10e8b73d..0794ce0328 100644
--- a/spec/unit/provider/user_spec.rb
+++ b/spec/unit/provider/user_spec.rb
@@ -183,7 +183,7 @@ describe Chef::Provider::User do
expect(@provider).to receive(:require).with("shadow") { raise LoadError }
@provider.load_current_resource
@provider.define_resource_requirements
- expect {@provider.process_resource_requirements}.to raise_error Chef::Exceptions::MissingLibrary
+ expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::MissingLibrary
end
end
@@ -197,8 +197,8 @@ describe Chef::Provider::User do
"uid" => [1000, 1001],
"gid" => [1000, 1001],
"home" => ["/home/adam", "/Users/adam"],
- "shell"=> ["/usr/bin/zsh", "/bin/bash"],
- "password"=> ["abcd","12345"],
+ "shell" => ["/usr/bin/zsh", "/bin/bash"],
+ "password" => ["abcd", "12345"],
}
}
@@ -380,7 +380,6 @@ describe Chef::Provider::User do
end
end
-
describe "action_lock" do
before(:each) do
allow(@provider).to receive(:load_current_resource)
diff --git a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
index ccd3358e2a..29d49ff90b 100644
--- a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::WhyrunSafeRubyBlock.new("bloc party")
- @new_resource.block { $evil_global_evil_laugh = :mwahahaha}
+ @new_resource.block { $evil_global_evil_laugh = :mwahahaha }
@provider = Chef::Provider::WhyrunSafeRubyBlock.new(@new_resource, @run_context)
end
@@ -44,4 +44,3 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do
end
end
-
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index 8dd6724192..2bc2ae7c88 100644
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -18,15 +18,15 @@
require "spec_helper"
-
class NoWhyrunDemonstrator < Chef::Provider
attr_reader :system_state_altered
def whyrun_supported?
false
end
- def load_current_resource
+ def load_current_resource
end
+
def action_foo
@system_state_altered = true
end
@@ -55,7 +55,6 @@ class CheckResourceSemanticsDemonstrator < ConvergeActionDemonstrator
end
end
-
describe Chef::Provider do
before(:each) do
@cookbook_collection = Chef::CookbookCollection.new([])
@@ -107,7 +106,7 @@ describe Chef::Provider do
it "evals embedded recipes with a pristine resource collection" do
@provider.run_context.instance_variable_set(:@resource_collection, "doesn't matter what this is")
temporary_collection = nil
- snitch = Proc.new {temporary_collection = @run_context.resource_collection}
+ snitch = Proc.new { temporary_collection = @run_context.resource_collection }
@provider.send(:recipe_eval, &snitch)
expect(temporary_collection).to be_an_instance_of(Chef::ResourceCollection)
expect(@provider.run_context.instance_variable_get(:@resource_collection)).to eq("doesn't matter what this is")
@@ -115,7 +114,7 @@ describe Chef::Provider do
it "does not re-load recipes when creating the temporary run context" do
expect_any_instance_of(Chef::RunContext).not_to receive(:load)
- snitch = Proc.new {temporary_collection = @run_context.resource_collection}
+ snitch = Proc.new { temporary_collection = @run_context.resource_collection }
@provider.send(:recipe_eval, &snitch)
end
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index fd7fb47ea0..8f43d0cbca 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -100,7 +100,7 @@ describe Chef::Recipe do
end
end
- expect(run_context.resource_collection.map{|r| r.name}).to eql(["monkey", "dog", "cat"])
+ expect(run_context.resource_collection.map { |r| r.name }).to eql(["monkey", "dog", "cat"])
end
it "should return the new resource after creating it" do
@@ -270,14 +270,12 @@ describe Chef::Recipe do
it "validating resources via build_resource" do
expect {recipe.build_resource(:remote_file, "klopp") do
- source Chef::DelayedEvaluator.new {"http://chef.io"}
+ source Chef::DelayedEvaluator.new { "http://chef.io" }
end}.to_not raise_error
end
end
-
-
describe "creating resources via declare_resource" do
let(:zm_resource) do
recipe.declare_resource(:zen_master, "klopp") do
@@ -322,8 +320,8 @@ describe Chef::Recipe do
zm_resource
recipe.declare_resource(:zen_master, "klopp2", run_context: run_context2)
run_context2.resource_collection.lookup("zen_master[klopp2]")
- expect {run_context2.resource_collection.lookup("zen_master[klopp]")}.to raise_error(Chef::Exceptions::ResourceNotFound)
- expect {run_context.resource_collection.lookup("zen_master[klopp2]")}.to raise_error(Chef::Exceptions::ResourceNotFound)
+ expect { run_context2.resource_collection.lookup("zen_master[klopp]") }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ expect { run_context.resource_collection.lookup("zen_master[klopp2]") }.to raise_error(Chef::Exceptions::ResourceNotFound)
run_context.resource_collection.lookup("zen_master[klopp]")
end
end
@@ -355,7 +353,6 @@ describe Chef::Recipe do
end
end
-
it "defines the resource using the declaration name with long name" do
resource_zn_follower
expect(run_context.resource_collection.lookup("zen_follower[srst]")).not_to be_nil
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index ee4a66f8d5..b34b4200e6 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Resource::Conditional do
end
it "raises an exception when neither a block or command is given" do
- expect { Chef::Resource::Conditional.send(:new, :always, @parent_resource, nil, {})}.to raise_error(ArgumentError, /requires either a command or a block/)
+ expect { Chef::Resource::Conditional.send(:new, :always, @parent_resource, nil, {}) }.to raise_error(ArgumentError, /requires either a command or a block/)
end
it "does not evaluate a guard interpreter on initialization of the conditional" do
@@ -171,7 +171,7 @@ describe Chef::Resource::Conditional do
describe "after running a command which timed out" do
before do
- @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false")
+ @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false")
allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
end
diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index ca49320503..6886ce1f31 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -48,28 +48,27 @@ describe Chef::Resource::CookbookFile do
describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do
before do
- if Chef::Platform.windows?
- @cookbook_file.path("C:/temp/origin/file.txt")
- @cookbook_file.rights(:read, "Everyone")
- @cookbook_file.deny_rights(:full_control, "Clumsy_Sam")
- else
- @cookbook_file.path("/tmp/origin/file.txt")
- @cookbook_file.group("wheel")
- @cookbook_file.mode("0664")
- @cookbook_file.owner("root")
- @cookbook_file.source("/tmp/foo.txt")
- @cookbook_file.cookbook("/tmp/cookbooks/cooked.rb")
- end
+ if Chef::Platform.windows?
+ @cookbook_file.path("C:/temp/origin/file.txt")
+ @cookbook_file.rights(:read, "Everyone")
+ @cookbook_file.deny_rights(:full_control, "Clumsy_Sam")
+ else
+ @cookbook_file.path("/tmp/origin/file.txt")
+ @cookbook_file.group("wheel")
+ @cookbook_file.mode("0664")
+ @cookbook_file.owner("root")
+ @cookbook_file.source("/tmp/foo.txt")
+ @cookbook_file.cookbook("/tmp/cookbooks/cooked.rb")
+ end
@cookbook_file.checksum("1" * 64)
end
-
it "describes the state" do
state = @cookbook_file.state
if Chef::Platform.windows?
puts state
- expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}])
- expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}])
+ expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
+ expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }])
else
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0664")
diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb
index ad2ec08bb2..037bbaf733 100644
--- a/spec/unit/resource/cron_spec.rb
+++ b/spec/unit/resource/cron_spec.rb
@@ -100,7 +100,7 @@ describe Chef::Resource::Cron do
end
it "should allow you to specify environment variables hash" do
- env = {"TEST" => "LOL"}
+ env = { "TEST" => "LOL" }
@resource.environment env
expect(@resource.environment).to eql(env)
end
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb
index bd9d8295a4..0eeb51c8a0 100644
--- a/spec/unit/resource/deploy_spec.rb
+++ b/spec/unit/resource/deploy_spec.rb
@@ -28,17 +28,16 @@ describe Chef::Resource::Deploy do
action: :deploy,
)
-
class << self
def resource_has_a_string_attribute(attr_name)
it "has a String attribute for #{attr_name}" do
@resource.send(attr_name, "this is a string")
expect(@resource.send(attr_name)).to eql("this is a string")
- expect {@resource.send(attr_name, 8675309)}.to raise_error(ArgumentError)
+ expect { @resource.send(attr_name, 8675309) }.to raise_error(ArgumentError)
end
end
- def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false})
+ def resource_has_a_boolean_attribute(attr_name, opts = { :defaults_to => false })
it "has a Boolean attribute for #{attr_name}" do
expect(@resource.send(attr_name)).to eql(opts[:defaults_to])
@resource.send(attr_name, !opts[:defaults_to])
@@ -49,12 +48,12 @@ describe Chef::Resource::Deploy do
def resource_has_a_callback_attribute(attr_name)
it "has a Callback attribute #{attr_name}" do
callback_block = lambda { :noop }
- expect {@resource.send(attr_name, &callback_block)}.not_to raise_error
+ expect { @resource.send(attr_name, &callback_block) }.not_to raise_error
expect(@resource.send(attr_name)).to eq(callback_block)
callback_file = "path/to/callback.rb"
- expect {@resource.send(attr_name, callback_file)}.not_to raise_error
+ expect { @resource.send(attr_name, callback_file) }.not_to raise_error
expect(@resource.send(attr_name)).to eq(callback_file)
- expect {@resource.send(attr_name, :this_is_fail)}.to raise_error(ArgumentError)
+ expect { @resource.send(attr_name, :this_is_fail) }.to raise_error(ArgumentError)
end
end
end
@@ -80,9 +79,9 @@ describe Chef::Resource::Deploy do
resource_has_a_string_attribute(:svn_arguments)
resource_has_a_string_attribute(:svn_info_args)
- resource_has_a_boolean_attribute(:migrate, :defaults_to=>false)
- resource_has_a_boolean_attribute(:enable_submodules, :defaults_to=>false)
- resource_has_a_boolean_attribute(:shallow_clone, :defaults_to=>false)
+ resource_has_a_boolean_attribute(:migrate, :defaults_to => false)
+ resource_has_a_boolean_attribute(:enable_submodules, :defaults_to => false)
+ resource_has_a_boolean_attribute(:shallow_clone, :defaults_to => false)
it "uses the first argument as the deploy directory" do
expect(@resource.deploy_to).to eql("/my/deploy/dir")
@@ -118,17 +117,17 @@ describe Chef::Resource::Deploy do
expect(@resource.svn_force_export).to be_falsey
@resource.svn_force_export true
expect(@resource.svn_force_export).to be_truthy
- expect {@resource.svn_force_export(10053)}.to raise_error(ArgumentError)
+ expect { @resource.svn_force_export(10053) }.to raise_error(ArgumentError)
end
it "takes arbitrary environment variables in a hash" do
@resource.environment "RAILS_ENV" => "production"
- expect(@resource.environment).to eq({"RAILS_ENV" => "production"})
+ expect(@resource.environment).to eq({ "RAILS_ENV" => "production" })
end
it "takes string arguments to environment for backwards compat, setting RAILS_ENV, RACK_ENV, and MERB_ENV" do
@resource.environment "production"
- expect(@resource.environment).to eq({"RAILS_ENV"=>"production", "RACK_ENV"=>"production","MERB_ENV"=>"production"})
+ expect(@resource.environment).to eq({ "RAILS_ENV" => "production", "RACK_ENV" => "production", "MERB_ENV" => "production" })
end
it "sets destination to $deploy_to/shared/$repository_cache" do
@@ -183,16 +182,16 @@ describe Chef::Resource::Deploy do
end
it 'has a Hash attribute symlinks, default: {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}' do
- default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
+ default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log" }
expect(@resource.symlinks).to eq(default)
@resource.symlinks "foo" => "bar/baz"
- expect(@resource.symlinks).to eq({"foo" => "bar/baz"})
+ expect(@resource.symlinks).to eq({ "foo" => "bar/baz" })
end
it 'has a Hash attribute symlink_before_migrate, default "config/database.yml" => "config/database.yml"' do
- expect(@resource.symlink_before_migrate).to eq({"config/database.yml" => "config/database.yml"})
+ expect(@resource.symlink_before_migrate).to eq({ "config/database.yml" => "config/database.yml" })
@resource.symlink_before_migrate "wtf?" => "wtf is going on"
- expect(@resource.symlink_before_migrate).to eq({"wtf?" => "wtf is going on"})
+ expect(@resource.symlink_before_migrate).to eq({ "wtf?" => "wtf is going on" })
end
resource_has_a_callback_attribute :before_migrate
@@ -206,7 +205,7 @@ describe Chef::Resource::Deploy do
end
it "takes a block for the restart parameter" do
- restart_like_this = lambda {p :noop}
+ restart_like_this = lambda { p :noop }
@resource.restart(&restart_like_this)
expect(@resource.restart).to eq(restart_like_this)
end
@@ -264,8 +263,8 @@ describe Chef::Resource::Deploy do
@resource.group("pokemon")
@resource.scm_provider(Chef::Provider::Git)
@resource.repository_cache("cached-copy")
- @resource.environment({"SUDO" => "TRUE"})
- @resource.symlinks({"system" => "public/system"})
+ @resource.environment({ "SUDO" => "TRUE" })
+ @resource.symlinks({ "system" => "public/system" })
@resource.migrate(false)
end
diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb
index ebedd55dec..64f5f50e5e 100644
--- a/spec/unit/resource/dsc_resource_spec.rb
+++ b/spec/unit/resource/dsc_resource_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Resource::DscResource do
end
it "has an ed_actions attribute with only the `:run` and `:nothing` attributes" 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([:run, :nothing].to_set)
end
it "allows the resource attribute to be set" do
diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb
index 7139405f38..55473e3146 100644
--- a/spec/unit/resource/dsc_script_spec.rb
+++ b/spec/unit/resource/dsc_script_spec.rb
@@ -31,8 +31,8 @@ describe Chef::Resource::DscScript do
let(:dsc_test_resource) {
Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
}
- let(:configuration_code) {'echo "This is supposed to create a configuration document."'}
- let(:configuration_path) {"c:/myconfigs/formatc.ps1"}
+ let(:configuration_code) { 'echo "This is supposed to create a configuration document."' }
+ let(:configuration_path) { "c:/myconfigs/formatc.ps1" }
let(:configuration_name) { "formatme" }
let(:configuration_data) { '@{AllNodes = @( @{ NodeName = "localhost"; PSDscAllowPlainTextPassword = $true })}' }
let(:configuration_data_script) { "c:/myconfigs/data/safedata.psd1" }
@@ -42,7 +42,7 @@ describe Chef::Resource::DscScript do
end
it "has an allowed_actions attribute with only the `:run` and `:nothing` attributes" 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([:run, :nothing].to_set)
end
it "allows the code attribute to be set" do
diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb
index f9719689c5..cff862b69e 100644
--- a/spec/unit/resource/env_spec.rb
+++ b/spec/unit/resource/env_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Resource::Env do
expect(@resource.action).to eql([:create])
end
- { :create => false, :delete => false, :modify => false, :flibber => true }.each do |action,bad_value|
+ { :create => false, :delete => false, :modify => false, :flibber => true }.each do |action, bad_value|
it "should #{bad_value ? 'not' : ''} accept #{action}" do
if bad_value
expect { @resource.action action }.to raise_error(ArgumentError)
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index b27d8ca754..f55f6416aa 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Resource::File::Verification do
let(:t_block) { Proc.new { true } }
let(:f_block) { Proc.new { false } }
- let(:path_block) { Proc.new { |path| path }}
+ let(:path_block) { Proc.new { |path| path } }
let(:temp_path) { "/tmp/foobar" }
describe "verification registration" do
@@ -33,7 +33,7 @@ describe Chef::Resource::File::Verification do
end
it "raises an error if a verification can't be found" do
- expect{Chef::Resource::File::Verification.lookup(:dne)}.to raise_error(Chef::Exceptions::VerificationNotFound)
+ expect { Chef::Resource::File::Verification.lookup(:dne) }.to raise_error(Chef::Exceptions::VerificationNotFound)
end
end
@@ -42,13 +42,13 @@ describe Chef::Resource::File::Verification do
it "expects a string argument" do
v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {}
- expect{ v.verify("/foo/bar") }.to_not raise_error
- expect{ v.verify }.to raise_error
+ expect { v.verify("/foo/bar") }.to_not raise_error
+ expect { v.verify }.to raise_error
end
it "accepts an options hash" do
v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {}
- expect{ v.verify("/foo/bar", {:future => true}) }.to_not raise_error
+ expect { v.verify("/foo/bar", { :future => true }) }.to_not raise_error
end
context "with a verification block" do
diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb
index f5b576c0f5..c93a213480 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_spec.rb
@@ -67,11 +67,11 @@ describe Chef::Resource::File do
end
it "should accept a block, symbol, or string for verify" do
- expect {@resource.verify {}}.not_to raise_error
- expect {@resource.verify ""}.not_to raise_error
- expect {@resource.verify :json}.not_to raise_error
- expect {@resource.verify true}.to raise_error
- expect {@resource.verify false}.to raise_error
+ expect { @resource.verify {} }.not_to raise_error
+ expect { @resource.verify "" }.not_to raise_error
+ expect { @resource.verify :json }.not_to raise_error
+ expect { @resource.verify true }.to raise_error
+ expect { @resource.verify false }.to raise_error
end
it "should accept multiple verify statements" do
@@ -122,8 +122,8 @@ describe Chef::Resource::File do
end
it "describes its state including windows ACL attributes" do
state = @resource.state
- expect(state[:rights]).to eq([ {:permissions => :read, :principals => "Everyone"},
- {:permissions => :full_control, :principals => "DOMAIN\User"} ])
+ expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" },
+ { :permissions => :full_control, :principals => "DOMAIN\User" } ])
end
end
diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb
index 97966de2af..0842114c47 100644
--- a/spec/unit/resource/freebsd_package_spec.rb
+++ b/spec/unit/resource/freebsd_package_spec.rb
@@ -29,7 +29,6 @@ describe Chef::Resource::FreebsdPackage do
@resource = Chef::Resource::FreebsdPackage.new("foo", @run_context)
end
-
describe "Initialization" do
it "should return a Chef::Resource::FreebsdPackage" do
expect(@resource).to be_a_kind_of(Chef::Resource::FreebsdPackage)
@@ -44,7 +43,6 @@ describe Chef::Resource::FreebsdPackage do
end
end
-
describe "Assigning provider after creation" do
describe "if ports specified as source" do
it "should be Freebsd::Port" do
@@ -87,4 +85,3 @@ describe Chef::Resource::FreebsdPackage do
end
end
end
-
diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb
index 8a5745a1af..318a154b88 100644
--- a/spec/unit/resource/http_request_spec.rb
+++ b/spec/unit/resource/http_request_spec.rb
@@ -48,7 +48,7 @@ describe Chef::Resource::HttpRequest do
before do
@resource.url("http://www.trololol.net")
@resource.message("Get sum post brah.")
- @resource.headers({"head" => "tail"})
+ @resource.headers({ "head" => "tail" })
end
it "returns the url as its identity" do
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index dfd98eb16e..bd0976d8ea 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Resource::Link do
expect(@resource.action).to eql([:create])
end
- { :create => false, :delete => false, :blues => true }.each do |action,bad_value|
+ { :create => false, :delete => false, :blues => true }.each do |action, bad_value|
it "should #{bad_value ? 'not' : ''} accept #{action}" do
if bad_value
expect { @resource.action action }.to raise_error(ArgumentError)
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index 53efb055e8..ea20511990 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -92,12 +92,12 @@ describe Chef::Resource::Mount do
end
it "should allow options to be sent as a delayed evaluator" do
- @resource.options Chef::DelayedEvaluator.new {["rw", "noexec"]}
+ @resource.options Chef::DelayedEvaluator.new { ["rw", "noexec"] }
expect(@resource.options).to eql(["rw", "noexec"])
end
it "should allow options to be sent as a delayed evaluator, and convert to array" do
- @resource.options Chef::DelayedEvaluator.new {"rw,noexec"}
+ @resource.options Chef::DelayedEvaluator.new { "rw,noexec" }
expect(@resource.options).to be_a_kind_of(Array)
expect(@resource.options).to eql(["rw", "noexec"])
end
diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb
index 0d1d5efd5b..9669ef193d 100644
--- a/spec/unit/resource/ohai_spec.rb
+++ b/spec/unit/resource/ohai_spec.rb
@@ -58,5 +58,4 @@ describe Chef::Resource::Ohai do
end
end
-
end
diff --git a/spec/unit/resource/openbsd_package_spec.rb b/spec/unit/resource/openbsd_package_spec.rb
index 840cabf1fe..9bdc823576 100644
--- a/spec/unit/resource/openbsd_package_spec.rb
+++ b/spec/unit/resource/openbsd_package_spec.rb
@@ -46,4 +46,3 @@ describe Chef::Resource::OpenbsdPackage do
end
end
-
diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb
index a244048878..7bd504d414 100644
--- a/spec/unit/resource/osx_profile_spec.rb
+++ b/spec/unit/resource/osx_profile_spec.rb
@@ -38,8 +38,8 @@ describe Chef::Resource::OsxProfile do
end
it "should accept install and remove as actions" do
- expect { resource.action :install}.not_to raise_error
- expect { resource.action :remove}.not_to raise_error
+ expect { resource.action :install }.not_to raise_error
+ expect { resource.action :remove }.not_to raise_error
end
it "should allow you to set the profile attribute" do
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index ef8f6cce53..dbd76d2eba 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_spec.rb
@@ -50,8 +50,8 @@ describe Chef::Resource::Package do
end
it "should accept a hash for response file template variables" do
- @resource.response_file_variables({:variables => true})
- expect(@resource.response_file_variables).to eql({:variables => true})
+ @resource.response_file_variables({ :variables => true })
+ expect(@resource.response_file_variables).to eql({ :variables => true })
end
it "should accept a string for the source" do
diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb
index 3cb5e1b5a9..f1a9215caa 100644
--- a/spec/unit/resource/powershell_script_spec.rb
+++ b/spec/unit/resource/powershell_script_spec.rb
@@ -49,7 +49,7 @@ describe Chef::Resource::PowershellScript do
it "raises an error when architecture is i386 on Windows Nano Server" do
allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true)
- expect{@resource.architecture(:i386)}.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect, "cannot execute script with requested architecture 'i386' on Windows Nano Server")
+ expect { @resource.architecture(:i386) }.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect, "cannot execute script with requested architecture 'i386' on Windows Nano Server")
end
context "when using guards" do
@@ -61,7 +61,7 @@ describe Chef::Resource::PowershellScript do
it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, and :architecture attributes from a parent resource class" do
inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes -
- [:cwd, :environment, :group, :path, :user, :umask, :architecture ]
+ [:cwd, :environment, :group, :path, :user, :umask, :architecture ]
expect(inherited_difference).to eq([])
end
@@ -87,7 +87,7 @@ describe Chef::Resource::PowershellScript do
it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true)
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- {:convert_boolean_return => true, :code => "$true"}).and_return(Proc.new {})
+ { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {})
resource.only_if("$true")
end
@@ -98,27 +98,27 @@ describe Chef::Resource::PowershellScript do
file_resource.guard_interpreter :powershell_script
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- {:convert_boolean_return => true, :code => "$true"}).and_return(Proc.new {})
+ { :convert_boolean_return => true, :code => "$true" }).and_return(Proc.new {})
resource.only_if("$true")
end
it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do
- guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64}
+ guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 }
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {})
+ { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {})
resource.only_if("$true", guard_parameters)
end
it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do
- guard_parameters = {:cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64}
+ guard_parameters = { :cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64 }
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
- {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {})
+ { :convert_boolean_return => true, :code => "$true" }.merge(guard_parameters)).and_return(Proc.new {})
resource.only_if("$true", guard_parameters)
end
it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do
- other_guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64}
- parameters_with_boolean_disabled = other_guard_parameters.merge({:convert_boolean_return => false, :code => "$true"})
+ other_guard_parameters = { :cwd => "/etc/chef", :architecture => :x86_64 }
+ parameters_with_boolean_disabled = other_guard_parameters.merge({ :convert_boolean_return => false, :code => "$true" })
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
parameters_with_boolean_disabled).and_return(Proc.new {})
resource.only_if("$true", parameters_with_boolean_disabled)
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index a2ba6f500d..472c511857 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -130,7 +130,7 @@ describe Chef::Resource::RegistryKey, "recursive" do
end
it "should not allow a hash" do
- expect { @resource.recursive({:sonic => :screwdriver}) }.to raise_error(ArgumentError)
+ expect { @resource.recursive({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
end
it "should not allow an array" do
@@ -159,7 +159,7 @@ describe Chef::Resource::RegistryKey, "architecture" do
end
it "should not allow a hash" do
- expect { @resource.architecture({:sonic => :screwdriver}) }.to raise_error(ArgumentError)
+ expect { @resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
end
it "should not allow an array" do
@@ -194,6 +194,6 @@ describe Chef::Resource::RegistryKey, "state" do
it "should return scrubbed values" do
@resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ])
- expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89"}] } )
+ expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] } )
end
end
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index b511377a51..718129aba3 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -66,7 +66,7 @@ describe Chef::Resource::RemoteFile do
end
it "should accept a delayed evalutator (string) for the remote file source" do
- @resource.source Chef::DelayedEvaluator.new {"http://opscode.com/"}
+ @resource.source Chef::DelayedEvaluator.new { "http://opscode.com/" }
expect(@resource.source).to eql([ "http://opscode.com/" ])
end
@@ -87,13 +87,13 @@ describe Chef::Resource::RemoteFile do
it "should only accept a single argument if a delayed evalutor is used" do
expect {
- @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"})
+ @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" })
}.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "should only accept a single array item if a delayed evalutor is used" do
expect {
- @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}])
+ @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" }])
}.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
@@ -103,7 +103,7 @@ describe Chef::Resource::RemoteFile do
it "does not accept a non-URI as the source when read from a delayed evaluator" do
expect {
- @resource.source(Chef::DelayedEvaluator.new {"not-a-uri"})
+ @resource.source(Chef::DelayedEvaluator.new { "not-a-uri" })
@resource.source
}.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
@@ -179,20 +179,20 @@ describe Chef::Resource::RemoteFile do
@resource.owner("root")
end
@resource.source("https://www.google.com/images/srpr/logo3w.png")
- @resource.checksum("1"*26)
+ @resource.checksum("1" * 26)
end
it "describes its state" do
state = @resource.state
if Chef::Platform.windows?
puts state
- expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}])
- expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}])
+ expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
+ expect(state[:deny_rights]).to eq([{ :permissions => :full_control, :principals => "Clumsy_Sam" }])
else
expect(state[:group]).to eq("pokemon")
expect(state[:mode]).to eq("0664")
expect(state[:owner]).to eq("root")
- expect(state[:checksum]).to eq("1"*26)
+ expect(state[:checksum]).to eq("1" * 26)
end
end
diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb
index 5ba6ea35d3..5bb3ba95ea 100644
--- a/spec/unit/resource/resource_notification_spec.rb
+++ b/spec/unit/resource/resource_notification_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Resource::Notification do
end
it "raises an ArgumentError if you try to check a non-ducktype object for duplication" do
- expect {notification.duplicates?(:not_a_notification)}.to raise_error(ArgumentError)
+ expect { notification.duplicates?(:not_a_notification) }.to raise_error(ArgumentError)
end
it "takes no action to resolve a resource reference that doesn't need to be resolved" do
@@ -65,7 +65,7 @@ describe Chef::Resource::Notification do
end
it "resolves a lazy reference to a resource" do
- notification.resource = {:cat => "keyboard_cat"}
+ notification.resource = { :cat => "keyboard_cat" }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @keyboard_cat
@@ -78,7 +78,7 @@ describe Chef::Resource::Notification do
it "resolves a lazy reference to its notifying resource" do
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
notification.resource = @keyboard_cat
- notification.notifying_resource = {:cat => "long_cat"}
+ notification.notifying_resource = { :cat => "long_cat" }
@long_cat = Chef::Resource::Cat.new("long_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @long_cat
@@ -87,11 +87,11 @@ describe Chef::Resource::Notification do
end
it "resolves lazy references to both its resource and its notifying resource" do
- notification.resource = {:cat => "keyboard_cat"}
+ notification.resource = { :cat => "keyboard_cat" }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @keyboard_cat
- notification.notifying_resource = {:cat => "long_cat"}
+ notification.notifying_resource = { :cat => "long_cat" }
@long_cat = Chef::Resource::Cat.new("long_cat")
@resource_collection << @long_cat
notification.resolve_resource_reference(@resource_collection)
@@ -100,7 +100,7 @@ describe Chef::Resource::Notification do
end
it "raises a RuntimeError if you try to reference multiple resources" do
- notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]}
+ notification.resource = { :cat => ["keyboard_cat", "cheez_cat"] }
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@@ -108,11 +108,11 @@ describe Chef::Resource::Notification do
@resource_collection << @cheez_cat
@long_cat = Chef::Resource::Cat.new("long_cat")
notification.notifying_resource = @long_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError)
end
it "raises a RuntimeError if you try to reference multiple notifying resources" do
- notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]}
+ notification.notifying_resource = { :cat => ["long_cat", "cheez_cat"] }
@long_cat = Chef::Resource::Cat.new("long_cat")
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@@ -120,27 +120,27 @@ describe Chef::Resource::Notification do
@resource_collection << @cheez_cat
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
notification.resource = @keyboard_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError)
end
it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do
- notification.resource = {:cat => "keyboard_cat"}
+ notification.resource = { :cat => "keyboard_cat" }
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @cheez_cat
@long_cat = Chef::Resource::Cat.new("long_cat")
notification.notifying_resource = @long_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError)
end
it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do
- notification.notifying_resource = {:cat => "long_cat"}
+ notification.notifying_resource = { :cat => "long_cat" }
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
@resource_collection = Chef::ResourceCollection.new
@resource_collection << @cheez_cat
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
notification.resource = @keyboard_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(RuntimeError)
end
it "raises an ArgumentError if improper syntax is used in the lazy reference to its resource" do
@@ -150,7 +150,7 @@ describe Chef::Resource::Notification do
@resource_collection << @keyboard_cat
@long_cat = Chef::Resource::Cat.new("long_cat")
notification.notifying_resource = @long_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(ArgumentError)
end
it "raises an ArgumentError if improper syntax is used in the lazy reference to its notifying resource" do
@@ -160,7 +160,7 @@ describe Chef::Resource::Notification do
@resource_collection << @long_cat
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
notification.resource = @keyboard_cat
- expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
+ expect { notification.resolve_resource_reference(@resource_collection) }.to raise_error(ArgumentError)
end
# Create test to resolve lazy references to both notifying resource and dest. resource
diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb
index 8667b244d7..f39334348e 100644
--- a/spec/unit/resource/scm_spec.rb
+++ b/spec/unit/resource/scm_spec.rb
@@ -101,7 +101,7 @@ describe Chef::Resource::Scm do
it "takes the depth as an integer for shallow clones" do
@resource.depth 5
expect(@resource.depth).to eq(5)
- expect {@resource.depth "five"}.to raise_error(ArgumentError)
+ expect { @resource.depth "five" }.to raise_error(ArgumentError)
end
it "defaults to nil depth for a full clone" do
@@ -111,7 +111,7 @@ describe Chef::Resource::Scm do
it "takes a boolean for #enable_submodules" do
@resource.enable_submodules true
expect(@resource.enable_submodules).to be_truthy
- expect {@resource.enable_submodules "lolz"}.to raise_error(ArgumentError)
+ expect { @resource.enable_submodules "lolz" }.to raise_error(ArgumentError)
end
it "defaults to not enabling submodules" do
@@ -121,7 +121,7 @@ describe Chef::Resource::Scm do
it "takes a boolean for #enable_checkout" do
@resource.enable_checkout true
expect(@resource.enable_checkout).to be_truthy
- expect {@resource.enable_checkout "lolz"}.to raise_error(ArgumentError)
+ expect { @resource.enable_checkout "lolz" }.to raise_error(ArgumentError)
end
it "defaults to enabling checkout" do
@@ -131,7 +131,7 @@ describe Chef::Resource::Scm do
it "takes a string for the remote" do
@resource.remote "opscode"
expect(@resource.remote).to eql("opscode")
- expect {@resource.remote 1337}.to raise_error(ArgumentError)
+ expect { @resource.remote 1337 }.to raise_error(ArgumentError)
end
it "defaults to ``origin'' for the remote" do
@@ -184,7 +184,7 @@ describe Chef::Resource::Scm do
end
describe "when it has a environment attribute" do
- let(:test_environment) { {"CHEF_ENV" => "/tmp" } }
+ let(:test_environment) { { "CHEF_ENV" => "/tmp" } }
before { @resource.environment(test_environment) }
it "stores this environment" do
expect(@resource.environment).to eq(test_environment)
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index f9953afd53..e06f5bca5e 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -140,7 +140,7 @@ describe Chef::Resource::Service do
end
it "should default all the feature support to nil" do
- support_hash = { :status => nil, :restart => nil, :reload=> nil }
+ support_hash = { :status => nil, :restart => nil, :reload => nil }
expect(@resource.supports).to eq(support_hash)
end
@@ -176,5 +176,4 @@ describe Chef::Resource::Service do
end
end
-
end
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 19d8b1716f..9060f02d29 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -127,7 +127,7 @@ describe Chef::Resource::Template do
modules = @resource.helper_modules
expect(modules.size).to eq(1)
o = Object.new
- modules.each {|m| o.extend(m)}
+ modules.each { |m| o.extend(m) }
expect(o.example_1).to eq("example_1")
expect(o.example_2).to eq("example_2")
end
@@ -136,7 +136,7 @@ describe Chef::Resource::Template do
@resource.helper(:shout) { |quiet| quiet.upcase }
modules = @resource.helper_modules
o = Object.new
- modules.each {|m| o.extend(m)}
+ modules.each { |m| o.extend(m) }
expect(o.shout("shout")).to eq("SHOUT")
end
@@ -167,7 +167,7 @@ describe Chef::Resource::Template do
modules = @resource.helper_modules
expect(modules.size).to eq(1)
o = Object.new
- modules.each {|m| o.extend(m)}
+ modules.each { |m| o.extend(m) }
expect(o.example_1).to eq("example_1")
end
@@ -199,13 +199,12 @@ describe Chef::Resource::Template do
expect(@resource.helper_modules.size).to eq(3)
o = Object.new
- @resource.helper_modules.each {|m| o.extend(m)}
+ @resource.helper_modules.each { |m| o.extend(m) }
expect(o.static_example).to eq("static_example")
expect(o.inline_module).to eq("inline_module")
expect(o.inline_method).to eq("inline_method")
end
-
end
end
diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb
index 4b26288715..9648ee1305 100644
--- a/spec/unit/resource/user_spec.rb
+++ b/spec/unit/resource/user_spec.rb
@@ -68,7 +68,7 @@ describe Chef::Resource::User, "initialize" do
expect { @resource.username "domain\@user" }.not_to raise_error
expect(@resource.username).to eq("domain\@user")
expect { @resource.username "domain\\user" }.not_to raise_error
- expect(@resource.username).to eq("domain\\user")
+ expect(@resource.username).to eq("domain\\user")
end
end
diff --git a/spec/unit/resource_collection/resource_list_spec.rb b/spec/unit/resource_collection/resource_list_spec.rb
index 9863747bf4..dabb8f037d 100644
--- a/spec/unit/resource_collection/resource_list_spec.rb
+++ b/spec/unit/resource_collection/resource_list_spec.rb
@@ -24,7 +24,7 @@ describe Chef::ResourceCollection::ResourceList do
let(:second_resource) { Chef::Resource::ZenMaster.new("hattori") }
def insert_resource(res)
- expect{ resource_list.insert(res) }.not_to raise_error
+ expect { resource_list.insert(res) }.not_to raise_error
end
describe "initialize" do
@@ -47,14 +47,14 @@ describe Chef::ResourceCollection::ResourceList do
end
it "should raise error when trying to install something other than Chef::Resource" do
- expect{ resource_list.insert("not a resource") }.to raise_error(ArgumentError)
+ expect { resource_list.insert("not a resource") }.to raise_error(ArgumentError)
end
end
describe "accessors" do
it "should be able to insert with []=" do
- expect{ resource_list[0] = resource }.not_to raise_error
- expect{ resource_list[1] = second_resource }.not_to raise_error
+ expect { resource_list[0] = resource }.not_to raise_error
+ expect { resource_list[1] = second_resource }.not_to raise_error
expect(resource_list[0]).to be(resource)
expect(resource_list[1]).to be(second_resource)
end
diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb
index cacd555b4b..2f8ba0e1aa 100644
--- a/spec/unit/resource_collection/resource_set_spec.rb
+++ b/spec/unit/resource_collection/resource_set_spec.rb
@@ -78,13 +78,13 @@ describe Chef::ResourceCollection::ResourceSet do
it "should find a resource by type symbol and array of names" do
collection.insert_as(zen_master)
collection.insert_as(zen_master2)
- check_by_names(collection.find(:zen_master => [zen_master_name,zen_master2_name]), zen_master_name, zen_master2_name)
+ check_by_names(collection.find(:zen_master => [zen_master_name, zen_master2_name]), zen_master_name, zen_master2_name)
end
it "should find a resource by type symbol and array of names with custom names" do
collection.insert_as(zen_master, :zzz, "name1")
collection.insert_as(zen_master2, :zzz, "name2")
- check_by_names(collection.find( :zzz => ["name1","name2"]), zen_master_name, zen_master2_name)
+ check_by_names(collection.find( :zzz => ["name1", "name2"]), zen_master_name, zen_master2_name)
end
it "should find resources of multiple kinds (:zen_master => a, :zen_follower => b)" do
@@ -98,7 +98,7 @@ describe Chef::ResourceCollection::ResourceSet do
collection.insert_as(zen_master, :zzz, "name1")
collection.insert_as(zen_master2, :zzz, "name2")
collection.insert_as(zen_follower, :yyy, "name3")
- check_by_names(collection.find(:zzz => ["name1","name2"], :yyy => ["name3"]),
+ check_by_names(collection.find(:zzz => ["name1", "name2"], :yyy => ["name3"]),
zen_master_name, zen_follower_name, zen_master2_name)
end
@@ -138,13 +138,13 @@ describe Chef::ResourceCollection::ResourceSet do
collection.insert_as(zen_master2, :zzz, "name2")
collection.insert_as(zen_follower, :yyy, "name3")
check_by_names(collection.find("zzz[name1,name2]", "yyy[name3]"),
- zen_master_name, zen_follower_name,zen_master2_name)
+ zen_master_name, zen_follower_name, zen_master2_name)
end
it "should only keep the last copy when multiple instances of a Resource are inserted" do
collection.insert_as(zen_master)
expect(collection.find("zen_master[#{zen_master_name}]")).to eq(zen_master)
- new_zm =zen_master.dup
+ new_zm = zen_master.dup
new_zm.retries = 10
expect(new_zm).to_not eq(zen_master)
collection.insert_as(new_zm)
@@ -192,7 +192,7 @@ describe Chef::ResourceCollection::ResourceSet do
def check_by_names(results, *names)
expect(results.size).to eq(names.size)
names.each do |name|
- expect(results.detect{|r| r.name == name}).to_not eq(nil)
+ expect(results.detect { |r| r.name == name }).to_not eq(nil)
end
end
diff --git a/spec/unit/resource_collection/stepable_iterator_spec.rb b/spec/unit/resource_collection/stepable_iterator_spec.rb
index 61d374ab0b..6354b1b7fb 100644
--- a/spec/unit/resource_collection/stepable_iterator_spec.rb
+++ b/spec/unit/resource_collection/stepable_iterator_spec.rb
@@ -26,7 +26,7 @@ describe Chef::ResourceCollection::StepableIterator do
describe "doing basic iteration" do
before do
- @simple_collection = [1,2,3,4]
+ @simple_collection = [1, 2, 3, 4]
@iterator = CRSI.for_collection(@simple_collection)
end
@@ -57,7 +57,7 @@ describe Chef::ResourceCollection::StepableIterator do
@iterator.each_with_index do |element, index|
collected[index] = element
end
- expect(collected).to eq({0=>1, 1=>2, 2=>3, 3=>4})
+ expect(collected).to eq({ 0 => 1, 1 => 2, 2 => 3, 3 => 4 })
end
end
@@ -117,7 +117,7 @@ describe Chef::ResourceCollection::StepableIterator do
it "doesn't step if there are no more steps" do
expect(@iterator.step).to eq(3)
- expect {@iterator.step}.not_to raise_error
+ expect { @iterator.step }.not_to raise_error
expect(@iterator.step).to be_nil
end
@@ -131,7 +131,7 @@ describe Chef::ResourceCollection::StepableIterator do
end
it "should work correctly when elements are added to the collection during iteration" do
- @collection.insert(2, lambda { @snitch_var = 815})
+ @collection.insert(2, lambda { @snitch_var = 815 })
@collection.insert(3, lambda { @iterator.pause })
@iterator.resume
expect(@snitch_var).to eq(815)
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 0ec14200ca..178d58b303 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -65,7 +65,7 @@ describe Chef::ResourceCollection do
end
it "should accept named arguments in any order" do
- rc.insert(resource, :instance_name => "foo", :resource_type =>"bar")
+ rc.insert(resource, :instance_name => "foo", :resource_type => "bar")
expect(rc[0]).to eq(resource)
end
@@ -211,7 +211,7 @@ describe Chef::ResourceCollection do
end
it "raises an error when attempting to find a resource that does not exist" do
- expect {rc.find("script[nonesuch]")}.to raise_error(Chef::Exceptions::ResourceNotFound)
+ expect { rc.find("script[nonesuch]") }.to raise_error(Chef::Exceptions::ResourceNotFound)
end
end
@@ -225,7 +225,6 @@ describe Chef::ResourceCollection do
expect(rc.validate_lookup_spec!(:service => "apache2")).to be_truthy
end
-
it "accepts a chef resource object" do
res = Chef::Resource.new("foo", nil)
expect(rc.validate_lookup_spec!(res)).to be_truthy
@@ -286,13 +285,13 @@ describe Chef::ResourceCollection do
def check_by_names(results, *names)
names.each do |res_name|
- expect(results.detect{ |res| res.name == res_name }).not_to eql(nil)
+ expect(results.detect { |res| res.name == res_name }).not_to eql(nil)
end
end
def load_up_resources
%w{dog cat monkey}.each do |n|
- rc << Chef::Resource::ZenMaster.new(n)
+ rc << Chef::Resource::ZenMaster.new(n)
end
rc << Chef::Resource::File.new("something")
end
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 5517865c8e..30b5717f4e 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -44,7 +44,7 @@ describe Chef::ResourceReporter do
@new_resource.cookbook_name = @cookbook_name
@cookbook_version = double("Cookbook::Version", :version => "1.2.3")
allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version)
- @current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
+ @current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
@start_time = Time.new
@end_time = Time.new + 20
@events = Chef::EventDispatch::Dispatcher.new
@@ -92,8 +92,8 @@ describe Chef::ResourceReporter do
context "when chef fails" do
before do
- allow(@rest_client).to receive(:raw_request).and_return({"result"=>"ok"});
- allow(@rest_client).to receive(:post).and_return({"uri"=>"https://example.com/reports/nodes/spitfire/runs/#{@run_id}"});
+ allow(@rest_client).to receive(:raw_request).and_return({ "result" => "ok" });
+ allow(@rest_client).to receive(:post).and_return({ "uri" => "https://example.com/reports/nodes/spitfire/runs/#{@run_id}" });
end
@@ -201,12 +201,12 @@ describe Chef::ResourceReporter do
context "and a nested resource is updated" do
before do
@implementation_resource = Chef::Resource::CookbookFile.new("/preseed-file.txt")
- @resource_reporter.resource_action_start(@implementation_resource , :create)
- @resource_reporter.resource_current_state_loaded(@implementation_resource, :create, @implementation_resource)
- @resource_reporter.resource_updated(@implementation_resource, :create)
- @resource_reporter.resource_completed(@implementation_resource)
- @resource_reporter.resource_updated(@new_resource, :create)
- @resource_reporter.resource_completed(@new_resource)
+ @resource_reporter.resource_action_start(@implementation_resource , :create)
+ @resource_reporter.resource_current_state_loaded(@implementation_resource, :create, @implementation_resource)
+ @resource_reporter.resource_updated(@implementation_resource, :create)
+ @resource_reporter.resource_completed(@implementation_resource)
+ @resource_reporter.resource_updated(@new_resource, :create)
+ @resource_reporter.resource_completed(@new_resource)
end
it "does not collect data about the nested resource" do
@@ -259,8 +259,8 @@ describe Chef::ResourceReporter do
describe "when generating a report for the server" do
before do
- allow(@rest_client).to receive(:raw_request).and_return({"result"=>"ok"});
- allow(@rest_client).to receive(:post).and_return({"uri"=>"https://example.com/reports/nodes/spitfire/runs/#{@run_id}"});
+ allow(@rest_client).to receive(:raw_request).and_return({ "result" => "ok" });
+ allow(@rest_client).to receive(:post).and_return({ "uri" => "https://example.com/reports/nodes/spitfire/runs/#{@run_id}" });
@resource_reporter.run_started(@run_status)
end
@@ -293,9 +293,9 @@ describe Chef::ResourceReporter do
context "the new_resource name and id are hashes" do
before do
@bad_resource = Chef::Resource::File.new("/tmp/filename_as_hash.txt")
- allow(@bad_resource).to receive(:name).and_return({:foo=>:bar})
- allow(@bad_resource).to receive(:identity).and_return({:foo=>:bar})
- allow(@bad_resource).to receive(:path).and_return({:foo=>:bar})
+ allow(@bad_resource).to receive(:name).and_return({ :foo => :bar })
+ allow(@bad_resource).to receive(:identity).and_return({ :foo => :bar })
+ allow(@bad_resource).to receive(:path).and_return({ :foo => :bar })
@resource_reporter.resource_action_start(@bad_resource, :create)
@resource_reporter.resource_current_state_loaded(@bad_resource, :create, @current_resource)
@resource_reporter.resource_updated(@bad_resource, :create)
@@ -466,7 +466,7 @@ describe Chef::ResourceReporter do
context "for an unsuccessful run" do
before do
- @backtrace = ["foo.rb:1 in `foo!'","bar.rb:2 in `bar!","'baz.rb:3 in `baz!'"]
+ @backtrace = ["foo.rb:1 in `foo!'", "bar.rb:2 in `bar!", "'baz.rb:3 in `baz!'"]
@node = Chef::Node.new
@node.name("spitfire")
@exception = ArgumentError.new
@@ -496,7 +496,7 @@ describe Chef::ResourceReporter do
it "includes the error inspector output in the event data" do
expect(@report["data"]["exception"]).to have_key("description")
- expect(@report["data"]["exception"]["description"]).to include({"title"=>"Error expanding the run_list:", "sections"=>[{"Unexpected Error:" => "ArgumentError: Object not found"}]})
+ expect(@report["data"]["exception"]["description"]).to include({ "title" => "Error expanding the run_list:", "sections" => [{ "Unexpected Error:" => "ArgumentError: Object not found" }] })
end
end
@@ -593,9 +593,9 @@ describe Chef::ResourceReporter do
@response = Net::HTTPNotFound.new("a response body", "404", "Not Found")
@error = Net::HTTPServerException.new("404 message", @response)
expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id,
- :start_time => @start_time.to_s},
- {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
+ with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id,
+ :start_time => @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
and_raise(@error)
end
@@ -623,8 +623,8 @@ describe Chef::ResourceReporter do
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
@error = Net::HTTPServerException.new("500 message", @response)
expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s},
- {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
+ with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
and_raise(@error)
end
@@ -653,8 +653,8 @@ describe Chef::ResourceReporter do
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
@error = Net::HTTPServerException.new("500 message", @response)
expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s},
- {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
+ with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
and_raise(@error)
end
@@ -672,10 +672,10 @@ describe Chef::ResourceReporter do
context "after creating the run history document" do
before do
- response = {"uri"=>"https://example.com/reports/nodes/spitfire/runs/@run_id"}
+ response = { "uri" => "https://example.com/reports/nodes/spitfire/runs/@run_id" }
expect(@rest_client).to receive(:post).
- with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s},
- {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
+ with("reports/nodes/spitfire/runs", { :action => :start, :run_id => @run_id, :start_time => @start_time.to_s },
+ { "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION }).
and_return(response)
@resource_reporter.run_started(@run_status)
end
@@ -693,12 +693,12 @@ describe Chef::ResourceReporter do
allow(@resource_reporter).to receive(:end_time).and_return(@end_time)
@expected_data = @resource_reporter.prepare_run_data
- response = {"result"=>"ok"}
+ response = { "result" => "ok" }
expect(@rest_client).to receive(:raw_request).ordered do |method, url, headers, data|
expect(method).to eq(:POST)
- expect(headers).to eq({"Content-Encoding" => "gzip",
- "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION,
+ expect(headers).to eq({ "Content-Encoding" => "gzip",
+ "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION,
},)
data_stream = Zlib::GzipReader.new(StringIO.new(data))
data = data_stream.read
diff --git a/spec/unit/resource_resolver_spec.rb b/spec/unit/resource_resolver_spec.rb
index 964886f8b8..f3a20ab0e3 100644
--- a/spec/unit/resource_resolver_spec.rb
+++ b/spec/unit/resource_resolver_spec.rb
@@ -19,7 +19,6 @@
require "spec_helper"
require "chef/resource_resolver"
-
describe Chef::ResourceResolver do
it '#resolve' do
expect(described_class.resolve(:execute)).to eq(Chef::Resource::Execute)
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index d3d6164a69..1297ed6f04 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -225,13 +225,13 @@ describe Chef::Resource do
it "should make notified resources appear in the actions hash" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee")
- expect(resource.delayed_notifications.detect{|e| e.resource.name == "coffee" && e.action == :reload}).not_to be_nil
+ expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
end
it "should make notified resources be capable of acting immediately" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :immediate
- expect(resource.immediate_notifications.detect{|e| e.resource.name == "coffee" && e.action == :reload}).not_to be_nil
+ expect(resource.immediate_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
end
it "should raise an exception if told to act in other than :delay or :immediate(ly)" do
@@ -244,35 +244,35 @@ describe Chef::Resource do
it "should allow multiple notified resources appear in the actions hash" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee")
- expect(resource.delayed_notifications.detect{|e| e.resource.name == "coffee" && e.action == :reload}).not_to be_nil
+ expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee" && e.action == :reload }).not_to be_nil
run_context.resource_collection << Chef::Resource::ZenMaster.new("beans")
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "beans")
- expect(resource.delayed_notifications.detect{|e| e.resource.name == "beans" && e.action == :reload}).not_to be_nil
+ expect(resource.delayed_notifications.detect { |e| e.resource.name == "beans" && e.action == :reload }).not_to be_nil
end
it "creates a notification for a resource that is not yet in the resource collection" do
resource.notifies(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource)
+ expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
expect(resource.delayed_notifications).to include(expected_notification)
end
it "notifies another resource immediately" do
resource.notifies_immediately(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource)
+ expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
expect(resource.immediate_notifications).to include(expected_notification)
end
it "notifies a resource to take action at the end of the chef run" do
resource.notifies_delayed(:restart, :service => "apache")
- expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource)
+ expected_notification = Chef::Resource::Notification.new({ :service => "apache" }, :restart, resource)
expect(resource.delayed_notifications).to include(expected_notification)
end
it "notifies a resource with an array for its name via its prettified string name" do
run_context.resource_collection << Chef::Resource::ZenMaster.new(["coffee", "tea"])
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee, tea")
- expect(resource.delayed_notifications.detect{|e| e.resource.name == "coffee, tea" && e.action == :reload}).not_to be_nil
+ expect(resource.delayed_notifications.detect { |e| e.resource.name == "coffee, tea" && e.action == :reload }).not_to be_nil
end
end
@@ -281,26 +281,26 @@ describe Chef::Resource do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
zr = run_context.resource_collection.find(:zen_master => "coffee")
resource.subscribes :reload, zr
- expect(zr.delayed_notifications.detect{|e| e.resource.name == "funk" && e.action == :reload}).not_to be_nil
+ expect(zr.delayed_notifications.detect { |e| e.resource.name == "funk" && e.action == :reload }).not_to be_nil
end
it "should make resources appear in the actions hash of subscribed nodes" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
zr = run_context.resource_collection.find(:zen_master => "coffee")
resource.subscribes :reload, zr
- expect(zr.delayed_notifications.detect{|e| e.resource.name == resource.name && e.action == :reload}).not_to be_nil
+ expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
run_context.resource_collection << Chef::Resource::ZenMaster.new("bean")
zrb = run_context.resource_collection.find(:zen_master => "bean")
zrb.subscribes :reload, zr
- expect(zr.delayed_notifications.detect{|e| e.resource.name == resource.name && e.action == :reload}).not_to be_nil
+ expect(zr.delayed_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
end
it "should make subscribed resources be capable of acting immediately" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
zr = run_context.resource_collection.find(:zen_master => "coffee")
resource.subscribes :reload, zr, :immediately
- expect(zr.immediate_notifications.detect{|e| e.resource.name == resource.name && e.action == :reload}).not_to be_nil
+ expect(zr.immediate_notifications.detect { |e| e.resource.name == resource.name && e.action == :reload }).not_to be_nil
end
end
@@ -644,7 +644,7 @@ describe Chef::Resource do
it "accepts command options for only_if conditionals" do
expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_command).at_least(1).times
resource.only_if("true", :cwd => "/tmp")
- expect(resource.only_if.first.command_opts).to eq({:cwd => "/tmp"})
+ expect(resource.only_if.first.command_opts).to eq({ :cwd => "/tmp" })
resource.run_action(:purr)
end
@@ -668,13 +668,13 @@ describe Chef::Resource do
it "accepts command options for not_if conditionals" do
resource.not_if("pwd" , :cwd => "/tmp")
- expect(resource.not_if.first.command_opts).to eq({:cwd => "/tmp"})
+ expect(resource.not_if.first.command_opts).to eq({ :cwd => "/tmp" })
end
it "accepts multiple not_if conditionals" do
snitch_var1, snitch_var2 = true, true
- resource.not_if {snitch_var1 = nil}
- resource.not_if {snitch_var2 = false}
+ resource.not_if { snitch_var1 = nil }
+ resource.not_if { snitch_var2 = false }
resource.run_action(:purr)
expect(snitch_var1).to be_nil
expect(snitch_var2).to be_falsey
@@ -859,7 +859,7 @@ describe Chef::Resource do
it "adds mappings for multiple platforms" do
expect(Chef.resource_handler_map).to receive(:set).with(
- :energy, Chef::Resource::Klz, { platform: ["autobots", "decepticons"]}
+ :energy, Chef::Resource::Klz, { platform: ["autobots", "decepticons"] }
)
klz.provides :energy, platform: ["autobots", "decepticons"]
end
@@ -1000,14 +1000,14 @@ describe Chef::Resource do
it "when set to false should show compiled resource for failed resource" do
expect { resource_file.run_action(action) }.to raise_error { |err|
- expect(compiled_resource_data(resource_file, action, err)).to match 'path "/nonexistent/CHEF-5098/file"'
+ expect(compiled_resource_data(resource_file, action, err)).to match 'path "/nonexistent/CHEF-5098/file"'
}
end
it "when set to true should show compiled resource for failed resource" do
resource_file.sensitive true
expect { resource_file.run_action(action) }.to raise_error { |err|
- expect(compiled_resource_data(resource_file, action, err)).to eql("suppressed sensitive resource output")
+ expect(compiled_resource_data(resource_file, action, err)).to eql("suppressed sensitive resource output")
}
end
@@ -1070,7 +1070,7 @@ describe Chef::Resource do
end
describe ".default_action" do
- let(:default_action) { }
+ let(:default_action) {}
let(:resource_class) do
actions = default_action
Class.new(described_class) do
diff --git a/spec/unit/rest/auth_credentials_spec.rb b/spec/unit/rest/auth_credentials_spec.rb
index 2036a3b3e7..164c0eb235 100644
--- a/spec/unit/rest/auth_credentials_spec.rb
+++ b/spec/unit/rest/auth_credentials_spec.rb
@@ -42,14 +42,14 @@ describe Chef::REST::AuthCredentials do
describe "when loading the private key" do
it "strips extra whitespace before checking the key" do
key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key_with_whitespace.pem"
- expect {Chef::REST::AuthCredentials.new("client-name", @key_file_fixture)}.not_to raise_error
+ expect { Chef::REST::AuthCredentials.new("client-name", @key_file_fixture) }.not_to raise_error
end
end
describe "generating signature headers for a request" do
before do
@request_time = Time.at(1270920860)
- @request_params = {:http_method => :POST, :path => "/clients", :body => '{"some":"json"}', :host => "localhost"}
+ @request_params = { :http_method => :POST, :path => "/clients", :body => '{"some":"json"}', :host => "localhost" }
allow(Chef::Config).to(
receive(:[]).with(:authentication_protocol_version).and_return(protocol_version))
end
@@ -60,7 +60,7 @@ describe Chef::REST::AuthCredentials do
it "generates signature headers for the request" do
allow(Time).to receive(:now).and_return(@request_time)
actual = @auth_credentials.signature_headers(@request_params)
- expect(actual["HOST"]).to eq("localhost")
+ expect(actual["HOST"]).to eq("localhost")
expect(actual["X-OPS-AUTHORIZATION-1"]).to eq("kBssX1ENEwKtNYFrHElN9vYGWS7OeowepN9EsYc9csWfh8oUovryPKDxytQ/")
expect(actual["X-OPS-AUTHORIZATION-2"]).to eq("Wc2/nSSyxdWJjjfHzrE+YrqNQTaArOA7JkAf5p75eTUonCWcvNPjFrZVgKGS")
expect(actual["X-OPS-AUTHORIZATION-3"]).to eq("yhzHJQh+lcVA9wwARg5Hu9q+ddS8xBOdm3Vp5atl5NGHiP0loiigMYvAvzPO")
@@ -80,7 +80,7 @@ describe Chef::REST::AuthCredentials do
it "generates the correct signature for version 1.1" do
allow(Time).to receive(:now).and_return(@request_time)
actual = @auth_credentials.signature_headers(@request_params)
- expect(actual["HOST"]).to eq("localhost")
+ expect(actual["HOST"]).to eq("localhost")
expect(actual["X-OPS-CONTENT-HASH"]).to eq("1tuzs5XKztM1ANrkGNPah6rW9GY=")
expect(actual["X-OPS-SIGN"]).to eq("algorithm=sha1;version=1.1;")
expect(actual["X-OPS-TIMESTAMP"]).to eq("2010-04-10T17:34:20Z")
@@ -94,7 +94,7 @@ describe Chef::REST::AuthCredentials do
end
describe Chef::REST::RESTRequest do
- def new_request(method=nil)
+ def new_request(method = nil)
method ||= :POST
Chef::REST::RESTRequest.new(method, @url, @req_body, @headers)
end
@@ -103,8 +103,8 @@ describe Chef::REST::RESTRequest do
@auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + "/ssl/private_key.pem")
@url = URI.parse("http://chef.example.com:4000/?q=chef_is_awesome")
@req_body = '{"json_data":"as_a_string"}'
- @headers = { "Content-type" =>"application/json",
- "Accept"=>"application/json",
+ @headers = { "Content-type" => "application/json",
+ "Accept" => "application/json",
"Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
"Host" => "chef.example.com:4000" }
@request = Chef::REST::RESTRequest.new(:POST, @url, @req_body, @headers)
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb
index 5b4b6f2a88..9e99a3e32f 100644
--- a/spec/unit/rest_spec.rb
+++ b/spec/unit/rest_spec.rb
@@ -24,7 +24,7 @@ require "uri"
require "net/https"
require "stringio"
-SIGNING_KEY_DOT_PEM="-----BEGIN RSA PRIVATE KEY-----
+SIGNING_KEY_DOT_PEM = "-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA49TA0y81ps0zxkOpmf5V4/c4IeR5yVyQFpX3JpxO4TquwnRh
8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE6915kXSuk/cWIcNozujLK7tkuPEy
YVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXrWqYCnhxgOjxocenREYNhZ/OETIei
@@ -59,7 +59,7 @@ describe Chef::REST do
let(:log_stringio) { StringIO.new }
- let(:request_id) {"1234"}
+ let(:request_id) { "1234" }
let(:rest) do
allow(Chef::REST::CookieJar).to receive(:instance).and_return({})
@@ -69,8 +69,8 @@ describe Chef::REST do
rest
end
- let(:standard_read_headers) {{"Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}}
- let(:standard_write_headers) {{"Accept"=>"application/json", "Content-Type"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}}
+ let(:standard_read_headers) { { "Accept" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID" => request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION } }
+ let(:standard_write_headers) { { "Accept" => "application/json", "Content-Type" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID" => request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION } }
before(:each) do
Chef::Log.init(log_stringio)
@@ -120,8 +120,8 @@ describe Chef::REST do
it "makes a :GET request with the composed url object" do
expect(rest).to receive(:send_http_request).
with(:GET, monkey_uri, standard_read_headers, false).
- and_return([1,2,3])
- expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
+ and_return([1, 2, 3])
+ expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.get_rest("monkey")
end
@@ -134,8 +134,8 @@ describe Chef::REST do
it "makes a :DELETE request with the composed url object" do
expect(rest).to receive(:send_http_request).
with(:DELETE, monkey_uri, standard_read_headers, false).
- and_return([1,2,3])
- expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
+ and_return([1, 2, 3])
+ expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.delete_rest("monkey")
end
@@ -143,8 +143,8 @@ describe Chef::REST do
it "makes a :POST request with the composed url object and data" do
expect(rest).to receive(:send_http_request).
with(:POST, monkey_uri, standard_write_headers, "\"data\"").
- and_return([1,2,3])
- expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
+ and_return([1, 2, 3])
+ expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.post_rest("monkey", "data")
end
@@ -152,8 +152,8 @@ describe Chef::REST do
it "makes a :PUT request with the composed url object and data" do
expect(rest).to receive(:send_http_request).
with(:PUT, monkey_uri, standard_write_headers, "\"data\"").
- and_return([1,2,3])
- expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
+ and_return([1, 2, 3])
+ expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.put_rest("monkey", "data")
end
@@ -176,14 +176,14 @@ describe Chef::REST do
it "calls the authn middleware" do
data = "\"secure data\""
- auth_headers = standard_write_headers.merge({"auth_done"=>"yep"})
+ auth_headers = standard_write_headers.merge({ "auth_done" => "yep" })
expect(rest.authenticator).to receive(:handle_request).
with(:POST, monkey_uri, standard_write_headers, data).
and_return([:POST, monkey_uri, auth_headers, data])
expect(rest).to receive(:send_http_request).
with(:POST, monkey_uri, auth_headers, data).
- and_return([1,2,3])
+ and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data)
end
@@ -194,13 +194,12 @@ describe Chef::REST do
expect(rest).to receive(:send_http_request).
with(:POST, monkey_uri, auth_headers, data).
- and_return([1,2,3])
+ and_return([1, 2, 3])
expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data)
end
end
-
describe "when configured to authenticate to the Chef server" do
let(:base_url) { URI.parse("http://chef.example.com:4000") }
@@ -234,12 +233,12 @@ describe Chef::REST do
end
it "raises PrivateKeyMissing when the key file doesn't exist" do
- expect {Chef::REST.new(base_url, "client-name", "/dev/null/nothing_here")}.to raise_error(Chef::Exceptions::PrivateKeyMissing)
+ expect { Chef::REST.new(base_url, "client-name", "/dev/null/nothing_here") }.to raise_error(Chef::Exceptions::PrivateKeyMissing)
end
it "raises InvalidPrivateKey when the key file doesnt' look like a key" do
invalid_key_file = CHEF_SPEC_DATA + "/bad-config.rb"
- expect {Chef::REST.new(base_url, "client-name", invalid_key_file)}.to raise_error(Chef::Exceptions::InvalidPrivateKey)
+ expect { Chef::REST.new(base_url, "client-name", invalid_key_file) }.to raise_error(Chef::Exceptions::InvalidPrivateKey)
end
it "can take private key as a sting :raw_key in options during initializaton" do
@@ -247,7 +246,7 @@ describe Chef::REST do
end
it "raises InvalidPrivateKey when the key passed as string :raw_key in options doesnt' look like a key" do
- expect {Chef::REST.new(base_url, "client-name", nil, :raw_key => "bad key string")}.to raise_error(Chef::Exceptions::InvalidPrivateKey)
+ expect { Chef::REST.new(base_url, "client-name", nil, :raw_key => "bad key string") }.to raise_error(Chef::Exceptions::InvalidPrivateKey)
end
end
@@ -292,7 +291,7 @@ describe Chef::REST do
describe "as JSON API requests" do
let(:request_mock) { {} }
- let(:base_headers) do #FIXME: huh?
+ let(:base_headers) do #FIXME: huh?
{
"Accept" => "application/json",
"X-Chef-Version" => Chef::VERSION,
@@ -393,15 +392,15 @@ describe Chef::REST do
expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13")
expect(Net::HTTP::Post).to receive(:new).with("/?foo=bar", expected_headers).and_return(request)
- rest.request(:POST, url, {}, {:one=>:two})
+ rest.request(:POST, url, {}, { :one => :two })
expect(request.body).to eq('{"one":"two"}')
end
it "should build a new HTTP PUT request" do
request = Net::HTTP::Put.new(url.path)
expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13")
- expect(Net::HTTP::Put).to receive(:new).with("/?foo=bar",expected_headers).and_return(request)
- rest.request(:PUT, url, {}, {:one=>:two})
+ expect(Net::HTTP::Put).to receive(:new).with("/?foo=bar", expected_headers).and_return(request)
+ rest.request(:PUT, url, {}, { :one => :two })
expect(request.body).to eq('{"one":"two"}')
end
@@ -427,7 +426,7 @@ describe Chef::REST do
let(:body) { '{"ohai2u":"json_api"}' }
it "should inflate the body as to an object" do
http_response.add_field("content-type", "application/json")
- expect(rest.request(:GET, url, {})).to eq({"ohai2u"=>"json_api"})
+ expect(rest.request(:GET, url, {})).to eq({ "ohai2u" => "json_api" })
end
it "should fail if the response is truncated" do
@@ -492,7 +491,7 @@ describe Chef::REST do
it "should show the JSON error message" do
allow(rest).to receive(:sleep)
- expect {rest.request(:GET, url)}.to raise_error(Net::HTTPFatalError)
+ expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four"))
end
end
@@ -517,13 +516,13 @@ describe Chef::REST do
end
it "decompresses the JSON error message" do
- expect {rest.request(:GET, url)}.to raise_error(Net::HTTPFatalError)
+ expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four"))
end
it "fails when the compressed body is truncated" do
http_response["Content-Length"] = (body.bytesize + 99).to_s
- expect {rest.request(:GET, url)}.to raise_error(Chef::Exceptions::ContentLengthMismatch)
+ expect { rest.request(:GET, url) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
end
@@ -537,7 +536,7 @@ describe Chef::REST do
it "retries then throws an exception" do
allow(rest).to receive(:sleep)
- expect {rest.request(:GET, url)}.to raise_error(Net::HTTPFatalError)
+ expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
count = Chef::Config[:http_retry_count]
expect(log_stringio.string).to match(Regexp.escape("ERROR: Server returned error 500 for #{url}, retrying #{count}/#{count}"))
end
@@ -551,7 +550,7 @@ describe Chef::REST do
let(:request_mock) { {} }
let(:http_response) do
- http_response = Net::HTTPSuccess.new("1.1","200", "it-works")
+ http_response = Net::HTTPSuccess.new("1.1", "200", "it-works")
allow(http_response).to receive(:read_body)
expect(http_response).not_to receive(:body)
@@ -577,24 +576,24 @@ describe Chef::REST do
end
it " build a new HTTP GET request without the application/json accept header" do
- expected_headers = {"Accept" => "*/*",
- "X-Chef-Version" => Chef::VERSION,
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => host_header,
- "X-REMOTE-REQUEST-ID"=> request_id,
- "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
+ expected_headers = { "Accept" => "*/*",
+ "X-Chef-Version" => Chef::VERSION,
+ "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
+ "Host" => host_header,
+ "X-REMOTE-REQUEST-ID" => request_id,
+ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
}
expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock)
rest.streaming_request(url, {})
end
it "build a new HTTP GET request with the X-Remote-Request-Id header" do
- expected_headers = {"Accept" => "*/*",
- "X-Chef-Version" => Chef::VERSION,
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => host_header,
- "X-REMOTE-REQUEST-ID"=> request_id,
- "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
+ expected_headers = { "Accept" => "*/*",
+ "X-Chef-Version" => Chef::VERSION,
+ "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
+ "Host" => host_header,
+ "X-REMOTE-REQUEST-ID" => request_id,
+ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
}
expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock)
rest.streaming_request(url, {})
@@ -661,7 +660,7 @@ describe Chef::REST do
path = tempfile.path
expect(path).not_to be_nil
allow(tempfile).to receive(:write).and_raise(IOError)
- rest.fetch("cookbooks/a_cookbook") {|tmpfile| "shouldn't get here"}
+ rest.fetch("cookbooks/a_cookbook") { |tmpfile| "shouldn't get here" }
expect(File.exists?(path)).to be_falsey
end
@@ -676,12 +675,12 @@ describe Chef::REST do
expect(http_client).to receive(:request).and_yield(redirect).and_return(redirect)
expect(http_client).to receive(:request).and_yield(http_response).and_return(http_response)
- rest.fetch("cookbooks/a_cookbook") {|tmpfile| "shouldn't get here"}
+ rest.fetch("cookbooks/a_cookbook") { |tmpfile| "shouldn't get here" }
end
it "passes the original block to the redirected request" do
http_redirect = Net::HTTPFound.new("1.1", "302", "bob is taking care of that one for me today")
- http_redirect.add_field("location","/that-thing-is-here-now")
+ http_redirect.add_field("location", "/that-thing-is-here-now")
allow(http_redirect).to receive(:read_body)
block_called = false
@@ -705,8 +704,8 @@ describe Chef::REST do
end
it "raises a RedirectLimitExceeded when redirected more than 10 times" do
- redirected = lambda {rest.follow_redirect { redirected.call }}
- expect {redirected.call}.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
+ redirected = lambda { rest.follow_redirect { redirected.call } }
+ expect { redirected.call }.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
end
it "does not count redirects from previous calls against the redirect limit" do
@@ -717,9 +716,9 @@ describe Chef::REST do
redirected.call unless total_redirects >= 9
end
end
- expect {redirected.call}.not_to raise_error
+ expect { redirected.call }.not_to raise_error
total_redirects = 0
- expect {redirected.call}.not_to raise_error
+ expect { redirected.call }.not_to raise_error
end
it "does not sign the redirected request when sign_on_redirect is false" do
@@ -743,11 +742,11 @@ describe Chef::REST do
redirected.call unless total_redirects >= 9
end
end
- expect {redirected.call}.not_to raise_error
+ expect { redirected.call }.not_to raise_error
total_redirects = 0
rest.redirect_limit = 3
- expect {redirected.call}.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
+ expect { redirected.call }.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
end
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 6cdeaced47..1ff76d7207 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -44,7 +44,6 @@ describe Chef::Role do
@role.run_list(%w{ nginx recipe[ree] role[base]})
end
-
it "returns the run list" do
expect(@role.run_list).to eq(%w{ nginx recipe[ree] role[base]})
end
@@ -79,12 +78,11 @@ describe Chef::Role do
it "env_run_lists can only be set with _default run list in it" do
long_exception_name = Chef::Exceptions::InvalidEnvironmentRunListSpecification
- expect {@role.env_run_lists({})}.to raise_error(long_exception_name)
+ expect { @role.env_run_lists({}) }.to raise_error(long_exception_name)
end
end
-
describe "using the old #recipes API" do
it "should let you set the recipe array" do
expect(@role.recipes([ "one", "two" ])).to eq([ "one", "two" ])
@@ -104,8 +102,6 @@ describe Chef::Role do
end
-
-
describe "default_attributes" do
it "should let you set the default attributes hash explicitly" do
expect(@role.default_attributes({ :one => "two" })).to eq({ :one => "two" })
@@ -249,7 +245,7 @@ describe Chef::Role do
end
end
- ROLE_DSL=<<-EOR
+ ROLE_DSL = <<-EOR
name "ceiling_cat"
description "like Aliens, but furry"
EOR
@@ -293,20 +289,20 @@ EOR
it "should raise an exception if the file does not exist" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/meme.rb"])
expect(File).not_to receive(:exists?)
- expect {@role.class.from_disk("lolcat")}.to raise_error(Chef::Exceptions::RoleNotFound)
+ expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::RoleNotFound)
end
it "should raise an exception if two files exist with the same name" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/lolcat.rb"])
expect(File).not_to receive(:exists?)
- expect {@role.class.from_disk("lolcat")}.to raise_error(Chef::Exceptions::DuplicateRole)
+ expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::DuplicateRole)
end
it "should not raise an exception if two files exist with a similar name" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/super_lolcat.rb"])
expect(File).to receive(:exists?).with("#{Chef::Config[:role_path]}/memes/lolcat.rb").and_return(true)
allow_any_instance_of(Chef::Role).to receive(:from_file).with("#{Chef::Config[:role_path]}/memes/lolcat.rb")
- expect{ @role.class.from_disk("lolcat") }.not_to raise_error
+ expect { @role.class.from_disk("lolcat") }.not_to raise_error
end
end
@@ -355,7 +351,7 @@ EOR
it "should raise an exception if the file does not exist" do
expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([])
expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return([])
- expect {@role.class.from_disk("lolcat")}.to raise_error(Chef::Exceptions::RoleNotFound)
+ expect { @role.class.from_disk("lolcat") }.to raise_error(Chef::Exceptions::RoleNotFound)
end
end
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index c53d10da47..868bed4bfd 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -51,7 +51,6 @@ describe Chef::RunContext::CookbookCompiler do
Chef::RunContext::CookbookCompiler.new(run_context, run_list_expansion, events)
end
-
describe "loading attribute files" do
# Attribute files in the fixture data will append their
@@ -181,6 +180,5 @@ describe Chef::RunContext::CookbookCompiler do
expect(compiler.unreachable_cookbook?(:'circular-dep2')).to be_truthy
end
-
end
end
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index 3bc09c8bc3..33f2f49366 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -202,7 +202,7 @@ describe Chef::RunContext do
let(:notification) { Chef::Resource::Notification.new(nil, nil, notifying_resource) }
shared_context "notifying resource is a Chef::Resource" do
- let(:notifying_resource) { Chef::Resource.new("gerbil") }
+ let(:notifying_resource) { Chef::Resource.new("gerbil") }
it "should be keyed off the resource name" do
run_context.send(setter, notification)
@@ -212,7 +212,7 @@ describe Chef::RunContext do
shared_context "notifying resource is a subclass of Chef::Resource" do
let(:declared_type) { :alpaca }
- let(:notifying_resource) {
+ let(:notifying_resource) {
r = Class.new(Chef::Resource).new("guinea pig")
r.declared_type = declared_type
r
diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb
index b269c7923d..b0cb978bb1 100644
--- a/spec/unit/run_list/run_list_expansion_spec.rb
+++ b/spec/unit/run_list/run_list_expansion_spec.rb
@@ -84,17 +84,17 @@ describe Chef::RunList::RunListExpansion do
@first_role = Chef::Role.new
@first_role.name("rage")
@first_role.run_list("role[mollusk]")
- @first_role.default_attributes({"foo" => "bar"})
- @first_role.override_attributes({"baz" => "qux"})
+ @first_role.default_attributes({ "foo" => "bar" })
+ @first_role.override_attributes({ "baz" => "qux" })
@second_role = Chef::Role.new
@second_role.name("rage")
@second_role.run_list("recipe[crabrevenge]")
- @second_role.default_attributes({"foo" => "boo"})
- @second_role.override_attributes({"baz" => "bux"})
+ @second_role.default_attributes({ "foo" => "boo" })
+ @second_role.override_attributes({ "baz" => "bux" })
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(
+ .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,'
@@ -113,8 +113,8 @@ describe Chef::RunList::RunListExpansion do
end
it "has the merged attributes from the roles with outer roles overriding inner" do
- expect(@expansion.default_attrs).to eq({"foo" => "bar"})
- expect(@expansion.override_attrs).to eq({"baz" => "qux"})
+ expect(@expansion.default_attrs).to eq({ "foo" => "bar" })
+ expect(@expansion.override_attrs).to eq({ "baz" => "qux" })
end
it "has the list of all roles applied" do
diff --git a/spec/unit/run_list/run_list_item_spec.rb b/spec/unit/run_list/run_list_item_spec.rb
index b4fe42f041..3f8fd2ab3b 100644
--- a/spec/unit/run_list/run_list_item_spec.rb
+++ b/spec/unit/run_list/run_list_item_spec.rb
@@ -22,11 +22,11 @@ describe Chef::RunList::RunListItem do
describe "when creating from a Hash" do
it "raises an exception when the hash doesn't have a :type key" do
- expect {Chef::RunList::RunListItem.new(:name => "tatft")}.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new(:name => "tatft") }.to raise_error(ArgumentError)
end
it "raises an exception when the hash doesn't have an :name key" do
- expect {Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError)
end
it "sets the name and type as given in the hash" do
@@ -71,15 +71,15 @@ describe Chef::RunList::RunListItem do
end
it "raises an exception when the string has typo on the type part" do
- expect {Chef::RunList::RunListItem.new("Recipe[lobster]") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new("Recipe[lobster]") }.to raise_error(ArgumentError)
end
it "raises an exception when the string has extra space between the type and the name" do
- expect {Chef::RunList::RunListItem.new("recipe [lobster]") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new("recipe [lobster]") }.to raise_error(ArgumentError)
end
it "raises an exception when the string does not close the bracket" do
- expect {Chef::RunList::RunListItem.new("recipe[lobster") }.to raise_error(ArgumentError)
+ expect { Chef::RunList::RunListItem.new("recipe[lobster") }.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb
index df9c8930ea..2b1c6edebc 100644
--- a/spec/unit/run_list/versioned_recipe_list_spec.rb
+++ b/spec/unit/run_list/versioned_recipe_list_spec.rb
@@ -34,7 +34,7 @@ describe Chef::RunList::VersionedRecipeList do
before do
recipes.each { |r| list << r }
- versioned_recipes.each {|r| list.add_recipe r[:name], r[:version]}
+ versioned_recipes.each { |r| list.add_recipe r[:name], r[:version] }
end
describe "add_recipe" do
@@ -54,30 +54,30 @@ describe Chef::RunList::VersionedRecipeList do
it "should allow you to specify a version" do
list.add_recipe "rails", "1.0.0"
expect(list).to eq(["apt", "god", "apache2", "rails"])
- expect(list.with_versions).to include({:name => "rails", :version => "1.0.0"})
+ expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
end
it "should allow you to specify a version for a recipe that already exists" do
list.add_recipe "apt", "1.2.3"
expect(list).to eq(["apt", "god", "apache2"])
- expect(list.with_versions).to include({:name => "apt", :version => "1.2.3"})
+ expect(list.with_versions).to include({ :name => "apt", :version => "1.2.3" })
end
it "should allow you to specify the same version of a recipe twice" do
list.add_recipe "rails", "1.0.0"
list.add_recipe "rails", "1.0.0"
- expect(list.with_versions).to include({:name => "rails", :version => "1.0.0"})
+ expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
end
it "should allow you to spcify no version, even when a version already exists" do
list.add_recipe "rails", "1.0.0"
list.add_recipe "rails"
- expect(list.with_versions).to include({:name => "rails", :version => "1.0.0"})
+ expect(list.with_versions).to include({ :name => "rails", :version => "1.0.0" })
end
it "should not allow multiple versions of the same recipe" do
list.add_recipe "rails", "1.0.0"
- expect {list.add_recipe "rails", "0.1.0"}.to raise_error Chef::Exceptions::CookbookVersionConflict
+ expect { list.add_recipe "rails", "0.1.0" }.to raise_error Chef::Exceptions::CookbookVersionConflict
end
end
@@ -85,9 +85,9 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- {:name => "apt", :version => "1.0.0"},
- {:name => "god", :version => nil},
- {:name => "apache2", :version => "0.0.1"},
+ { :name => "apt", :version => "1.0.0" },
+ { :name => "god", :version => nil },
+ { :name => "apache2", :version => "0.0.1" },
]
end
it "should return an array of hashes with :name and :version" do
@@ -106,13 +106,12 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- {:name => "apt", :version => "~> 1.2.0"},
- {:name => "god", :version => nil},
- {:name => "apache2", :version => "0.0.1"},
+ { :name => "apt", :version => "~> 1.2.0" },
+ { :name => "god", :version => nil },
+ { :name => "apache2", :version => "0.0.1" },
]
end
-
it "should return an array of hashes with :name and :version_constraint" do
list.with_version_constraints.each_with_index do |recipe_spec, i|
@@ -152,7 +151,7 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- {:name => "apt", :version => "~> 1.2.0"},
+ { :name => "apt", :version => "~> 1.2.0" },
]
end
@@ -171,7 +170,7 @@ describe Chef::RunList::VersionedRecipeList do
let(:versioned_recipes) do
[
- {:name => "apt::cacher", :version => "~> 1.2.0"},
+ { :name => "apt::cacher", :version => "~> 1.2.0" },
]
end
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index 20de26ec78..6d17e654cd 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -223,7 +223,6 @@ describe Chef::RunList do
@role_prod_base.name("prod-base")
@role_prod_base.env_run_list["production"] = Chef::RunList.new("role[nested-deeper]")
-
@role_nested_deeper = Chef::Role.new
@role_nested_deeper.name("nested-deeper")
@role_nested_deeper.env_run_list["production"] = Chef::RunList.new("recipe[prod-secret-sauce]")
diff --git a/spec/unit/run_lock_spec.rb b/spec/unit/run_lock_spec.rb
index 937a6dc258..350a0b2c66 100644
--- a/spec/unit/run_lock_spec.rb
+++ b/spec/unit/run_lock_spec.rb
@@ -91,7 +91,7 @@ describe Chef::RunLock do
it "should raise Chef::Exceptions::RunLockTimeout" do
stub_blocked_run(0.001)
expect(runlock).not_to receive(:wait)
- expect{ runlock.acquire }.to raise_error(Chef::Exceptions::RunLockTimeout)
+ expect { runlock.acquire }.to raise_error(Chef::Exceptions::RunLockTimeout)
end
end
end
@@ -118,9 +118,9 @@ describe Chef::RunLock do
describe "and the lockfile is locked by another client run" do
describe "and the lock is released before the timeout expires" do
it "should acquire the lock" do
- stub_blocked_run(@timeout/2.0)
+ stub_blocked_run(@timeout / 2.0)
expect(runlock).to receive(:wait)
- expect{ runlock.acquire }.not_to raise_error
+ expect { runlock.acquire }.not_to raise_error
end
end
@@ -128,7 +128,7 @@ describe Chef::RunLock do
it "should raise a RunLockTimeout exception" do
stub_blocked_run(2.0)
expect(runlock).to receive(:wait)
- expect{ runlock.acquire }.to raise_error(Chef::Exceptions::RunLockTimeout)
+ expect { runlock.acquire }.to raise_error(Chef::Exceptions::RunLockTimeout)
end
end
end
diff --git a/spec/unit/run_status_spec.rb b/spec/unit/run_status_spec.rb
index 016f5d608a..6305b7497b 100644
--- a/spec/unit/run_status_spec.rb
+++ b/spec/unit/run_status_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
describe Chef::RunStatus do
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index fe524e1cd3..300d51229b 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -239,7 +239,7 @@ describe Chef::Runner do
second_resource.notifies(:fail, third_resource, :delayed)
second_resource.notifies(:purr, first_resource, :delayed)
- expect {runner.converge}.to raise_error(FailureProvider::ChefClientFail)
+ expect { runner.converge }.to raise_error(FailureProvider::ChefClientFail)
expect(first_resource).to be_updated
end
@@ -271,7 +271,7 @@ describe Chef::Runner do
end
expect(exception).to be_a(Chef::Exceptions::MultipleFailures)
- expected_message =<<-E
+ expected_message = <<-E
Multiple failures occurred:
* FailureProvider::ChefClientFail occurred in delayed notification: [explode] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
* FailureProvider::ChefClientFail occurred in delayed notification: [explode again] (dynamically defined) had an error: FailureProvider::ChefClientFail: chef had an error of some sort
@@ -372,10 +372,10 @@ Multiple failures occurred:
first_resource.action = :buy
only_if_called_times = 0
- first_resource.only_if {only_if_called_times += 1; true}
+ first_resource.only_if { only_if_called_times += 1; true }
not_if_called_times = 0
- first_resource.not_if {not_if_called_times += 1; false}
+ first_resource.not_if { not_if_called_times += 1; false }
second_resource = Chef::Resource::Cat.new("carmel", run_context)
run_context.resource_collection << second_resource
diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb
index c48b92349f..c747f6cc4a 100644
--- a/spec/unit/scan_access_control_spec.rb
+++ b/spec/unit/scan_access_control_spec.rb
@@ -181,4 +181,3 @@ describe Chef::ScanAccessControl do
end
end
end
-
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index 54c21944f0..9652d69783 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -68,9 +68,9 @@ describe Chef::Search::Query do
let(:response_rows) {
[
{ "env" => "elysium", "ruby_plat" => "nudibranch" },
- { "env" => "hades", "ruby_plat" => "i386-mingw32"},
- { "env" => "elysium", "ruby_plat" => "centos"},
- { "env" => "moon", "ruby_plat" => "solaris2"},
+ { "env" => "hades", "ruby_plat" => "i386-mingw32" },
+ { "env" => "elysium", "ruby_plat" => "centos" },
+ { "env" => "moon", "ruby_plat" => "solaris2" },
]
}
end
diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb
index 311b90ecbe..00425f2a01 100644
--- a/spec/unit/shell/model_wrapper_spec.rb
+++ b/spec/unit/shell/model_wrapper_spec.rb
@@ -21,13 +21,13 @@ require "ostruct"
describe Shell::ModelWrapper do
before do
- @model = OpenStruct.new(:name=>"Chef::Node")
+ @model = OpenStruct.new(:name => "Chef::Node")
@wrapper = Shell::ModelWrapper.new(@model)
end
describe "when created with an explicit model_symbol" do
before do
- @model = OpenStruct.new(:name=>"Chef::ApiClient")
+ @model = OpenStruct.new(:name => "Chef::ApiClient")
@wrapper = Shell::ModelWrapper.new(@model, :client)
end
@@ -46,7 +46,7 @@ describe Shell::ModelWrapper do
@node_1.name("sammich")
@node_2 = Chef::Node.new
@node_2.name("yummy")
- @server_response = {:node_1 => @node_1, :node_2 => @node_2}
+ @server_response = { :node_1 => @node_1, :node_2 => @node_2 }
@wrapper = Shell::ModelWrapper.new(Chef::Node)
allow(Chef::Node).to receive(:list).and_return(@server_response)
end
@@ -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 { |n| n.name }.sort.reverse).to eq(%w{yummy sammich})
end
end
@@ -67,7 +67,7 @@ describe Shell::ModelWrapper do
@node_1.name("sammich")
@node_2 = Chef::Node.new
@node_2.name("yummy")
- @server_response = {:node_1 => @node_1, :node_2 => @node_2}
+ @server_response = { :node_1 => @node_1, :node_2 => @node_2 }
@wrapper = Shell::ModelWrapper.new(Chef::Node)
# Creating a Chef::Search::Query object tries to read the private key...
@@ -88,10 +88,9 @@ describe Shell::ModelWrapper do
it "creates a 'AND'-joined query string from a HASH" do
# Hash order woes
expect(@searcher).to receive(:search).with(:node, "name:app* AND name:app*").and_yield(@node_1).and_yield(@node_2)
- expect(@wrapper.find(:name=>"app*","name"=>"app*")).to include(@node_1, @node_2)
+ expect(@wrapper.find(:name => "app*", "name" => "app*")).to include(@node_1, @node_2)
end
end
-
end
diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb
index a418eba217..0afa1f6390 100644
--- a/spec/unit/shell/shell_ext_spec.rb
+++ b/spec/unit/shell/shell_ext_spec.rb
@@ -92,9 +92,9 @@ describe Shell::Extensions do
end
it "prints node attributes" do
- node = double("node", :attribute => {:foo => :bar})
+ node = double("node", :attribute => { :foo => :bar })
@shell_client.node = node
- expect(@root_context).to receive(:pp).with({:foo => :bar})
+ expect(@root_context).to receive(:pp).with({ :foo => :bar })
@root_context.ohai
expect(@root_context).to receive(:pp).with(:bar)
@root_context.ohai(:foo)
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index 289bf35313..22f3dc6f0c 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -18,7 +18,6 @@
require "spec_helper"
require "ostruct"
-
class TestableShellSession < Shell::ShellSession
def rebuild_node
@@ -158,7 +157,7 @@ describe Shell::SoloSession do
end
it "keeps json attribs and passes them to the node for consumption" do
- @session.node_attributes = {"besnard_lakes" => "are_the_dark_horse"}
+ @session.node_attributes = { "besnard_lakes" => "are_the_dark_horse" }
expect(@session.node.besnard_lakes).to eq("are_the_dark_horse")
#pending "1) keep attribs in an ivar 2) pass them to the node 3) feed them to the node on reset"
end
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index cebd7b0389..8ba1afa72a 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -82,7 +82,7 @@ describe Shell do
conf = OpenStruct.new
events = Chef::EventDispatch::Dispatcher.new
- conf.main = Chef::Recipe.new(nil,nil,Chef::RunContext.new(Chef::Node.new, {}, events))
+ conf.main = Chef::Recipe.new(nil, nil, Chef::RunContext.new(Chef::Node.new, {}, events))
Shell.irb_conf[:IRB_RC].call(conf)
expect(conf.prompt_c).to eq("chef:recipe > ")
expect(conf.prompt_i).to eq("chef:recipe (#{Chef::VERSION})> ")
@@ -116,7 +116,7 @@ describe Shell do
end
it "adds help text when a new method is described then defined" do
- describe_define =<<-EVAL
+ describe_define = <<-EVAL
desc "foo2the Bar"
def baz
end
@@ -127,7 +127,7 @@ describe Shell do
end
it "adds help text for subcommands" do
- describe_define =<<-EVAL
+ describe_define = <<-EVAL
subcommands :baz_obj_command => "something you can do with baz.baz_obj_command"
def baz
end
@@ -139,7 +139,7 @@ describe Shell do
end
it "doesn't add previous subcommand help to commands defined afterward" do
- describe_define =<<-EVAL
+ describe_define = <<-EVAL
desc "swingFromTree"
def monkey_time
end
@@ -150,7 +150,7 @@ describe Shell do
EVAL
@chef_object.instance_eval describe_define
expect(@chef_object.help_descriptions.size).to eq(2)
- expect(@chef_object.help_descriptions.select {|h| h.cmd == "super_monkey_time" }).to be_empty
+ expect(@chef_object.help_descriptions.select { |h| h.cmd == "super_monkey_time" }).to be_empty
end
it "creates a help banner with the command descriptions" do
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index a4f1dff721..a1806db987 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -60,7 +60,6 @@ describe Chef::User do
expect { @user.name "foo&" }.to raise_error(ArgumentError)
end
-
it "should not accept spaces" do
expect { @user.name "ops master" }.to raise_error(ArgumentError)
end
@@ -168,10 +167,10 @@ describe Chef::User do
describe "when deserializing from JSON" do
before(:each) do
user = { "name" => "mr_spinks",
- "public_key" => "turtles",
- "private_key" => "pandas",
- "password" => "password",
- "admin" => true }
+ "public_key" => "turtles",
+ "private_key" => "pandas",
+ "password" => "password",
+ "admin" => true }
@user = Chef::User.from_json(Chef::JSONCompat.to_json(user))
end
@@ -212,8 +211,8 @@ describe Chef::User do
describe "list" do
before(:each) do
Chef::Config[:chef_server_url] = "http://www.example.com"
- @osc_response = { "admin" => "http://www.example.com/users/admin"}
- @ohc_response = [ { "user" => { "username" => "admin" }} ]
+ @osc_response = { "admin" => "http://www.example.com/users/admin" }
+ @ohc_response = [ { "user" => { "username" => "admin" } } ]
allow(Chef::User).to receive(:load).with("admin").and_return(@user)
@osc_inflated_response = { "admin" => @user }
end
@@ -244,14 +243,14 @@ describe Chef::User do
describe "create" do
it "creates a new user via the API" do
@user.password "password"
- expect(@http_client).to receive(:post).with("users", {:name => "foobar", :admin => false, :password => "password"}).and_return({})
+ expect(@http_client).to receive(:post).with("users", { :name => "foobar", :admin => false, :password => "password" }).and_return({})
@user.create
end
end
describe "read" do
it "loads a named user from the API" do
- expect(@http_client).to receive(:get).with("users/foobar").and_return({"name" => "foobar", "admin" => true, "public_key" => "pubkey"})
+ expect(@http_client).to receive(:get).with("users/foobar").and_return({ "name" => "foobar", "admin" => true, "public_key" => "pubkey" })
user = Chef::User.load("foobar")
expect(user.name).to eq("foobar")
expect(user.admin).to eq(true)
@@ -261,7 +260,7 @@ describe Chef::User do
describe "update" do
it "updates an existing user on via the API" do
- expect(@http_client).to receive(:put).with("users/foobar", {:name => "foobar", :admin => false}).and_return({})
+ expect(@http_client).to receive(:put).with("users/foobar", { :name => "foobar", :admin => false }).and_return({})
@user.update
end
end
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index 165437d350..dd02502ff2 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -90,7 +90,6 @@ describe Chef::UserV1 do
expect { @user.username "foo&" }.to raise_error(ArgumentError)
end
-
it "should not accept spaces" do
expect { @user.username "ops master" }.to raise_error(ArgumentError)
end
@@ -474,7 +473,7 @@ describe Chef::UserV1 do
context "when handling API V1" do
it "creates a new user via the API with a middle_name when it exists" do
@user.middle_name "some_middle_name"
- expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({:middle_name => "some_middle_name"})).and_return({})
+ expect(@user.chef_root_rest_v1).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({})
@user.create
end
end # when server API V1 is valid on the Chef Server receiving the request
@@ -497,7 +496,7 @@ describe Chef::UserV1 do
it "creates a new user via the API with a middle_name when it exists" do
@user.middle_name "some_middle_name"
- expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({:middle_name => "some_middle_name"})).and_return({})
+ expect(@user.chef_root_rest_v0).to receive(:post).with("users", payload.merge({ :middle_name => "some_middle_name" })).and_return({})
@user.create
end
end # when server API V1 is not valid on the Chef Server receiving the request
@@ -519,7 +518,7 @@ describe Chef::UserV1 do
context "when server API V0 is valid on the Chef Server receiving the request" do
it "creates a new object via the API" do
- expect(@user.chef_root_rest_v0).to receive(:put).with("users/#{@user.username}", payload.merge({"private_key" => true})).and_return({})
+ expect(@user.chef_root_rest_v0).to receive(:put).with("users/#{@user.username}", payload.merge({ "private_key" => true })).and_return({})
@user.reregister
end
end # when server API V0 is valid on the Chef Server receiving the request
@@ -546,8 +545,8 @@ describe Chef::UserV1 do
describe "list" do
before(:each) do
Chef::Config[:chef_server_url] = "http://www.example.com"
- @osc_response = { "admin" => "http://www.example.com/users/admin"}
- @ohc_response = [ { "user" => { "username" => "admin" }} ]
+ @osc_response = { "admin" => "http://www.example.com/users/admin" }
+ @ohc_response = [ { "user" => { "username" => "admin" } } ]
allow(Chef::UserV1).to receive(:load).with("admin").and_return(@user)
@osc_inflated_response = { "admin" => @user }
end
@@ -567,7 +566,7 @@ describe Chef::UserV1 do
describe "read" do
it "loads a named user from the API" do
- expect(@http_client).to receive(:get).with("users/foobar").and_return({"username" => "foobar", "admin" => true, "public_key" => "pubkey"})
+ expect(@http_client).to receive(:get).with("users/foobar").and_return({ "username" => "foobar", "admin" => true, "public_key" => "pubkey" })
user = Chef::UserV1.load("foobar")
expect(user.username).to eq("foobar")
expect(user.public_key).to eq("pubkey")
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index 8d7caff8d6..3454e07692 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
require "tmpdir"
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index 8a2bef2858..29c645bb1d 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
require "tmpdir"
@@ -553,11 +552,11 @@ describe Chef::Util::Diff, :uses_diff => true do
let(:plain_ascii) { "This is a text file.\nWith more than one line.\nAnd a \tTab.\nAnd lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=\n" }
# these are all byte sequences that are illegal in the other encodings... (but they may legally transcode)
- let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash
+ let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash
let(:latin_1) { "It is more metal.\nif you have an \xFDmlaut.\n" } # NB: changed to y-with-diaresis, but i'm American so I don't know the difference
let(:shift_jis) { "I have no idea what this character is:\n \x83\x80.\n" } # seriously, no clue, but \x80 is nice and illegal in other encodings
- let(:differ) do # subject
+ let(:differ) do # subject
differ = Chef::Util::Diff.new
differ.diff(old_file, new_file)
differ
@@ -569,11 +568,9 @@ describe Chef::Util::Diff, :uses_diff => true do
it_behaves_like "a diff util"
end
-
describe "when file path doesn't have spaces" do
include_context "using file paths without spaces"
it_behaves_like "a diff util"
end
end
-
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index 7b39404c4d..d59423e1e5 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
describe "#get_merged_configuration_flags" do
context "when strings are used as switches" do
it "should merge the hash if there are no restricted switches" do
- merged = conf_man.send(:get_merged_configuration_flags!, {"flag" => "a"}, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { "flag" => "a" }, "hello")
expect(merged).to include(:flag)
expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
@@ -58,25 +58,25 @@ describe Chef::Util::DSC::ConfigurationGenerator do
it "should raise an ArgumentError if you try to override outputpath" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {"outputpath" => "a"}, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { "outputpath" => "a" }, "hello")
}.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {"OutputPath" => "a"}, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { "OutputPath" => "a" }, "hello")
}.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
- merged = conf_man.send(:get_merged_configuration_flags!, {"FLAG" => "a"}, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { "FLAG" => "a" }, "hello")
expect(merged).to include(:flag)
end
end
context "when symbols are used as switches" do
it "should merge the hash if there are no restricted switches" do
- merged = conf_man.send(:get_merged_configuration_flags!, {:flag => "a"}, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { :flag => "a" }, "hello")
expect(merged).to include(:flag)
expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
@@ -84,18 +84,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do
it "should raise an ArgumentError if you try to override outputpath" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {:outputpath => "a"}, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello")
}.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {:OutputPath => "a"}, "hello")
+ conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello")
}.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
- merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => "a"}, "hello")
+ merged = conf_man.send(:get_merged_configuration_flags!, { :FLAG => "a" }, "hello")
expect(merged).to include(:flag)
end
end
@@ -127,7 +127,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
it "should write the input to a file" do
allow(File).to receive(:open).and_yield(file_like_object)
allow(File).to receive(:join) do |a, b|
- [a,b].join("++")
+ [a, b].join("++")
end
allow(file_like_object).to receive(:write)
conf_man.send(:write_document_generation_script, "file", "hello", {})
@@ -140,18 +140,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do
# These tests seem way too implementation specific. Unfortunately, File and Dir
# need to be mocked because they are OS specific
allow(File).to receive(:join) do |a, b|
- [a,b].join("++")
+ [a, b].join("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "hello.mof", "f3"]}
+ allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "hello.mof", "f3"] }
expect(conf_man.send(:find_configuration_document, "hello")).to eql("tmp++hello++hello.mof")
end
it "should return nil if the mof file is not found" do
allow(File).to receive(:join) do |a, b|
- [a,b].join("++")
+ [a, b].join("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "f3"]}
+ allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "f3"] }
expect(conf_man.send(:find_configuration_document, "hello")).to be_nil
end
end
@@ -169,25 +169,25 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
context "with imports" do
it "should import all resources when a module has an empty list" do
- dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => []})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => [] })
expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/)
end
it "should import all resources when a module has a list with *" do
- dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "*", "BarResource"]})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "*", "BarResource"] })
expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/)
end
it "should import specific resources when a module has list without * that is not empty" do
- dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"]})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"] })
expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/)
end
it "should import multiple modules with multiple import statements" do
- dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"], "BazModule" => []})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"], "BazModule" => [] })
expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/)
expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/)
- end
+ end
end
end
end
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 06f2a9288a..69eb8724ea 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -22,13 +22,13 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser do
context "empty input parameter" do
it "raises an exception when there are no valid lines" do
str = <<-EOF
-
+
EOF
- expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)}.to raise_error(Chef::Exceptions::LCMParser)
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to raise_error(Chef::Exceptions::LCMParser)
end
it "raises an exception for a nil input" do
- expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil)}.to raise_error(Chef::Exceptions::LCMParser)
+ expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil) }.to raise_error(Chef::Exceptions::LCMParser)
end
end
@@ -69,7 +69,7 @@ logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
- expect(resources[0].change_log).to match_array(["[name]","[message]","[name]"])
+ expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"])
end
it "should return false for changes_state?" do
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 0ea544d839..15cf38394e 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -85,7 +85,7 @@ EOH
expect(Chef::Log).to receive(:warn).at_least(:once)
expect(lcm).to receive(:whatif_not_supported?).and_call_original
test_configuration_result = nil
- expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error
+ expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
expect(test_configuration_result.class).to be(Array)
end
end
@@ -99,13 +99,13 @@ EOH
expect(Chef::Log).to receive(:warn).at_least(:once)
expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
test_configuration_result = nil
- expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error
+ expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
end
it "should return a (possibly empty) array of ResourceInfo instances" do
expect(Chef::Log).to receive(:warn).at_least(:once)
test_configuration_result = nil
- expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error
+ expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
expect(test_configuration_result.class).to be(Array)
end
end
@@ -118,7 +118,7 @@ EOH
it "should log a warning" do
expect(Chef::Log).to receive(:warn).at_least(:once)
expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
- expect {lcm.test_configuration("config", {})}.not_to raise_error
+ expect { lcm.test_configuration("config", {}) }.not_to raise_error
end
end
end
@@ -136,4 +136,3 @@ EOH
end
end
end
-
diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb
index 5adcd378c0..84b39190b2 100644
--- a/spec/unit/util/dsc/resource_store.rb
+++ b/spec/unit/util/dsc/resource_store.rb
@@ -24,14 +24,14 @@ describe Chef::Util::DSC::ResourceStore do
let(:resource_a) { {
"ResourceType" => "AFoo",
"Name" => "Foo",
- "Module" => {"Name" => "ModuleA"},
+ "Module" => { "Name" => "ModuleA" },
}
}
let(:resource_b) { {
"ResourceType" => "BFoo",
"Name" => "Foo",
- "Module" => {"Name" => "ModuleB"},
+ "Module" => { "Name" => "ModuleB" },
}
}
diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb
index af8dd4907d..1a71d1d856 100644
--- a/spec/unit/util/file_edit_spec.rb
+++ b/spec/unit/util/file_edit_spec.rb
@@ -111,7 +111,7 @@ twice
end
it "should throw an exception if the input file does not exist" do
- expect{Chef::Util::FileEdit.new("nonexistfile")}.to raise_error(ArgumentError)
+ expect { Chef::Util::FileEdit.new("nonexistfile") }.to raise_error(ArgumentError)
end
# CHEF-5018: people have monkey patched this and it has accidentally been broken
@@ -124,7 +124,7 @@ twice
let(:hosts_content) { "" }
it "should not throw an exception" do
- expect{ fedit }.not_to raise_error
+ expect { fedit }.not_to raise_error
end
end
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index 2d6b34ded8..5c0e66aee2 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -69,38 +69,38 @@ describe Chef::Util::Powershell::Cmdlet do
describe '#command_switches_string' do
it "raises an ArgumentError if the key is not a symbol" do
expect {
- @cmdlet.send(:command_switches_string, {"foo" => "bar"})
+ @cmdlet.send(:command_switches_string, { "foo" => "bar" })
}.to raise_error(ArgumentError)
end
it "does not allow invalid switch names" do
expect {
- @cmdlet.send(:command_switches_string, {:foo! => "bar"})
+ @cmdlet.send(:command_switches_string, { :foo! => "bar" })
}.to raise_error(ArgumentError)
end
it "ignores switches with a false value" do
- expect(@cmdlet.send(:command_switches_string, {foo: false})).to eql("")
+ expect(@cmdlet.send(:command_switches_string, { foo: false })).to eql("")
end
it "should correctly handle a value type of string" do
- expect(@cmdlet.send(:command_switches_string, {foo: "bar"})).to eql("-foo 'bar'")
+ expect(@cmdlet.send(:command_switches_string, { foo: "bar" })).to eql("-foo 'bar'")
end
it "should correctly handle a value type of string even when it is 0 length" do
- expect(@cmdlet.send(:command_switches_string, {foo: ""})).to eql("-foo ''")
+ expect(@cmdlet.send(:command_switches_string, { foo: "" })).to eql("-foo ''")
end
it "should not quote integers" do
- expect(@cmdlet.send(:command_switches_string, {foo: 1})).to eql("-foo 1")
+ expect(@cmdlet.send(:command_switches_string, { foo: 1 })).to eql("-foo 1")
end
it "should not quote floats" do
- expect(@cmdlet.send(:command_switches_string, {foo: 1.0})).to eql("-foo 1.0")
+ expect(@cmdlet.send(:command_switches_string, { foo: 1.0 })).to eql("-foo 1.0")
end
it "has just the switch when the value is true" do
- expect(@cmdlet.send(:command_switches_string, {foo: true})).to eql("-foo")
+ expect(@cmdlet.send(:command_switches_string, { foo: true })).to eql("-foo")
end
end
end
diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb
index 88e772c4e6..6f65174d15 100644
--- a/spec/unit/util/powershell/ps_credential_spec.rb
+++ b/spec/unit/util/powershell/ps_credential_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Util::Powershell::PSCredential do
let (:password) { "ThIsIsThEpAsSwOrD" }
context "when username and password are provided" do
- let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password)}
+ let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password) }
context "when calling to_psobject" do
it "should create the script to create a PSCredential when calling" do
allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted")
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 205553aa0c..609ff02215 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "spec_helper"
describe Chef::Util::Selinux do
@@ -62,7 +61,7 @@ describe Chef::Util::Selinux do
describe "when selinux is enabled" do
before do
cmd_result = double("Cmd Result", :exitstatus => 0)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
end
it "should report selinux is enabled" do
@@ -75,7 +74,7 @@ describe Chef::Util::Selinux do
describe "when selinux is disabled" do
before do
cmd_result = double("Cmd Result", :exitstatus => 1)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
end
it "should report selinux is disabled" do
@@ -88,11 +87,11 @@ describe Chef::Util::Selinux do
describe "when selinux gives an unexpected status" do
before do
cmd_result = double("Cmd Result", :exitstatus => 101)
- expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result)
+ expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result)
end
it "should throw an error" do
- expect {@test_instance.selinux_enabled?}.to raise_error(RuntimeError)
+ expect { @test_instance.selinux_enabled? }.to raise_error(RuntimeError)
end
end
end
diff --git a/spec/unit/version/platform_spec.rb b/spec/unit/version/platform_spec.rb
index 698339164a..cd2d37f5d4 100644
--- a/spec/unit/version/platform_spec.rb
+++ b/spec/unit/version/platform_spec.rb
@@ -58,4 +58,3 @@ describe Chef::Version::Platform do
end
end
-
diff --git a/spec/unit/version_class_spec.rb b/spec/unit/version_class_spec.rb
index 4cbd09ce53..5543fbe3c7 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 { |v| v.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
@@ -169,4 +169,3 @@ describe Chef::Version do
end
end
end
-
diff --git a/spec/unit/version_constraint/platform_spec.rb b/spec/unit/version_constraint/platform_spec.rb
index 96edbf46cc..593a47b903 100644
--- a/spec/unit/version_constraint/platform_spec.rb
+++ b/spec/unit/version_constraint/platform_spec.rb
@@ -43,4 +43,3 @@ describe Chef::VersionConstraint::Platform do
end
end
-
diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb
index 63ab520611..1523ac1919 100644
--- a/spec/unit/win32/registry_spec.rb
+++ b/spec/unit/win32/registry_spec.rb
@@ -22,13 +22,13 @@ describe Chef::Win32::Registry do
include_context "Win32"
let(:value1) { { :name => "one", :type => :string, :data => "1" } }
- let(:value1_upcase_name) { {:name => "ONE", :type => :string, :data => "1"} }
+ let(:value1_upcase_name) { { :name => "ONE", :type => :string, :data => "1" } }
let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
let(:key) { 'Software\OpscodeNumbers' }
let(:key_parent) { "Software" }
let(:key_to_delete) { "OpscodeNumbers" }
- let(:sub_key) {"OpscodePrimes"}
- let(:missing_key_path) {'HKCU\Software'}
+ let(:sub_key) { "OpscodePrimes" }
+ let(:missing_key_path) { 'HKCU\Software' }
let(:registry) { Chef::Win32::Registry.new() }
let(:hive_mock) { double("::Win32::Registry::KHKEY_CURRENT_USER") }
let(:reg_mock) { double("reg") }
@@ -40,7 +40,7 @@ describe Chef::Win32::Registry do
before(:each) do
allow_any_instance_of(Chef::Win32::Registry).to receive(:machine_architecture).and_return(:x86_64)
-
+
#Making the values for registry constants available on unix
Win32::Registry::KEY_SET_VALUE = 0x0002
Win32::Registry::KEY_QUERY_VALUE = 0x0001
@@ -67,7 +67,7 @@ describe Chef::Win32::Registry do
it "throws an exception if key does not exist" do
expect(registry).to receive(:get_hive_and_key).with(key_path).and_return([hive_mock, key])
expect(registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
- expect{registry.get_values(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.get_values(key_path) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
@@ -116,7 +116,7 @@ describe Chef::Win32::Registry do
it "should raise an exception if the key does not exist" do
expect(registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
- expect {registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.set_value(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
@@ -153,7 +153,7 @@ describe Chef::Win32::Registry do
it "raises an exception if intermediate keys are missing and recursive is set to false" do
expect(registry).to receive(:keys_missing?).with(key_path).and_return(true)
- expect{registry.create_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { registry.create_key(key_path, false) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "does nothing if the key exists" do
@@ -193,7 +193,7 @@ describe Chef::Win32::Registry do
it "raises an exception if it has subkeys but recursive is set to false" do
expect(registry).to receive(:key_exists?).with(key_path).and_return(true)
expect(registry).to receive(:has_subkeys?).with(key_path).and_return(true)
- expect{registry.delete_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect { registry.delete_key(key_path, false) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "deletes key if the key exists and has no subkeys" do
@@ -223,7 +223,7 @@ describe Chef::Win32::Registry do
describe "key_exists!" do
it "throws an exception if the key_parent does not exist" do
expect(registry).to receive(:key_exists?).with(key_path).and_return(false)
- expect{registry.key_exists!(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.key_exists!(key_path) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
@@ -258,7 +258,7 @@ describe Chef::Win32::Registry do
it "throws an exception if the key does not exist" do
expect(registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
- expect {registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.set_value(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
@@ -275,7 +275,7 @@ describe Chef::Win32::Registry do
describe "value_exists?" do
it "throws an exception if the key does not exist" do
expect(registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
- expect {registry.value_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.value_exists?(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
@@ -298,7 +298,7 @@ describe Chef::Win32::Registry do
describe "data_exists?" do
it "throws an exception if the key does not exist" do
expect(registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
- expect {registry.data_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect { registry.data_exists?(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the data exists" do
@@ -328,7 +328,7 @@ describe Chef::Win32::Registry do
it "throws an exception if the value does not exist" do
expect(registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
- expect{registry.value_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
+ expect { registry.value_exists!(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegValueMissing)
end
end
@@ -340,7 +340,7 @@ describe Chef::Win32::Registry do
it "throws an exception if the data does not exist" do
expect(registry).to receive(:data_exists?).with(key_path, value1).and_return(false)
- expect{registry.data_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect { registry.data_exists!(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
end
@@ -364,7 +364,7 @@ describe Chef::Win32::Registry do
it "throws an exception if value does not exist" do
expect(registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
- expect{registry.type_matches?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
+ expect { registry.type_matches?(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegValueMissing)
end
end
@@ -376,7 +376,7 @@ describe Chef::Win32::Registry do
it "throws an exception if the type does not match" do
expect(registry).to receive(:type_matches?).with(key_path, value1).and_return(false)
- expect{registry.type_matches!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegTypesMismatch)
+ expect { registry.type_matches!(key_path, value1) }.to raise_error(Chef::Exceptions::Win32RegTypesMismatch)
end
end