summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-01-14 14:08:03 +0000
committerThom May <thom@chef.io>2016-01-14 14:08:03 +0000
commit51cfbdc4d16739caac4d946fadbe678444aafe34 (patch)
tree56dfd8f1cd9fd933de27268b32402e955a43ac2b /spec/unit
parent05064423057d4cf46f4713b81b08829cf6d20af6 (diff)
downloadchef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go along with chef/chefstyle#5 . We should pick something and use it consistently, and my opinion is that double quotes are the appropriate thing.
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/api_client/registration_spec.rb20
-rw-r--r--spec/unit/api_client_spec.rb10
-rw-r--r--spec/unit/api_client_v1_spec.rb16
-rw-r--r--spec/unit/application/apply_spec.rb2
-rw-r--r--spec/unit/application/client_spec.rb10
-rw-r--r--spec/unit/application/knife_spec.rb20
-rw-r--r--spec/unit/application/solo_spec.rb6
-rw-r--r--spec/unit/application_spec.rb16
-rw-r--r--spec/unit/audit/audit_event_proxy_spec.rb4
-rw-r--r--spec/unit/audit/audit_reporter_spec.rb4
-rw-r--r--spec/unit/audit/control_group_data_spec.rb4
-rw-r--r--spec/unit/audit/logger_spec.rb8
-rw-r--r--spec/unit/audit/rspec_formatter_spec.rb4
-rw-r--r--spec/unit/audit/runner_spec.rb16
-rw-r--r--spec/unit/chef_class_spec.rb8
-rw-r--r--spec/unit/chef_fs/config_spec.rb18
-rw-r--r--spec/unit/chef_fs/data_handler/group_handler_spec.rb30
-rw-r--r--spec/unit/chef_fs/diff_spec.rb120
-rw-r--r--spec/unit/chef_fs/file_pattern_spec.rb732
-rw-r--r--spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb12
-rw-r--r--spec/unit/chef_fs/file_system/operation_failed_error_spec.rb14
-rw-r--r--spec/unit/chef_fs/file_system_spec.rb138
-rw-r--r--spec/unit/chef_fs/parallelizer.rb50
-rw-r--r--spec/unit/chef_fs/path_util_spec.rb88
-rw-r--r--spec/unit/chef_spec.rb2
-rw-r--r--spec/unit/client_spec.rb20
-rw-r--r--spec/unit/config_fetcher_spec.rb4
-rw-r--r--spec/unit/config_spec.rb4
-rw-r--r--spec/unit/cookbook/chefignore_spec.rb12
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb6
-rw-r--r--spec/unit/cookbook/file_vendor_spec.rb2
-rw-r--r--spec/unit/cookbook/metadata_spec.rb44
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb30
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb36
-rw-r--r--spec/unit/cookbook_loader_spec.rb4
-rw-r--r--spec/unit/cookbook_manifest_spec.rb36
-rw-r--r--spec/unit/cookbook_site_streaming_uploader_spec.rb46
-rw-r--r--spec/unit/cookbook_spec.rb2
-rw-r--r--spec/unit/cookbook_uploader_spec.rb2
-rw-r--r--spec/unit/cookbook_version_file_specificity_spec.rb20
-rw-r--r--spec/unit/cookbook_version_spec.rb78
-rw-r--r--spec/unit/daemon_spec.rb8
-rw-r--r--spec/unit/data_bag_item_spec.rb18
-rw-r--r--spec/unit/data_bag_spec.rb76
-rw-r--r--spec/unit/deprecation_spec.rb18
-rw-r--r--spec/unit/digester_spec.rb4
-rw-r--r--spec/unit/dsl/audit_spec.rb4
-rw-r--r--spec/unit/dsl/data_query_spec.rb4
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb26
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb14
-rw-r--r--spec/unit/dsl/recipe_spec.rb4
-rw-r--r--spec/unit/dsl/regsitry_helper_spec.rb12
-rw-r--r--spec/unit/dsl/resources_spec.rb20
-rw-r--r--spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb4
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb4
-rw-r--r--spec/unit/environment_spec.rb66
-rw-r--r--spec/unit/event_dispatch/dispatcher_spec.rb4
-rw-r--r--spec/unit/event_dispatch/dsl_spec.rb26
-rw-r--r--spec/unit/exceptions_spec.rb2
-rw-r--r--spec/unit/file_access_control_spec.rb60
-rw-r--r--spec/unit/file_cache_spec.rb34
-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.rb4
-rw-r--r--spec/unit/formatters/base_spec.rb2
-rw-r--r--spec/unit/formatters/doc_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb8
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb2
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb8
-rw-r--r--spec/unit/guard_interpreter_spec.rb2
-rw-r--r--spec/unit/handler/json_file_spec.rb16
-rw-r--r--spec/unit/handler_spec.rb6
-rw-r--r--spec/unit/http/authenticator_spec.rb10
-rw-r--r--spec/unit/http/basic_client_spec.rb4
-rw-r--r--spec/unit/http/http_request_spec.rb42
-rw-r--r--spec/unit/http/json_input_spec.rb4
-rw-r--r--spec/unit/http/simple_spec.rb2
-rw-r--r--spec/unit/http/socketless_chef_zero_client_spec.rb2
-rw-r--r--spec/unit/http/ssl_policies_spec.rb20
-rw-r--r--spec/unit/http/validate_content_length_spec.rb6
-rw-r--r--spec/unit/http_spec.rb34
-rw-r--r--spec/unit/json_compat_spec.rb14
-rw-r--r--spec/unit/key_spec.rb6
-rw-r--r--spec/unit/knife/bootstrap/chef_vault_handler_spec.rb52
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb14
-rw-r--r--spec/unit/knife/bootstrap_spec.rb34
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_create_spec.rb14
-rw-r--r--spec/unit/knife/client_delete_spec.rb22
-rw-r--r--spec/unit/knife/client_edit_spec.rb14
-rw-r--r--spec/unit/knife/client_list_spec.rb8
-rw-r--r--spec/unit/knife/client_reregister_spec.rb24
-rw-r--r--spec/unit/knife/client_show_spec.rb20
-rw-r--r--spec/unit/knife/configure_client_spec.rb32
-rw-r--r--spec/unit/knife/configure_spec.rb68
-rw-r--r--spec/unit/knife/cookbook_bulk_delete_spec.rb18
-rw-r--r--spec/unit/knife/cookbook_create_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb150
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb148
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb40
-rw-r--r--spec/unit/knife/cookbook_metadata_from_file_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb86
-rw-r--r--spec/unit/knife/cookbook_show_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_site_download_spec.rb68
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb6
-rw-r--r--spec/unit/knife/cookbook_site_share_spec.rb60
-rw-r--r--spec/unit/knife/cookbook_site_unshare_spec.rb26
-rw-r--r--spec/unit/knife/cookbook_test_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb112
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb26
-rw-r--r--spec/unit/knife/core/cookbook_scm_repo_spec.rb48
-rw-r--r--spec/unit/knife/core/custom_manifest_loader_spec.rb4
-rw-r--r--spec/unit/knife/core/gem_glob_loader_spec.rb28
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb4
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb130
-rw-r--r--spec/unit/knife/core/object_loader_spec.rb20
-rw-r--r--spec/unit/knife/core/subcommand_loader_spec.rb18
-rw-r--r--spec/unit/knife/core/ui_spec.rb48
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb8
-rw-r--r--spec/unit/knife/data_bag_edit_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb8
-rw-r--r--spec/unit/knife/data_bag_secret_options_spec.rb8
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb10
-rw-r--r--spec/unit/knife/environment_compare_spec.rb44
-rw-r--r--spec/unit/knife/environment_create_spec.rb2
-rw-r--r--spec/unit/knife/environment_delete_spec.rb2
-rw-r--r--spec/unit/knife/environment_edit_spec.rb2
-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/environment_show_spec.rb2
-rw-r--r--spec/unit/knife/index_rebuild_spec.rb2
-rw-r--r--spec/unit/knife/key_create_spec.rb10
-rw-r--r--spec/unit/knife/key_delete_spec.rb10
-rw-r--r--spec/unit/knife/key_edit_spec.rb10
-rw-r--r--spec/unit/knife/key_helper.rb2
-rw-r--r--spec/unit/knife/key_list_spec.rb10
-rw-r--r--spec/unit/knife/key_show_spec.rb14
-rw-r--r--spec/unit/knife/knife_help.rb2
-rw-r--r--spec/unit/knife/node_bulk_delete_spec.rb10
-rw-r--r--spec/unit/knife/node_delete_spec.rb2
-rw-r--r--spec/unit/knife/node_edit_spec.rb4
-rw-r--r--spec/unit/knife/node_environment_set_spec.rb4
-rw-r--r--spec/unit/knife/node_from_file_spec.rb4
-rw-r--r--spec/unit/knife/node_list_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_add_spec.rb4
-rw-r--r--spec/unit/knife/node_run_list_remove_spec.rb48
-rw-r--r--spec/unit/knife/node_run_list_set_spec.rb4
-rw-r--r--spec/unit/knife/node_show_spec.rb8
-rw-r--r--spec/unit/knife/osc_user_create_spec.rb10
-rw-r--r--spec/unit/knife/osc_user_delete_spec.rb10
-rw-r--r--spec/unit/knife/osc_user_edit_spec.rb8
-rw-r--r--spec/unit/knife/osc_user_list_spec.rb4
-rw-r--r--spec/unit/knife/osc_user_reregister_spec.rb16
-rw-r--r--spec/unit/knife/osc_user_show_spec.rb12
-rw-r--r--spec/unit/knife/raw_spec.rb8
-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.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb6
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb20
-rw-r--r--spec/unit/knife/role_env_run_list_remove_spec.rb34
-rw-r--r--spec/unit/knife/role_env_run_list_replace_spec.rb38
-rw-r--r--spec/unit/knife/role_env_run_list_set_spec.rb26
-rw-r--r--spec/unit/knife/role_from_file_spec.rb8
-rw-r--r--spec/unit/knife/role_list_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_clear_spec.rb4
-rw-r--r--spec/unit/knife/role_run_list_remove_spec.rb20
-rw-r--r--spec/unit/knife/role_run_list_replace_spec.rb30
-rw-r--r--spec/unit/knife/role_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/role_show_spec.rb20
-rw-r--r--spec/unit/knife/ssh_spec.rb40
-rw-r--r--spec/unit/knife/ssl_check_spec.rb2
-rw-r--r--spec/unit/knife/ssl_fetch_spec.rb4
-rw-r--r--spec/unit/knife/status_spec.rb2
-rw-r--r--spec/unit/knife/tag_create_spec.rb2
-rw-r--r--spec/unit/knife/tag_delete_spec.rb2
-rw-r--r--spec/unit/knife/tag_list_spec.rb2
-rw-r--r--spec/unit/knife/user_create_spec.rb52
-rw-r--r--spec/unit/knife/user_delete_spec.rb14
-rw-r--r--spec/unit/knife/user_edit_spec.rb8
-rw-r--r--spec/unit/knife/user_list_spec.rb4
-rw-r--r--spec/unit/knife/user_reregister_spec.rb18
-rw-r--r--spec/unit/knife/user_show_spec.rb16
-rw-r--r--spec/unit/knife_spec.rb44
-rw-r--r--spec/unit/log/syslog_spec.rb4
-rw-r--r--spec/unit/log/winevt_spec.rb2
-rw-r--r--spec/unit/log_spec.rb6
-rw-r--r--spec/unit/lwrp_spec.rb70
-rw-r--r--spec/unit/mash_spec.rb4
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb8
-rw-r--r--spec/unit/mixin/checksum_spec.rb6
-rw-r--r--spec/unit/mixin/command_spec.rb2
-rw-r--r--spec/unit/mixin/convert_to_class_name_spec.rb2
-rw-r--r--spec/unit/mixin/deep_merge_spec.rb16
-rw-r--r--spec/unit/mixin/deprecation_spec.rb6
-rw-r--r--spec/unit/mixin/enforce_ownership_and_permissions_spec.rb14
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb22
-rw-r--r--spec/unit/mixin/params_validate_spec.rb22
-rw-r--r--spec/unit/mixin/path_sanity_spec.rb16
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb4
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb40
-rw-r--r--spec/unit/mixin/properties_spec.rb54
-rw-r--r--spec/unit/mixin/proxified_socket_spec.rb8
-rw-r--r--spec/unit/mixin/securable_spec.rb64
-rw-r--r--spec/unit/mixin/shell_out_spec.rb112
-rw-r--r--spec/unit/mixin/subclass_directive_spec.rb2
-rw-r--r--spec/unit/mixin/template_spec.rb16
-rw-r--r--spec/unit/mixin/unformatter_spec.rb4
-rw-r--r--spec/unit/mixin/uris_spec.rb12
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb4
-rw-r--r--spec/unit/mixin/xml_escape_spec.rb2
-rw-r--r--spec/unit/monkey_patches/uri_spec.rb2
-rw-r--r--spec/unit/monologger_spec.rb6
-rw-r--r--spec/unit/node/attribute_spec.rb32
-rw-r--r--spec/unit/node/immutable_collections_spec.rb16
-rw-r--r--spec/unit/node_map_spec.rb8
-rw-r--r--spec/unit/node_spec.rb98
-rw-r--r--spec/unit/org_spec.rb8
-rw-r--r--spec/unit/platform/query_helpers_spec.rb42
-rw-r--r--spec/unit/platform_spec.rb4
-rw-r--r--spec/unit/policy_builder/dynamic_spec.rb4
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb4
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb4
-rw-r--r--spec/unit/policy_builder_spec.rb4
-rw-r--r--spec/unit/property/state_spec.rb90
-rw-r--r--spec/unit/property/validation_spec.rb234
-rw-r--r--spec/unit/property_spec.rb168
-rw-r--r--spec/unit/provider/breakpoint_spec.rb2
-rw-r--r--spec/unit/provider/cookbook_file/content_spec.rb14
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb16
-rw-r--r--spec/unit/provider/cron/unix_spec.rb10
-rw-r--r--spec/unit/provider/cron_spec.rb124
-rw-r--r--spec/unit/provider/deploy/revision_spec.rb2
-rw-r--r--spec/unit/provider/deploy/timestamped_spec.rb2
-rw-r--r--spec/unit/provider/deploy_spec.rb12
-rw-r--r--spec/unit/provider/directory_spec.rb12
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb42
-rw-r--r--spec/unit/provider/dsc_script_spec.rb88
-rw-r--r--spec/unit/provider/env/windows_spec.rb30
-rw-r--r--spec/unit/provider/env_spec.rb2
-rw-r--r--spec/unit/provider/erl_call_spec.rb4
-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.rb10
-rw-r--r--spec/unit/provider/git_spec.rb56
-rw-r--r--spec/unit/provider/group/dscl_spec.rb10
-rw-r--r--spec/unit/provider/group/gpasswd_spec.rb2
-rw-r--r--spec/unit/provider/group/groupadd_spec.rb2
-rw-r--r--spec/unit/provider/group/groupmod_spec.rb2
-rw-r--r--spec/unit/provider/group/pw_spec.rb2
-rw-r--r--spec/unit/provider/group/usermod_spec.rb2
-rw-r--r--spec/unit/provider/group/windows_spec.rb4
-rw-r--r--spec/unit/provider/group_spec.rb6
-rw-r--r--spec/unit/provider/http_request_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/aix_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig/redhat_spec.rb4
-rw-r--r--spec/unit/provider/ifconfig_spec.rb4
-rw-r--r--spec/unit/provider/link_spec.rb20
-rw-r--r--spec/unit/provider/log_spec.rb2
-rw-r--r--spec/unit/provider/mdadm_spec.rb14
-rw-r--r--spec/unit/provider/mount/aix_spec.rb6
-rw-r--r--spec/unit/provider/mount/mount_spec.rb20
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb46
-rw-r--r--spec/unit/provider/mount/windows_spec.rb2
-rw-r--r--spec/unit/provider/mount_spec.rb6
-rw-r--r--spec/unit/provider/ohai_spec.rb16
-rw-r--r--spec/unit/provider/osx_profile_spec.rb98
-rw-r--r--spec/unit/provider/package/aix_spec.rb2
-rw-r--r--spec/unit/provider/package/apt_spec.rb10
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb2
-rw-r--r--spec/unit/provider/package/dpkg_spec.rb22
-rw-r--r--spec/unit/provider/package/easy_install_spec.rb6
-rw-r--r--spec/unit/provider/package/freebsd/pkg_spec.rb8
-rw-r--r--spec/unit/provider/package/freebsd/pkgng_spec.rb20
-rw-r--r--spec/unit/provider/package/freebsd/port_spec.rb14
-rw-r--r--spec/unit/provider/package/homebrew_spec.rb274
-rw-r--r--spec/unit/provider/package/ips_spec.rb8
-rw-r--r--spec/unit/provider/package/macports_spec.rb2
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb58
-rw-r--r--spec/unit/provider/package/pacman_spec.rb2
-rw-r--r--spec/unit/provider/package/paludis_spec.rb4
-rw-r--r--spec/unit/provider/package/portage_spec.rb2
-rw-r--r--spec/unit/provider/package/rpm_spec.rb6
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb254
-rw-r--r--spec/unit/provider/package/smartos_spec.rb10
-rw-r--r--spec/unit/provider/package/solaris_spec.rb2
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb24
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb24
-rw-r--r--spec/unit/provider/package/windows_spec.rb56
-rw-r--r--spec/unit/provider/package/yum_spec.rb234
-rw-r--r--spec/unit/provider/package/zypper_spec.rb2
-rw-r--r--spec/unit/provider/package_spec.rb176
-rw-r--r--spec/unit/provider/powershell_script_spec.rb34
-rw-r--r--spec/unit/provider/registry_key_spec.rb2
-rw-r--r--spec/unit/provider/remote_directory_spec.rb82
-rw-r--r--spec/unit/provider/remote_file/cache_control_data_spec.rb14
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/fetcher_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/local_file_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/network_file_spec.rb2
-rw-r--r--spec/unit/provider/remote_file_spec.rb12
-rw-r--r--spec/unit/provider/route_spec.rb42
-rw-r--r--spec/unit/provider/ruby_block_spec.rb2
-rw-r--r--spec/unit/provider/script_spec.rb16
-rw-r--r--spec/unit/provider/service/aix_service_spec.rb8
-rw-r--r--spec/unit/provider/service/aixinit_service_spec.rb24
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb12
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb4
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb2
-rw-r--r--spec/unit/provider/service/gentoo_service_spec.rb2
-rw-r--r--spec/unit/provider/service/init_service_spec.rb4
-rw-r--r--spec/unit/provider/service/insserv_service_spec.rb2
-rw-r--r--spec/unit/provider/service/invokercd_service_spec.rb4
-rw-r--r--spec/unit/provider/service/macosx_spec.rb26
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb40
-rw-r--r--spec/unit/provider/service/redhat_spec.rb4
-rw-r--r--spec/unit/provider/service/simple_service_spec.rb2
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb76
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb6
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb20
-rw-r--r--spec/unit/provider/service/windows_spec.rb12
-rw-r--r--spec/unit/provider/service_spec.rb2
-rw-r--r--spec/unit/provider/subversion_spec.rb34
-rw-r--r--spec/unit/provider/template/content_spec.rb36
-rw-r--r--spec/unit/provider/template_spec.rb24
-rw-r--r--spec/unit/provider/user/dscl_spec.rb64
-rw-r--r--spec/unit/provider/user/pw_spec.rb12
-rw-r--r--spec/unit/provider/user/solaris_spec.rb54
-rw-r--r--spec/unit/provider/user/useradd_spec.rb14
-rw-r--r--spec/unit/provider/user/windows_spec.rb8
-rw-r--r--spec/unit/provider/user_spec.rb30
-rw-r--r--spec/unit/provider/whyrun_safe_ruby_block_spec.rb2
-rw-r--r--spec/unit/provider_resolver_spec.rb34
-rw-r--r--spec/unit/provider_spec.rb2
-rw-r--r--spec/unit/pure_application_spec.rb2
-rw-r--r--spec/unit/recipe_spec.rb4
-rw-r--r--spec/unit/resource/apt_package_spec.rb4
-rw-r--r--spec/unit/resource/bash_spec.rb2
-rw-r--r--spec/unit/resource/batch_spec.rb6
-rw-r--r--spec/unit/resource/breakpoint_spec.rb4
-rw-r--r--spec/unit/resource/chef_gem_spec.rb4
-rw-r--r--spec/unit/resource/chocolatey_package_spec.rb2
-rw-r--r--spec/unit/resource/conditional_action_not_nothing_spec.rb2
-rw-r--r--spec/unit/resource/conditional_spec.rb16
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb12
-rw-r--r--spec/unit/resource/cron_spec.rb2
-rw-r--r--spec/unit/resource/csh_spec.rb2
-rw-r--r--spec/unit/resource/deploy_revision_spec.rb4
-rw-r--r--spec/unit/resource/deploy_spec.rb4
-rw-r--r--spec/unit/resource/directory_spec.rb2
-rw-r--r--spec/unit/resource/dpkg_package_spec.rb6
-rw-r--r--spec/unit/resource/dsc_resource_spec.rb14
-rw-r--r--spec/unit/resource/dsc_script_spec.rb22
-rw-r--r--spec/unit/resource/easy_install_package_spec.rb4
-rw-r--r--spec/unit/resource/env_spec.rb2
-rw-r--r--spec/unit/resource/erl_call_spec.rb2
-rw-r--r--spec/unit/resource/execute_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb10
-rw-r--r--spec/unit/resource/file_spec.rb2
-rw-r--r--spec/unit/resource/freebsd_package_spec.rb6
-rw-r--r--spec/unit/resource/gem_package_spec.rb4
-rw-r--r--spec/unit/resource/git_spec.rb4
-rw-r--r--spec/unit/resource/group_spec.rb2
-rw-r--r--spec/unit/resource/homebrew_package_spec.rb22
-rw-r--r--spec/unit/resource/http_request_spec.rb2
-rw-r--r--spec/unit/resource/ifconfig_spec.rb14
-rw-r--r--spec/unit/resource/ips_package_spec.rb4
-rw-r--r--spec/unit/resource/ksh_spec.rb2
-rw-r--r--spec/unit/resource/link_spec.rb2
-rw-r--r--spec/unit/resource/log_spec.rb2
-rw-r--r--spec/unit/resource/macports_package_spec.rb4
-rw-r--r--spec/unit/resource/mdadm_spec.rb2
-rw-r--r--spec/unit/resource/mount_spec.rb4
-rw-r--r--spec/unit/resource/ohai_spec.rb2
-rw-r--r--spec/unit/resource/openbsd_package_spec.rb4
-rw-r--r--spec/unit/resource/osx_profile_spec.rb4
-rw-r--r--spec/unit/resource/package_spec.rb2
-rw-r--r--spec/unit/resource/pacman_package_spec.rb4
-rw-r--r--spec/unit/resource/perl_spec.rb2
-rw-r--r--spec/unit/resource/powershell_script_spec.rb14
-rw-r--r--spec/unit/resource/python_spec.rb2
-rw-r--r--spec/unit/resource/registry_key_spec.rb34
-rw-r--r--spec/unit/resource/remote_directory_spec.rb2
-rw-r--r--spec/unit/resource/remote_file_spec.rb8
-rw-r--r--spec/unit/resource/resource_notification_spec.rb4
-rw-r--r--spec/unit/resource/route_spec.rb2
-rw-r--r--spec/unit/resource/rpm_package_spec.rb4
-rw-r--r--spec/unit/resource/ruby_block_spec.rb2
-rw-r--r--spec/unit/resource/ruby_spec.rb2
-rw-r--r--spec/unit/resource/scm_spec.rb4
-rw-r--r--spec/unit/resource/script_spec.rb2
-rw-r--r--spec/unit/resource/service_spec.rb2
-rw-r--r--spec/unit/resource/smartos_package_spec.rb4
-rw-r--r--spec/unit/resource/solaris_package_spec.rb4
-rw-r--r--spec/unit/resource/subversion_spec.rb8
-rw-r--r--spec/unit/resource/template_spec.rb2
-rw-r--r--spec/unit/resource/timestamped_deploy_spec.rb6
-rw-r--r--spec/unit/resource/user_spec.rb2
-rw-r--r--spec/unit/resource/windows_package_spec.rb10
-rw-r--r--spec/unit/resource/windows_service_spec.rb2
-rw-r--r--spec/unit/resource/yum_package_spec.rb8
-rw-r--r--spec/unit/resource_collection/resource_list_spec.rb2
-rw-r--r--spec/unit/resource_collection/resource_set_spec.rb2
-rw-r--r--spec/unit/resource_collection/stepable_iterator_spec.rb2
-rw-r--r--spec/unit/resource_collection_spec.rb4
-rw-r--r--spec/unit/resource_definition_spec.rb2
-rw-r--r--spec/unit/resource_reporter_spec.rb26
-rw-r--r--spec/unit/resource_resolver_spec.rb8
-rw-r--r--spec/unit/resource_spec.rb68
-rw-r--r--spec/unit/rest/auth_credentials_spec.rb12
-rw-r--r--spec/unit/rest_spec.rb98
-rw-r--r--spec/unit/role_spec.rb108
-rw-r--r--spec/unit/run_context/child_run_context_spec.rb38
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb6
-rw-r--r--spec/unit/run_context_spec.rb6
-rw-r--r--spec/unit/run_list/run_list_expansion_spec.rb42
-rw-r--r--spec/unit/run_list/run_list_item_spec.rb44
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb2
-rw-r--r--spec/unit/run_list_spec.rb46
-rw-r--r--spec/unit/run_lock_spec.rb8
-rw-r--r--spec/unit/run_status_spec.rb4
-rw-r--r--spec/unit/runner_spec.rb2
-rw-r--r--spec/unit/scan_access_control_spec.rb4
-rw-r--r--spec/unit/search/query_spec.rb12
-rw-r--r--spec/unit/shell/model_wrapper_spec.rb10
-rw-r--r--spec/unit/shell/shell_ext_spec.rb2
-rw-r--r--spec/unit/shell/shell_session_spec.rb8
-rw-r--r--spec/unit/shell_out_spec.rb2
-rw-r--r--spec/unit/shell_spec.rb6
-rw-r--r--spec/unit/user_spec.rb6
-rw-r--r--spec/unit/user_v1_spec.rb14
-rw-r--r--spec/unit/util/backup_spec.rb30
-rw-r--r--spec/unit/util/diff_spec.rb4
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb84
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb34
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb56
-rw-r--r--spec/unit/util/dsc/resource_store.rb42
-rw-r--r--spec/unit/util/editor_spec.rb130
-rw-r--r--spec/unit/util/file_edit_spec.rb6
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb44
-rw-r--r--spec/unit/util/powershell/ps_credential_spec.rb22
-rw-r--r--spec/unit/util/selinux_spec.rb4
-rw-r--r--spec/unit/util/threaded_job_queue_spec.rb2
-rw-r--r--spec/unit/version/platform_spec.rb6
-rw-r--r--spec/unit/version_class_spec.rb4
-rw-r--r--spec/unit/version_constraint/platform_spec.rb4
-rw-r--r--spec/unit/version_constraint_spec.rb34
-rw-r--r--spec/unit/win32/registry_spec.rb16
-rw-r--r--spec/unit/windows_service_spec.rb14
460 files changed, 4931 insertions, 4931 deletions
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb
index 6f0f552c4d..bddb33fa0d 100644
--- a/spec/unit/api_client/registration_spec.rb
+++ b/spec/unit/api_client/registration_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
-require 'chef/api_client/registration'
+require "chef/api_client/registration"
describe Chef::ApiClient::Registration do
@@ -63,7 +63,7 @@ describe Chef::ApiClient::Registration do
let(:response_409) { Net::HTTPConflict.new("1.1", "409", "Conflict") }
let(:exception_409) { Net::HTTPServerException.new("409 conflict", response_409) }
- let(:generated_private_key_pem) { IO.read(File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)) }
+ let(:generated_private_key_pem) { IO.read(File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)) }
let(:generated_private_key) { OpenSSL::PKey::RSA.new(generated_private_key_pem) }
let(:generated_public_key) { generated_private_key.public_key }
@@ -88,7 +88,7 @@ describe Chef::ApiClient::Registration do
before do
Chef::Config[:validation_client_name] = "test-validator"
- Chef::Config[:validation_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)
+ Chef::Config[:validation_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)
allow(OpenSSL::PKey::RSA).to receive(:generate).with(2048).and_return(generated_private_key)
end
@@ -196,7 +196,7 @@ describe Chef::ApiClient::Registration do
describe "when writing the private key to disk" do
before do
- allow(registration).to receive(:private_key).and_return('--begin rsa key etc--')
+ allow(registration).to receive(:private_key).and_return("--begin rsa key etc--")
end
# Permission read via File.stat is busted on windows, though creating the
@@ -215,8 +215,8 @@ describe Chef::ApiClient::Registration do
expect(IO.read(key_location)).to eq("--begin rsa key etc--")
end
- context 'when the client key location is a symlink' do
- it 'does not follow the symlink', :unix_only 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)
if defined?(File::NOFOLLOW)
@@ -226,12 +226,12 @@ describe Chef::ApiClient::Registration do
expect(registration.file_flags).to eq(expected_flags)
end
- context 'with follow_client_key_symlink set to true' do
+ context "with follow_client_key_symlink set to true" do
before do
Chef::Config[:follow_client_key_symlink] = true
end
- it 'follows the symlink', :unix_only do
+ it "follows the symlink", :unix_only do
expect(registration.file_flags).to eq(File::CREAT|File::TRUNC|File::RDWR)
end
end
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index 2a3f63bde5..1f313d7447 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/api_client'
-require 'tempfile'
+require "chef/api_client"
+require "tempfile"
# DEPRECATION NOTE
#
@@ -226,7 +226,7 @@ describe Chef::ApiClient do
@http_client = double("Chef::ServerAPI mock")
allow(Chef::ServerAPI).to receive(:new).and_return(@http_client)
expect(@http_client).to receive(:get).with("clients/black").and_return(client)
- @client = Chef::ApiClient.load(client['name'])
+ @client = Chef::ApiClient.load(client["name"])
end
it "should deserialize to a Chef::ApiClient object" do
@@ -258,7 +258,7 @@ describe Chef::ApiClient do
describe "with correctly configured API credentials" do
before do
Chef::Config[:node_name] = "silent-bob"
- Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)
+ Chef::Config[:client_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)
end
after do
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index ab55a04950..f3df1f44eb 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/api_client_v1'
-require 'tempfile'
+require "chef/api_client_v1"
+require "tempfile"
describe Chef::ApiClientV1 do
before(:each) do
@@ -254,7 +254,7 @@ describe Chef::ApiClientV1 do
@http_client = double("Chef::ServerAPI mock")
allow(Chef::ServerAPI).to receive(:new).and_return(@http_client)
expect(@http_client).to receive(:get).with("clients/black").and_return(client)
- @client = Chef::ApiClientV1.load(client['name'])
+ @client = Chef::ApiClientV1.load(client["name"])
end
it "should deserialize to a Chef::ApiClientV1 object" do
@@ -290,7 +290,7 @@ describe Chef::ApiClientV1 do
describe "with correctly configured API credentials" do
before do
Chef::Config[:node_name] = "silent-bob"
- Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)
+ Chef::Config[:client_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)
end
after do
@@ -326,7 +326,7 @@ describe Chef::ApiClientV1 do
end
describe "Versioned API Interactions" do
- let(:response_406) { OpenStruct.new(:code => '406') }
+ let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
let(:payload) {
{
@@ -338,8 +338,8 @@ describe Chef::ApiClientV1 do
before do
@client = Chef::ApiClientV1.new
- allow(@client).to receive(:chef_rest_v0).and_return(double('chef rest root v0 object'))
- allow(@client).to receive(:chef_rest_v1).and_return(double('chef rest root v1 object'))
+ allow(@client).to receive(:chef_rest_v0).and_return(double("chef rest root v0 object"))
+ allow(@client).to receive(:chef_rest_v1).and_return(double("chef rest root v1 object"))
@client.name "some_name"
@client.validator true
@client.admin true
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index f6cd0bae03..5aad53d209 100644
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::Application::Apply do
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 727536f1f8..6ff9597b53 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::Application::Client, "reconfigure" do
let(:app) do
@@ -42,8 +42,8 @@ describe Chef::Application::Client, "reconfigure" do
ARGV.replace(@original_argv)
end
- describe 'parse cli_arguments' do
- it 'should call set_specific_recipes' do
+ describe "parse cli_arguments" do
+ it "should call set_specific_recipes" do
expect(app).to receive(:set_specific_recipes).and_return(true)
app.reconfigure
end
@@ -310,9 +310,9 @@ describe Chef::Application::Client, "run_application", :unix_only do
@client = Chef::Client.new
allow(Chef::Client).to receive(:new).and_return(@client)
allow(@client).to receive(:run) do
- @pipe[1].puts 'started'
+ @pipe[1].puts "started"
sleep 1
- @pipe[1].puts 'finished'
+ @pipe[1].puts "finished"
end
end
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 0fb25176f9..163489110f 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
require "#{CHEF_SPEC_DATA}/knife_subcommand/test_yourself"
describe Chef::Application::Knife do
@@ -84,7 +84,7 @@ describe Chef::Application::Knife do
describe "when given a path to the client key" do
it "expands a relative path relative to the CWD" do
- relative_path = '.chef/client.pem'
+ relative_path = ".chef/client.pem"
allow(Dir).to receive(:pwd).and_return(CHEF_SPEC_DATA)
with_argv(*%W{noop knife command -k #{relative_path}}) do
expect(@knife).to receive(:exit).with(0)
@@ -94,19 +94,19 @@ describe Chef::Application::Knife do
end
it "expands a ~/home/path to the correct full path" do
- home_path = '~/.chef/client.pem'
+ home_path = "~/.chef/client.pem"
with_argv(*%W{noop knife command -k #{home_path}}) do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- expect(Chef::Config[:client_key]).to eq(File.join(ENV['HOME'], '.chef/client.pem').gsub((File::ALT_SEPARATOR || '\\'), File::SEPARATOR))
+ expect(Chef::Config[:client_key]).to eq(File.join(ENV["HOME"], ".chef/client.pem").gsub((File::ALT_SEPARATOR || '\\'), File::SEPARATOR))
end
it "does not expand a full path" do
full_path = if windows?
- 'C:/chef/client.pem'
+ "C:/chef/client.pem"
else
- '/etc/chef/client.pem'
+ "/etc/chef/client.pem"
end
with_argv(*%W{noop knife command -k #{full_path}}) do
expect(@knife).to receive(:exit).with(0)
@@ -135,7 +135,7 @@ describe Chef::Application::Knife do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- expect(Chef::Config[:environment]).to eq('production')
+ expect(Chef::Config[:environment]).to eq("production")
end
it "should load the environment from the CLI options" do
@@ -143,7 +143,7 @@ describe Chef::Application::Knife do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- expect(Chef::Config[:environment]).to eq('development')
+ expect(Chef::Config[:environment]).to eq("development")
end
it "should override the config file environment with the CLI environment" do
@@ -152,7 +152,7 @@ describe Chef::Application::Knife do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- expect(Chef::Config[:environment]).to eq('override')
+ expect(Chef::Config[:environment]).to eq("override")
end
it "should override the config file environment with the CLI environment regardless of order" do
@@ -161,7 +161,7 @@ describe Chef::Application::Knife do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- expect(Chef::Config[:environment]).to eq('override')
+ expect(Chef::Config[:environment]).to eq("override")
end
it "should run a sub command with the applications command line option prototype" do
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 7013bfa0bc..c5b24f7826 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::Application::Solo do
@@ -34,7 +34,7 @@ describe Chef::Application::Solo do
end
describe "configuring the application" do
- it 'should call set_specific_recipes' do
+ it "should call set_specific_recipes" do
expect(app).to receive(:set_specific_recipes)
app.reconfigure
end
@@ -106,7 +106,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
describe "when the recipe_url configuration option is specified" do
let(:tarfile) { StringIO.new("remote_tarball_content") }
let(:target_file) { StringIO.new }
- let(:shellout) { double(run_command: nil, error!: nil, stdout: '') }
+ let(:shellout) { double(run_command: nil, error!: nil, stdout: "") }
before do
Chef::Config[:cookbook_path] = "#{Dir.tmpdir}/chef-solo/cookbooks"
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index 20b7e3a506..6a78e5c827 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::Application do
before do
@@ -51,7 +51,7 @@ describe Chef::Application do
@app.reconfigure
end
- it 'should not receive set_specific_recipes' do
+ it "should not receive set_specific_recipes" do
expect(@app).to_not receive(:set_specific_recipes)
@app.reconfigure
end
@@ -298,18 +298,18 @@ describe Chef::Application do
end
end
- describe 'run_chef_client' do
- context 'with an application' do
+ describe "run_chef_client" do
+ context "with an application" do
let(:app) { Chef::Application.new }
- context 'when called with an invalid argument' do
+ context "when called with an invalid argument" do
before do
allow(app).to receive(:fork_chef_client).and_return(true)
allow(app).to receive(:run_with_graceful_exit_option).and_return(true)
end
- it 'should raise an argument error detailing the problem' do
- specific_recipes_regexp = Regexp.new 'received non-Array like specific_recipes argument'
+ it "should raise an argument error detailing the problem" do
+ specific_recipes_regexp = Regexp.new "received non-Array like specific_recipes argument"
expect { app.run_chef_client(nil) }.to raise_error(ArgumentError, specific_recipes_regexp)
end
end
@@ -320,7 +320,7 @@ describe Chef::Application do
allow(app).to receive(:run_with_graceful_exit_option).and_return(true)
end
- it 'should be cool' do
+ it "should be cool" do
expect { app.run_chef_client([]) }.not_to raise_error
end
end
diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb
index d8c495deeb..a866075f72 100644
--- a/spec/unit/audit/audit_event_proxy_spec.rb
+++ b/spec/unit/audit/audit_event_proxy_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/audit/audit_event_proxy'
+require "spec_helper"
+require "chef/audit/audit_event_proxy"
describe Chef::Audit::AuditEventProxy do
diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb
index f9f03c9620..6b0d1566bf 100644
--- a/spec/unit/audit/audit_reporter_spec.rb
+++ b/spec/unit/audit/audit_reporter_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Audit::AuditReporter do
@@ -75,7 +75,7 @@ describe Chef::Audit::AuditReporter do
it "posts audit data to server endpoint" do
headers = {
- 'X-Ops-Audit-Report-Protocol-Version' => Chef::Audit::AuditReporter::PROTOCOL_VERSION
+ "X-Ops-Audit-Report-Protocol-Version" => Chef::Audit::AuditReporter::PROTOCOL_VERSION
}
expect(rest).to receive(:post).
diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb
index 3705fafbe7..b25d925e12 100644
--- a/spec/unit/audit/control_group_data_spec.rb
+++ b/spec/unit/audit/control_group_data_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'securerandom'
+require "spec_helper"
+require "securerandom"
describe Chef::Audit::AuditData do
diff --git a/spec/unit/audit/logger_spec.rb b/spec/unit/audit/logger_spec.rb
index 9dd9ce2cd9..1091ed936b 100644
--- a/spec/unit/audit/logger_spec.rb
+++ b/spec/unit/audit/logger_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Audit::Logger do
@@ -23,19 +23,19 @@ describe Chef::Audit::Logger do
Chef::Audit::Logger.instance_variable_set(:@buffer, nil)
end
- it 'calling puts creates @buffer and adds the message' do
+ it "calling puts creates @buffer and adds the message" do
Chef::Audit::Logger.puts("Output message")
expect(Chef::Audit::Logger.read_buffer).to eq("Output message\n")
end
- it 'calling puts multiple times adds to the message' do
+ it "calling puts multiple times adds to the message" do
Chef::Audit::Logger.puts("Output message")
Chef::Audit::Logger.puts("Output message")
Chef::Audit::Logger.puts("Output message")
expect(Chef::Audit::Logger.read_buffer).to eq("Output message\nOutput message\nOutput message\n")
end
- it 'calling it before @buffer is set returns an empty string' do
+ it "calling it before @buffer is set returns an empty string" do
expect(Chef::Audit::Logger.read_buffer).to eq("")
end
diff --git a/spec/unit/audit/rspec_formatter_spec.rb b/spec/unit/audit/rspec_formatter_spec.rb
index 471473e387..e4160bb070 100644
--- a/spec/unit/audit/rspec_formatter_spec.rb
+++ b/spec/unit/audit/rspec_formatter_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/audit/rspec_formatter'
+require "spec_helper"
+require "chef/audit/rspec_formatter"
describe Chef::Audit::RspecFormatter do
let(:formatter) { Chef::Audit::RspecFormatter.new(nil) }
diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb
index 1de024260f..83cf8e370b 100644
--- a/spec/unit/audit/runner_spec.rb
+++ b/spec/unit/audit/runner_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'rspec/core/sandbox'
-require 'chef/audit/runner'
-require 'chef/audit/audit_event_proxy'
-require 'chef/audit/rspec_formatter'
-require 'rspec/support/spec/in_sub_process'
-require 'rspec/support/spec/stderr_splitter'
+require "spec_helper"
+require "rspec/core/sandbox"
+require "chef/audit/runner"
+require "chef/audit/audit_event_proxy"
+require "chef/audit/rspec_formatter"
+require "rspec/support/spec/in_sub_process"
+require "rspec/support/spec/stderr_splitter"
describe Chef::Audit::Runner do
@@ -54,7 +54,7 @@ describe Chef::Audit::Runner do
context "during #run" do
describe "#setup" do
- let(:log_location) { File.join(Dir.tmpdir, 'audit_log') }
+ let(:log_location) { File.join(Dir.tmpdir, "audit_log") }
let(:color) { false }
before do
diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb
index f1b877520c..899ce1c7d2 100644
--- a/spec/unit/chef_class_spec.rb
+++ b/spec/unit/chef_class_spec.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe "Chef class" do
let(:platform) { "debian" }
let(:node) do
node = Chef::Node.new
- node.automatic['platform'] = platform
+ node.automatic["platform"] = platform
node
end
@@ -86,7 +86,7 @@ describe "Chef class" do
end
context '#event_handler' do
- it 'adds a new handler' do
+ it "adds a new handler" do
x = 1
Chef.event_handler do
on :converge_start do
@@ -98,7 +98,7 @@ describe "Chef class" do
expect(x).to eq(2)
end
- it 'raise error if unknown event type is passed' do
+ it "raise error if unknown event type is passed" do
expect do
Chef.event_handler do
on :yolo do
diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb
index 145cdf2d12..cac4d7d9a2 100644
--- a/spec/unit/chef_fs/config_spec.rb
+++ b/spec/unit/chef_fs/config_spec.rb
@@ -16,16 +16,16 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/exceptions'
-require 'lib/chef/chef_fs/config.rb'
+require "spec_helper"
+require "chef/exceptions"
+require "lib/chef/chef_fs/config.rb"
describe Chef::ChefFS::Config do
describe "initialize" do
it "warns when hosted setups use 'everything'" do
base_config = Hash.new()
- base_config[:repo_mode] = 'everything'
- base_config[:chef_server_url] = 'http://foo.com/organizations/fake_org/'
+ base_config[:repo_mode] = "everything"
+ base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/"
ui = double("ui")
expect(ui).to receive(:warn)
@@ -35,8 +35,8 @@ describe Chef::ChefFS::Config do
it "doesn't warn when hosted setups use 'hosted_everything'" do
base_config = Hash.new()
- base_config[:repo_mode] = 'hosted_everything'
- base_config[:chef_server_url] = 'http://foo.com/organizations/fake_org/'
+ base_config[:repo_mode] = "hosted_everything"
+ base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/"
ui = double("ui")
expect(ui).to receive(:warn).exactly(0).times
@@ -46,8 +46,8 @@ describe Chef::ChefFS::Config do
it "doesn't warn when non-hosted setups use 'everything'" do
base_config = Hash.new()
- base_config[:repo_mode] = 'everything'
- base_config[:chef_server_url] = 'http://foo.com/'
+ base_config[:repo_mode] = "everything"
+ base_config[:chef_server_url] = "http://foo.com/"
ui = double("ui")
expect(ui).to receive(:warn).exactly(0).times
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 6e71fa3b10..7cbd0e4c22 100644
--- a/spec/unit/chef_fs/data_handler/group_handler_spec.rb
+++ b/spec/unit/chef_fs/data_handler/group_handler_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'lib/chef/chef_fs/data_handler/group_data_handler'
+require "spec_helper"
+require "lib/chef/chef_fs/data_handler/group_data_handler"
class TestEntry < Mash
attr_accessor :name, :org
@@ -31,32 +31,32 @@ end
describe Chef::ChefFS::DataHandler::GroupDataHandler do
describe '#normalize_for_post' do
let(:entry) do
- TestEntry.new('workers.json', 'hive')
+ TestEntry.new("workers.json", "hive")
end
let(:group) do
- { 'name' => 'worker_bees',
- 'clients' => %w(honey sting),
- 'users' => %w(fizz buzz),
- 'actors' => %w(honey),
+ { "name" => "worker_bees",
+ "clients" => %w(honey sting),
+ "users" => %w(fizz buzz),
+ "actors" => %w(honey),
}
end
let(:normalized) do
- { 'actors' =>
- { 'users' => %w(fizz buzz),
- 'clients'=> %w(honey sting),
- 'groups'=> [],
+ { "actors" =>
+ { "users" => %w(fizz buzz),
+ "clients"=> %w(honey sting),
+ "groups"=> [],
},
- 'groupname' => 'workers',
- 'name' => 'worker_bees',
- 'orgname' => 'hive',
+ "groupname" => "workers",
+ "name" => "worker_bees",
+ "orgname" => "hive",
}
end
let(:handler) { described_class.new }
- it 'normalizes the users, clients and groups into actors' do
+ it "normalizes the users, clients and groups into actors" do
expect(handler.normalize_for_post(group, entry)).to eq(normalized)
end
end
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index 284a7a5ab7..e2f9a9169d 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -16,24 +16,24 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/file_pattern'
-require 'chef/chef_fs/command_line'
+require "spec_helper"
+require "chef/chef_fs/file_pattern"
+require "chef/chef_fs/command_line"
# Removes the date stamp from the diff and replaces it with ' DATE'
# example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000"
# windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012"
def remove_os_differences(diff)
diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE')
- diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, 'CONTEXT_LINE_NUMBERS')
+ diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS")
end
-describe 'diff', :uses_diff => true do
+describe "diff", :uses_diff => true do
include FileSystemSupport
- context 'with two filesystems with all types of difference' do
+ context "with two filesystems with all types of difference" do
let(:a) {
- memory_fs('a', {
+ memory_fs("a", {
:both_dirs => {
:sub_both_dirs => { :subsub => nil },
:sub_both_files => nil,
@@ -60,7 +60,7 @@ describe 'diff', :uses_diff => true do
}, /cannot_be_in_a/)
}
let(:b) {
- memory_fs('b', {
+ memory_fs("b", {
:both_dirs => {
:sub_both_dirs => { :subsub => nil },
:sub_both_files => nil,
@@ -86,9 +86,9 @@ describe 'diff', :uses_diff => true do
:file_in_a_dir_in_b => {},
}, /cannot_be_in_b/)
}
- it 'Chef::ChefFS::CommandLine.diff_print(/)' do
+ it "Chef::ChefFS::CommandLine.diff_print(/)" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, nil) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, nil) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
@@ -110,17 +110,17 @@ deleted file
+++ /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
@@ -144,17 +144,17 @@ deleted file
+++ /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
@@ -162,9 +162,9 @@ CONTEXT_LINE_NUMBERS
+b_only_file
' ])
end
- it 'Chef::ChefFS::CommandLine.diff_print(/both_dirs)' do
+ it "Chef::ChefFS::CommandLine.diff_print(/both_dirs)" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/both_dirs'), a, b, nil, nil) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/both_dirs"), a, b, nil, nil) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
@@ -186,17 +186,17 @@ deleted file
+++ /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
@@ -204,33 +204,33 @@ CONTEXT_LINE_NUMBERS
+sub_b_only_file
' ])
end
- it 'Chef::ChefFS::CommandLine.diff_print(/) with depth 1' do
+ it "Chef::ChefFS::CommandLine.diff_print(/) with depth 1" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, 1, nil) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, 1, nil) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
-'Common subdirectories: b/both_dirs
-','diff --knife a/both_files_different b/both_files_different
+"Common subdirectories: b/both_dirs
+",'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
@@ -238,33 +238,33 @@ CONTEXT_LINE_NUMBERS
+b_only_file
' ])
end
- it 'Chef::ChefFS::CommandLine.diff_print(/*_*) with depth 0' do
+ it "Chef::ChefFS::CommandLine.diff_print(/*_*) with depth 0" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/*_*'), a, b, 0, nil) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/*_*"), a, b, 0, nil) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
-'Common subdirectories: b/both_dirs
-','diff --knife a/both_files_different b/both_files_different
+"Common subdirectories: b/both_dirs
+",'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
@@ -272,9 +272,9 @@ CONTEXT_LINE_NUMBERS
+b_only_file
' ])
end
- it 'Chef::ChefFS::CommandLine.diff_print(/) in name-only mode' do
+ it "Chef::ChefFS::CommandLine.diff_print(/) in name-only mode" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, :name_only) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, :name_only) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
@@ -298,9 +298,9 @@ CONTEXT_LINE_NUMBERS
"b/file_in_a_dir_in_b\n",
])
end
- it 'Chef::ChefFS::CommandLine.diff_print(/) in name-status mode' do
+ it "Chef::ChefFS::CommandLine.diff_print(/) in name-status mode" do
results = []
- Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, :name_status) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, :name_status) do |diff|
results << remove_os_differences(diff)
end
expect(results).to match_array([
diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb
index ed5f314605..91970cd23c 100644
--- a/spec/unit/chef_fs/file_pattern_spec.rb
+++ b/spec/unit/chef_fs/file_pattern_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/file_pattern'
+require "spec_helper"
+require "chef/chef_fs/file_pattern"
describe Chef::ChefFS::FilePattern do
def p(str)
@@ -26,455 +26,455 @@ describe Chef::ChefFS::FilePattern do
# Different kinds of patterns
context 'with empty pattern ""' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('') }
- it 'match?' do
- expect(pattern.match?('')).to be_truthy
- expect(pattern.match?('/')).to be_falsey
- expect(pattern.match?('a')).to be_falsey
- expect(pattern.match?('a/b')).to be_falsey
+ let(:pattern) { Chef::ChefFS::FilePattern.new("") }
+ it "match?" do
+ expect(pattern.match?("")).to be_truthy
+ expect(pattern.match?("/")).to be_falsey
+ expect(pattern.match?("a")).to be_falsey
+ expect(pattern.match?("a/b")).to be_falsey
end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('')
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("")
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('')).to be_falsey
- expect(pattern.could_match_children?('a/b')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("")).to be_falsey
+ expect(pattern.could_match_children?("a/b")).to be_falsey
end
end
context 'with root pattern "/"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/') }
- it 'match?' do
- expect(pattern.match?('/')).to be_truthy
- expect(pattern.match?('')).to be_falsey
- expect(pattern.match?('a')).to be_falsey
- expect(pattern.match?('/a')).to be_falsey
- end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('/')
- end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('')).to be_falsey
- expect(pattern.could_match_children?('/')).to be_falsey
- expect(pattern.could_match_children?('a')).to be_falsey
- expect(pattern.could_match_children?('a/b')).to be_falsey
- expect(pattern.could_match_children?('/a')).to be_falsey
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/") }
+ it "match?" do
+ expect(pattern.match?("/")).to be_truthy
+ expect(pattern.match?("")).to be_falsey
+ expect(pattern.match?("a")).to be_falsey
+ expect(pattern.match?("/a")).to be_falsey
+ end
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("/")
+ end
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("")).to be_falsey
+ expect(pattern.could_match_children?("/")).to be_falsey
+ expect(pattern.could_match_children?("a")).to be_falsey
+ expect(pattern.could_match_children?("a/b")).to be_falsey
+ expect(pattern.could_match_children?("/a")).to be_falsey
end
end
context 'with simple pattern "abc"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('abc') }
- it 'match?' do
- expect(pattern.match?('abc')).to be_truthy
- expect(pattern.match?('a')).to be_falsey
- expect(pattern.match?('abcd')).to be_falsey
- expect(pattern.match?('/abc')).to be_falsey
- expect(pattern.match?('')).to be_falsey
- expect(pattern.match?('/')).to be_falsey
- end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('abc')
- end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc')).to be_falsey
+ let(:pattern) { Chef::ChefFS::FilePattern.new("abc") }
+ it "match?" do
+ expect(pattern.match?("abc")).to be_truthy
+ expect(pattern.match?("a")).to be_falsey
+ expect(pattern.match?("abcd")).to be_falsey
+ expect(pattern.match?("/abc")).to be_falsey
+ expect(pattern.match?("")).to be_falsey
+ expect(pattern.match?("/")).to be_falsey
+ end
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("abc")
+ end
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc")).to be_falsey
end
end
context 'with simple pattern "/abc"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc') }
- it 'match?' do
- expect(pattern.match?('/abc')).to be_truthy
- expect(pattern.match?('abc')).to be_falsey
- expect(pattern.match?('a')).to be_falsey
- expect(pattern.match?('abcd')).to be_falsey
- expect(pattern.match?('')).to be_falsey
- expect(pattern.match?('/')).to be_falsey
- end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('/abc')
- end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc')).to be_falsey
- expect(pattern.could_match_children?('/')).to be_truthy
- expect(pattern.could_match_children?('')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc") }
+ it "match?" do
+ expect(pattern.match?("/abc")).to be_truthy
+ expect(pattern.match?("abc")).to be_falsey
+ expect(pattern.match?("a")).to be_falsey
+ expect(pattern.match?("abcd")).to be_falsey
+ expect(pattern.match?("")).to be_falsey
+ expect(pattern.match?("/")).to be_falsey
+ end
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("/abc")
+ end
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc")).to be_falsey
+ expect(pattern.could_match_children?("/")).to be_truthy
+ expect(pattern.could_match_children?("")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
end
end
context 'with simple pattern "abc/def/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('abc/def/ghi') }
- it 'match?' do
- expect(pattern.match?('abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/def/ghi')).to be_falsey
- expect(pattern.match?('abc')).to be_falsey
- expect(pattern.match?('abc/def')).to be_falsey
- end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('abc/def/ghi')
- end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('abc')).to be_truthy
- expect(pattern.could_match_children?('xyz')).to be_falsey
- expect(pattern.could_match_children?('/abc')).to be_falsey
- expect(pattern.could_match_children?('abc/def')).to be_truthy
- expect(pattern.could_match_children?('abc/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc/def/ghi')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('abc')).to eq('def')
- expect(pattern.exact_child_name_under('abc/def')).to eq('ghi')
+ let(:pattern) { Chef::ChefFS::FilePattern.new("abc/def/ghi") }
+ it "match?" do
+ expect(pattern.match?("abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/def/ghi")).to be_falsey
+ expect(pattern.match?("abc")).to be_falsey
+ expect(pattern.match?("abc/def")).to be_falsey
+ end
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("abc/def/ghi")
+ end
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("abc")).to be_truthy
+ expect(pattern.could_match_children?("xyz")).to be_falsey
+ expect(pattern.could_match_children?("/abc")).to be_falsey
+ expect(pattern.could_match_children?("abc/def")).to be_truthy
+ expect(pattern.could_match_children?("abc/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc/def/ghi")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("abc")).to eq("def")
+ expect(pattern.exact_child_name_under("abc/def")).to eq("ghi")
end
end
context 'with simple pattern "/abc/def/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/def/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('abc/def/ghi')).to be_falsey
- expect(pattern.match?('/abc')).to be_falsey
- expect(pattern.match?('/abc/def')).to be_falsey
- end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('/abc/def/ghi')
- end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc/def')).to be_truthy
- expect(pattern.could_match_children?('/abc/xyz')).to be_falsey
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq('def')
- expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi')
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/def/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("abc/def/ghi")).to be_falsey
+ expect(pattern.match?("/abc")).to be_falsey
+ expect(pattern.match?("/abc/def")).to be_falsey
+ end
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("/abc/def/ghi")
+ end
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def")).to be_truthy
+ expect(pattern.could_match_children?("/abc/xyz")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq("def")
+ expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi")
end
end
context 'with simple pattern "a\*\b"', :skip => (Chef::Platform.windows?) do
let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') }
- it 'match?' do
- expect(pattern.match?('a*b')).to be_truthy
- expect(pattern.match?('ab')).to be_falsey
- expect(pattern.match?('acb')).to be_falsey
- expect(pattern.match?('ab')).to be_falsey
+ it "match?" do
+ expect(pattern.match?("a*b")).to be_truthy
+ expect(pattern.match?("ab")).to be_falsey
+ expect(pattern.match?("acb")).to be_falsey
+ expect(pattern.match?("ab")).to be_falsey
end
- it 'exact_path' do
- expect(pattern.exact_path).to eq('a*b')
+ it "exact_path" do
+ expect(pattern.exact_path).to eq("a*b")
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('a/*b')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("a/*b")).to be_falsey
end
end
context 'with star pattern "/abc/*/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/*/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/ghi')).to be_falsey
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/*/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/ghi")).to be_falsey
end
- it 'exact_path' do
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc/def')).to be_truthy
- expect(pattern.could_match_children?('/abc/xyz')).to be_truthy
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def")).to be_truthy
+ expect(pattern.could_match_children?("/abc/xyz")).to be_truthy
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey
end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi')
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi")
end
end
context 'with star pattern "/abc/d*f/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d*f/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/dxf/ghi')).to be_truthy
- expect(pattern.match?('/abc/df/ghi')).to be_truthy
- expect(pattern.match?('/abc/dxyzf/ghi')).to be_truthy
- expect(pattern.match?('/abc/d/ghi')).to be_falsey
- expect(pattern.match?('/abc/f/ghi')).to be_falsey
- expect(pattern.match?('/abc/ghi')).to be_falsey
- expect(pattern.match?('/abc/xyz/ghi')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d*f/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/dxf/ghi")).to be_truthy
+ expect(pattern.match?("/abc/df/ghi")).to be_truthy
+ expect(pattern.match?("/abc/dxyzf/ghi")).to be_truthy
+ expect(pattern.match?("/abc/d/ghi")).to be_falsey
+ expect(pattern.match?("/abc/f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/ghi")).to be_falsey
+ expect(pattern.match?("/abc/xyz/ghi")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc/def')).to be_truthy
- expect(pattern.could_match_children?('/abc/xyz')).to be_falsey
- expect(pattern.could_match_children?('/abc/dxyzf')).to be_truthy
- expect(pattern.could_match_children?('/abc/df')).to be_truthy
- expect(pattern.could_match_children?('/abc/d')).to be_falsey
- expect(pattern.could_match_children?('/abc/f')).to be_falsey
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi')
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def")).to be_truthy
+ expect(pattern.could_match_children?("/abc/xyz")).to be_falsey
+ expect(pattern.could_match_children?("/abc/dxyzf")).to be_truthy
+ expect(pattern.could_match_children?("/abc/df")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d")).to be_falsey
+ expect(pattern.could_match_children?("/abc/f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi")
end
end
context 'with star pattern "/abc/d??f/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d??f/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/deef/ghi')).to be_truthy
- expect(pattern.match?('/abc/deeef/ghi')).to be_falsey
- expect(pattern.match?('/abc/def/ghi')).to be_falsey
- expect(pattern.match?('/abc/df/ghi')).to be_falsey
- expect(pattern.match?('/abc/d/ghi')).to be_falsey
- expect(pattern.match?('/abc/f/ghi')).to be_falsey
- expect(pattern.match?('/abc/ghi')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d??f/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/deef/ghi")).to be_truthy
+ expect(pattern.match?("/abc/deeef/ghi")).to be_falsey
+ expect(pattern.match?("/abc/def/ghi")).to be_falsey
+ expect(pattern.match?("/abc/df/ghi")).to be_falsey
+ expect(pattern.match?("/abc/d/ghi")).to be_falsey
+ expect(pattern.match?("/abc/f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/ghi")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc/deef')).to be_truthy
- expect(pattern.could_match_children?('/abc/deeef')).to be_falsey
- expect(pattern.could_match_children?('/abc/def')).to be_falsey
- expect(pattern.could_match_children?('/abc/df')).to be_falsey
- expect(pattern.could_match_children?('/abc/d')).to be_falsey
- expect(pattern.could_match_children?('/abc/f')).to be_falsey
- expect(pattern.could_match_children?('/abc/deef/ghi')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/deef')).to eq('ghi')
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc/deef")).to be_truthy
+ expect(pattern.could_match_children?("/abc/deeef")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def")).to be_falsey
+ expect(pattern.could_match_children?("/abc/df")).to be_falsey
+ expect(pattern.could_match_children?("/abc/d")).to be_falsey
+ expect(pattern.could_match_children?("/abc/f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/deef/ghi")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/deef")).to eq("ghi")
end
end
context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', :skip => (Chef::Platform.windows?) do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d[a-z][0-9]f/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/de1f/ghi')).to be_truthy
- expect(pattern.match?('/abc/deef/ghi')).to be_falsey
- expect(pattern.match?('/abc/d11f/ghi')).to be_falsey
- expect(pattern.match?('/abc/de11f/ghi')).to be_falsey
- expect(pattern.match?('/abc/dee1f/ghi')).to be_falsey
- expect(pattern.match?('/abc/df/ghi')).to be_falsey
- expect(pattern.match?('/abc/d/ghi')).to be_falsey
- expect(pattern.match?('/abc/f/ghi')).to be_falsey
- expect(pattern.match?('/abc/ghi')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/de1f/ghi")).to be_truthy
+ expect(pattern.match?("/abc/deef/ghi")).to be_falsey
+ expect(pattern.match?("/abc/d11f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/de11f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/dee1f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/df/ghi")).to be_falsey
+ expect(pattern.match?("/abc/d/ghi")).to be_falsey
+ expect(pattern.match?("/abc/f/ghi")).to be_falsey
+ expect(pattern.match?("/abc/ghi")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/xyz')).to be_falsey
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/abc/de1f')).to be_truthy
- expect(pattern.could_match_children?('/abc/deef')).to be_falsey
- expect(pattern.could_match_children?('/abc/d11f')).to be_falsey
- expect(pattern.could_match_children?('/abc/de11f')).to be_falsey
- expect(pattern.could_match_children?('/abc/dee1f')).to be_falsey
- expect(pattern.could_match_children?('/abc/def')).to be_falsey
- expect(pattern.could_match_children?('/abc/df')).to be_falsey
- expect(pattern.could_match_children?('/abc/d')).to be_falsey
- expect(pattern.could_match_children?('/abc/f')).to be_falsey
- expect(pattern.could_match_children?('/abc/de1f/ghi')).to be_falsey
- end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/de1f')).to eq('ghi')
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/abc/de1f")).to be_truthy
+ expect(pattern.could_match_children?("/abc/deef")).to be_falsey
+ expect(pattern.could_match_children?("/abc/d11f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/de11f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/dee1f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/def")).to be_falsey
+ expect(pattern.could_match_children?("/abc/df")).to be_falsey
+ expect(pattern.could_match_children?("/abc/d")).to be_falsey
+ expect(pattern.could_match_children?("/abc/f")).to be_falsey
+ expect(pattern.could_match_children?("/abc/de1f/ghi")).to be_falsey
+ end
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/de1f")).to eq("ghi")
end
end
context 'with star pattern "/abc/**/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/**/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy
- expect(pattern.match?('/abc/ghi')).to be_falsey
- expect(pattern.match?('/abcdef/d/ghi')).to be_falsey
- expect(pattern.match?('/abc/d/defghi')).to be_falsey
- expect(pattern.match?('/xyz')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/**/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy
+ expect(pattern.match?("/abc/ghi")).to be_falsey
+ expect(pattern.match?("/abcdef/d/ghi")).to be_falsey
+ expect(pattern.match?("/abc/d/defghi")).to be_falsey
+ expect(pattern.match?("/xyz")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/abc/d')).to be_truthy
- expect(pattern.could_match_children?('/abc/d/e')).to be_truthy
- expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/xyz')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d/e")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/def')).to eq(nil)
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/def")).to eq(nil)
end
end
context 'with star pattern "/abc**/ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc**/ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy
- expect(pattern.match?('/abc/ghi')).to be_truthy
- expect(pattern.match?('/abcdef/ghi')).to be_truthy
- expect(pattern.match?('/abc/defghi')).to be_falsey
- expect(pattern.match?('/xyz')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc**/ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy
+ expect(pattern.match?("/abc/ghi")).to be_truthy
+ expect(pattern.match?("/abcdef/ghi")).to be_truthy
+ expect(pattern.match?("/abc/defghi")).to be_falsey
+ expect(pattern.match?("/xyz")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/abcdef')).to be_truthy
- expect(pattern.could_match_children?('/abc/d/e')).to be_truthy
- expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy
- expect(pattern.could_match_children?('abc')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/abcdef")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d/e")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy
+ expect(pattern.could_match_children?("abc")).to be_falsey
end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/def')).to eq(nil)
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/def")).to eq(nil)
end
end
context 'with star pattern "/abc/**ghi"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/**ghi') }
- it 'match?' do
- expect(pattern.match?('/abc/def/ghi')).to be_truthy
- expect(pattern.match?('/abc/def/ghi/ghi')).to be_truthy
- expect(pattern.match?('/abc/def/ghi/jkl')).to be_falsey
- expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy
- expect(pattern.match?('/abc/ghi')).to be_truthy
- expect(pattern.match?('/abcdef/ghi')).to be_falsey
- expect(pattern.match?('/abc/defghi')).to be_truthy
- expect(pattern.match?('/xyz')).to be_falsey
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/**ghi") }
+ it "match?" do
+ expect(pattern.match?("/abc/def/ghi")).to be_truthy
+ expect(pattern.match?("/abc/def/ghi/ghi")).to be_truthy
+ expect(pattern.match?("/abc/def/ghi/jkl")).to be_falsey
+ expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy
+ expect(pattern.match?("/abc/ghi")).to be_truthy
+ expect(pattern.match?("/abcdef/ghi")).to be_falsey
+ expect(pattern.match?("/abc/defghi")).to be_truthy
+ expect(pattern.match?("/xyz")).to be_falsey
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
- it 'could_match_children?' do
- expect(pattern.could_match_children?('/abc')).to be_truthy
- expect(pattern.could_match_children?('/abcdef')).to be_falsey
- expect(pattern.could_match_children?('/abc/d/e')).to be_truthy
- expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy
- expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy
- expect(pattern.could_match_children?('abc')).to be_falsey
- expect(pattern.could_match_children?('/xyz')).to be_falsey
+ it "could_match_children?" do
+ expect(pattern.could_match_children?("/abc")).to be_truthy
+ expect(pattern.could_match_children?("/abcdef")).to be_falsey
+ expect(pattern.could_match_children?("/abc/d/e")).to be_truthy
+ expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy
+ expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy
+ expect(pattern.could_match_children?("abc")).to be_falsey
+ expect(pattern.could_match_children?("/xyz")).to be_falsey
end
- it 'exact_child_name_under' do
- expect(pattern.exact_child_name_under('/')).to eq('abc')
- expect(pattern.exact_child_name_under('/abc')).to eq(nil)
- expect(pattern.exact_child_name_under('/abc/def')).to eq(nil)
+ it "exact_child_name_under" do
+ expect(pattern.exact_child_name_under("/")).to eq("abc")
+ expect(pattern.exact_child_name_under("/abc")).to eq(nil)
+ expect(pattern.exact_child_name_under("/abc/def")).to eq(nil)
end
end
context 'with star pattern "a**b**c"' do
- let(:pattern) { Chef::ChefFS::FilePattern.new('a**b**c') }
- it 'match?' do
- expect(pattern.match?('axybzwc')).to be_truthy
- expect(pattern.match?('abc')).to be_truthy
- expect(pattern.match?('axyzwc')).to be_falsey
- expect(pattern.match?('ac')).to be_falsey
- expect(pattern.match?('a/x/y/b/z/w/c')).to be_truthy
- end
- it 'exact_path' do
+ let(:pattern) { Chef::ChefFS::FilePattern.new("a**b**c") }
+ it "match?" do
+ expect(pattern.match?("axybzwc")).to be_truthy
+ expect(pattern.match?("abc")).to be_truthy
+ expect(pattern.match?("axyzwc")).to be_falsey
+ expect(pattern.match?("ac")).to be_falsey
+ expect(pattern.match?("a/x/y/b/z/w/c")).to be_truthy
+ end
+ it "exact_path" do
expect(pattern.exact_path).to be_nil
end
end
- context 'normalization tests' do
- it 'handles trailing slashes' do
- expect(p('abc/').normalized_pattern).to eq('abc')
- expect(p('abc/').exact_path).to eq('abc')
- expect(p('abc/').match?('abc')).to be_truthy
- expect(p('//').normalized_pattern).to eq('/')
- expect(p('//').exact_path).to eq('/')
- expect(p('//').match?('/')).to be_truthy
- expect(p('/./').normalized_pattern).to eq('/')
- expect(p('/./').exact_path).to eq('/')
- expect(p('/./').match?('/')).to be_truthy
- end
- it 'handles multiple slashes' do
- expect(p('abc//def').normalized_pattern).to eq('abc/def')
- expect(p('abc//def').exact_path).to eq('abc/def')
- expect(p('abc//def').match?('abc/def')).to be_truthy
- expect(p('abc//').normalized_pattern).to eq('abc')
- expect(p('abc//').exact_path).to eq('abc')
- expect(p('abc//').match?('abc')).to be_truthy
- end
- it 'handles dot' do
- expect(p('abc/./def').normalized_pattern).to eq('abc/def')
- expect(p('abc/./def').exact_path).to eq('abc/def')
- expect(p('abc/./def').match?('abc/def')).to be_truthy
- expect(p('./abc/def').normalized_pattern).to eq('abc/def')
- expect(p('./abc/def').exact_path).to eq('abc/def')
- expect(p('./abc/def').match?('abc/def')).to be_truthy
- expect(p('/.').normalized_pattern).to eq('/')
- expect(p('/.').exact_path).to eq('/')
- expect(p('/.').match?('/')).to be_truthy
- end
- it 'handles dotdot' do
- expect(p('abc/../def').normalized_pattern).to eq('def')
- expect(p('abc/../def').exact_path).to eq('def')
- expect(p('abc/../def').match?('def')).to be_truthy
- expect(p('abc/def/../..').normalized_pattern).to eq('')
- expect(p('abc/def/../..').exact_path).to eq('')
- expect(p('abc/def/../..').match?('')).to be_truthy
- expect(p('/*/../def').normalized_pattern).to eq('/def')
- expect(p('/*/../def').exact_path).to eq('/def')
- expect(p('/*/../def').match?('/def')).to be_truthy
- expect(p('/*/*/../def').normalized_pattern).to eq('/*/def')
- expect(p('/*/*/../def').exact_path).to be_nil
- expect(p('/*/*/../def').match?('/abc/def')).to be_truthy
- expect(p('/abc/def/../..').normalized_pattern).to eq('/')
- expect(p('/abc/def/../..').exact_path).to eq('/')
- expect(p('/abc/def/../..').match?('/')).to be_truthy
- expect(p('abc/../../def').normalized_pattern).to eq('../def')
- expect(p('abc/../../def').exact_path).to eq('../def')
- expect(p('abc/../../def').match?('../def')).to be_truthy
- end
- it 'handles dotdot with double star' do
- expect(p('abc**/def/../ghi').exact_path).to be_nil
- expect(p('abc**/def/../ghi').match?('abc/ghi')).to be_truthy
- expect(p('abc**/def/../ghi').match?('abc/x/y/z/ghi')).to be_truthy
- expect(p('abc**/def/../ghi').match?('ghi')).to be_falsey
- end
- it 'raises error on dotdot with overlapping double star' do
- expect { Chef::ChefFS::FilePattern.new('abc/**/../def').exact_path }.to raise_error(ArgumentError)
- expect { Chef::ChefFS::FilePattern.new('abc/**/abc/../../def').exact_path }.to raise_error(ArgumentError)
- end
- it 'handles leading dotdot' do
- expect(p('../abc/def').exact_path).to eq('../abc/def')
- expect(p('../abc/def').match?('../abc/def')).to be_truthy
- expect(p('/../abc/def').exact_path).to eq('/abc/def')
- expect(p('/../abc/def').match?('/abc/def')).to be_truthy
- expect(p('..').exact_path).to eq('..')
- expect(p('..').match?('..')).to be_truthy
- expect(p('/..').exact_path).to eq('/')
- expect(p('/..').match?('/')).to be_truthy
+ context "normalization tests" do
+ it "handles trailing slashes" do
+ expect(p("abc/").normalized_pattern).to eq("abc")
+ expect(p("abc/").exact_path).to eq("abc")
+ expect(p("abc/").match?("abc")).to be_truthy
+ expect(p("//").normalized_pattern).to eq("/")
+ expect(p("//").exact_path).to eq("/")
+ expect(p("//").match?("/")).to be_truthy
+ expect(p("/./").normalized_pattern).to eq("/")
+ expect(p("/./").exact_path).to eq("/")
+ expect(p("/./").match?("/")).to be_truthy
+ end
+ it "handles multiple slashes" do
+ expect(p("abc//def").normalized_pattern).to eq("abc/def")
+ expect(p("abc//def").exact_path).to eq("abc/def")
+ expect(p("abc//def").match?("abc/def")).to be_truthy
+ expect(p("abc//").normalized_pattern).to eq("abc")
+ expect(p("abc//").exact_path).to eq("abc")
+ expect(p("abc//").match?("abc")).to be_truthy
+ end
+ it "handles dot" do
+ expect(p("abc/./def").normalized_pattern).to eq("abc/def")
+ expect(p("abc/./def").exact_path).to eq("abc/def")
+ expect(p("abc/./def").match?("abc/def")).to be_truthy
+ expect(p("./abc/def").normalized_pattern).to eq("abc/def")
+ expect(p("./abc/def").exact_path).to eq("abc/def")
+ expect(p("./abc/def").match?("abc/def")).to be_truthy
+ expect(p("/.").normalized_pattern).to eq("/")
+ expect(p("/.").exact_path).to eq("/")
+ expect(p("/.").match?("/")).to be_truthy
+ end
+ it "handles dotdot" do
+ expect(p("abc/../def").normalized_pattern).to eq("def")
+ expect(p("abc/../def").exact_path).to eq("def")
+ expect(p("abc/../def").match?("def")).to be_truthy
+ expect(p("abc/def/../..").normalized_pattern).to eq("")
+ expect(p("abc/def/../..").exact_path).to eq("")
+ expect(p("abc/def/../..").match?("")).to be_truthy
+ expect(p("/*/../def").normalized_pattern).to eq("/def")
+ expect(p("/*/../def").exact_path).to eq("/def")
+ expect(p("/*/../def").match?("/def")).to be_truthy
+ expect(p("/*/*/../def").normalized_pattern).to eq("/*/def")
+ expect(p("/*/*/../def").exact_path).to be_nil
+ expect(p("/*/*/../def").match?("/abc/def")).to be_truthy
+ expect(p("/abc/def/../..").normalized_pattern).to eq("/")
+ expect(p("/abc/def/../..").exact_path).to eq("/")
+ expect(p("/abc/def/../..").match?("/")).to be_truthy
+ expect(p("abc/../../def").normalized_pattern).to eq("../def")
+ expect(p("abc/../../def").exact_path).to eq("../def")
+ expect(p("abc/../../def").match?("../def")).to be_truthy
+ end
+ it "handles dotdot with double star" do
+ expect(p("abc**/def/../ghi").exact_path).to be_nil
+ expect(p("abc**/def/../ghi").match?("abc/ghi")).to be_truthy
+ expect(p("abc**/def/../ghi").match?("abc/x/y/z/ghi")).to be_truthy
+ expect(p("abc**/def/../ghi").match?("ghi")).to be_falsey
+ end
+ it "raises error on dotdot with overlapping double star" do
+ expect { Chef::ChefFS::FilePattern.new("abc/**/../def").exact_path }.to raise_error(ArgumentError)
+ expect { Chef::ChefFS::FilePattern.new("abc/**/abc/../../def").exact_path }.to raise_error(ArgumentError)
+ end
+ it "handles leading dotdot" do
+ expect(p("../abc/def").exact_path).to eq("../abc/def")
+ expect(p("../abc/def").match?("../abc/def")).to be_truthy
+ expect(p("/../abc/def").exact_path).to eq("/abc/def")
+ expect(p("/../abc/def").match?("/abc/def")).to be_truthy
+ expect(p("..").exact_path).to eq("..")
+ expect(p("..").match?("..")).to be_truthy
+ expect(p("/..").exact_path).to eq("/")
+ expect(p("/..").match?("/")).to be_truthy
end
end
diff --git a/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb
index b98ec12161..56967eaa63 100644
--- a/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb
+++ b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb
@@ -16,19 +16,19 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/file_system/chef_server/cookbook_subdir'
+require "spec_helper"
+require "chef/chef_fs/file_system/chef_server/cookbook_subdir"
describe Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir do
let(:root) do
- Chef::ChefFS::FileSystem::BaseFSDir.new('', nil)
+ Chef::ChefFS::FileSystem::BaseFSDir.new("", nil)
end
let(:cookbook_subdir) do
- Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir.new('test', root, false, true)
+ Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir.new("test", root, false, true)
end
- it 'can get child' do
- cookbook_subdir.child('test')
+ it "can get child" do
+ cookbook_subdir.child("test")
end
end
diff --git a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
index 142755a4f1..f3054d8158 100644
--- a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
+++ b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/file_system/operation_failed_error'
+require "spec_helper"
+require "chef/chef_fs/file_system/operation_failed_error"
describe Chef::ChefFS::FileSystem::OperationFailedError do
- context 'message' do
+ context "message" do
let(:error_message) { 'HTTP error writing: 400 "Bad Request"' }
- context 'has a cause attribute and HTTP result code is 400' do
- it 'include error cause' do
+ context "has a cause attribute and HTTP result code is 400" do
+ it "include error cause" do
allow_message_expectations_on_nil
response_body = '{"error":["Invalid key test in request body"]}'
allow(@response).to receive(:code).and_return("400")
@@ -36,8 +36,8 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do
end
end
- context 'does not have a cause attribute' do
- it 'does not include error cause' do
+ context "does not have a cause attribute" do
+ it "does not include error cause" do
expect {
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self), error_message
}.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, error_message)
diff --git a/spec/unit/chef_fs/file_system_spec.rb b/spec/unit/chef_fs/file_system_spec.rb
index a765be61db..8b1c90b91c 100644
--- a/spec/unit/chef_fs/file_system_spec.rb
+++ b/spec/unit/chef_fs/file_system_spec.rb
@@ -16,132 +16,132 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/file_system'
-require 'chef/chef_fs/file_pattern'
+require "spec_helper"
+require "chef/chef_fs/file_system"
+require "chef/chef_fs/file_pattern"
describe Chef::ChefFS::FileSystem do
include FileSystemSupport
- context 'with empty filesystem' do
- let(:fs) { memory_fs('', {}) }
+ context "with empty filesystem" do
+ let(:fs) { memory_fs("", {}) }
- context 'list' do
- it '/' do
- list_should_yield_paths(fs, '/', '/')
+ context "list" do
+ it "/" do
+ list_should_yield_paths(fs, "/", "/")
end
- it '/a' do
- list_should_yield_paths(fs, '/a', '/a')
+ it "/a" do
+ list_should_yield_paths(fs, "/a", "/a")
end
- it '/a/b' do
- list_should_yield_paths(fs, '/a/b', '/a/b')
+ it "/a/b" do
+ list_should_yield_paths(fs, "/a/b", "/a/b")
end
- it '/*' do
- list_should_yield_paths(fs, '/*', '/')
+ it "/*" do
+ list_should_yield_paths(fs, "/*", "/")
end
end
- context 'resolve_path' do
- it '/' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').path).to eq('/')
+ context "resolve_path" do
+ it "/" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").path).to eq("/")
end
- it 'nonexistent /a' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a').path).to eq('/a')
+ it "nonexistent /a" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a").path).to eq("/a")
end
- it 'nonexistent /a/b' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/b').path).to eq('/a/b')
+ it "nonexistent /a/b" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/b").path).to eq("/a/b")
end
end
end
- context 'with a populated filesystem' do
+ context "with a populated filesystem" do
let(:fs) {
- memory_fs('', {
+ memory_fs("", {
:a => {
:aa => {
- :c => '',
- :zz => '',
+ :c => "",
+ :zz => "",
},
:ab => {
- :c => ''
+ :c => ""
},
},
- :x => '',
+ :x => "",
:y => {},
},)
}
- context 'list' do
- it '/**' do
- list_should_yield_paths(fs, '/**', '/', '/a', '/x', '/y', '/a/aa', '/a/aa/c', '/a/aa/zz', '/a/ab', '/a/ab/c')
+ context "list" do
+ it "/**" do
+ list_should_yield_paths(fs, "/**", "/", "/a", "/x", "/y", "/a/aa", "/a/aa/c", "/a/aa/zz", "/a/ab", "/a/ab/c")
end
- it '/' do
- list_should_yield_paths(fs, '/', '/')
+ it "/" do
+ list_should_yield_paths(fs, "/", "/")
end
- it '/*' do
- list_should_yield_paths(fs, '/*', '/', '/a', '/x', '/y')
+ it "/*" do
+ list_should_yield_paths(fs, "/*", "/", "/a", "/x", "/y")
end
- it '/*/*' do
- list_should_yield_paths(fs, '/*/*', '/a/aa', '/a/ab')
+ it "/*/*" do
+ list_should_yield_paths(fs, "/*/*", "/a/aa", "/a/ab")
end
- it '/*/*/*' do
- list_should_yield_paths(fs, '/*/*/*', '/a/aa/c', '/a/aa/zz', '/a/ab/c')
+ it "/*/*/*" do
+ list_should_yield_paths(fs, "/*/*/*", "/a/aa/c", "/a/aa/zz", "/a/ab/c")
end
- it '/*/*/?' do
- list_should_yield_paths(fs, '/*/*/?', '/a/aa/c', '/a/ab/c')
+ it "/*/*/?" do
+ list_should_yield_paths(fs, "/*/*/?", "/a/aa/c", "/a/ab/c")
end
- it '/a/*/c' do
- list_should_yield_paths(fs, '/a/*/c', '/a/aa/c', '/a/ab/c')
+ it "/a/*/c" do
+ list_should_yield_paths(fs, "/a/*/c", "/a/aa/c", "/a/ab/c")
end
- it '/**b/c' do
- list_should_yield_paths(fs, '/**b/c', '/a/ab/c')
+ it "/**b/c" do
+ list_should_yield_paths(fs, "/**b/c", "/a/ab/c")
end
- it '/a/ab/c' do
+ it "/a/ab/c" do
no_blocking_calls_allowed
- list_should_yield_paths(fs, '/a/ab/c', '/a/ab/c')
+ list_should_yield_paths(fs, "/a/ab/c", "/a/ab/c")
end
- it 'nonexistent /a/ab/blah' do
+ it "nonexistent /a/ab/blah" do
no_blocking_calls_allowed
- list_should_yield_paths(fs, '/a/ab/blah', '/a/ab/blah')
+ list_should_yield_paths(fs, "/a/ab/blah", "/a/ab/blah")
end
- it 'nonexistent /a/ab/blah/bjork' do
+ it "nonexistent /a/ab/blah/bjork" do
no_blocking_calls_allowed
- list_should_yield_paths(fs, '/a/ab/blah/bjork', '/a/ab/blah/bjork')
+ list_should_yield_paths(fs, "/a/ab/blah/bjork", "/a/ab/blah/bjork")
end
end
- context 'resolve_path' do
+ context "resolve_path" do
before(:each) do
no_blocking_calls_allowed
end
- it 'resolves /' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').path).to eq('/')
+ it "resolves /" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").path).to eq("/")
end
- it 'resolves /x' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/x').path).to eq('/x')
+ it "resolves /x" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/x").path).to eq("/x")
end
- it 'resolves /a' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a').path).to eq('/a')
+ it "resolves /a" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a").path).to eq("/a")
end
- it 'resolves /a/aa' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/aa').path).to eq('/a/aa')
+ it "resolves /a/aa" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/aa").path).to eq("/a/aa")
end
- it 'resolves /a/aa/zz' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/aa/zz').path).to eq('/a/aa/zz')
+ it "resolves /a/aa/zz" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/aa/zz").path).to eq("/a/aa/zz")
end
- it 'resolves nonexistent /q/x/w' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/q/x/w').path).to eq('/q/x/w')
+ it "resolves nonexistent /q/x/w" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/q/x/w").path).to eq("/q/x/w")
end
end
- context 'empty?' do
- it 'is not empty /' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').empty?).to be false
+ context "empty?" do
+ it "is not empty /" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").empty?).to be false
end
- it 'is empty /y' do
- expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/y').empty?).to be true
+ it "is empty /y" do
+ expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/y").empty?).to be true
end
it 'is not a directory and can\'t be tested /x' do
- expect { Chef::ChefFS::FileSystem.resolve_path(fs, '/x').empty? }.to raise_error(NoMethodError)
+ expect { Chef::ChefFS::FileSystem.resolve_path(fs, "/x").empty? }.to raise_error(NoMethodError)
end
end
end
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 3ca4ee0092..0d667098a8 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'chef/chef_fs/parallelizer'
+require "spec_helper"
+require "chef/chef_fs/parallelizer"
describe Chef::ChefFS::Parallelizer do
before :each do
@@ -14,7 +14,7 @@ describe Chef::ChefFS::Parallelizer do
parallelizer.kill
end
- context 'With a Parallelizer with 5 threads' do
+ context "With a Parallelizer with 5 threads" do
let :parallelizer do
Chef::ChefFS::Parallelizer.new(5)
end
@@ -44,7 +44,7 @@ describe Chef::ChefFS::Parallelizer do
it "10 sleep(0.2)s complete within 0.5 seconds" do
expect(parallelize(1.upto(10), :ordered => false) do |i|
sleep 0.2
- 'x'
+ "x"
end.to_a).to eq(%w(x x x x x x x x x x))
expect(elapsed_time).to be < 0.5
end
@@ -62,28 +62,28 @@ describe Chef::ChefFS::Parallelizer do
it "An exception in input is passed through but does NOT stop processing" do
input = TestEnumerable.new(0.5,0.3,0.1) do
- raise 'hi'
+ raise "hi"
end
enum = parallelize(input, :ordered => false) { |x| sleep(x); x }
results = []
- expect { enum.each { |value| results << value } }.to raise_error 'hi'
+ expect { enum.each { |value| results << value } }.to raise_error "hi"
expect(results).to eq([ 0.1, 0.3, 0.5 ])
expect(elapsed_time).to be < 0.6
end
it "Exceptions in output are raised after all processing is done" do
processed = 0
- enum = parallelize([1,2,'x',3], :ordered => false) do |x|
- if x == 'x'
+ enum = parallelize([1,2,"x",3], :ordered => false) do |x|
+ if x == "x"
sleep 0.1
- raise 'hi'
+ raise "hi"
end
sleep 0.2
processed += 1
x
end
results = []
- expect { enum.each { |value| results << value } }.to raise_error 'hi'
+ expect { enum.each { |value| results << value } }.to raise_error "hi"
expect(results.sort).to eq([ 1, 2, 3 ])
expect(elapsed_time).to be < 0.3
expect(processed).to eq(3)
@@ -91,16 +91,16 @@ 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|
- if x == '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'
+ raise "hi"
end
sleep(x)
processed += 1
x
end
- expect { parallelized.to_a }.to raise_error 'hi'
+ expect { parallelized.to_a }.to raise_error "hi"
expect(processed).to eq(4)
end
end
@@ -116,7 +116,7 @@ describe Chef::ChefFS::Parallelizer do
it "10 sleep(0.2)s complete within 0.5 seconds" do
expect(parallelize(1.upto(10), :ordered => true) do |i|
sleep 0.2
- 'x'
+ "x"
end.to_a).to eq(%w(x x x x x x x x x x))
expect(elapsed_time).to be < 0.5
end
@@ -134,28 +134,28 @@ describe Chef::ChefFS::Parallelizer do
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
- raise 'hi'
+ raise "hi"
end
results = []
enum = parallelize(input) { |x| sleep(x); x }
- expect { enum.each { |value| results << value } }.to raise_error 'hi'
+ expect { enum.each { |value| results << value } }.to raise_error "hi"
expect(elapsed_time).to be < 0.6
expect(results).to eq([ 0.5, 0.3, 0.1 ])
end
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|
- if x == 'x'
+ enum = parallelize([1,2,"x",3]) do |x|
+ if x == "x"
sleep(0.1)
- raise 'hi'
+ raise "hi"
end
sleep(0.2)
processed += 1
x
end
results = []
- expect { enum.each { |value| results << value } }.to raise_error 'hi'
+ expect { enum.each { |value| results << value } }.to raise_error "hi"
expect(results).to eq([ 1, 2 ])
expect(elapsed_time).to be < 0.3
expect(processed).to eq(3)
@@ -163,16 +163,16 @@ 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|
- if x == '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'
+ raise "hi"
end
sleep(x)
processed += 1
x
end
- expect { parallelized.to_a }.to raise_error 'hi'
+ expect { parallelized.to_a }.to raise_error "hi"
expect(processed).to eq(4)
end
end
diff --git a/spec/unit/chef_fs/path_util_spec.rb b/spec/unit/chef_fs/path_util_spec.rb
index 42eb126dfb..02d0de8857 100644
--- a/spec/unit/chef_fs/path_util_spec.rb
+++ b/spec/unit/chef_fs/path_util_spec.rb
@@ -16,93 +16,93 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/chef_fs/path_utils'
+require "spec_helper"
+require "chef/chef_fs/path_utils"
describe Chef::ChefFS::PathUtils do
- context 'invoking join' do
- it 'joins well-behaved distinct path elements' do
- expect(Chef::ChefFS::PathUtils.join('a', 'b', 'c')).to eq('a/b/c')
+ context "invoking join" do
+ it "joins well-behaved distinct path elements" do
+ expect(Chef::ChefFS::PathUtils.join("a", "b", "c")).to eq("a/b/c")
end
- it 'strips extraneous slashes in the middle of paths' do
- expect(Chef::ChefFS::PathUtils.join('a/', '/b', '/c/')).to eq('a/b/c')
- expect(Chef::ChefFS::PathUtils.join('a/', '/b', '///c/')).to eq('a/b/c')
+ it "strips extraneous slashes in the middle of paths" do
+ expect(Chef::ChefFS::PathUtils.join("a/", "/b", "/c/")).to eq("a/b/c")
+ expect(Chef::ChefFS::PathUtils.join("a/", "/b", "///c/")).to eq("a/b/c")
end
- it 'preserves the whether the first element was absolute or not' do
- expect(Chef::ChefFS::PathUtils.join('/a/', '/b', 'c/')).to eq('/a/b/c')
- expect(Chef::ChefFS::PathUtils.join('///a/', '/b', 'c/')).to eq('/a/b/c')
+ it "preserves the whether the first element was absolute or not" do
+ expect(Chef::ChefFS::PathUtils.join("/a/", "/b", "c/")).to eq("/a/b/c")
+ expect(Chef::ChefFS::PathUtils.join("///a/", "/b", "c/")).to eq("/a/b/c")
end
end
- context 'invoking is_absolute?' do
- it 'confirms that paths starting with / are absolute' do
- expect(Chef::ChefFS::PathUtils.is_absolute?('/foo/bar/baz')).to be true
- expect(Chef::ChefFS::PathUtils.is_absolute?('/foo')).to be true
+ context "invoking is_absolute?" do
+ it "confirms that paths starting with / are absolute" do
+ expect(Chef::ChefFS::PathUtils.is_absolute?("/foo/bar/baz")).to be true
+ expect(Chef::ChefFS::PathUtils.is_absolute?("/foo")).to be true
end
- it 'confirms that paths starting with // are absolute even though that looks like some windows network path' do
- expect(Chef::ChefFS::PathUtils.is_absolute?('//foo/bar/baz')).to be true
+ it "confirms that paths starting with // are absolute even though that looks like some windows network path" do
+ expect(Chef::ChefFS::PathUtils.is_absolute?("//foo/bar/baz")).to be true
end
- it 'confirms that root is indeed absolute' do
- expect(Chef::ChefFS::PathUtils.is_absolute?('/')).to be true
+ it "confirms that root is indeed absolute" do
+ expect(Chef::ChefFS::PathUtils.is_absolute?("/")).to be true
end
- it 'confirms that paths starting without / are relative' do
- expect(Chef::ChefFS::PathUtils.is_absolute?('foo/bar/baz')).to be false
- expect(Chef::ChefFS::PathUtils.is_absolute?('a')).to be false
+ it "confirms that paths starting without / are relative" do
+ expect(Chef::ChefFS::PathUtils.is_absolute?("foo/bar/baz")).to be false
+ expect(Chef::ChefFS::PathUtils.is_absolute?("a")).to be false
end
- it 'returns false for an empty path.' do
- expect(Chef::ChefFS::PathUtils.is_absolute?('')).to be false
+ it "returns false for an empty path." do
+ expect(Chef::ChefFS::PathUtils.is_absolute?("")).to be false
end
end
- context 'invoking realest_path' do
+ context "invoking realest_path" do
let(:good_path) { File.dirname(__FILE__) }
let(:parent_path) { File.dirname(good_path) }
- it 'handles paths with no wildcards or globs' do
+ it "handles paths with no wildcards or globs" do
expect(Chef::ChefFS::PathUtils.realest_path(good_path)).to eq(File.expand_path(good_path))
end
- it 'handles paths with .. and .' do
- expect(Chef::ChefFS::PathUtils.realest_path(good_path+'/../.')).to eq(File.expand_path(parent_path))
+ it "handles paths with .. and ." do
+ expect(Chef::ChefFS::PathUtils.realest_path(good_path+"/../.")).to eq(File.expand_path(parent_path))
end
- it 'handles paths with *' do
- expect(Chef::ChefFS::PathUtils.realest_path(good_path + '/*/foo')).to eq(File.expand_path(good_path + '/*/foo'))
+ it "handles paths with *" do
+ expect(Chef::ChefFS::PathUtils.realest_path(good_path + "/*/foo")).to eq(File.expand_path(good_path + "/*/foo"))
end
- it 'handles directories that do not exist' do
- expect(Chef::ChefFS::PathUtils.realest_path(good_path + '/something/or/other')).to eq(File.expand_path(good_path + '/something/or/other'))
+ it "handles directories that do not exist" do
+ expect(Chef::ChefFS::PathUtils.realest_path(good_path + "/something/or/other")).to eq(File.expand_path(good_path + "/something/or/other"))
end
- it 'handles root correctly' do
+ it "handles root correctly" do
if Chef::Platform.windows?
- expect(Chef::ChefFS::PathUtils.realest_path('C:/')).to eq('C:/')
+ expect(Chef::ChefFS::PathUtils.realest_path("C:/")).to eq("C:/")
else
- expect(Chef::ChefFS::PathUtils.realest_path('/')).to eq('/')
+ expect(Chef::ChefFS::PathUtils.realest_path("/")).to eq("/")
end
end
end
- context 'invoking descendant_path' do
- it 'handles paths with various casing on windows' do
+ context "invoking descendant_path" do
+ it "handles paths with various casing on windows" do
allow(Chef::ChefFS).to receive(:windows?) { true }
- expect(Chef::ChefFS::PathUtils.descendant_path('C:/ab/b/c', 'C:/AB/B')).to eq('c')
- expect(Chef::ChefFS::PathUtils.descendant_path('C:/ab/b/c', 'c:/ab/B')).to eq('c')
+ expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "C:/AB/B")).to eq("c")
+ expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "c:/ab/B")).to eq("c")
end
- it 'returns nil if the path does not have the given ancestor' do
- expect(Chef::ChefFS::PathUtils.descendant_path('/D/E/F', '/A/B/C')).to be_nil
- expect(Chef::ChefFS::PathUtils.descendant_path('/A/B/D', '/A/B/C')).to be_nil
+ it "returns nil if the path does not have the given ancestor" do
+ expect(Chef::ChefFS::PathUtils.descendant_path("/D/E/F", "/A/B/C")).to be_nil
+ expect(Chef::ChefFS::PathUtils.descendant_path("/A/B/D", "/A/B/C")).to be_nil
end
- it 'returns blank if the ancestor equals the path' do
- expect(Chef::ChefFS::PathUtils.descendant_path('/A/B/D', '/A/B/D')).to eq('')
+ it "returns blank if the ancestor equals the path" do
+ expect(Chef::ChefFS::PathUtils.descendant_path("/A/B/D", "/A/B/D")).to eq("")
end
end
end
diff --git a/spec/unit/chef_spec.rb b/spec/unit/chef_spec.rb
index 8a8d6c6c68..b2be2af5f3 100644
--- a/spec/unit/chef_spec.rb
+++ b/spec/unit/chef_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef do
it "should have a version defined" do
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index ca7440061e..e41c092ae5 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -18,13 +18,13 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'spec/support/shared/context/client'
-require 'spec/support/shared/examples/client'
+require "spec_helper"
+require "spec/support/shared/context/client"
+require "spec/support/shared/examples/client"
-require 'chef/run_context'
-require 'chef/server_api'
-require 'rbconfig'
+require "chef/run_context"
+require "chef/server_api"
+require "rbconfig"
class FooError < RuntimeError
end
@@ -157,7 +157,7 @@ describe Chef::Client do
context "when an override run list is given" do
it "permits spaces in overriding run list" do
- Chef::Client.new(nil, :override_runlist => 'role[a], role[b]')
+ Chef::Client.new(nil, :override_runlist => "role[a], role[b]")
end
describe "calling run" do
@@ -220,7 +220,7 @@ describe Chef::Client do
describe "when converge completes successfully" do
include_context "a client run"
include_context "converge completed"
- context 'when audit mode is enabled' do
+ context "when audit mode is enabled" do
describe "when audit phase errors" do
include_context "audit phase failed with error"
include_examples "a completed run with audit failure" do
@@ -500,7 +500,7 @@ describe Chef::Client do
allow_any_instance_of(Chef::RunLock).to receive(:save_pid).and_raise(NoMethodError)
end
- context 'when audit mode is enabled' do
+ context "when audit mode is enabled" do
before do
Chef::Config[:audit_mode] = :enabled
end
@@ -513,7 +513,7 @@ describe Chef::Client do
end
end
- context 'when audit mode is disabled' do
+ context "when audit mode is disabled" do
before do
Chef::Config[:audit_mode] = :disabled
end
diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb
index 1b4a4903a8..417087d9a3 100644
--- a/spec/unit/config_fetcher_spec.rb
+++ b/spec/unit/config_fetcher_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'chef/config_fetcher'
+require "spec_helper"
+require "chef/config_fetcher"
describe Chef::ConfigFetcher do
let(:valid_json) { Chef::JSONCompat.to_json({:a=>"b"}) }
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 8d155c61ab..68cb589251 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-require 'chef/config'
+require "chef/config"
RSpec.describe Chef::Config do
diff --git a/spec/unit/cookbook/chefignore_spec.rb b/spec/unit/cookbook/chefignore_spec.rb
index 9f5546de28..9d81981dcf 100644
--- a/spec/unit/cookbook/chefignore_spec.rb
+++ b/spec/unit/cookbook/chefignore_spec.rb
@@ -15,11 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::Chefignore do
before do
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'cookbooks'))
+ @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "cookbooks"))
end
it "loads the globs in the chefignore file" do
@@ -32,14 +32,14 @@ describe Chef::Cookbook::Chefignore do
end
it "determines if a file is ignored" do
- expect(@chefignore.ignored?('ignored')).to be_truthy
- expect(@chefignore.ignored?('recipes/ignoreme.rb')).to be_truthy
- expect(@chefignore.ignored?('recipes/dontignoreme.rb')).to be_falsey
+ expect(@chefignore.ignored?("ignored")).to be_truthy
+ expect(@chefignore.ignored?("recipes/ignoreme.rb")).to be_truthy
+ expect(@chefignore.ignored?("recipes/dontignoreme.rb")).to be_falsey
end
context "when using the single cookbook pattern" do
before do
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'standalone_cookbook'))
+ @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "standalone_cookbook"))
end
it "loads the globs in the chefignore file" do
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 23ffc21f7f..1a0c1ddf94 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::CookbookVersionLoader do
before do
@@ -58,8 +58,8 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
it "loads libraries" do
- expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap.rb'))
- expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap/version.rb'))
+ expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap.rb"))
+ expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap/version.rb"))
end
it "loads static files in the files/ dir" do
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb
index 8bf2d3c2a3..2420718dea 100644
--- a/spec/unit/cookbook/file_vendor_spec.rb
+++ b/spec/unit/cookbook/file_vendor_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::FileVendor do
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 48b0b2a059..ad4863ad3d 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/cookbook/metadata'
+require "spec_helper"
+require "chef/cookbook/metadata"
describe Chef::Cookbook::Metadata do
@@ -142,11 +142,11 @@ describe Chef::Cookbook::Metadata do
end
it "has an empty source_url string" do
- expect(metadata.source_url).to eq('')
+ expect(metadata.source_url).to eq("")
end
it "has an empty issues_url string" do
- expect(metadata.issues_url).to eq('')
+ expect(metadata.issues_url).to eq("")
end
it "is not private" do
@@ -189,7 +189,7 @@ describe Chef::Cookbook::Metadata do
describe "adding a supported platform" do
it "should support adding a supported platform with a single expression" do
metadata.supports("ubuntu", ">= 8.04")
- expect(metadata.platforms["ubuntu"]).to eq('>= 8.04')
+ expect(metadata.platforms["ubuntu"]).to eq(">= 8.04")
end
end
@@ -311,17 +311,17 @@ describe Chef::Cookbook::Metadata do
end
it "strips out self-dependencies", :chef_lt_13_only do
- metadata.name('foo')
+ metadata.name("foo")
expect(Chef::Log).to receive(:warn).with(
"Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)."
)
- metadata.depends('foo')
+ metadata.depends("foo")
expect(metadata.dependencies).to eql({})
end
it "errors on self-dependencies", :chef_gte_13_only do
- metadata.name('foo')
- expect { metadata.depends('foo') }.to raise_error
+ metadata.name("foo")
+ expect { metadata.depends("foo") }.to raise_error
# FIXME: add the error type
end
end
@@ -462,10 +462,10 @@ describe Chef::Cookbook::Metadata do
attrs = {
"display_name" => "MySQL Databases",
"description" => "Description of MySQL",
- "choice" => ['dedicated', 'shared'],
+ "choice" => ["dedicated", "shared"],
"calculated" => false,
- "type" => 'string',
- "required" => 'recommended',
+ "type" => "string",
+ "required" => "recommended",
"recipes" => [ "mysql::server", "mysql::master" ],
"default" => [ ],
"source_url" => "http://example.com",
@@ -519,16 +519,16 @@ describe Chef::Cookbook::Metadata do
metadata.attribute("db/mysql/databases", :privacy => false)
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :privacy => 'true')
+ metadata.attribute("db/mysql/databases", :privacy => "true")
}.to raise_error(ArgumentError)
end
it "should not accept anything but an array of strings for choice" do
expect {
- metadata.attribute("db/mysql/databases", :choice => ['dedicated', 'shared'])
+ metadata.attribute("db/mysql/databases", :choice => ["dedicated", "shared"])
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :choice => [10, 'shared'])
+ metadata.attribute("db/mysql/databases", :choice => [10, "shared"])
}.to raise_error(ArgumentError)
expect {
metadata.attribute("db/mysql/databases", :choice => Hash.new)
@@ -586,13 +586,13 @@ describe Chef::Cookbook::Metadata do
it "should let required be required, recommended or optional" do
expect {
- metadata.attribute("db/mysql/databases", :required => 'required')
+ metadata.attribute("db/mysql/databases", :required => "required")
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :required => 'recommended')
+ metadata.attribute("db/mysql/databases", :required => "recommended")
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :required => 'optional')
+ metadata.attribute("db/mysql/databases", :required => "optional")
}.not_to raise_error
end
@@ -612,7 +612,7 @@ describe Chef::Cookbook::Metadata do
it "should set required to 'optional' by default" do
metadata.attribute("db/mysql/databases", {})
- expect(metadata.attributes["db/mysql/databases"][:required]).to eq('optional')
+ expect(metadata.attributes["db/mysql/databases"][:required]).to eq("optional")
end
it "should make sure recipes is an array" do
@@ -742,7 +742,7 @@ describe Chef::Cookbook::Metadata do
describe "recipes" do
let(:cookbook) do
- c = Chef::CookbookVersion.new('test_cookbook')
+ c = Chef::CookbookVersion.new("test_cookbook")
c.recipe_files = [ "default.rb", "enlighten.rb" ]
c
end
@@ -894,13 +894,13 @@ describe Chef::Cookbook::Metadata do
it "should transform deprecated greater than syntax for :#{to_check}" do
@hash[to_check.to_s]["foo::bar"] = ">> 0.2"
deserial = Chef::Cookbook::Metadata.from_hash(@hash)
- expect(deserial.send(to_check)["foo::bar"]).to eq('> 0.2')
+ expect(deserial.send(to_check)["foo::bar"]).to eq("> 0.2")
end
it "should transform deprecated less than syntax for :#{to_check}" do
@hash[to_check.to_s]["foo::bar"] = "<< 0.2"
deserial = Chef::Cookbook::Metadata.from_hash(@hash)
- expect(deserial.send(to_check)["foo::bar"]).to eq('< 0.2')
+ expect(deserial.send(to_check)["foo::bar"]).to eq("< 0.2")
end
it "should ignore multiple dependency constraints for :#{to_check}" do
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 30ddaad1d7..17803a8392 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require 'chef/cookbook/synchronizer'
-require 'chef/cookbook_version'
+require "spec_helper"
+require "chef/cookbook/synchronizer"
+require "chef/cookbook_version"
describe Chef::CookbookCacheCleaner do
describe "when cleaning up unused cookbook components" do
@@ -164,8 +164,8 @@ describe Chef::CookbookSynchronizer do
valid_cached_cb_files = %w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb}
obsolete_cb_files = %w{cookbooks/old1/recipes/default.rb cookbooks/old2/recipes/default.rb}
expect(file_cache).to receive(:find).with(File.join(%w{cookbooks ** {*,.*}})).and_return(valid_cached_cb_files + obsolete_cb_files)
- expect(file_cache).to receive(:delete).with('cookbooks/old1/recipes/default.rb')
- expect(file_cache).to receive(:delete).with('cookbooks/old2/recipes/default.rb')
+ expect(file_cache).to receive(:delete).with("cookbooks/old1/recipes/default.rb")
+ expect(file_cache).to receive(:delete).with("cookbooks/old2/recipes/default.rb")
allow(synchronizer).to receive(:cache).and_return(file_cache)
synchronizer.remove_old_cookbooks
end
@@ -186,7 +186,7 @@ describe Chef::CookbookSynchronizer do
expect(synchronizer).to receive(:have_cookbook?).with("valid1").at_least(:once).and_return(true)
# valid2 is a cookbook not in our run_list (we're simulating an override run_list where valid2 needs to be preserved)
expect(synchronizer).to receive(:have_cookbook?).with("valid2").at_least(:once).and_return(false)
- expect(file_cache).to receive(:delete).with('cookbooks/valid1/recipes/deleted.rb')
+ expect(file_cache).to receive(:delete).with("cookbooks/valid1/recipes/deleted.rb")
expect(synchronizer).to receive(:cookbook_segment).with("valid1", "recipes").at_least(:once).and_return([ { "path" => "recipes/default.rb" }])
allow(synchronizer).to receive(:cache).and_return(file_cache)
synchronizer.remove_deleted_files
@@ -224,7 +224,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb recipe
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc123').
+ with("http://chef.example.com/abc123").
and_return(cookbook_a_default_recipe_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
@@ -234,7 +234,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc456').
+ with("http://chef.example.com/abc456").
and_return(cookbook_a_default_attribute_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
@@ -252,7 +252,7 @@ describe Chef::CookbookSynchronizer do
and_return(false)
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/megaman.conf').
+ with("http://chef.example.com/megaman.conf").
and_return(cookbook_a_file_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
@@ -261,7 +261,7 @@ describe Chef::CookbookSynchronizer do
and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/ffffff').
+ with("http://chef.example.com/ffffff").
and_return(cookbook_a_template_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
@@ -281,7 +281,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb recipe
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc123').
+ with("http://chef.example.com/abc123").
and_return(cookbook_a_default_recipe_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
@@ -297,7 +297,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc456').
+ with("http://chef.example.com/abc456").
and_return(cookbook_a_default_attribute_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
@@ -323,7 +323,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy megaman.conf
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/megaman.conf').
+ with("http://chef.example.com/megaman.conf").
and_return(cookbook_a_file_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
@@ -334,7 +334,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy apache2.conf template
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/ffffff').
+ with("http://chef.example.com/ffffff").
and_return(cookbook_a_template_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
@@ -442,7 +442,7 @@ describe Chef::CookbookSynchronizer do
it "does not fetch templates or cookbook files" do
# Implicitly tested in previous test; this test is just for behavior specification.
expect(server_api).not_to receive(:streaming_request).
- with('http://chef.example.com/ffffff')
+ with("http://chef.example.com/ffffff")
synchronizer.sync_cookbooks
end
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index efdb5b7926..ad270ae712 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
require "chef/cookbook/syntax_check"
describe Chef::Cookbook::SyntaxCheck do
@@ -24,7 +24,7 @@ describe Chef::Cookbook::SyntaxCheck do
allow(ChefConfig).to receive(:windows?) { false }
end
- let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap') }
+ let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks", "openldap") }
let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) }
let(:open_ldap_cookbook_files) do
@@ -46,10 +46,10 @@ describe Chef::Cookbook::SyntaxCheck do
@original_log_level = Chef::Log.level
Chef::Log.level = :warn # suppress "Syntax OK" messages
- @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)}
- @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, 'recipes', f) }
+ @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)}
+ @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
helper_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
@@ -77,18 +77,18 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "creates a syntax checker given the cookbook name and cookbook_path" do
- syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, 'cookbooks'))
+ syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, "cookbooks"))
expect(syntax_check.cookbook_path).to eq(cookbook_path)
expect(syntax_check.ruby_files.sort).to eq(open_ldap_cookbook_files.sort)
end
context "when using a standalone cookbook" do
- let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'standalone_cookbook') }
+ let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "standalone_cookbook") }
it "creates a syntax checker given the cookbook name and cookbook_path for a standalone cookbook" do
syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:standalone_cookbook, CHEF_SPEC_DATA)
expect(syntax_check.cookbook_path).to eq(cookbook_path)
- expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, 'recipes/default.rb')])
+ expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, "recipes/default.rb")])
end
end
@@ -128,13 +128,13 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "removes a ruby file from the list of untested files after it is marked as validated" do
- recipe = File.join(cookbook_path, 'recipes', 'default.rb')
+ recipe = File.join(cookbook_path, "recipes", "default.rb")
syntax_check.validated(recipe)
expect(syntax_check.untested_ruby_files).not_to include(recipe)
end
it "removes a template file from the list of untested files after it is marked as validated" do
- template = File.join(cookbook_path, 'templates', 'default', 'test.erb')
+ template = File.join(cookbook_path, "templates", "default", "test.erb")
syntax_check.validated(template)
expect(syntax_check.untested_template_files).not_to include(template)
end
@@ -151,7 +151,7 @@ describe Chef::Cookbook::SyntaxCheck do
describe "and a file has a syntax error" do
before do
- cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'borken')
+ cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "borken")
syntax_check.cookbook_path.replace(cookbook_path)
end
@@ -160,9 +160,9 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "does not remove the invalid file from the list of untested files" do
- expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb'))
+ expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb"))
syntax_check.validate_ruby_files
- expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb'))
+ expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb"))
end
it "indicates that a template file has a syntax error" do
@@ -170,7 +170,7 @@ describe Chef::Cookbook::SyntaxCheck do
end
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.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)
end
@@ -178,10 +178,10 @@ describe Chef::Cookbook::SyntaxCheck do
describe "and an ignored file has a syntax error" do
before do
- cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'ignorken')
+ cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "ignorken")
Chef::Config[:cookbook_path] = File.dirname(cookbook_path)
syntax_check.cookbook_path.replace(cookbook_path)
- @ruby_files = [File.join(cookbook_path, 'metadata.rb'), File.join(cookbook_path, 'recipes/default.rb')]
+ @ruby_files = [File.join(cookbook_path, "metadata.rb"), File.join(cookbook_path, "recipes/default.rb")]
end
it "shows that ignored ruby files do not require a syntax check" do
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index 8d4413105d..36060cde99 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::CookbookLoader do
before do
@@ -223,7 +223,7 @@ describe Chef::CookbookLoader do
end
it "should not load the cookbook again when accessed" do
- expect(cookbook_loader).not_to receive('load_cookbook')
+ expect(cookbook_loader).not_to receive("load_cookbook")
cookbook_loader["openldap"]
end
diff --git a/spec/unit/cookbook_manifest_spec.rb b/spec/unit/cookbook_manifest_spec.rb
index f985942e09..8b7cf1fc7e 100644
--- a/spec/unit/cookbook_manifest_spec.rb
+++ b/spec/unit/cookbook_manifest_spec.rb
@@ -15,10 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/cookbook_manifest'
-require 'chef/digester'
-require 'pathname'
+require "spec_helper"
+require "chef/cookbook_manifest"
+require "chef/digester"
+require "pathname"
describe Chef::CookbookManifest do
@@ -32,7 +32,7 @@ describe Chef::CookbookManifest do
end
end
- let(:cookbook_root) { '/tmp/blah' }
+ let(:cookbook_root) { "/tmp/blah" }
let(:cookbook_version) do
Chef::CookbookVersion.new("tatft", cookbook_root).tap do |c|
@@ -62,7 +62,7 @@ describe Chef::CookbookManifest do
end
it "delegates `root_paths' to cookbook_version" do
- expect(cookbook_manifest.root_paths).to eq(['/tmp/blah'])
+ expect(cookbook_manifest.root_paths).to eq(["/tmp/blah"])
end
it "delegates `metadata' to cookbook_version" do
@@ -121,18 +121,18 @@ describe Chef::CookbookManifest do
context "when given a cookbook with files" do
- let(:cookbook_root) { File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft') }
-
- let(:attribute_filenames) { Dir[File.join(cookbook_root, 'attributes', '**', '*.rb')] }
- let(:definition_filenames) { Dir[File.join(cookbook_root, 'definitions', '**', '*.rb')] }
- let(:file_filenames) { Dir[File.join(cookbook_root, 'files', '**', '*.tgz')] }
- let(:recipe_filenames) { Dir[File.join(cookbook_root, 'recipes', '**', '*.rb')] }
- let(:template_filenames) { Dir[File.join(cookbook_root, 'templates', '**', '*.erb')] }
- let(:library_filenames) { Dir[File.join(cookbook_root, 'libraries', '**', '*.rb')] }
- let(:resource_filenames) { Dir[File.join(cookbook_root, 'resources', '**', '*.rb')] }
- let(:provider_filenames) { Dir[File.join(cookbook_root, 'providers', '**', '*.rb')] }
- let(:root_filenames) { Array(File.join(cookbook_root, 'README.rdoc')) }
- let(:metadata_filenames) { Array(File.join(cookbook_root, 'metadata.json')) }
+ let(:cookbook_root) { File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "tatft") }
+
+ let(:attribute_filenames) { Dir[File.join(cookbook_root, "attributes", "**", "*.rb")] }
+ let(:definition_filenames) { Dir[File.join(cookbook_root, "definitions", "**", "*.rb")] }
+ let(:file_filenames) { Dir[File.join(cookbook_root, "files", "**", "*.tgz")] }
+ let(:recipe_filenames) { Dir[File.join(cookbook_root, "recipes", "**", "*.rb")] }
+ let(:template_filenames) { Dir[File.join(cookbook_root, "templates", "**", "*.erb")] }
+ let(:library_filenames) { Dir[File.join(cookbook_root, "libraries", "**", "*.rb")] }
+ let(:resource_filenames) { Dir[File.join(cookbook_root, "resources", "**", "*.rb")] }
+ let(:provider_filenames) { Dir[File.join(cookbook_root, "providers", "**", "*.rb")] }
+ let(:root_filenames) { Array(File.join(cookbook_root, "README.rdoc")) }
+ let(:metadata_filenames) { Array(File.join(cookbook_root, "metadata.json")) }
let(:match_md5) { /[0-9a-f]{32}/ }
diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb
index 07069810dd..bc01962a01 100644
--- a/spec/unit/cookbook_site_streaming_uploader_spec.rb
+++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/cookbook_site_streaming_uploader'
+require "chef/cookbook_site_streaming_uploader"
class FakeTempfile
def initialize(basename)
@@ -39,7 +39,7 @@ describe Chef::CookbookSiteStreamingUploader do
describe "create_build_dir" do
before(:each) do
- @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, 'cookbooks'))
+ @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
@loader = Chef::CookbookLoader.new(@cookbook_repo)
@loader.load_cookbooks
allow(File).to receive(:unlink)
@@ -47,7 +47,7 @@ describe Chef::CookbookSiteStreamingUploader do
it "should create the cookbook tmp dir" do
cookbook = @loader[:openldap]
- files_count = Dir.glob(File.join(@cookbook_repo, cookbook.name.to_s, '**', '*'), File::FNM_DOTMATCH).count { |file| File.file?(file) }
+ files_count = Dir.glob(File.join(@cookbook_repo, cookbook.name.to_s, "**", "*"), File::FNM_DOTMATCH).count { |file| File.file?(file) }
expect(Tempfile).to receive(:new).with("chef-#{cookbook.name}-build").and_return(FakeTempfile.new("chef-#{cookbook.name}-build"))
expect(FileUtils).to receive(:mkdir_p).exactly(files_count + 1).times
@@ -61,25 +61,25 @@ describe Chef::CookbookSiteStreamingUploader do
before(:each) do
@uri = "http://cookbooks.dummy.com/api/v1/cookbooks"
- @secret_filename = File.join(CHEF_SPEC_DATA, 'ssl/private_key.pem')
+ @secret_filename = File.join(CHEF_SPEC_DATA, "ssl/private_key.pem")
@rsa_key = File.read(@secret_filename)
- response = Net::HTTPResponse.new('1.0', '200', 'OK')
+ response = Net::HTTPResponse.new("1.0", "200", "OK")
allow_any_instance_of(Net::HTTP).to receive(:request).and_return(response)
end
it "should send an http request" do
expect_any_instance_of(Net::HTTP).to receive(:request)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename)
+ Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
end
it "should read the private key file" do
expect(File).to receive(:read).with(@secret_filename).and_return(@rsa_key)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename)
+ Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
end
it "should add the authentication signed header" do
expect_any_instance_of(Mixlib::Authentication::SigningObject).to receive(:sign).and_return({})
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename)
+ Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
end
it "should be able to send post requests" do
@@ -88,7 +88,7 @@ describe Chef::CookbookSiteStreamingUploader do
expect(Net::HTTP::Post).to receive(:new).once.and_return(post)
expect(Net::HTTP::Put).not_to receive(:new)
expect(Net::HTTP::Get).not_to receive(:new)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename)
+ Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
end
it "should be able to send put requests" do
@@ -97,27 +97,27 @@ describe Chef::CookbookSiteStreamingUploader do
expect(Net::HTTP::Post).not_to receive(:new)
expect(Net::HTTP::Put).to receive(:new).once.and_return(put)
expect(Net::HTTP::Get).not_to receive(:new)
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename)
+ Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename)
end
it "should be able to receive files to attach as argument" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, {
- :myfile => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')), # a dummy file
+ Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ :myfile => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file
})
end
it "should be able to receive strings to attach as argument" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, {
- :mystring => 'Lorem ipsum'
+ Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ :mystring => "Lorem ipsum"
})
end
it "should be able to receive strings and files as argument at the same time" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, {
- :myfile1 => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')),
- :mystring1 => 'Lorem ipsum',
- :myfile2 => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')),
- :mystring2 => 'Dummy text',
+ Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ :myfile1 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
+ :mystring1 => "Lorem ipsum",
+ :myfile2 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
+ :mystring2 => "Dummy text",
})
end
@@ -125,7 +125,7 @@ describe Chef::CookbookSiteStreamingUploader do
describe "StreamPart" do
before(:each) do
- @file = File.new(File.join(CHEF_SPEC_DATA, 'config.rb'))
+ @file = File.new(File.join(CHEF_SPEC_DATA, "config.rb"))
@stream_part = Chef::CookbookSiteStreamingUploader::StreamPart.new(@file, File.size(@file))
end
@@ -147,7 +147,7 @@ describe Chef::CookbookSiteStreamingUploader do
describe "StringPart" do
before(:each) do
- @str = 'What a boring string'
+ @str = "What a boring string"
@string_part = Chef::CookbookSiteStreamingUploader::StringPart.new(@str)
end
@@ -189,7 +189,7 @@ describe Chef::CookbookSiteStreamingUploader do
end
it "should read receiving destination buffer as second argument (CHEF-4456: Ruby 2 compat)" do
- dst_buf = ''
+ dst_buf = ""
@multipart_stream.read(10, dst_buf)
expect(dst_buf).to eql("#{@string1}#{@string2}"[0, 10])
end
diff --git a/spec/unit/cookbook_spec.rb b/spec/unit/cookbook_spec.rb
index f36b031309..dac65a4bf4 100644
--- a/spec/unit/cookbook_spec.rb
+++ b/spec/unit/cookbook_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::CookbookVersion do
# COOKBOOK_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks", "openldap"))
diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb
index b74d08f620..19fce12a52 100644
--- a/spec/unit/cookbook_uploader_spec.rb
+++ b/spec/unit/cookbook_uploader_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::CookbookUploader do
diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb
index ff79573113..6aaf68b251 100644
--- a/spec/unit/cookbook_version_file_specificity_spec.rb
+++ b/spec/unit/cookbook_version_file_specificity_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::CookbookVersion, "file specificity" do
before(:each) do
@@ -444,7 +444,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.host', 'anotherfile2.rb.host'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.host", "anotherfile2.rb.host"])
end
it "should return a list of relative paths based on priority preference: platform & full version" do
@@ -457,7 +457,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"])
end
it "should return a list of relative paths based on priority preference: platform & partial version" do
@@ -470,7 +470,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-partial-version', 'anotherfile2.rb.platform-partial-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-partial-version", "anotherfile2.rb.platform-partial-version"])
end
it "should return a list of relative paths based on priority preference: platform only" do
@@ -483,7 +483,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform', 'anotherfile2.rb.platform'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform", "anotherfile2.rb.platform"])
end
it "should return a list of relative paths based on priority preference: default" do
@@ -496,7 +496,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.default', 'anotherfile2.rb.default'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.default", "anotherfile2.rb.default"])
end
it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 1" do
@@ -509,7 +509,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"])
end
it "should return a list of relative paths based on priority preference: platform & partial version - platform_version variant 1" do
@@ -522,7 +522,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-partial-version', 'anotherfile2.rb.platform-partial-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-partial-version", "anotherfile2.rb.platform-partial-version"])
end
it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 2" do
@@ -535,7 +535,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"])
end
it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 3" do
@@ -548,7 +548,7 @@ describe Chef::CookbookVersion, "file specificity" do
expect(filenames).not_to be_nil
expect(filenames.size).to eq(2)
- expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version'])
+ expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"])
end
end
end
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index e248267eab..856dc00006 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -15,16 +15,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::CookbookVersion do
describe "when first created" do
before do
- @cookbook_version = Chef::CookbookVersion.new("tatft", '/tmp/blah')
+ @cookbook_version = Chef::CookbookVersion.new("tatft", "/tmp/blah")
end
it "has a name" do
- expect(@cookbook_version.name).to eq('tatft')
+ expect(@cookbook_version.name).to eq("tatft")
end
it "has no attribute files" do
@@ -80,26 +80,26 @@ describe Chef::CookbookVersion do
before do
@cookbook = Hash.new { |hash, key| hash[key] = [] }
- @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft')
+ @cookbook_root = File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "tatft")
# Dunno if the paths here are representitive of what is set by CookbookLoader...
- @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')]
- @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')]
- @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.tgz')]
- @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')]
- @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.erb')]
- @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')]
- @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')]
- @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')]
- @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc'))
- @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json'))
+ @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, "attributes", "**", "*.rb")]
+ @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, "definitions", "**", "*.rb")]
+ @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, "files", "**", "*.tgz")]
+ @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, "recipes", "**", "*.rb")]
+ @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, "templates", "**", "*.erb")]
+ @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, "libraries", "**", "*.rb")]
+ @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, "resources", "**", "*.rb")]
+ @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, "providers", "**", "*.rb")]
+ @cookbook[:root_filenames] = Array(File.join(@cookbook_root, "README.rdoc"))
+ @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, "metadata.json"))
end
describe "and a cookbook with the same name" do
before do
# Currently the cookbook loader finds all the files then tells CookbookVersion
# where they are.
- @cookbook_version = Chef::CookbookVersion.new('tatft', @cookbook_root)
+ @cookbook_version = Chef::CookbookVersion.new("tatft", @cookbook_root)
@cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
@cookbook_version.definition_filenames = @cookbook[:definition_filenames]
@@ -154,25 +154,25 @@ describe Chef::CookbookVersion do
end
- describe 'with a cookbook directory named cookbook2 that has unscoped files' do
+ describe "with a cookbook directory named cookbook2 that has unscoped files" do
before do
@cookbook = Hash.new { |hash, key| hash[key] = [] }
- @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'cookbook2')
+ @cookbook_root = File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "cookbook2")
# Dunno if the paths here are representitive of what is set by CookbookLoader...
- @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')]
- @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')]
- @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.*')]
- @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')]
- @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.*')]
- @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')]
- @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')]
- @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')]
- @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc'))
- @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json'))
-
- @cookbook_version = Chef::CookbookVersion.new('cookbook2', @cookbook_root)
+ @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, "attributes", "**", "*.rb")]
+ @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, "definitions", "**", "*.rb")]
+ @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, "files", "**", "*.*")]
+ @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, "recipes", "**", "*.rb")]
+ @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, "templates", "**", "*.*")]
+ @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, "libraries", "**", "*.rb")]
+ @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, "resources", "**", "*.rb")]
+ @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, "providers", "**", "*.rb")]
+ @cookbook[:root_filenames] = Array(File.join(@cookbook_root, "README.rdoc"))
+ @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, "metadata.json"))
+
+ @cookbook_version = Chef::CookbookVersion.new("cookbook2", @cookbook_root)
@cookbook_version.attribute_filenames = @cookbook[:attribute_filenames]
@cookbook_version.definition_filenames = @cookbook[:definition_filenames]
@cookbook_version.recipe_filenames = @cookbook[:recipe_filenames]
@@ -252,8 +252,8 @@ describe Chef::CookbookVersion do
["1.2", "2.1"],
]
examples.each do |smaller, larger|
- sm = Chef::CookbookVersion.new("foo", '/tmp/blah')
- lg = Chef::CookbookVersion.new("foo", '/tmp/blah')
+ sm = Chef::CookbookVersion.new("foo", "/tmp/blah")
+ lg = Chef::CookbookVersion.new("foo", "/tmp/blah")
sm.version = smaller
lg.version = larger
expect(sm).to be < lg
@@ -263,8 +263,8 @@ describe Chef::CookbookVersion do
end
it "should equate versions 1.2 and 1.2.0" do
- a = Chef::CookbookVersion.new("foo", '/tmp/blah')
- b = Chef::CookbookVersion.new("foo", '/tmp/blah')
+ a = Chef::CookbookVersion.new("foo", "/tmp/blah")
+ b = Chef::CookbookVersion.new("foo", "/tmp/blah")
a.version = "1.2"
b.version = "1.2.0"
expect(a).to eq(b)
@@ -272,9 +272,9 @@ describe Chef::CookbookVersion do
it "should not allow you to sort cookbooks with different names" do
- apt = Chef::CookbookVersion.new "apt", '/tmp/blah'
+ apt = Chef::CookbookVersion.new "apt", "/tmp/blah"
apt.version = "1.0"
- god = Chef::CookbookVersion.new "god", '/tmp/blah'
+ god = Chef::CookbookVersion.new "god", "/tmp/blah"
god.version = "2.0"
expect {apt <=> god}.to raise_error(Chef::Exceptions::CookbookVersionNameMismatch)
end
@@ -282,7 +282,7 @@ describe Chef::CookbookVersion do
describe "when you set a version" do
before do
- @cbv = Chef::CookbookVersion.new("version validation", '/tmp/blah')
+ @cbv = Chef::CookbookVersion.new("version validation", "/tmp/blah")
end
it "should accept valid cookbook versions" do
good_versions = %w(1.2 1.2.3 1000.80.50000 0.300.25)
@@ -304,7 +304,7 @@ describe Chef::CookbookVersion do
describe "when deprecation warnings are errors" do
- subject(:cbv) { Chef::CookbookVersion.new("version validation", '/tmp/blah') }
+ subject(:cbv) { Chef::CookbookVersion.new("version validation", "/tmp/blah") }
it "errors on #status and #status=" do
expect { cbv.status = :wat }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
@@ -315,7 +315,7 @@ describe Chef::CookbookVersion do
describe "deprecated features" do
- subject(:cbv) { Chef::CookbookVersion.new("tatft", '/tmp/blah').tap { |c| c.version = "1.2.3" } }
+ subject(:cbv) { Chef::CookbookVersion.new("tatft", "/tmp/blah").tap { |c| c.version = "1.2.3" } }
before do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
@@ -337,7 +337,7 @@ describe Chef::CookbookVersion do
include_examples "to_json equivalent to Chef::JSONCompat.to_json" do
- let(:jsonable) { Chef::CookbookVersion.new("tatft", '/tmp/blah') }
+ let(:jsonable) { Chef::CookbookVersion.new("tatft", "/tmp/blah") }
end
end
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index e020576a23..267fda77b5 100644
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Daemon do
before do
@@ -74,7 +74,7 @@ describe Chef::Daemon do
before do
allow(Chef::Application).to receive(:fatal!).and_return(true)
- Chef::Config[:user] = 'aj'
+ Chef::Config[:user] = "aj"
allow(Dir).to receive(:chdir)
end
@@ -86,7 +86,7 @@ describe Chef::Daemon do
describe "when the user and group options are supplied" do
before do
- Chef::Config[:group] = 'staff'
+ Chef::Config[:group] = "staff"
end
it "should log an appropriate info message" do
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 47042aa7ba..0329264718 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/data_bag_item'
+require "spec_helper"
+require "chef/data_bag_item"
describe Chef::DataBagItem do
let(:data_bag_item) { Chef::DataBagItem.new }
@@ -169,7 +169,7 @@ describe Chef::DataBagItem do
describe "when deserializing from JSON" do
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
- data_bag_item.data_bag('mars_volta')
+ data_bag_item.data_bag("mars_volta")
data_bag_item.raw_data = { "id" => "octahedron", "snooze" => { "finally" => :world_will } }
data_bag_item
}
@@ -200,8 +200,8 @@ describe Chef::DataBagItem do
describe "when converting to a string" do
it "converts to a string in the form data_bag_item[ID]" do
- data_bag_item['id'] = "heart of darkness"
- expect(data_bag_item.to_s).to eq('data_bag_item[heart of darkness]')
+ data_bag_item["id"] = "heart of darkness"
+ expect(data_bag_item.to_s).to eq("data_bag_item[heart of darkness]")
end
it "inspects as data_bag_item[BAG, ID, RAW_DATA]" do
@@ -218,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["id"] = "heart of darkness"
data_bag_item.raw_data = {"id" => "heart_of_darkness", "author" => "Conrad"}
data_bag_item.data_bag("books")
data_bag_item
@@ -263,7 +263,7 @@ describe Chef::DataBagItem do
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
- data_bag_item.data_bag('a_baggy_bag')
+ data_bag_item.data_bag("a_baggy_bag")
data_bag_item.raw_data = { "id" => "some_id" }
data_bag_item
}
@@ -314,8 +314,8 @@ 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})
- item = Chef::DataBagItem.load('users', 'charlie')
+ 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)
end
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index a325b1260f..4e06a31911 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/data_bag'
+require "spec_helper"
+require "chef/data_bag"
describe Chef::DataBag do
before(:each) do
@@ -58,7 +58,7 @@ describe Chef::DataBag do
describe "deserialize" do
before(:each) do
- @data_bag.name('mars_volta')
+ @data_bag.name("mars_volta")
@deserial = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@data_bag))
end
@@ -82,7 +82,7 @@ describe Chef::DataBag do
describe "when saving" do
before do
- @data_bag.name('piggly_wiggly')
+ @data_bag.name("piggly_wiggly")
@rest = double("Chef::ServerAPI")
allow(Chef::ServerAPI).to receive(:new).and_return(@rest)
end
@@ -115,21 +115,21 @@ describe Chef::DataBag do
describe "when loading" do
describe "from an API call" do
before do
- Chef::Config[:chef_server_url] = 'https://myserver.example.com'
- @http_client = double('Chef::ServerAPI')
+ Chef::Config[:chef_server_url] = "https://myserver.example.com"
+ @http_client = double("Chef::ServerAPI")
end
it "should get the data bag from the server" do
- expect(Chef::ServerAPI).to receive(:new).with('https://myserver.example.com').and_return(@http_client)
- expect(@http_client).to receive(:get).with('data/foo')
- Chef::DataBag.load('foo')
+ expect(Chef::ServerAPI).to receive(:new).with("https://myserver.example.com").and_return(@http_client)
+ expect(@http_client).to receive(:get).with("data/foo")
+ Chef::DataBag.load("foo")
end
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'})
- data_bag = Chef::DataBag.load('foo')
- expect(data_bag).to eq({'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"})
end
end
@@ -138,7 +138,7 @@ describe Chef::DataBag do
end
def dir_glob_stub(path, returns = [])
- expect(Dir).to receive(:glob).with(File.join(path, 'foo/*.json')).and_return(returns)
+ expect(Dir).to receive(:glob).with(File.join(path, "foo/*.json")).and_return(returns)
end
shared_examples_for "data bag in solo mode" do |data_bag_path|
@@ -157,7 +157,7 @@ describe Chef::DataBag do
file_dir_stub(path)
dir_glob_stub(path)
end
- Chef::DataBag.load('foo')
+ Chef::DataBag.load("foo")
end
it "should get the data bag from the data_bag_path by symbolic name" do
@@ -172,57 +172,57 @@ describe Chef::DataBag do
@paths.each do |path|
file_dir_stub(path)
if path == @paths.first
- dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')])
+ dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")])
else
dir_glob_stub(path)
end
end
- 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(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" }})
end
it "should raise if data bag has items with similar names but different content" do
@paths.each do |path|
file_dir_stub(path)
item_with_different_content = "{\"id\": \"bar\", \"name\": \"Bob Bar\", \"path\": \"#{path}\"}"
- expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(item_with_different_content)
+ expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(item_with_different_content)
if data_bag_path.is_a?(String)
- dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')])
+ dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")])
item_2_with_different_content = '{"id": "bar", "name": "John Baz"}'
- expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(item_2_with_different_content)
+ expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(item_2_with_different_content)
else
- dir_glob_stub(path, [File.join(path, 'foo/bar.json')])
+ dir_glob_stub(path, [File.join(path, "foo/bar.json")])
end
end
- expect { Chef::DataBag.load('foo') }.to raise_error(Chef::Exceptions::DuplicateDataBagItem)
+ expect { Chef::DataBag.load("foo") }.to raise_error(Chef::Exceptions::DuplicateDataBagItem)
end
it "should return data bag if it has items with similar names and the same content" do
@paths.each do |path|
file_dir_stub(path)
- dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')])
+ dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")])
item_with_same_content = '{"id": "bar", "name": "Bob Bar"}'
- expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(item_with_same_content)
- expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(item_with_same_content)
+ expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(item_with_same_content)
+ 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'} }
+ data_bag = Chef::DataBag.load("foo")
+ test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar"} }
expect(data_bag).to eq(test_data_bag)
end
it "should merge data bag items if there are no conflicts" do
@paths.each_with_index do |path, index|
file_dir_stub(path)
- dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')])
+ dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")])
test_item_with_same_content = '{"id": "bar", "name": "Bob Bar"}'
- expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(test_item_with_same_content)
+ expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(test_item_with_same_content)
test_uniq_item = "{\"id\": \"baz_#{index}\", \"name\": \"John Baz\", \"path\": \"#{path}\"}"
- expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(test_uniq_item)
+ 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'} }
+ data_bag = Chef::DataBag.load("foo")
+ 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
@@ -232,17 +232,17 @@ describe Chef::DataBag do
it "should return the data bag list" do
@paths.each do |path|
file_dir_stub(path)
- expect(Dir).to receive(:glob).and_return([File.join(path, 'foo'), File.join(path, 'bar')])
+ expect(Dir).to receive(:glob).and_return([File.join(path, "foo"), File.join(path, "bar")])
end
data_bag_list = Chef::DataBag.list
- expect(data_bag_list).to eq({ 'bar' => 'bar', 'foo' => 'foo' })
+ expect(data_bag_list).to eq({ "bar" => "bar", "foo" => "foo" })
end
- it 'should raise an error if the configured data_bag_path is invalid' do
+ it "should raise an error if the configured data_bag_path is invalid" do
file_dir_stub(@paths.first, false)
expect {
- Chef::DataBag.load('foo')
+ Chef::DataBag.load("foo")
}.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid"
end
diff --git a/spec/unit/deprecation_spec.rb b/spec/unit/deprecation_spec.rb
index 674de5ec1d..f2f99e9ba6 100644
--- a/spec/unit/deprecation_spec.rb
+++ b/spec/unit/deprecation_spec.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/deprecation/warnings'
+require "spec_helper"
+require "chef/deprecation/warnings"
describe Chef::Deprecation do
# Support code for Chef::Deprecation
def self.class_from_string(str)
- str.split('::').inject(Object) do |mod, class_name|
+ str.split("::").inject(Object) do |mod, class_name|
mod.const_get(class_name)
end
end
@@ -59,33 +59,33 @@ describe Chef::Deprecation do
end
end
- context 'when Chef::Config[:treat_deprecation_warnings_as_errors] is off' do
+ context "when Chef::Config[:treat_deprecation_warnings_as_errors] is off" do
before do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
end
- context 'deprecation warning messages' do
+ context "deprecation warning messages" do
RSpec::Matchers.define_negated_matcher :a_non_empty_array, :be_empty
- it 'should be enabled for deprecated methods' do
+ it "should be enabled for deprecated methods" do
expect(Chef::Log).to receive(:warn).with(a_non_empty_array)
TestClass.new.deprecated_method(10)
end
- it 'should contain stack trace' do
+ it "should contain stack trace" do
expect(Chef::Log).to receive(:warn).with(a_string_including(".rb"))
TestClass.new.deprecated_method(10)
end
end
- it 'deprecated methods should still be called' do
+ it "deprecated methods should still be called" do
test_instance = TestClass.new
test_instance.deprecated_method(10)
expect(test_instance.get_value).to eq(10)
end
end
- it 'should raise when deprecation warnings are treated as errors' do
+ it "should raise when deprecation warnings are treated as errors" do
# rspec should set this
expect(Chef::Config[:treat_deprecation_warnings_as_errors]).to be true
test_instance = TestClass.new
diff --git a/spec/unit/digester_spec.rb b/spec/unit/digester_spec.rb
index 51bcfbdde5..2dbbb5b25f 100644
--- a/spec/unit/digester_spec.rb
+++ b/spec/unit/digester_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Digester do
before(:each) do
@@ -40,7 +40,7 @@ describe Chef::Digester do
it "generates a checksum from a non-file IO object" do
io = StringIO.new("riseofthemachines\nriseofthechefs\n")
- expected_md5 = '0e157ac1e2dd73191b76067fb6b4bceb'
+ expected_md5 = "0e157ac1e2dd73191b76067fb6b4bceb"
expect(@cache.generate_md5_checksum(io)).to eq(expected_md5)
end
diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb
index 28b28e0a7c..df8dbc95c0 100644
--- a/spec/unit/dsl/audit_spec.rb
+++ b/spec/unit/dsl/audit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require 'chef/dsl/audit'
+require "spec_helper"
+require "chef/dsl/audit"
class AuditDSLTester < Chef::Recipe
include Chef::DSL::Audit
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 7bca47af3e..34d4cfdba3 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/dsl/data_query'
+require "spec_helper"
+require "chef/dsl/data_query"
class DataQueryDSLTester
include Chef::DSL::DataQuery
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 438dde126e..61a7d8ca82 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/dsl/platform_introspection'
+require "spec_helper"
+require "chef/dsl/platform_introspection"
class LanguageTester
attr_reader :node
@@ -39,16 +39,16 @@ end
describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
before do
platform_hash = {
- :openbsd => {:default => 'free, functional, secure'},
+ :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',
+ :ubuntu => {"10.04" => "using upstart more", :default => "using init more"},
+ :default => "bork da bork",
}
@platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(platform_hash)
end
it "returns the default value when the platform doesn't match" do
- expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq('bork da bork')
+ expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq("bork da bork")
end
it "returns a value for a platform set as a group" do
@@ -60,20 +60,20 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "returns a value for a specific platform version" do
- node = {:platform => 'ubuntu', :platform_version => '10.04'}
- expect(@platform_specific_value.value_for_node(node)).to eq('using upstart more')
+ 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' }
- expect(@platform_specific_value.value_for_node(node)).to eq('using init more')
+ node = {:platform => "ubuntu", :platform_version => "9.10" }
+ expect(@platform_specific_value.value_for_node(node)).to eq("using init more")
end
it "returns nil if there is no default and no platforms match" do
# this matches the behavior in the original implementation.
# whether or not it's correct is another matter.
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new({})
- expect(platform_specific_value.value_for_node(:platform => 'foo')).to be_nil
+ expect(platform_specific_value.value_for_node(:platform => "foo")).to be_nil
end
it "raises an argument error if the platform hash is not correctly structured" do
@@ -98,7 +98,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
end
it "returns the default value when the platform family doesn't match" do
- expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq('default value')
+ expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq("default value")
end
@@ -124,7 +124,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
it "returns nil if there is no default and no platforms match" do
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue.new({})
- expect(platform_specific_value.value_for_node(:platform_family => 'foo')).to be_nil
+ expect(platform_specific_value.value_for_node(:platform_family => "foo")).to be_nil
end
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 6705820e17..49696f7cc3 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -30,13 +30,13 @@ describe Chef::DSL::RebootPending do
context "platform is windows" do
before do
- allow(recipe).to receive(:platform?).with('windows').and_return(true)
+ allow(recipe).to receive(:platform?).with("windows").and_return(true)
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)
+ 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
@@ -66,16 +66,16 @@ describe Chef::DSL::RebootPending do
context "platform is ubuntu" do
before do
- allow(recipe).to receive(:platform?).with('ubuntu').and_return(true)
+ 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)
+ 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)
+ 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
end
end
diff --git a/spec/unit/dsl/recipe_spec.rb b/spec/unit/dsl/recipe_spec.rb
index dfaad0b73e..108fe81d2b 100644
--- a/spec/unit/dsl/recipe_spec.rb
+++ b/spec/unit/dsl/recipe_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/dsl/recipe'
+require "spec_helper"
+require "chef/dsl/recipe"
RecipeDSLExampleClass = Struct.new(:cookbook_name, :recipe_name)
diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb
index 6508a12b6f..8647b79020 100644
--- a/spec/unit/dsl/regsitry_helper_spec.rb
+++ b/spec/unit/dsl/regsitry_helper_spec.rb
@@ -33,22 +33,22 @@ describe Chef::Resource::RegistryKey do
context "tests registry dsl" do
it "resource can access registry_helper method registry_key_exists" do
- expect(@resource.respond_to?('registry_key_exists?')).to eq(true)
+ expect(@resource.respond_to?("registry_key_exists?")).to eq(true)
end
it "resource can access registry_helper method registry_get_values" do
- expect(@resource.respond_to?('registry_get_values')).to eq(true)
+ expect(@resource.respond_to?("registry_get_values")).to eq(true)
end
it "resource can access registry_helper method registry_has_subkey" do
- expect(@resource.respond_to?('registry_has_subkeys?')).to eq(true)
+ expect(@resource.respond_to?("registry_has_subkeys?")).to eq(true)
end
it "resource can access registry_helper method registry_get_subkeys" do
- expect(@resource.respond_to?('registry_get_subkeys')).to eq(true)
+ expect(@resource.respond_to?("registry_get_subkeys")).to eq(true)
end
it "resource can access registry_helper method registry_value_exists" do
- expect(@resource.respond_to?('registry_value_exists?')).to eq(true)
+ expect(@resource.respond_to?("registry_value_exists?")).to eq(true)
end
it "resource can access registry_helper method data_value_exists" do
- expect(@resource.respond_to?('registry_data_exists?')).to eq(true)
+ expect(@resource.respond_to?("registry_data_exists?")).to eq(true)
end
end
end
diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb
index 581c835290..72ee23c8c9 100644
--- a/spec/unit/dsl/resources_spec.rb
+++ b/spec/unit/dsl/resources_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/dsl/resources'
+require "spec_helper"
+require "chef/dsl/resources"
describe Chef::DSL::Resources do
let(:declared_resources) { [] }
@@ -36,21 +36,21 @@ describe Chef::DSL::Resources do
described_class.remove_resource_dsl(:test_resource)
end
- context 'with a resource added' do
+ context "with a resource added" do
before do
Chef::DSL::Resources.add_resource_dsl(:test_resource)
test_class.new.instance_eval do
- test_resource 'test_name' do
+ test_resource "test_name" 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
+ context "with no resource added" do
subject do
test_class.new.instance_eval do
- test_resource 'test_name' do
+ test_resource "test_name" do
end
end
end
@@ -58,14 +58,14 @@ describe Chef::DSL::Resources do
it { expect { subject }.to raise_error NoMethodError }
end
- context 'with a resource added and removed' do
+ context "with a resource added and removed" do
before do
Chef::DSL::Resources.add_resource_dsl(:test_resource)
Chef::DSL::Resources.remove_resource_dsl(:test_resource)
end
subject do
test_class.new.instance_eval do
- test_resource 'test_name' do
+ test_resource "test_name" do
end
end
end
@@ -73,7 +73,7 @@ describe Chef::DSL::Resources do
it { expect { subject }.to raise_error NoMethodError }
end
- context 'with a nameless resource' do
+ context "with a nameless resource" do
before do
Chef::DSL::Resources.add_resource_dsl(:test_resource)
test_class.new.instance_eval do
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 1090f46745..fc5a7276fb 100644
--- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
+++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/encrypted_data_bag_item/check_encrypted'
+require "spec_helper"
+require "chef/encrypted_data_bag_item/check_encrypted"
class CheckEncryptedTester
include Chef::EncryptedDataBagItem::CheckEncrypted
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb
index 26501684c8..796ad8ff5b 100644
--- a/spec/unit/encrypted_data_bag_item_spec.rb
+++ b/spec/unit/encrypted_data_bag_item_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/encrypted_data_bag_item'
+require "spec_helper"
+require "chef/encrypted_data_bag_item"
module Version0Encryptor
def self.encrypt_value(plaintext_data, key)
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 4a8f94e770..0f3ee17872 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -19,8 +19,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/environment'
+require "spec_helper"
+require "chef/environment"
describe Chef::Environment do
before(:each) do
@@ -73,12 +73,12 @@ describe Chef::Environment do
describe "default attributes" do
it "should let you set the attributes hash explicitly" do
- expect(@environment.default_attributes({ :one => 'two' })).to eq({ :one => 'two' })
+ expect(@environment.default_attributes({ :one => "two" })).to eq({ :one => "two" })
end
it "should let you return the attributes hash" do
- @environment.default_attributes({ :one => 'two' })
- expect(@environment.default_attributes).to eq({ :one => 'two' })
+ @environment.default_attributes({ :one => "two" })
+ expect(@environment.default_attributes).to eq({ :one => "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -88,12 +88,12 @@ describe Chef::Environment do
describe "override attributes" do
it "should let you set the attributes hash explicitly" do
- expect(@environment.override_attributes({ :one => 'two' })).to eq({ :one => 'two' })
+ expect(@environment.override_attributes({ :one => "two" })).to eq({ :one => "two" })
end
it "should let you return the attributes hash" do
- @environment.override_attributes({ :one => 'two' })
- expect(@environment.override_attributes).to eq({ :one => 'two' })
+ @environment.override_attributes({ :one => "two" })
+ expect(@environment.override_attributes).to eq({ :one => "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -393,7 +393,7 @@ describe Chef::Environment do
describe "in solo mode" do
before do
Chef::Config[:solo] = true
- Chef::Config[:environment_path] = '/var/chef/environments'
+ Chef::Config[:environment_path] = "/var/chef/environments"
end
after do
@@ -402,17 +402,17 @@ describe Chef::Environment do
it "should get the environment from the environment_path" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- 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)
+ 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"
- expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(role_dsl)
- Chef::Environment.load('foo')
+ expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl)
+ Chef::Environment.load("foo")
end
it "should return a Chef::Environment object from JSON" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(true)
+ expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
environment_hash = {
"name" => "foo",
"default_attributes" => {
@@ -424,44 +424,44 @@ describe Chef::Environment do
"description" => "desc",
"chef_type" => "environment",
}
- expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(Chef::JSONCompat.to_json(environment_hash))
- environment = Chef::Environment.load('foo')
+ expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(Chef::JSONCompat.to_json(environment_hash))
+ environment = Chef::Environment.load("foo")
expect(environment).to be_a_kind_of(Chef::Environment)
- expect(environment.name).to eq(environment_hash['name'])
- expect(environment.description).to eq(environment_hash['description'])
- expect(environment.default_attributes).to eq(environment_hash['default_attributes'])
+ expect(environment.name).to eq(environment_hash["name"])
+ expect(environment.description).to eq(environment_hash["description"])
+ expect(environment.default_attributes).to eq(environment_hash["default_attributes"])
end
it "should return a Chef::Environment object from Ruby DSL" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- 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)
+ 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"
- expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(role_dsl)
- environment = Chef::Environment.load('foo')
+ expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl)
+ environment = Chef::Environment.load("foo")
expect(environment).to be_a_kind_of(Chef::Environment)
- expect(environment.name).to eq('foo')
- expect(environment.description).to eq('desc')
+ expect(environment.name).to eq("foo")
+ expect(environment.description).to eq("desc")
end
- it 'should raise an error if the configured environment_path is invalid' do
+ it "should raise an error if the configured environment_path is invalid" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(false)
expect {
- Chef::Environment.load('foo')
+ Chef::Environment.load("foo")
}.to raise_error Chef::Exceptions::InvalidEnvironmentPath, "Environment path '/var/chef/environments' is invalid"
end
- it 'should raise an error if the file does not exist' do
+ it "should raise an error if the file does not exist" do
expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
- 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')).and_return(false)
+ 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")).and_return(false)
expect {
- Chef::Environment.load('foo')
+ Chef::Environment.load("foo")
}.to raise_error Chef::Exceptions::EnvironmentNotFound, "Environment 'foo' could not be loaded from disk"
end
end
diff --git a/spec/unit/event_dispatch/dispatcher_spec.rb b/spec/unit/event_dispatch/dispatcher_spec.rb
index 5a06e1d6d1..eaeb164414 100644
--- a/spec/unit/event_dispatch/dispatcher_spec.rb
+++ b/spec/unit/event_dispatch/dispatcher_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/event_dispatch/dispatcher'
+require "spec_helper"
+require "chef/event_dispatch/dispatcher"
describe Chef::EventDispatch::Dispatcher do
diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb
index 0f7adce7a8..7c74e6738c 100644
--- a/spec/unit/event_dispatch/dsl_spec.rb
+++ b/spec/unit/event_dispatch/dsl_spec.rb
@@ -16,8 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/event_dispatch/dsl'
+require "spec_helper"
+require "chef/event_dispatch/dsl"
describe Chef::EventDispatch::DSL do
let(:events) do
@@ -32,25 +32,25 @@ 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
+ it "set handler name" do
subject.on(:run_started) {}
- expect(events.subscribers.first.name).to eq('test')
+ expect(events.subscribers.first.name).to eq("test")
end
- it 'raise error when invalid event type is supplied' do
+ it "raise error when invalid event type is supplied" do
expect do
subject.on(:foo_bar) {}
end.to raise_error(Chef::Exceptions::InvalidEventType)
end
- it 'register user hooks against valid event type' do
- subject.on(:run_failed) {'testhook'}
- expect(events.subscribers.first.run_failed).to eq('testhook')
+ it "register user hooks against valid event type" do
+ subject.on(:run_failed) {"testhook"}
+ expect(events.subscribers.first.run_failed).to eq("testhook")
end
- it 'preserve state across event hooks' do
+ it "preserve state across event hooks" do
calls = []
Chef.event_handler do
on :resource_updated do
@@ -60,13 +60,13 @@ describe Chef::EventDispatch::DSL do
calls << :started
end
end
- resource = Chef::Resource::RubyBlock.new('foo', run_context)
+ resource = Chef::Resource::RubyBlock.new("foo", run_context)
resource.block { }
resource.run_action(:run)
expect(calls).to eq([:started, :updated])
end
- it 'preserve instance variables across handler callbacks' do
+ it "preserve instance variables across handler callbacks" do
Chef.event_handler do
on :resource_action_start do
@ivar = [1]
@@ -75,7 +75,7 @@ describe Chef::EventDispatch::DSL do
@ivar << 2
end
end
- resource = Chef::Resource::RubyBlock.new('foo', run_context)
+ resource = Chef::Resource::RubyBlock.new("foo", run_context)
resource.block { }
resource.run_action(:run)
expect(events.subscribers.first.instance_variable_get(:@ivar)).to eq([1, 2])
diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb
index c738bcf840..881fad4c20 100644
--- a/spec/unit/exceptions_spec.rb
+++ b/spec/unit/exceptions_spec.rb
@@ -19,7 +19,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Exceptions do
exception_to_super_class = {
diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb
index 2c68792c63..724c2385c7 100644
--- a/spec/unit/file_access_control_spec.rb
+++ b/spec/unit/file_access_control_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::FileAccessControl do
describe "Unix" do
@@ -27,14 +27,14 @@ describe Chef::FileAccessControl do
# platform specific module is mixed in
@node = Chef::Node.new
load File.join(File.dirname(__FILE__), "..", "..", "lib", "chef", "file_access_control.rb")
- @resource = Chef::Resource::File.new('/tmp/a_file.txt')
- @resource.owner('toor')
- @resource.group('wheel')
- @resource.mode('0400')
+ @resource = Chef::Resource::File.new("/tmp/a_file.txt")
+ @resource.owner("toor")
+ @resource.group("wheel")
+ @resource.mode("0400")
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @current_resource = Chef::Resource::File.new('/tmp/different_file.txt')
+ @current_resource = Chef::Resource::File.new("/tmp/different_file.txt")
@provider_requirements = Chef::Provider::ResourceRequirements.new(@resource, @run_context)
@provider = double("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false)
@@ -42,7 +42,7 @@ describe Chef::FileAccessControl do
end
end
- describe 'class methods' do
+ describe "class methods" do
it 'responds to #writable?' do
expect(Chef::FileAccessControl).to respond_to(:writable?)
end
@@ -53,7 +53,7 @@ describe Chef::FileAccessControl do
end
it "has a file to manage" do
- expect(@fac.file).to eq('/tmp/different_file.txt')
+ expect(@fac.file).to eq("/tmp/different_file.txt")
end
it "is not modified yet" do
@@ -61,12 +61,12 @@ describe Chef::FileAccessControl do
end
it "determines the uid of the owner specified by the resource" do
- expect(Etc).to receive(:getpwnam).with('toor').and_return(OpenStruct.new(:uid => 2342))
+ expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(:uid => 2342))
expect(@fac.target_uid).to eq(2342)
end
it "raises a Chef::Exceptions::UserIDNotFound error when Etc can't find the user's name" do
- expect(Etc).to receive(:getpwnam).with('toor').and_raise(ArgumentError)
+ expect(Etc).to receive(:getpwnam).with("toor").and_raise(ArgumentError)
expect { @fac.target_uid ; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::UserIDNotFound, "cannot determine user id for 'toor', does the user exist on this system?")
end
@@ -98,16 +98,16 @@ describe Chef::FileAccessControl do
# complement (i.e., it wraps around the maximum size of C unsigned int) of these
# uids. So we have to get ruby and negative uids to smoke the peace pipe
# with each other.
- @resource.owner('nobody')
- expect(Etc).to receive(:getpwnam).with('nobody').and_return(OpenStruct.new(:uid => (4294967294)))
+ @resource.owner("nobody")
+ expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(:uid => (4294967294)))
expect(@fac.target_uid).to eq(-2)
end
it "does not wrap uids to their negative complements beyond -9" do
# More: when OSX userIDs are created by ActiveDirectory sync, it tends to use huge numbers
# which had been incorrectly wrapped. It does not look like the OSX IDs go below -2
- @resource.owner('bigdude')
- expect(Etc).to receive(:getpwnam).with('bigdude').and_return(OpenStruct.new(:uid => (4294967286)))
+ @resource.owner("bigdude")
+ expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(:uid => (4294967286)))
expect(@fac.target_uid).to eq(4294967286)
end
@@ -133,7 +133,7 @@ describe Chef::FileAccessControl do
it "sets the file's owner as specified in the resource when the current owner is incorrect" do
@resource.owner(2342)
- expect(File).to receive(:chown).with(2342, nil, '/tmp/different_file.txt')
+ expect(File).to receive(:chown).with(2342, nil, "/tmp/different_file.txt")
@fac.set_owner
expect(@fac).to be_modified
end
@@ -153,7 +153,7 @@ describe Chef::FileAccessControl do
end
it "determines the gid of the group specified by the resource" do
- expect(Etc).to receive(:getgrnam).with('wheel').and_return(OpenStruct.new(:gid => 2342))
+ expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(:gid => 2342))
expect(@fac.target_gid).to eq(2342)
end
@@ -163,18 +163,18 @@ describe Chef::FileAccessControl do
end
it "raises a Chef::Exceptions::GroupIDNotFound error when Etc can't find the user's name" do
- expect(Etc).to receive(:getgrnam).with('wheel').and_raise(ArgumentError)
+ expect(Etc).to receive(:getgrnam).with("wheel").and_raise(ArgumentError)
expect { @fac.target_gid; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::GroupIDNotFound, "cannot determine group id for 'wheel', does the group exist on this system?")
end
it "does not attempt to resolve a gid when none is supplied" do
- resource = Chef::Resource::File.new('crab')
+ resource = Chef::Resource::File.new("crab")
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
expect(fac.target_gid).to be_nil
end
it "does not want to update the group when no target group is specified" do
- resource = Chef::Resource::File.new('crab')
+ resource = Chef::Resource::File.new("crab")
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
expect(fac.should_update_group?).to be_falsey
end
@@ -197,7 +197,7 @@ describe Chef::FileAccessControl do
end
it "includes updating the group in the list of changes" do
- resource = Chef::Resource::File.new('crab')
+ resource = Chef::Resource::File.new("crab")
resource.group(2342)
@current_resource.group(815)
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
@@ -208,7 +208,7 @@ describe Chef::FileAccessControl do
@resource.group(2342)
@current_resource.group(815)
- expect(File).to receive(:chown).with(nil, 2342, '/tmp/different_file.txt')
+ expect(File).to receive(:chown).with(nil, 2342, "/tmp/different_file.txt")
@fac.set_group
expect(@fac).to be_modified
end
@@ -230,7 +230,7 @@ describe Chef::FileAccessControl do
end
it "uses the supplied mode as octal when it's a string" do
- @resource.mode('444')
+ @resource.mode("444")
expect(@fac.target_mode).to eq(292) # octal 444 => decimal 292
end
@@ -240,13 +240,13 @@ describe Chef::FileAccessControl do
end
it "does not try to determine the mode when none is given" do
- resource = Chef::Resource::File.new('blahblah')
+ resource = Chef::Resource::File.new("blahblah")
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
expect(fac.target_mode).to be_nil
end
it "doesn't want to update the mode when no target mode is given" do
- resource = Chef::Resource::File.new('blahblah')
+ resource = Chef::Resource::File.new("blahblah")
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
expect(fac.should_update_mode?).to be_falsey
end
@@ -264,7 +264,7 @@ describe Chef::FileAccessControl do
end
it "includes changing the mode in the list of desired changes" do
- resource = Chef::Resource::File.new('blahblah')
+ resource = Chef::Resource::File.new("blahblah")
resource.mode("0750")
@current_resource.mode("0444")
fac = Chef::FileAccessControl.new(@current_resource, resource, @provider)
@@ -275,7 +275,7 @@ describe Chef::FileAccessControl do
# stat returns modes like 0100644 (octal) => 33188 (decimal)
#@fac.stub(:stat).and_return(OpenStruct.new(:mode => 33188))
@current_resource.mode("0644")
- expect(File).to receive(:chmod).with(256, '/tmp/different_file.txt')
+ expect(File).to receive(:chmod).with(256, "/tmp/different_file.txt")
@fac.set_mode
expect(@fac).to be_modified
end
@@ -298,9 +298,9 @@ describe Chef::FileAccessControl do
@resource.mode(0400)
@resource.owner(0)
@resource.group(0)
- expect(File).to receive(:chmod).with(0400, '/tmp/different_file.txt')
- expect(File).to receive(:chown).with(0, nil, '/tmp/different_file.txt')
- expect(File).to receive(:chown).with(nil, 0, '/tmp/different_file.txt')
+ expect(File).to receive(:chmod).with(0400, "/tmp/different_file.txt")
+ expect(File).to receive(:chown).with(0, nil, "/tmp/different_file.txt")
+ expect(File).to receive(:chown).with(nil, 0, "/tmp/different_file.txt")
@fac.set_all
expect(@fac).to be_modified
end
diff --git a/spec/unit/file_cache_spec.rb b/spec/unit/file_cache_spec.rb
index a24c3d3b97..1b273c9adf 100644
--- a/spec/unit/file_cache_spec.rb
+++ b/spec/unit/file_cache_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::FileCache do
before do
@@ -32,11 +32,11 @@ describe Chef::FileCache do
describe "when the relative path to the cache file doesn't exist" do
it "creates intermediate directories as needed" do
Chef::FileCache.store("whiz/bang", "I found a poop")
- expect(File).to exist(File.join(@file_cache_path, 'whiz'))
+ expect(File).to exist(File.join(@file_cache_path, "whiz"))
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
@@ -56,35 +56,35 @@ describe Chef::FileCache do
describe "when loading cached files" do
it "finds and reads the cached file" do
- FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz'))
- File.open(File.join(@file_cache_path, 'whiz', 'bang'), 'w') { |f| f.print("borkborkbork") }
- expect(Chef::FileCache.load('whiz/bang')).to eq('borkborkbork')
+ FileUtils.mkdir_p(File.join(@file_cache_path, "whiz"))
+ File.open(File.join(@file_cache_path, "whiz", "bang"), "w") { |f| f.print("borkborkbork") }
+ expect(Chef::FileCache.load("whiz/bang")).to eq("borkborkbork")
end
it "should raise a Chef::Exceptions::FileNotFound if the file doesn't exist" do
- expect { Chef::FileCache.load('whiz/bang') }.to raise_error(Chef::Exceptions::FileNotFound)
+ expect { Chef::FileCache.load("whiz/bang") }.to raise_error(Chef::Exceptions::FileNotFound)
end
end
describe "when deleting cached files" do
before(:each) do
- FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz'))
- File.open(File.join(@file_cache_path, 'whiz', 'bang'), 'w') { |f| f.print("borkborkbork") }
+ FileUtils.mkdir_p(File.join(@file_cache_path, "whiz"))
+ File.open(File.join(@file_cache_path, "whiz", "bang"), "w") { |f| f.print("borkborkbork") }
end
it "unlinks the file" do
Chef::FileCache.delete("whiz/bang")
- expect(File).not_to exist(File.join(@file_cache_path, 'whiz', 'bang'))
+ expect(File).not_to exist(File.join(@file_cache_path, "whiz", "bang"))
end
end
describe "when listing files in the cache" do
before(:each) do
- FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz'))
- FileUtils.touch(File.join(@file_cache_path, 'whiz', 'bang'))
- FileUtils.mkdir_p(File.join(@file_cache_path, 'snappy'))
- FileUtils.touch(File.join(@file_cache_path, 'snappy', 'patter'))
+ FileUtils.mkdir_p(File.join(@file_cache_path, "whiz"))
+ FileUtils.touch(File.join(@file_cache_path, "whiz", "bang"))
+ FileUtils.mkdir_p(File.join(@file_cache_path, "snappy"))
+ FileUtils.touch(File.join(@file_cache_path, "snappy", "patter"))
end
it "should return the relative paths" do
@@ -92,18 +92,18 @@ describe Chef::FileCache do
end
it "searches for cached files by globbing" do
- expect(Chef::FileCache.find('snappy/**/*')).to eq(%w{snappy/patter})
+ expect(Chef::FileCache.find("snappy/**/*")).to eq(%w{snappy/patter})
end
end
describe "when checking for the existence of a file" do
before do
- FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz'))
+ FileUtils.mkdir_p(File.join(@file_cache_path, "whiz"))
end
it "has a key if the corresponding cache file exists" do
- FileUtils.touch(File.join(@file_cache_path, 'whiz', 'bang'))
+ FileUtils.touch(File.join(@file_cache_path, "whiz", "bang"))
expect(Chef::FileCache).to have_key("whiz/bang")
end
diff --git a/spec/unit/file_content_management/deploy/cp_spec.rb b/spec/unit/file_content_management/deploy/cp_spec.rb
index 5c6583e8a6..d99839710a 100644
--- a/spec/unit/file_content_management/deploy/cp_spec.rb
+++ b/spec/unit/file_content_management/deploy/cp_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::FileContentManagement::Deploy::Cp do
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 4511f91180..bebde96295 100644
--- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::FileContentManagement::Deploy::MvUnix do
diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
index 2d1981befc..7deeacf7ea 100644
--- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
unless Chef::Platform.windows?
class Chef
@@ -31,7 +31,7 @@ unless Chef::Platform.windows?
end
end
-require 'chef/file_content_management/deploy/mv_windows'
+require "chef/file_content_management/deploy/mv_windows"
describe Chef::FileContentManagement::Deploy::MvWindows do
diff --git a/spec/unit/formatters/base_spec.rb b/spec/unit/formatters/base_spec.rb
index 6a843ea775..9fe8109e98 100644
--- a/spec/unit/formatters/base_spec.rb
+++ b/spec/unit/formatters/base_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::Base do
let(:out) { double("out") }
diff --git a/spec/unit/formatters/doc_spec.rb b/spec/unit/formatters/doc_spec.rb
index b0be913304..d622b27bf9 100644
--- a/spec/unit/formatters/doc_spec.rb
+++ b/spec/unit/formatters/doc_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::Base do
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 6f90ea0b27..b417c76f8a 100644
--- a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
+++ b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/formatters/error_inspectors/api_error_formatting'
+require "spec_helper"
+require "chef/formatters/error_inspectors/api_error_formatting"
describe Chef::Formatters::APIErrorFormatting do
let(:class_instance) { (Class.new { include Chef::Formatters::APIErrorFormatting }).new }
@@ -43,7 +43,7 @@ describe Chef::Formatters::APIErrorFormatting do
before do
# mock out the header
- allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash))
+ allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash))
end
it "prints an error about client and server API version incompatibility with a min API version" do
@@ -65,7 +65,7 @@ describe Chef::Formatters::APIErrorFormatting do
context "when response.body['error'] != 'invalid-x-ops-server-api-version'" do
before do
- allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(nil)
+ allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(nil)
end
it "forwards the error_description to describe_http_error" do
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 6cea22680b..d6138f4c11 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
BAD_RECIPE=<<-E
#
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 7e4d89f144..9c4d63a2e8 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
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
diff --git a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
index 775a1838f3..0fac218eb5 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector do
before do
diff --git a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb
index d2bbffafee..8d882b045e 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
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# spec_helper loads the shared examples already.
#require 'support/shared/unit/api_error_inspector_spec'
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 4c21dadd82..0a8918d158 100644
--- a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# spec_helper loads the shared examples already.
#require 'support/shared/unit/api_error_inspector_spec'
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 5594d6e18a..d4185c2f5c 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
include Chef::DSL::Recipe
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 1cd97596a7..786b3e0c37 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
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
before do
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index acf1b15fd8..518610c13a 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::GuardInterpreter::ResourceGuardInterpreter do
let(:node) do
@@ -24,7 +24,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
- node.automatic[:os] = 'windows'
+ node.automatic[:os] = "windows"
node
end
@@ -52,7 +52,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
it "raises an exception if guard_interpreter is set to a resource not derived from Chef::Resource::Script" do
parent_resource.guard_interpreter(:file)
- expect { guard_interpreter }.to raise_error(ArgumentError, 'Specified guard interpreter class Chef::Resource::File must be a kind of Chef::Resource::Execute resource')
+ expect { guard_interpreter }.to raise_error(ArgumentError, "Specified guard interpreter class Chef::Resource::File must be a kind of Chef::Resource::Execute resource")
end
context "when the resource cannot be found for the platform" do
@@ -62,7 +62,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
it "raises an exception" do
parent_resource.guard_interpreter(:foobar)
- expect { guard_interpreter }.to raise_error(ArgumentError, 'Specified guard_interpreter resource foobar unknown for this platform')
+ expect { guard_interpreter }.to raise_error(ArgumentError, "Specified guard_interpreter resource foobar unknown for this platform")
end
end
diff --git a/spec/unit/guard_interpreter_spec.rb b/spec/unit/guard_interpreter_spec.rb
index a7fe064948..10084a156e 100644
--- a/spec/unit/guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::GuardInterpreter do
describe "#for_resource" do
diff --git a/spec/unit/handler/json_file_spec.rb b/spec/unit/handler/json_file_spec.rb
index f6c14a166e..76098e2522 100644
--- a/spec/unit/handler/json_file_spec.rb
+++ b/spec/unit/handler/json_file_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Handler::JsonFile do
before(:each) do
- @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => '/tmp/foobarbazqux')
+ @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => "/tmp/foobarbazqux")
end
it "accepts arbitrary config options" do
@@ -28,8 +28,8 @@ describe Chef::Handler::JsonFile do
end
it "creates the directory where the reports will be saved" do
- expect(FileUtils).to receive(:mkdir_p).with('/tmp/foobarbazqux')
- expect(File).to receive(:chmod).with(00700, '/tmp/foobarbazqux')
+ expect(FileUtils).to receive(:mkdir_p).with("/tmp/foobarbazqux")
+ expect(File).to receive(:chmod).with(00700, "/tmp/foobarbazqux")
@handler.build_report_dir
end
@@ -54,10 +54,10 @@ describe Chef::Handler::JsonFile do
expect(@handler).to receive(:build_report_dir)
@handler.run_report_unsafe(@run_status)
reported_data = Chef::JSONCompat.from_json(@file_mock.string)
- expect(reported_data['exception']).to eq("Exception: Boy howdy!")
- expect(reported_data['start_time']).to eq(@expected_time.to_s)
- expect(reported_data['end_time']).to eq((@expected_time + 5).to_s)
- expect(reported_data['elapsed_time']).to eq(5)
+ expect(reported_data["exception"]).to eq("Exception: Boy howdy!")
+ expect(reported_data["start_time"]).to eq(@expected_time.to_s)
+ expect(reported_data["end_time"]).to eq((@expected_time + 5).to_s)
+ expect(reported_data["elapsed_time"]).to eq(5)
end
end
diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb
index e7f67405fc..f3e527b69d 100644
--- a/spec/unit/handler_spec.rb
+++ b/spec/unit/handler_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Handler do
before(:each) do
@@ -36,7 +36,7 @@ describe Chef::Handler do
@exception.set_backtrace(@backtrace)
@run_status.exception = @exception
@run_context = Chef::RunContext.new(@node, {}, @events)
- @all_resources = [Chef::Resource::Cat.new('lolz'), Chef::Resource::ZenMaster.new('tzu')]
+ @all_resources = [Chef::Resource::Cat.new("lolz"), Chef::Resource::ZenMaster.new("tzu")]
@all_resources.first.updated = true
@run_context.resource_collection.all_resources.replace(@all_resources)
@run_status.run_context = @run_context
@@ -117,7 +117,7 @@ describe Chef::Handler do
describe "when running a report handler" do
before do
@run_context = Chef::RunContext.new(@node, {}, @events)
- @all_resources = [Chef::Resource::Cat.new('foo'), Chef::Resource::ZenMaster.new('moo')]
+ @all_resources = [Chef::Resource::Cat.new("foo"), Chef::Resource::ZenMaster.new("moo")]
@all_resources.first.updated = true
@run_context.resource_collection.all_resources.replace(@all_resources)
@run_status.run_context = @run_context
diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb
index 48bbdcf76c..1289ebb61e 100644
--- a/spec/unit/http/authenticator_spec.rb
+++ b/spec/unit/http/authenticator_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/http/authenticator'
+require "spec_helper"
+require "chef/http/authenticator"
describe Chef::HTTP::Authenticator do
let(:class_instance) { Chef::HTTP::Authenticator.new }
@@ -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
diff --git a/spec/unit/http/basic_client_spec.rb b/spec/unit/http/basic_client_spec.rb
index 16f62f8d97..4abdb52620 100644
--- a/spec/unit/http/basic_client_spec.rb
+++ b/spec/unit/http/basic_client_spec.rb
@@ -15,8 +15,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/http/basic_client'
+require "spec_helper"
+require "chef/http/basic_client"
describe "HTTP Connection" do
diff --git a/spec/unit/http/http_request_spec.rb b/spec/unit/http/http_request_spec.rb
index 3bba201963..33da210c36 100644
--- a/spec/unit/http/http_request_spec.rb
+++ b/spec/unit/http/http_request_spec.rb
@@ -16,40 +16,40 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::HTTP::HTTPRequest do
context "with HTTP url scheme" do
it "should not include port 80 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com"), "")
- expect(request.headers['Host']).to eql('dummy.com')
+ expect(request.headers["Host"]).to eql("dummy.com")
end
it "should not include explicit port 80 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:80'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:80"), "")
- expect(request.headers['Host']).to eql('dummy.com')
+ expect(request.headers["Host"]).to eql("dummy.com")
end
it "should include explicit port 8000 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "")
- expect(request.headers['Host']).to eql('dummy.com:8000')
+ expect(request.headers["Host"]).to eql("dummy.com:8000")
end
it "should include explicit 443 port in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:443'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:443"), "")
- expect(request.headers['Host']).to eql('dummy.com:443')
+ expect(request.headers["Host"]).to eql("dummy.com:443")
end
it "should pass on explicit Host header unchanged" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'yourhost.com:8888' })
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "", { "Host" => "yourhost.com:8888" })
- expect(request.headers['Host']).to eql('yourhost.com:8888')
+ expect(request.headers["Host"]).to eql("yourhost.com:8888")
end
end
@@ -57,35 +57,35 @@ describe Chef::HTTP::HTTPRequest do
context "with HTTPS url scheme" do
it "should not include port 443 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com"), "")
- expect(request.headers['Host']).to eql('dummy.com')
+ expect(request.headers["Host"]).to eql("dummy.com")
end
it "should include explicit port 80 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:80'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:80"), "")
- expect(request.headers['Host']).to eql('dummy.com:80')
+ expect(request.headers["Host"]).to eql("dummy.com:80")
end
it "should include explicit port 8000 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:8000'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:8000"), "")
- expect(request.headers['Host']).to eql('dummy.com:8000')
+ expect(request.headers["Host"]).to eql("dummy.com:8000")
end
it "should not include explicit port 443 in Host header" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:443'), '')
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:443"), "")
- expect(request.headers['Host']).to eql('dummy.com')
+ expect(request.headers["Host"]).to eql("dummy.com")
end
end
it "should pass on explicit Host header unchanged" do
- request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'myhost.com:80' })
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "", { "Host" => "myhost.com:80" })
- expect(request.headers['Host']).to eql('myhost.com:80')
+ expect(request.headers["Host"]).to eql("myhost.com:80")
end
end
diff --git a/spec/unit/http/json_input_spec.rb b/spec/unit/http/json_input_spec.rb
index fbf8f22503..6bc2bbf018 100644
--- a/spec/unit/http/json_input_spec.rb
+++ b/spec/unit/http/json_input_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/http/json_input'
+require "spec_helper"
+require "chef/http/json_input"
describe Chef::HTTP::JSONInput do
diff --git a/spec/unit/http/simple_spec.rb b/spec/unit/http/simple_spec.rb
index c8fb52e8b2..f132f1a890 100644
--- a/spec/unit/http/simple_spec.rb
+++ b/spec/unit/http/simple_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::HTTP::Simple do
it "should have content length validation middleware after compressor middleware" do
diff --git a/spec/unit/http/socketless_chef_zero_client_spec.rb b/spec/unit/http/socketless_chef_zero_client_spec.rb
index 963cc9e8c4..b65deafe53 100644
--- a/spec/unit/http/socketless_chef_zero_client_spec.rb
+++ b/spec/unit/http/socketless_chef_zero_client_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'chef/http/socketless_chef_zero_client'
+require "chef/http/socketless_chef_zero_client"
describe Chef::HTTP::SocketlessChefZeroClient do
diff --git a/spec/unit/http/ssl_policies_spec.rb b/spec/unit/http/ssl_policies_spec.rb
index 5ebebf39b1..98f1fa9c37 100644
--- a/spec/unit/http/ssl_policies_spec.rb
+++ b/spec/unit/http/ssl_policies_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/http/ssl_policies'
+require "spec_helper"
+require "chef/http/ssl_policies"
describe "HTTP SSL Policy" do
@@ -68,8 +68,8 @@ describe "HTTP SSL Policy" do
end
it "should set the CA file if that is set in the configuration" do
- Chef::Config[:ssl_ca_file] = CHEF_SPEC_DATA + '/ssl/5e707473.0'
- expect(http_client.ca_file).to eq(CHEF_SPEC_DATA + '/ssl/5e707473.0')
+ Chef::Config[:ssl_ca_file] = CHEF_SPEC_DATA + "/ssl/5e707473.0"
+ expect(http_client.ca_file).to eq(CHEF_SPEC_DATA + "/ssl/5e707473.0")
end
end
@@ -89,12 +89,12 @@ describe "HTTP SSL Policy" do
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'
+ Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key"
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_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)
end
@@ -106,10 +106,10 @@ describe "HTTP SSL Policy" do
end
it "configures the HTTP client's cert and private key" do
- Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + '/ssl/chef-rspec.cert'
- Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + '/ssl/chef-rspec.key'
- expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.cert')).to_s)
- expect(http_client.key.to_s).to eq(IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.key'))
+ Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec.cert"
+ Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key"
+ expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.cert")).to_s)
+ expect(http_client.key.to_s).to eq(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.key"))
end
end
diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb
index 16eede1859..18b0bead70 100644
--- a/spec/unit/http/validate_content_length_spec.rb
+++ b/spec/unit/http/validate_content_length_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'stringio'
+require "spec_helper"
+require "stringio"
describe Chef::HTTP::ValidateContentLength do
class TestClient < Chef::HTTP
@@ -44,7 +44,7 @@ describe Chef::HTTP::ValidateContentLength do
}
let(:response) {
- m = double('HttpResponse', :body => response_body)
+ m = double("HttpResponse", :body => response_body)
allow(m).to receive(:[]) do |key|
response_headers[key]
end
diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb
index ebb96d25e1..c35f8baaeb 100644
--- a/spec/unit/http_spec.rb
+++ b/spec/unit/http_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/http'
-require 'chef/http/basic_client'
-require 'chef/http/socketless_chef_zero_client'
+require "chef/http"
+require "chef/http/basic_client"
+require "chef/http/socketless_chef_zero_client"
class Chef::HTTP
public :create_url
@@ -43,26 +43,26 @@ describe Chef::HTTP do
describe "create_url" do
- it 'should return a correctly formatted url 1/3 CHEF-5261' do
- http = Chef::HTTP.new('http://www.getchef.com')
- expect(http.create_url('api/endpoint')).to eql(URI.parse('http://www.getchef.com/api/endpoint'))
+ it "should return a correctly formatted url 1/3 CHEF-5261" do
+ http = Chef::HTTP.new("http://www.getchef.com")
+ expect(http.create_url("api/endpoint")).to eql(URI.parse("http://www.getchef.com/api/endpoint"))
end
- it 'should return a correctly formatted url 2/3 CHEF-5261' do
- http = Chef::HTTP.new('http://www.getchef.com/')
- expect(http.create_url('/organization/org/api/endpoint/')).to eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint/'))
+ it "should return a correctly formatted url 2/3 CHEF-5261" do
+ http = Chef::HTTP.new("http://www.getchef.com/")
+ expect(http.create_url("/organization/org/api/endpoint/")).to eql(URI.parse("http://www.getchef.com/organization/org/api/endpoint/"))
end
- it 'should return a correctly formatted url 3/3 CHEF-5261' do
- http = Chef::HTTP.new('http://www.getchef.com/organization/org///')
- expect(http.create_url('///api/endpoint?url=http://foo.bar')).to eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar'))
+ it "should return a correctly formatted url 3/3 CHEF-5261" do
+ http = Chef::HTTP.new("http://www.getchef.com/organization/org///")
+ expect(http.create_url("///api/endpoint?url=http://foo.bar")).to eql(URI.parse("http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar"))
end
# As per: https://github.com/opscode/chef/issues/2500
- it 'should treat scheme part of the URI in a case-insensitive manner' do
+ it "should treat scheme part of the URI in a case-insensitive manner" do
http = Chef::HTTP.allocate # Calling Chef::HTTP::new sets @url, don't want that.
- expect { http.create_url('HTTP://www1.chef.io/') }.not_to raise_error
- expect(http.create_url('HTTP://www2.chef.io/')).to eql(URI.parse('http://www2.chef.io/'))
+ expect { http.create_url("HTTP://www1.chef.io/") }.not_to raise_error
+ expect(http.create_url("HTTP://www2.chef.io/")).to eql(URI.parse("http://www2.chef.io/"))
end
end # create_url
@@ -117,7 +117,7 @@ describe Chef::HTTP do
end
it "retries the request 5 times" do
- http.get('/')
+ http.get("/")
end
end
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index fd6469c146..524b71f09a 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require File.expand_path('../../spec_helper', __FILE__)
-require 'chef/json_compat'
+require File.expand_path("../../spec_helper", __FILE__)
+require "chef/json_compat"
describe Chef::JSONCompat do
@@ -46,7 +46,7 @@ describe Chef::JSONCompat do
end
describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
- require 'chef/sandbox' # Only needed for this test
+ require "chef/sandbox" # Only needed for this test
let(:json) { '{"json_class": "Chef::Sandbox", "arbitrary": "data"}' }
@@ -58,7 +58,7 @@ describe Chef::JSONCompat do
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
@@ -73,7 +73,7 @@ describe Chef::JSONCompat do
end
describe "with the file with 252 or less nested entries" do
- let(:json) { IO.read(File.join(CHEF_SPEC_DATA, 'nested.json')) }
+ let(:json) { IO.read(File.join(CHEF_SPEC_DATA, "nested.json")) }
let(:hash) { Chef::JSONCompat.from_json(json) }
describe "when the 252 json file is loaded" do
@@ -83,9 +83,9 @@ describe Chef::JSONCompat do
it "should has 'test' as a 252 nested value" do
v = 252.times.inject(hash) do |memo, _|
- memo['key']
+ memo["key"]
end
- expect(v).to eq('test')
+ expect(v).to eq("test")
end
end
end
diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb
index 64601cfbab..95124b5e8f 100644
--- a/spec/unit/key_spec.rb
+++ b/spec/unit/key_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/key'
+require "chef/key"
describe Chef::Key do
# whether user or client irrelevent to these tests
@@ -341,7 +341,7 @@ EOS
let(:rest) do
Chef::Config[:chef_server_root] = "http://www.example.com"
Chef::Config[:chef_server_url] = "http://www.example.com/organizations/test_org"
- r = double('rest')
+ r = double("rest")
allow(Chef::ServerAPI).to receive(:new).and_return(r)
r
end
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
index 75e0ff6b00..4bdd994906 100644
--- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
+++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Bootstrap::ChefVaultHandler do
@@ -57,29 +57,29 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
context "from knife_config[:bootstrap_vault_item]" do
it "sets a single item as a scalar" do
- knife_config[:bootstrap_vault_item] = { 'vault' => 'item1' }
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ knife_config[:bootstrap_vault_item] = { "vault" => "item1" }
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets a single item as an array" do
- knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1' ] }
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ knife_config[:bootstrap_vault_item] = { "vault" => [ "item1" ] }
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two items as an array" do
- knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1', 'item2' ] }
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
+ knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ] }
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two vaults from different hash keys" do
- knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1', 'item2' ], 'vault2' => [ 'item3' ] }
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item)
+ knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ], "vault2" => [ "item3" ] }
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
end
@@ -87,28 +87,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
context "from knife_config[:bootstrap_vault_json]" do
it "sets a single item as a scalar" do
knife_config[:bootstrap_vault_json] = '{ "vault": "item1" }'
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets a single item as an array" do
knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1" ] }'
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two items as an array" do
knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ] }'
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two vaults from different hash keys" do
knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }'
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
end
@@ -123,28 +123,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
it "sets a single item as a scalar" do
setup_file_contents('{ "vault": "item1" }')
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets a single item as an array" do
setup_file_contents('{ "vault": [ "item1" ] }')
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two items as an array" do
setup_file_contents('{ "vault": [ "item1", "item2" ] }')
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
it "sets two vaults from different hash keys" do
setup_file_contents('{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }')
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item)
- expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item)
+ expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item)
chef_vault_handler.run(client)
end
end
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 6812a24c91..791b84b9c3 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Bootstrap::ClientBuilder do
@@ -42,7 +42,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
}
context "#sanity_check!" do
- let(:response_404) { OpenStruct.new(:code => '404') }
+ let(:response_404) { OpenStruct.new(:code => "404") }
let(:exception_404) { Net::HTTPServerException.new("404 not found", response_404) }
context "in cases where the prompting fails" do
@@ -54,14 +54,14 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
it "exits when the node exists and the user does not want to delete" do
expect(rest).to receive(:get).with("nodes/#{node_name}")
- expect(ui.stdin).to receive(:readline).and_return('n')
+ expect(ui.stdin).to receive(:readline).and_return("n")
expect { client_builder.run }.to raise_error(SystemExit)
end
it "exits when the client exists and the user does not want to delete" do
expect(rest).to receive(:get).with("nodes/#{node_name}").and_raise(exception_404)
expect(rest).to receive(:get).with("clients/#{node_name}")
- expect(ui.stdin).to receive(:readline).and_return('n')
+ expect(ui.stdin).to receive(:readline).and_return("n")
expect { client_builder.run }.to raise_error(SystemExit)
end
end
@@ -81,7 +81,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
it "when we are allowed to delete an old node" do
expect(rest).to receive(:get).with("nodes/#{node_name}")
- expect(ui.stdin).to receive(:readline).and_return('y')
+ expect(ui.stdin).to receive(:readline).and_return("y")
expect(rest).to receive(:get).with("clients/#{node_name}").and_raise(exception_404)
expect(rest).to receive(:delete).with("nodes/#{node_name}")
expect { client_builder.run }.not_to raise_error
@@ -90,7 +90,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
it "when we are allowed to delete an old client" do
expect(rest).to receive(:get).with("nodes/#{node_name}").and_raise(exception_404)
expect(rest).to receive(:get).with("clients/#{node_name}")
- expect(ui.stdin).to receive(:readline).and_return('y')
+ expect(ui.stdin).to receive(:readline).and_return("y")
expect(rest).to receive(:delete).with("clients/#{node_name}")
expect { client_builder.run }.not_to raise_error
end
@@ -98,7 +98,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
it "when we are are allowed to delete both an old client and node" do
expect(rest).to receive(:get).with("nodes/#{node_name}")
expect(rest).to receive(:get).with("clients/#{node_name}")
- expect(ui.stdin).to receive(:readline).twice.and_return('y')
+ expect(ui.stdin).to receive(:readline).twice.and_return("y")
expect(rest).to receive(:delete).with("nodes/#{node_name}")
expect(rest).to receive(:delete).with("clients/#{node_name}")
expect { client_builder.run }.not_to raise_error
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index b4babdc14f..c64b2e49ea 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::Bootstrap.load_deps
-require 'net/ssh'
+require "net/ssh"
describe Chef::Knife::Bootstrap do
before do
@@ -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" }
@@ -237,7 +237,7 @@ describe Chef::Knife::Bootstrap do
context "with bootstrap_attribute options" do
let(:jsonfile) {
- file = Tempfile.new (['node', '.json'])
+ file = Tempfile.new (["node", ".json"])
File.open(file.path, "w") {|f| f.puts '{"foo":{"bar":"baz"}}' }
file
}
@@ -385,7 +385,7 @@ describe Chef::Knife::Bootstrap do
end
describe "when transferring trusted certificates" do
- let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), '../../data/trusted_certs')) }
+ let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs")) }
let(:rendered_template) do
knife.merge_configs
@@ -509,15 +509,15 @@ describe Chef::Knife::Bootstrap do
end
it "configures the ssh user" do
- expect(knife_ssh.config[:ssh_user]).to eq('rooty')
+ expect(knife_ssh.config[:ssh_user]).to eq("rooty")
end
it "configures the ssh password" do
- expect(knife_ssh.config[:ssh_password]).to eq('open_sesame')
+ expect(knife_ssh.config[:ssh_password]).to eq("open_sesame")
end
it "configures the ssh port" do
- expect(knife_ssh.config[:ssh_port]).to eq('4001')
+ expect(knife_ssh.config[:ssh_port]).to eq("4001")
end
it "configures the ssh agent forwarding" do
@@ -525,7 +525,7 @@ describe Chef::Knife::Bootstrap do
end
it "configures the ssh identity file" do
- expect(knife_ssh.config[:ssh_identity_file]).to eq('~/.ssh/me.rsa')
+ expect(knife_ssh.config[:ssh_identity_file]).to eq("~/.ssh/me.rsa")
end
end
@@ -537,8 +537,8 @@ describe Chef::Knife::Bootstrap do
it "use_sudo_password contains description and long params for help" do
expect(knife.options).to have_key(:use_sudo_password) \
- and expect(knife.options[:use_sudo_password][:description].to_s).not_to eq('')\
- and expect(knife.options[:use_sudo_password][:long].to_s).not_to eq('')
+ and expect(knife.options[:use_sudo_password][:description].to_s).not_to eq("")\
+ and expect(knife.options[:use_sudo_password][:long].to_s).not_to eq("")
end
it "uses the password from --ssh-password for sudo when --use-sudo-password is set" do
@@ -570,11 +570,11 @@ describe Chef::Knife::Bootstrap do
end
it "configures the ssh user" do
- expect(knife_ssh.config[:ssh_user]).to eq('curiosity')
+ expect(knife_ssh.config[:ssh_user]).to eq("curiosity")
end
it "configures the ssh port" do
- expect(knife_ssh.config[:ssh_port]).to eq('2430')
+ expect(knife_ssh.config[:ssh_port]).to eq("2430")
end
it "configures the ssh agent forwarding" do
@@ -582,11 +582,11 @@ describe Chef::Knife::Bootstrap do
end
it "configures the ssh identity file" do
- expect(knife_ssh.config[:ssh_identity_file]).to eq('~/.ssh/you.rsa')
+ expect(knife_ssh.config[:ssh_identity_file]).to eq("~/.ssh/you.rsa")
end
it "configures the ssh gateway" do
- expect(knife_ssh.config[:ssh_gateway]).to eq('towel.blinkenlights.nl')
+ expect(knife_ssh.config[:ssh_gateway]).to eq("towel.blinkenlights.nl")
end
it "configures the host key verify mode" do
@@ -601,13 +601,13 @@ describe Chef::Knife::Bootstrap do
knife.config[:ssh_identity_file] = "~/.ssh/me.rsa"
allow(knife).to receive(:render_template).and_return("")
k = knife.knife_ssh
- allow(k).to receive(:get_password).and_return('typed_in_password')
+ allow(k).to receive(:get_password).and_return("typed_in_password")
allow(knife).to receive(:knife_ssh).and_return(k)
knife.knife_ssh_with_password_auth
end
it "prompts the user for a password " do
- expect(knife_ssh_with_password_auth.config[:ssh_password]).to eq('typed_in_password')
+ expect(knife_ssh_with_password_auth.config[:ssh_password]).to eq("typed_in_password")
end
it "configures knife not to use the identity file that didn't work previously" do
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index 1a6317ac00..30bd8b5b97 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ClientBulkDelete do
let(:stdout_io) { StringIO.new }
diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb
index 9066505dfd..359271672e 100644
--- a/spec/unit/knife/client_create_spec.rb
+++ b/spec/unit/knife/client_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::ClientCreate.load_deps
@@ -61,13 +61,13 @@ describe Chef::Knife::ClientCreate do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
let(:name_args) { [] }
- let(:fieldname) { 'client name' }
+ let(:fieldname) { "client name" }
end
end
context "when clientname is passed" do
before do
- knife.name_args = ['adam']
+ knife.name_args = ["adam"]
end
context "when public_key and prevent_keygen are passed" do
@@ -131,7 +131,7 @@ describe Chef::Knife::ClientCreate do
it "should write the private key to a file" do
knife.config[:file] = "/tmp/monkeypants"
filehandle = double("Filehandle")
- expect(filehandle).to receive(:print).with('woot')
+ expect(filehandle).to receive(:print).with("woot")
expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle)
knife.run
end
@@ -150,14 +150,14 @@ describe Chef::Knife::ClientCreate do
describe "with -p or --public-key" do
before do
- knife.config[:public_key] = 'some_key'
- allow(File).to receive(:read).and_return('some_key')
+ knife.config[:public_key] = "some_key"
+ allow(File).to receive(:read).and_return("some_key")
allow(File).to receive(:expand_path)
end
it "sets the public key" do
knife.run
- expect(client.public_key).to eq('some_key')
+ expect(client.public_key).to eq("some_key")
end
end
diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb
index 619009979b..e08a9c59c8 100644
--- a/spec/unit/knife/client_delete_spec.rb
+++ b/spec/unit/knife/client_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ClientDelete do
before(:each) do
@@ -25,16 +25,16 @@ describe Chef::Knife::ClientDelete do
@knife.config = {
:delete_validators => false
}
- @knife.name_args = [ 'adam' ]
+ @knife.name_args = [ "adam" ]
end
- describe 'run' do
- it 'should delete the client' do
- expect(@knife).to receive(:delete_object).with(Chef::ApiClientV1, 'adam', 'client')
+ describe "run" do
+ it "should delete the client" do
+ expect(@knife).to receive(:delete_object).with(Chef::ApiClientV1, "adam", "client")
@knife.run
end
- it 'should print usage and exit when a client name is not provided' do
+ it "should print usage and exit when a client name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
@@ -42,7 +42,7 @@ describe Chef::Knife::ClientDelete do
end
end
- describe 'with a validator' do
+ describe "with a validator" do
before(:each) do
allow(Chef::Knife::UI).to receive(:confirm).and_return(true)
allow(@knife).to receive(:confirm).and_return(true)
@@ -50,7 +50,7 @@ describe Chef::Knife::ClientDelete do
expect(Chef::ApiClientV1).to receive(:load).and_return(@client)
end
- it 'should delete non-validator client if --delete-validators is not set' do
+ it "should delete non-validator client if --delete-validators is not set" do
@knife.config[:delete_validators] = false
expect(@client).to receive(:destroy).and_return(@client)
expect(@knife).to receive(:msg)
@@ -58,7 +58,7 @@ describe Chef::Knife::ClientDelete do
@knife.run
end
- it 'should delete non-validator client if --delete-validators is set' do
+ it "should delete non-validator client if --delete-validators is set" do
@knife.config[:delete_validators] = true
expect(@client).to receive(:destroy).and_return(@client)
expect(@knife).to receive(:msg)
@@ -66,13 +66,13 @@ describe Chef::Knife::ClientDelete do
@knife.run
end
- it 'should not delete validator client if --delete-validators is not set' 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)
end
- it 'should delete validator client if --delete-validators is set' do
+ it "should delete validator client if --delete-validators is set" do
@knife.config[:delete_validators] = true
expect(@client).to receive(:destroy).and_return(@client)
expect(@knife).to receive(:msg)
diff --git a/spec/unit/knife/client_edit_spec.rb b/spec/unit/knife/client_edit_spec.rb
index 75b0ef8c92..876dfc5770 100644
--- a/spec/unit/knife/client_edit_spec.rb
+++ b/spec/unit/knife/client_edit_spec.rb
@@ -16,17 +16,17 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/api_client_v1'
+require "spec_helper"
+require "chef/api_client_v1"
describe Chef::Knife::ClientEdit do
before(:each) do
@knife = Chef::Knife::ClientEdit.new
- @knife.name_args = [ 'adam' ]
+ @knife.name_args = [ "adam" ]
@knife.config[:disable_editing] = true
end
- describe 'run' do
+ describe "run" do
let(:data) {
{
"name" => "adam",
@@ -37,13 +37,13 @@ describe Chef::Knife::ClientEdit do
}
}
- it 'should edit the client' do
- allow(Chef::ApiClientV1).to receive(:load).with('adam').and_return(data)
+ it "should edit the client" do
+ allow(Chef::ApiClientV1).to receive(:load).with("adam").and_return(data)
expect(@knife).to receive(:edit_data).with(data).and_return(data)
@knife.run
end
- it 'should print usage and exit when a client name is not provided' do
+ it "should print usage and exit when a client name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/client_list_spec.rb b/spec/unit/knife/client_list_spec.rb
index ce0fa4f5e8..03d87022db 100644
--- a/spec/unit/knife/client_list_spec.rb
+++ b/spec/unit/knife/client_list_spec.rb
@@ -16,16 +16,16 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ClientList do
before(:each) do
@knife = Chef::Knife::ClientList.new
- @knife.name_args = [ 'adam' ]
+ @knife.name_args = [ "adam" ]
end
- describe 'run' do
- it 'should list the clients' do
+ describe "run" do
+ it "should list the clients" do
expect(Chef::ApiClientV1).to receive(:list)
expect(@knife).to receive(:format_list_for_display)
@knife.run
diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb
index 7e763242e4..da1f4314b6 100644
--- a/spec/unit/knife/client_reregister_spec.rb
+++ b/spec/unit/knife/client_reregister_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ClientReregister do
before(:each) do
@knife = Chef::Knife::ClientReregister.new
- @knife.name_args = [ 'adam' ]
- @client_mock = double('client_mock', :private_key => "foo_key")
+ @knife.name_args = [ "adam" ]
+ @client_mock = double("client_mock", :private_key => "foo_key")
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
@@ -32,28 +32,28 @@ describe Chef::Knife::ClientReregister do
@knife.name_args = []
end
- it 'should print usage and exit when a client name is not provided' do
+ it "should print usage and exit when a client name is not provided" do
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
end
- context 'when not configured for file output' do
- it 'reregisters the client and prints the key' do
- expect(Chef::ApiClientV1).to receive(:reregister).with('adam').and_return(@client_mock)
+ context "when not configured for file output" do
+ it "reregisters the client and prints the key" do
+ expect(Chef::ApiClientV1).to receive(:reregister).with("adam").and_return(@client_mock)
@knife.run
expect(@stdout.string).to match( /foo_key/ )
end
end
- context 'when configured for file output' do
- it 'should write the private key to a file' do
- expect(Chef::ApiClientV1).to receive(:reregister).with('adam').and_return(@client_mock)
+ context "when configured for file output" do
+ it "should write the private key to a file" do
+ expect(Chef::ApiClientV1).to receive(:reregister).with("adam").and_return(@client_mock)
- @knife.config[:file] = '/tmp/monkeypants'
+ @knife.config[:file] = "/tmp/monkeypants"
filehandle = StringIO.new
- expect(File).to receive(:open).with('/tmp/monkeypants', 'w').and_yield(filehandle)
+ expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle)
@knife.run
expect(filehandle.string).to eq("foo_key")
end
diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb
index 73a876cee0..96a7653d92 100644
--- a/spec/unit/knife/client_show_spec.rb
+++ b/spec/unit/knife/client_show_spec.rb
@@ -16,33 +16,33 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ClientShow do
before(:each) do
@knife = Chef::Knife::ClientShow.new
- @knife.name_args = [ 'adam' ]
- @client_mock = double('client_mock')
+ @knife.name_args = [ "adam" ]
+ @client_mock = double("client_mock")
end
- describe 'run' do
- it 'should list the client' do
- expect(Chef::ApiClientV1).to receive(:load).with('adam').and_return(@client_mock)
+ describe "run" do
+ it "should list the client" do
+ expect(Chef::ApiClientV1).to receive(:load).with("adam").and_return(@client_mock)
expect(@knife).to receive(:format_for_display).with(@client_mock)
@knife.run
end
- it 'should pretty print json' do
- @knife.config[:format] = 'json'
+ it "should pretty print json" do
+ @knife.config[:format] = "json"
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
fake_client_contents = {"foo"=>"bar", "baz"=>"qux"}
- expect(Chef::ApiClientV1).to receive(:load).with('adam').and_return(fake_client_contents)
+ 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")
end
- it 'should print usage and exit when a client name is not provided' do
+ it "should print usage and exit when a client name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index 363743f8cc..a825384785 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -16,21 +16,21 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::ConfigureClient do
before do
@knife = Chef::Knife::ConfigureClient.new
- Chef::Config[:chef_server_url] = 'https://chef.example.com'
- Chef::Config[:validation_client_name] = 'chef-validator'
- Chef::Config[:validation_key] = '/etc/chef/validation.pem'
+ Chef::Config[:chef_server_url] = "https://chef.example.com"
+ Chef::Config[:validation_client_name] = "chef-validator"
+ Chef::Config[:validation_key] = "/etc/chef/validation.pem"
@stderr = StringIO.new
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
end
- describe 'run' do
- it 'should print usage and exit when a directory is not provided' do
+ describe "run" do
+ it "should print usage and exit when a directory is not provided" do
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal).with(/must provide the directory/)
expect {
@@ -38,24 +38,24 @@ describe Chef::Knife::ConfigureClient do
}.to raise_error SystemExit
end
- describe 'when specifing a directory' do
+ describe "when specifing a directory" do
before do
- @knife.name_args = ['/home/bob/.chef']
+ @knife.name_args = ["/home/bob/.chef"]
@client_file = StringIO.new
@validation_file = StringIO.new
- expect(File).to receive(:open).with('/home/bob/.chef/client.rb', 'w').
+ expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w").
and_yield(@client_file)
- expect(File).to receive(:open).with('/home/bob/.chef/validation.pem', 'w').
+ expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w").
and_yield(@validation_file)
- expect(IO).to receive(:read).and_return('foo_bar_baz')
+ expect(IO).to receive(:read).and_return("foo_bar_baz")
end
- it 'should recursively create the directory' do
- expect(FileUtils).to receive(:mkdir_p).with('/home/bob/.chef')
+ it "should recursively create the directory" do
+ expect(FileUtils).to receive(:mkdir_p).with("/home/bob/.chef")
@knife.run
end
- it 'should write out the config file' do
+ it "should write out the config file" do
allow(FileUtils).to receive(:mkdir_p)
@knife.run
expect(@client_file.string).to match /log_level\s+\:info/
@@ -64,13 +64,13 @@ describe Chef::Knife::ConfigureClient do
expect(@client_file.string).to match /validation_client_name\s+'chef-validator'/
end
- it 'should write out the validation.pem file' do
+ it "should write out the validation.pem file" do
allow(FileUtils).to receive(:mkdir_p)
@knife.run
expect(@validation_file.string).to match /foo_bar_baz/
end
- it 'should print information on what is being configured' do
+ it "should print information on what is being configured" do
allow(FileUtils).to receive(:mkdir_p)
@knife.run
expect(@stderr.string).to match /creating client configuration/i
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 89874cfdf9..6c1d98c2f5 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Configure do
before do
@@ -11,7 +11,7 @@ describe Chef::Knife::Configure do
@out = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@out)
- @knife.config[:config_file] = '/home/you/.chef/knife.rb'
+ @knife.config[:config_file] = "/home/you/.chef/knife.rb"
@in = StringIO.new("\n" * 7)
allow(@knife.ui).to receive(:stdin).and_return(@in)
@@ -58,11 +58,11 @@ describe Chef::Knife::Configure do
it "should not ask the user for the clientname they want for the new client if -i and --node_name are specified" do
@knife.config[:initial] = true
- @knife.config[:node_name] = 'testnode'
+ @knife.config[:node_name] = "testnode"
allow(Etc).to receive(:getlogin).and_return("a-new-user")
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter a name for the new user"))
- expect(@knife.new_client_name).to eq('testnode')
+ expect(@knife.new_client_name).to eq("testnode")
end
it "asks the user for the existing API username or clientname if -i is not specified" do
@@ -76,21 +76,21 @@ describe Chef::Knife::Configure do
@knife.config[:initial] = true
@knife.ask_user_for_config
expect(@out.string).to match(Regexp.escape("Please enter the existing admin name: [admin]"))
- expect(@knife.admin_client_name).to eq('admin')
+ expect(@knife.admin_client_name).to eq("admin")
end
it "should not ask the user for the existing admin client's name if -i and --admin-client_name are specified" do
@knife.config[:initial] = true
- @knife.config[:admin_client_name] = 'my-webui'
+ @knife.config[:admin_client_name] = "my-webui"
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin:"))
- expect(@knife.admin_client_name).to eq('my-webui')
+ expect(@knife.admin_client_name).to eq("my-webui")
end
it "should not ask the user for the existing admin client's name if -i is not specified" do
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin: [admin]"))
- expect(@knife.admin_client_name).not_to eq('admin')
+ expect(@knife.admin_client_name).not_to eq("admin")
end
it "asks the user for the location of the existing admin key if -i is specified" do
@@ -106,13 +106,13 @@ describe Chef::Knife::Configure do
it "should not ask the user for the location of the existing admin key if -i and --admin_client_key are specified" do
@knife.config[:initial] = true
- @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem'
+ @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem"
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter the location of the existing admin client's private key:"))
if windows?
expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$}
else
- expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem')
+ expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem")
end
end
@@ -129,20 +129,20 @@ describe Chef::Knife::Configure do
it "asks the user for the location of a chef repo" do
@knife.ask_user_for_config
expect(@out.string).to match(Regexp.escape("Please enter the path to a chef repository (or leave blank):"))
- expect(@knife.chef_repo).to eq('')
+ expect(@knife.chef_repo).to eq("")
end
it "asks the users for the name of the validation client" do
@knife.ask_user_for_config
expect(@out.string).to match(Regexp.escape("Please enter the validation clientname: [chef-validator]"))
- expect(@knife.validation_client_name).to eq('chef-validator')
+ expect(@knife.validation_client_name).to eq("chef-validator")
end
it "should not ask the users for the name of the validation client if --validation_client_name is specified" do
- @knife.config[:validation_client_name] = 'my-validator'
+ @knife.config[:validation_client_name] = "my-validator"
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter the validation clientname:"))
- expect(@knife.validation_client_name).to eq('my-validator')
+ expect(@knife.validation_client_name).to eq("my-validator")
end
it "asks the users for the location of the validation key" do
@@ -156,45 +156,45 @@ describe Chef::Knife::Configure do
end
it "should not ask the users for the location of the validation key if --validation_key is specified" do
- @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem'
+ @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem"
@knife.ask_user_for_config
expect(@out.string).not_to match(Regexp.escape("Please enter the location of the validation key:"))
if windows?
expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$}
else
- expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem')
+ expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem")
end
end
it "should not ask the user for anything if -i and all other properties are specified" do
@knife.config[:initial] = true
- @knife.config[:chef_server_url] = 'http://localhost:5000'
- @knife.config[:node_name] = 'testnode'
- @knife.config[:admin_client_name] = 'my-webui'
- @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem'
- @knife.config[:validation_client_name] = 'my-validator'
- @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem'
- @knife.config[:repository] = ''
- @knife.config[:client_key] = '/home/you/a-new-user.pem'
- allow(Etc).to receive(:getlogin).and_return('a-new-user')
+ @knife.config[:chef_server_url] = "http://localhost:5000"
+ @knife.config[:node_name] = "testnode"
+ @knife.config[:admin_client_name] = "my-webui"
+ @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem"
+ @knife.config[:validation_client_name] = "my-validator"
+ @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem"
+ @knife.config[:repository] = ""
+ @knife.config[:client_key] = "/home/you/a-new-user.pem"
+ allow(Etc).to receive(:getlogin).and_return("a-new-user")
@knife.ask_user_for_config
expect(@out.string).to match(/\s*/)
- expect(@knife.new_client_name).to eq('testnode')
- expect(@knife.chef_server).to eq('http://localhost:5000')
- expect(@knife.admin_client_name).to eq('my-webui')
+ expect(@knife.new_client_name).to eq("testnode")
+ expect(@knife.chef_server).to eq("http://localhost:5000")
+ expect(@knife.admin_client_name).to eq("my-webui")
if windows?
expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$}
expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$}
expect(@knife.new_client_key).to match %r{^[A-Za-z]:/home/you/a-new-user\.pem$}
else
- expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem')
- expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem')
- expect(@knife.new_client_key).to eq('/home/you/a-new-user.pem')
+ expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem")
+ expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem")
+ expect(@knife.new_client_key).to eq("/home/you/a-new-user.pem")
end
- expect(@knife.validation_client_name).to eq('my-validator')
- expect(@knife.chef_repo).to eq('')
+ expect(@knife.validation_client_name).to eq("my-validator")
+ expect(@knife.chef_repo).to eq("")
end
it "writes the new data to a config file" do
@@ -205,7 +205,7 @@ describe Chef::Knife::Configure do
expect(FileUtils).to receive(:mkdir_p).with("/home/you/.chef")
config_file = StringIO.new
expect(::File).to receive(:open).with("/home/you/.chef/knife.rb", "w").and_yield config_file
- @knife.config[:repository] = '/home/you/chef-repo'
+ @knife.config[:repository] = "/home/you/chef-repo"
@knife.run
expect(config_file.string).to match(/^node_name[\s]+'#{Etc.getlogin}'$/)
expect(config_file.string).to match(%r{^client_key[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$})
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb
index 7d6e851589..6ef01bc0bb 100644
--- a/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookBulkDelete do
before(:each) do
@@ -48,12 +48,12 @@ describe Chef::Knife::CookbookBulkDelete do
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"}]}}
- 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"}]}}
- 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"}]}}
- allow(@rest).to receive(:get).with('cookbooks/lasagna').and_return(@lasagna)
+ @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"}]}}
+ 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"}]}}
+ allow(@rest).to receive(:get).with("cookbooks/lasagna").and_return(@lasagna)
end
it "should print the cookbooks you are about to delete" do
@@ -68,7 +68,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
@@ -76,7 +76,7 @@ describe Chef::Knife::CookbookBulkDelete do
it "should only delete cookbooks that match the regex" do
@knife.name_args = ["cheezburger"]
- expect(@rest).to receive(:delete).with('cookbooks/cheezburger/1.0.0')
+ expect(@rest).to receive(:delete).with("cookbooks/cheezburger/1.0.0")
@knife.run
end
end
diff --git a/spec/unit/knife/cookbook_create_spec.rb b/spec/unit/knife/cookbook_create_spec.rb
index 8619c8f64b..27bdc303c2 100644
--- a/spec/unit/knife/cookbook_create_spec.rb
+++ b/spec/unit/knife/cookbook_create_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tmpdir'
+require "spec_helper"
+require "tmpdir"
describe Chef::Knife::CookbookCreate do
before(:each) do
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index e9085e9512..aed5f197b9 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -16,51 +16,51 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookDelete do
before(:each) do
@knife = Chef::Knife::CookbookDelete.new
- @knife.name_args = ['foobar']
- @knife.cookbook_name = 'foobar'
+ @knife.name_args = ["foobar"]
+ @knife.cookbook_name = "foobar"
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
@stderr = StringIO.new
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
end
- describe 'run' do
- it 'should print usage and exit when a cookbook name is not provided' do
+ describe "run" do
+ it "should print usage and exit when a cookbook name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
- describe 'when specifying a cookbook name' do
- it 'should delete the cookbook without a specific version' do
+ describe "when specifying a cookbook name" do
+ it "should delete the cookbook without a specific version" do
expect(@knife).to receive(:delete_without_explicit_version)
@knife.run
end
- describe 'and a version' do
- it 'should delete the specific version of the cookbook' do
- @knife.name_args << '1.0.0'
+ describe "and a version" do
+ it "should delete the specific version of the cookbook" do
+ @knife.name_args << "1.0.0"
expect(@knife).to receive(:delete_explicit_version)
@knife.run
end
end
- describe 'with -a or --all' do
- it 'should delete all versions of the cookbook' do
+ describe "with -a or --all" do
+ it "should delete all versions of the cookbook" do
@knife.config[:all] = true
expect(@knife).to receive(:delete_all_versions)
@knife.run
end
end
- describe 'with -p or --purge' do
- it 'should prompt to purge the files' do
+ describe "with -p or --purge" do
+ it "should prompt to purge the files" do
@knife.config[:purge] = true
expect(@knife).to receive(:confirm).
with(/.+Are you sure you want to purge files.+/)
@@ -71,30 +71,30 @@ describe Chef::Knife::CookbookDelete do
end
end
- describe 'delete_explicit_version' do
- it 'should delete the specific cookbook version' do
- @knife.cookbook_name = 'foobar'
- @knife.version = '1.0.0'
+ describe "delete_explicit_version" do
+ it "should delete the specific cookbook version" do
+ @knife.cookbook_name = "foobar"
+ @knife.version = "1.0.0"
expect(@knife).to receive(:delete_object).with(Chef::CookbookVersion,
- 'foobar version 1.0.0',
- 'cookbook').and_yield()
- expect(@knife).to receive(:delete_request).with('cookbooks/foobar/1.0.0')
+ "foobar version 1.0.0",
+ "cookbook").and_yield()
+ expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0")
@knife.delete_explicit_version
end
end
- describe 'delete_all_versions' do
- it 'should prompt to delete all versions of the cookbook' do
- @knife.cookbook_name = 'foobar'
- expect(@knife).to receive(:confirm).with('Do you really want to delete all versions of foobar')
+ describe "delete_all_versions" do
+ it "should prompt to delete all versions of the cookbook" do
+ @knife.cookbook_name = "foobar"
+ expect(@knife).to receive(:confirm).with("Do you really want to delete all versions of foobar")
expect(@knife).to receive(:delete_all_without_confirmation)
@knife.delete_all_versions
end
end
- describe 'delete_all_without_confirmation' do
- it 'should delete all versions without confirmation' do
- versions = ['1.0.0', '1.1.0']
+ describe "delete_all_without_confirmation" do
+ it "should delete all versions without confirmation" do
+ versions = ["1.0.0", "1.1.0"]
expect(@knife).to receive(:available_versions).and_return(versions)
versions.each do |v|
expect(@knife).to receive(:delete_version_without_confirmation).with(v)
@@ -103,43 +103,43 @@ describe Chef::Knife::CookbookDelete do
end
end
- describe 'delete_without_explicit_version' do
- it 'should exit if there are no available versions' do
+ describe "delete_without_explicit_version" do
+ it "should exit if there are no available versions" do
expect(@knife).to receive(:available_versions).and_return(nil)
expect { @knife.delete_without_explicit_version }.to raise_error(SystemExit)
end
- it 'should delete the version if only one is found' do
- expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0'])
+ it "should delete the version if only one is found" do
+ expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0"])
expect(@knife).to receive(:delete_explicit_version)
@knife.delete_without_explicit_version
end
- it 'should ask which version(s) to delete if multiple are found' do
- expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0', '1.1.0'])
- expect(@knife).to receive(:ask_which_versions_to_delete).and_return(['1.0.0', '1.1.0'])
- expect(@knife).to receive(:delete_versions_without_confirmation).with(['1.0.0', '1.1.0'])
+ it "should ask which version(s) to delete if multiple are found" do
+ expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0", "1.1.0"])
+ expect(@knife).to receive(:ask_which_versions_to_delete).and_return(["1.0.0", "1.1.0"])
+ expect(@knife).to receive(:delete_versions_without_confirmation).with(["1.0.0", "1.1.0"])
@knife.delete_without_explicit_version
end
end
- describe 'available_versions' do
+ describe "available_versions" do
before(:each) do
- @rest_mock = double('rest')
+ @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
- it 'should return the list of versions of the cookbook' do
- expect(@rest_mock).to receive(:get).with('cookbooks/foobar').and_return(@cookbook_data)
- expect(@knife.available_versions).to eq(['1.0.0', '1.1.0', '2.0.0'])
+ it "should return the list of versions of the cookbook" do
+ expect(@rest_mock).to receive(:get).with("cookbooks/foobar").and_return(@cookbook_data)
+ expect(@knife.available_versions).to eq(["1.0.0", "1.1.0", "2.0.0"])
end
- it 'should raise if an error other than HTTP 404 is returned' do
- exception = Net::HTTPServerException.new('500 Internal Server Error', '500')
+ it "should raise if an error other than HTTP 404 is returned" do
+ exception = Net::HTTPServerException.new("500 Internal Server Error", "500")
expect(@rest_mock).to receive(:get).and_raise(exception)
expect { @knife.available_versions }.to raise_error Net::HTTPServerException
end
@@ -147,88 +147,88 @@ describe Chef::Knife::CookbookDelete do
describe "if the cookbook can't be found" do
before(:each) do
expect(@rest_mock).to receive(:get).
- and_raise(Net::HTTPServerException.new('404 Not Found', '404'))
+ and_raise(Net::HTTPServerException.new("404 Not Found", "404"))
end
- it 'should print an error' do
+ it "should print an error" do
@knife.available_versions
expect(@stderr.string).to match /error.+cannot find a cookbook named foobar/i
end
- it 'should return nil' do
+ it "should return nil" do
expect(@knife.available_versions).to eq(nil)
end
end
end
- describe 'ask_which_version_to_delete' do
+ describe "ask_which_version_to_delete" do
before(:each) do
- allow(@knife).to receive(:available_versions).and_return(['1.0.0', '1.1.0', '2.0.0'])
+ allow(@knife).to receive(:available_versions).and_return(["1.0.0", "1.1.0", "2.0.0"])
end
- it 'should prompt the user to select a version' do
+ it "should prompt the user to select a version" do
prompt = /Which version\(s\) do you want to delete\?.+1\. foobar 1\.0\.0.+2\. foobar 1\.1\.0.+3\. foobar 2\.0\.0.+4\. All versions.+/m
- expect(@knife).to receive(:ask_question).with(prompt).and_return('1')
+ expect(@knife).to receive(:ask_question).with(prompt).and_return("1")
@knife.ask_which_versions_to_delete
end
it "should print an error and exit if a version wasn't specified" do
- expect(@knife).to receive(:ask_question).and_return('')
+ expect(@knife).to receive(:ask_question).and_return("")
expect(@knife.ui).to receive(:error).with(/no versions specified/i)
expect { @knife.ask_which_versions_to_delete }.to raise_error(SystemExit)
end
- it 'should print an error if an invalid choice was selected' do
- expect(@knife).to receive(:ask_question).and_return('100')
+ it "should print an error if an invalid choice was selected" do
+ expect(@knife).to receive(:ask_question).and_return("100")
expect(@knife.ui).to receive(:error).with(/100 is not a valid choice/i)
@knife.ask_which_versions_to_delete
end
- it 'should return the selected versions' do
- expect(@knife).to receive(:ask_question).and_return('1, 3')
- expect(@knife.ask_which_versions_to_delete).to eq(['1.0.0', '2.0.0'])
+ it "should return the selected versions" do
+ expect(@knife).to receive(:ask_question).and_return("1, 3")
+ expect(@knife.ask_which_versions_to_delete).to eq(["1.0.0", "2.0.0"])
end
it "should return all of the versions if 'all' was selected" do
- expect(@knife).to receive(:ask_question).and_return('4')
+ expect(@knife).to receive(:ask_question).and_return("4")
expect(@knife.ask_which_versions_to_delete).to eq([:all])
end
end
- describe 'delete_version_without_confirmation' do
- it 'should delete the cookbook version' do
- expect(@knife).to receive(:delete_request).with('cookbooks/foobar/1.0.0')
- @knife.delete_version_without_confirmation('1.0.0')
+ describe "delete_version_without_confirmation" do
+ it "should delete the cookbook version" do
+ expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0")
+ @knife.delete_version_without_confirmation("1.0.0")
end
- it 'should output that the cookbook was deleted' do
+ it "should output that the cookbook was deleted" do
allow(@knife).to receive(:delete_request)
- @knife.delete_version_without_confirmation('1.0.0')
+ @knife.delete_version_without_confirmation("1.0.0")
expect(@stderr.string).to match /deleted cookbook\[foobar\]\[1.0.0\]/im
end
- describe 'with --print-after' do
- it 'should display the cookbook data' do
- object = ''
+ describe "with --print-after" do
+ it "should display the cookbook data" do
+ object = ""
@knife.config[:print_after] = true
allow(@knife).to receive(:delete_request).and_return(object)
expect(@knife).to receive(:format_for_display).with(object)
- @knife.delete_version_without_confirmation('1.0.0')
+ @knife.delete_version_without_confirmation("1.0.0")
end
end
end
- describe 'delete_versions_without_confirmation' do
- it 'should delete each version without confirmation' do
- versions = ['1.0.0', '1.1.0']
+ describe "delete_versions_without_confirmation" do
+ it "should delete each version without confirmation" do
+ versions = ["1.0.0", "1.1.0"]
versions.each do |v|
expect(@knife).to receive(:delete_version_without_confirmation).with(v)
end
@knife.delete_versions_without_confirmation(versions)
end
- describe 'with -a or --all' do
- it 'should delete all versions without confirmation' do
+ describe "with -a or --all" do
+ it "should delete all versions without confirmation" do
versions = [:all]
expect(@knife).to receive(:delete_all_without_confirmation)
@knife.delete_versions_without_confirmation(versions)
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 64b754d173..baa8acc6f4 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookDownload do
before(:each) do
@@ -25,66 +25,66 @@ describe Chef::Knife::CookbookDownload do
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
end
- describe 'run' do
- it 'should print usage and exit when a cookbook name is not provided' do
+ describe "run" do
+ it "should print usage and exit when a cookbook name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal).with(/must specify a cookbook name/)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should exit with a fatal error when there is no cookbook on the server' do
- @knife.name_args = ['foobar', nil]
+ it "should exit with a fatal error when there is no cookbook on the server" do
+ @knife.name_args = ["foobar", nil]
expect(@knife).to receive(:determine_version).and_return(nil)
- expect(@knife.ui).to receive(:fatal).with('No such cookbook found')
+ expect(@knife.ui).to receive(:fatal).with("No such cookbook found")
expect { @knife.run }.to raise_error(SystemExit)
end
- describe 'with a cookbook name' do
+ describe "with a cookbook name" do
before(:each) do
- @knife.name_args = ['foobar']
- @knife.config[:download_directory] = '/var/tmp/chef'
- @rest_mock = double('rest')
+ @knife.name_args = ["foobar"]
+ @knife.config[:download_directory] = "/var/tmp/chef"
+ @rest_mock = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_mock)
@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"},
],
}
- @cookbook_mock = double('cookbook')
- allow(@cookbook_mock).to receive(:version).and_return('1.0.0')
+ @cookbook_mock = double("cookbook")
+ allow(@cookbook_mock).to receive(:version).and_return("1.0.0")
allow(@cookbook_mock).to receive(:manifest).and_return(@manifest_data)
expect(Chef::CookbookVersion).to receive(:load).with("foobar", "1.0.0").
and_return(@cookbook_mock)
end
- it 'should determine which version if one was not explicitly specified'do
+ it "should determine which version if one was not explicitly specified"do
allow(@cookbook_mock).to receive(:manifest).and_return({})
- expect(@knife).to receive(:determine_version).and_return('1.0.0')
- expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(false)
+ expect(@knife).to receive(:determine_version).and_return("1.0.0")
+ expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
allow(Chef::CookbookVersion).to receive(:COOKBOOK_SEGEMENTS).and_return([])
@knife.run
end
- describe 'and a version' do
+ describe "and a version" do
before(:each) do
- @knife.name_args << '1.0.0'
- @files = @manifest_data.values.map { |v| v.map { |i| i['path'] } }.flatten.uniq
+ @knife.name_args << "1.0.0"
+ @files = @manifest_data.values.map { |v| v.map { |i| i["path"] } }.flatten.uniq
@files_mocks = {}
@files.map { |f| File.basename(f) }.flatten.uniq.each do |f|
@files_mocks[f] = double("#{f}_mock")
@@ -92,13 +92,13 @@ describe Chef::Knife::CookbookDownload do
end
end
- it 'should print an error and exit if the cookbook download directory already exists' do
- expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(true)
+ it "should print an error and exit if the cookbook download directory already exists" do
+ expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
expect(@knife.ui).to receive(:fatal).with(/\/var\/tmp\/chef\/foobar-1\.0\.0 exists/i)
expect { @knife.run }.to raise_error(SystemExit)
end
- describe 'when downloading the cookbook' do
+ describe "when downloading the cookbook" do
before(:each) do
@files.map { |f| File.dirname(f) }.flatten.uniq.each do |dir|
expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}").
@@ -117,20 +117,20 @@ describe Chef::Knife::CookbookDownload do
end
it "should download the cookbook when the cookbook download directory doesn't exist" do
- expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(false)
+ expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
@knife.run
- ['attributes', 'recipes', 'templates'].each do |segment|
+ ["attributes", "recipes", "templates"].each do |segment|
expect(@stderr.string).to match /downloading #{segment}/im
end
expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im
expect(@stderr.string).to match /cookbook downloaded to \/var\/tmp\/chef\/foobar-1\.0\.0/im
end
- describe 'with -f or --force' do
- it 'should remove the existing the cookbook download directory if it exists' do
+ describe "with -f or --force" do
+ it "should remove the existing the cookbook download directory if it exists" do
@knife.config[:force] = true
- expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(true)
- expect(FileUtils).to receive(:rm_rf).with('/var/tmp/chef/foobar-1.0.0')
+ expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
+ expect(FileUtils).to receive(:rm_rf).with("/var/tmp/chef/foobar-1.0.0")
@knife.run
end
end
@@ -141,94 +141,94 @@ describe Chef::Knife::CookbookDownload do
end
- describe 'determine_version' do
+ describe "determine_version" do
- it 'should return nil if there are no versions' do
+ it "should return nil if there are no versions" do
expect(@knife).to receive(:available_versions).and_return(nil)
expect(@knife.determine_version).to eq(nil)
expect(@knife.version).to eq(nil)
end
- it 'should return and set the version if there is only one version' do
- expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0'])
- expect(@knife.determine_version).to eq('1.0.0')
- expect(@knife.version).to eq('1.0.0')
+ it "should return and set the version if there is only one version" do
+ expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0"])
+ expect(@knife.determine_version).to eq("1.0.0")
+ expect(@knife.version).to eq("1.0.0")
end
- it 'should ask which version to download and return it if there is more than one' do
- expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0', '2.0.0'])
- expect(@knife).to receive(:ask_which_version).and_return('1.0.0')
- expect(@knife.determine_version).to eq('1.0.0')
+ it "should ask which version to download and return it if there is more than one" do
+ expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0", "2.0.0"])
+ expect(@knife).to receive(:ask_which_version).and_return("1.0.0")
+ expect(@knife.determine_version).to eq("1.0.0")
end
- describe 'with -N or --latest' do
- it 'should return and set the version to the latest version' do
+ describe "with -N or --latest" do
+ it "should return and set the version to the latest version" do
@knife.config[:latest] = true
expect(@knife).to receive(:available_versions).at_least(:once).
- and_return(['1.0.0', '1.1.0', '2.0.0'])
+ and_return(["1.0.0", "1.1.0", "2.0.0"])
@knife.determine_version
- expect(@knife.version.to_s).to eq('2.0.0')
+ expect(@knife.version.to_s).to eq("2.0.0")
end
end
end
- describe 'available_versions' do
+ describe "available_versions" do
before(:each) do
- @knife.cookbook_name = 'foobar'
+ @knife.cookbook_name = "foobar"
end
- it 'should return nil if there are no versions' do
+ it "should return nil if there are no versions" do
expect(Chef::CookbookVersion).to receive(:available_versions).
- with('foobar').
+ with("foobar").
and_return(nil)
expect(@knife.available_versions).to eq(nil)
end
- it 'should return the available versions' do
+ it "should return the available versions" do
expect(Chef::CookbookVersion).to receive(:available_versions).
- with('foobar').
- and_return(['1.1.0', '2.0.0', '1.0.0'])
- expect(@knife.available_versions).to eq([Chef::Version.new('1.0.0'),
- Chef::Version.new('1.1.0'),
- Chef::Version.new('2.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")])
end
- it 'should avoid multiple API calls to the server' 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'])
+ with("foobar").
+ and_return(["1.1.0", "2.0.0", "1.0.0"])
@knife.available_versions
@knife.available_versions
end
end
- describe 'ask_which_version' do
+ describe "ask_which_version" do
before(:each) do
- @knife.cookbook_name = 'foobar'
- allow(@knife).to receive(:available_versions).and_return(['1.0.0', '1.1.0', '2.0.0'])
+ @knife.cookbook_name = "foobar"
+ allow(@knife).to receive(:available_versions).and_return(["1.0.0", "1.1.0", "2.0.0"])
end
- it 'should prompt the user to select a version' do
+ it "should prompt the user to select a version" do
prompt = /Which version do you want to download\?.+1\. foobar 1\.0\.0.+2\. foobar 1\.1\.0.+3\. foobar 2\.0\.0.+/m
- expect(@knife).to receive(:ask_question).with(prompt).and_return('1')
+ expect(@knife).to receive(:ask_question).with(prompt).and_return("1")
@knife.ask_which_version
end
it "should set the version to the user's selection" do
- expect(@knife).to receive(:ask_question).and_return('1')
+ expect(@knife).to receive(:ask_question).and_return("1")
@knife.ask_which_version
- expect(@knife.version).to eq('1.0.0')
+ expect(@knife.version).to eq("1.0.0")
end
it "should print an error and exit if a version wasn't specified" do
- expect(@knife).to receive(:ask_question).and_return('')
+ expect(@knife).to receive(:ask_question).and_return("")
expect(@knife.ui).to receive(:error).with(/is not a valid value/i)
expect { @knife.ask_which_version }.to raise_error(SystemExit)
end
- it 'should print an error if an invalid choice was selected' do
- expect(@knife).to receive(:ask_question).and_return('100')
+ it "should print an error if an invalid choice was selected" do
+ expect(@knife).to receive(:ask_question).and_return("100")
expect(@knife.ui).to receive(:error).with(/'100' is not a valid value/i)
expect { @knife.ask_which_version }.to raise_error(SystemExit)
end
diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb
index fc07c8af3f..124c4bca8e 100644
--- a/spec/unit/knife/cookbook_list_spec.rb
+++ b/spec/unit/knife/cookbook_list_spec.rb
@@ -16,28 +16,28 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookList do
before do
@knife = Chef::Knife::CookbookList.new
- @rest_mock = double('rest')
+ @rest_mock = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_mock)
- @cookbook_names = ['apache2', 'mysql']
- @base_url = 'https://server.example.com/cookbooks'
+ @cookbook_names = ["apache2", "mysql"]
+ @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)
end
- describe 'run' do
- it 'should display the latest version of the cookbooks' do
- expect(@rest_mock).to receive(:get).with('/cookbooks?num_versions=1').
+ 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)
@knife.run
@cookbook_names.each do |item|
@@ -45,16 +45,16 @@ describe Chef::Knife::CookbookList do
end
end
- it 'should query cookbooks for the configured environment' do
- @knife.config[:environment] = 'production'
+ 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').
+ with("/environments/production/cookbooks?num_versions=1").
and_return(@cookbook_data)
@knife.run
end
- describe 'with -w or --with-uri' do
- it 'should display the cookbook uris' do
+ describe "with -w or --with-uri" do
+ it "should display the cookbook uris" do
@knife.config[:with_uri] = true
allow(@rest_mock).to receive(:get).and_return(@cookbook_data)
@knife.run
@@ -65,17 +65,17 @@ describe Chef::Knife::CookbookList do
end
end
- describe 'with -a or --all' 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
+ 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').
+ expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all").
and_return(@cookbook_data)
@knife.run
@cookbook_names.each do |item|
diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
index 456e378ca2..852258e8a0 100644
--- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookMetadataFromFile do
before(:each) do
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index bd54d4278b..1dcc840611 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookMetadata do
before(:each) do
@knife = Chef::Knife::CookbookMetadata.new
- @knife.name_args = ['foobar']
+ @knife.name_args = ["foobar"]
@cookbook_dir = Dir.mktmpdir
@json_data = '{ "version": "1.0.0" }'
@stdout = StringIO.new
@@ -30,50 +30,50 @@ describe Chef::Knife::CookbookMetadata do
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
end
- describe 'run' do
- it 'should print an error and exit if a cookbook name was not provided' do
+ describe "run" do
+ it "should print an error and exit if a cookbook name was not provided" do
@knife.name_args = []
expect(@knife.ui).to receive(:error).with(/you must specify the cookbook.+use the --all/i)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should print an error and exit if an empty cookbook name was provided' do
- @knife.name_args = ['']
+ it "should print an error and exit if an empty cookbook name was provided" do
+ @knife.name_args = [""]
expect(@knife.ui).to receive(:error).with(/you must specify the cookbook.+use the --all/i)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should generate the metadata for the cookbook' do
- expect(@knife).to receive(:generate_metadata).with('foobar')
+ it "should generate the metadata for the cookbook" do
+ expect(@knife).to receive(:generate_metadata).with("foobar")
@knife.run
end
- describe 'with -a or --all' do
+ describe "with -a or --all" do
before(:each) do
@knife.config[:all] = true
- @foo = Chef::CookbookVersion.new('foo', '/tmp/blah')
- @foo.version = '1.0.0'
- @bar = Chef::CookbookVersion.new('bar', '/tmp/blah')
- @bar.version = '2.0.0'
+ @foo = Chef::CookbookVersion.new("foo", "/tmp/blah")
+ @foo.version = "1.0.0"
+ @bar = Chef::CookbookVersion.new("bar", "/tmp/blah")
+ @bar.version = "2.0.0"
@cookbook_loader = {
"foo" => @foo,
"bar" => @bar,
}
expect(@cookbook_loader).to receive(:load_cookbooks).and_return(@cookbook_loader)
- expect(@knife).to receive(:generate_metadata).with('foo')
- expect(@knife).to receive(:generate_metadata).with('bar')
+ expect(@knife).to receive(:generate_metadata).with("foo")
+ expect(@knife).to receive(:generate_metadata).with("bar")
end
- it 'should generate the metadata for each cookbook' do
+ it "should generate the metadata for each cookbook" do
Chef::Config[:cookbook_path] = @cookbook_dir
expect(Chef::CookbookLoader).to receive(:new).with(@cookbook_dir).and_return(@cookbook_loader)
@knife.run
end
- describe 'and with -o or --cookbook-path' do
- it 'should look in the provided path and generate cookbook metadata' do
- @knife.config[:cookbook_path] = '/opt/chef/cookbooks'
- expect(Chef::CookbookLoader).to receive(:new).with('/opt/chef/cookbooks').and_return(@cookbook_loader)
+ describe "and with -o or --cookbook-path" do
+ it "should look in the provided path and generate cookbook metadata" do
+ @knife.config[:cookbook_path] = "/opt/chef/cookbooks"
+ expect(Chef::CookbookLoader).to receive(:new).with("/opt/chef/cookbooks").and_return(@cookbook_loader)
@knife.run
end
end
@@ -81,55 +81,55 @@ describe Chef::Knife::CookbookMetadata do
end
- describe 'generate_metadata' do
+ describe "generate_metadata" 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")
end
- it 'should generate the metadata from metadata.rb if it exists' do
+ 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)
- expect(@knife).to receive(:generate_metadata_from_file).with('foobar', "#{@cookbook_dir}/foobar/metadata.rb")
+ 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
+ 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)
- expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, 'foobar')
+ expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, "foobar")
@knife.run
end
end
- describe 'generate_metadata_from_file' do
+ describe "generate_metadata_from_file" do
before(:each) do
- @metadata_mock = double('metadata')
- @json_file_mock = double('json_file')
+ @metadata_mock = double("metadata")
+ @json_file_mock = double("json_file")
end
- it 'should generate the metatdata json from metatdata.rb' do
+ it "should generate the metatdata json from metatdata.rb" do
allow(Chef::Cookbook::Metadata).to receive(:new).and_return(@metadata_mock)
- expect(@metadata_mock).to receive(:name).with('foobar')
+ 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').
+ expect(File).to receive(:open).with("#{@cookbook_dir}/foobar/metadata.json", "w").
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)
- @knife.generate_metadata_from_file('foobar', "#{@cookbook_dir}/foobar/metadata.rb")
+ @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
- { Chef::Exceptions::ObsoleteDependencySyntax => 'obsolote dependency',
- Chef::Exceptions::InvalidVersionConstraint => 'invalid version constraint',
+ { Chef::Exceptions::ObsoleteDependencySyntax => "obsolote dependency",
+ Chef::Exceptions::InvalidVersionConstraint => "invalid version constraint",
}.each_pair do |klass, description|
it "should print an error and exit when an #{description} syntax exception is encountered" do
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:new).and_raise(exception)
expect {
- @knife.generate_metadata_from_file('foobar', "#{@cookbook_dir}/foobar/metadata.rb")
+ @knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb")
}.to raise_error(SystemExit)
expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im
expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.rb/im
@@ -138,26 +138,26 @@ describe Chef::Knife::CookbookMetadata do
end
end
- describe 'validate_metadata_json' do
- it 'should validate the metadata json' 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)
expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json").
and_return(@json_data)
expect(Chef::Cookbook::Metadata).to receive(:validate_json).with(@json_data)
- @knife.validate_metadata_json(@cookbook_dir, 'foobar')
+ @knife.validate_metadata_json(@cookbook_dir, "foobar")
end
- it 'should not try to validate the metadata json if the file does not exist' do
+ 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)
expect(IO).not_to receive(:read)
expect(Chef::Cookbook::Metadata).not_to receive(:validate_json)
- @knife.validate_metadata_json(@cookbook_dir, 'foobar')
+ @knife.validate_metadata_json(@cookbook_dir, "foobar")
end
- { Chef::Exceptions::ObsoleteDependencySyntax => 'obsolote dependency',
- Chef::Exceptions::InvalidVersionConstraint => 'invalid version constraint',
+ { Chef::Exceptions::ObsoleteDependencySyntax => "obsolote dependency",
+ Chef::Exceptions::InvalidVersionConstraint => "invalid version constraint",
}.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").
@@ -167,7 +167,7 @@ describe Chef::Knife::CookbookMetadata do
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception)
expect {
- @knife.validate_metadata_json(@cookbook_dir, 'foobar')
+ @knife.validate_metadata_json(@cookbook_dir, "foobar")
}.to raise_error(SystemExit)
expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im
expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.json/im
diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb
index 6c77db013f..bde33b0689 100644
--- a/spec/unit/knife/cookbook_show_spec.rb
+++ b/spec/unit/knife/cookbook_show_spec.rb
@@ -17,7 +17,7 @@
#
# rename to cookbook not coookbook
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookShow do
before(:each) do
@@ -33,7 +33,7 @@ describe Chef::Knife::CookbookShow do
describe "run" do
describe "with 0 arguments: help" do
- it 'should should print usage and exit when given no arguments' do
+ it "should should print usage and exit when given no arguments" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb
index 35c6544d58..52e82a7f0b 100644
--- a/spec/unit/knife/cookbook_site_download_spec.rb
+++ b/spec/unit/knife/cookbook_site_download_spec.rb
@@ -16,22 +16,22 @@
# limitations under the License.
#
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Chef::Knife::CookbookSiteDownload do
- describe 'run' do
+ describe "run" do
before do
@knife = Chef::Knife::CookbookSiteDownload.new
- @knife.name_args = ['apache2']
- @noauth_rest = double('no auth rest')
+ @knife.name_args = ["apache2"]
+ @noauth_rest = double("no auth rest")
@stderr = StringIO.new
- @cookbook_api_url = 'https://supermarket.chef.io/api/v1/cookbooks'
- @version = '1.0.2'
- @version_us = @version.gsub '.', '_'
- @current_data = { 'deprecated' => false,
- 'latest_version' => "#{@cookbook_api_url}/apache2/versions/#{@version_us}",
- 'replacement' => 'other_apache2' }
+ @cookbook_api_url = "https://supermarket.chef.io/api/v1/cookbooks"
+ @version = "1.0.2"
+ @version_us = @version.gsub ".", "_"
+ @current_data = { "deprecated" => false,
+ "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}",
+ "replacement" => "other_apache2" }
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
@@ -40,12 +40,12 @@ describe Chef::Knife::CookbookSiteDownload do
and_return(@current_data)
end
- context 'when the cookbook is deprecated and not forced' do
+ context "when the cookbook is deprecated and not forced" do
before do
- @current_data['deprecated'] = true
+ @current_data["deprecated"] = true
end
- it 'should warn with info about the replacement' do
+ it "should warn with info about the replacement" do
expect(@knife.ui).to receive(:warn).
with(/.+deprecated.+replaced by other_apache2.+/i)
expect(@knife.ui).to receive(:warn).
@@ -54,33 +54,33 @@ describe Chef::Knife::CookbookSiteDownload do
end
end
- context 'when' do
+ context "when" do
before do
- @cookbook_data = { 'version' => @version,
- 'file' => "http://example.com/apache2_#{@version_us}.tgz" }
+ @cookbook_data = { "version" => @version,
+ "file" => "http://example.com/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)
end
- context 'downloading the latest version' do
+ context "downloading the latest version" do
before do
expect(@noauth_rest).to receive(:get).
- with(@current_data['latest_version']).
+ with(@current_data["latest_version"]).
and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data['file'], true).
+ with(@cookbook_data["file"], true).
and_return(@temp_file)
end
- context 'and it is deprecated and with --force' do
+ context "and it is deprecated and with --force" do
before do
- @current_data['deprecated'] = true
+ @current_data["deprecated"] = true
@knife.config[:force] = true
end
- it 'should download the latest version' do
+ it "should download the latest version" do
expect(@knife.ui).to receive(:warn).
with(/.+deprecated.+replaced by other_apache2.+/i)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@@ -91,51 +91,51 @@ describe Chef::Knife::CookbookSiteDownload do
end
- it 'should download the latest version' do
+ it "should download the latest version" do
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i
end
- context 'with -f or --file' do
+ context "with -f or --file" do
before do
- @file = '/opt/chef/cookbooks/apache2.tar.gz'
+ @file = "/opt/chef/cookbooks/apache2.tar.gz"
@knife.config[:file] = @file
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
end
- it 'should download the cookbook to the desired file' do
+ it "should download the cookbook to the desired file" do
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i
end
end
- it 'should provide an accessor to the version' do
+ it "should provide an accessor to the version" do
allow(FileUtils).to receive(:cp).and_return(true)
expect(@knife.version).to eq(@version)
@knife.run
end
end
- context 'downloading a cookbook of a specific version' do
+ context "downloading a cookbook of a specific version" do
before do
- @version = '1.0.1'
- @version_us = @version.gsub '.', '_'
- @cookbook_data = { 'version' => @version,
- 'file' => "http://example.com/apache2_#{@version_us}.tgz" }
+ @version = "1.0.1"
+ @version_us = @version.gsub ".", "_"
+ @cookbook_data = { "version" => @version,
+ "file" => "http://example.com/apache2_#{@version_us}.tgz" }
@temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz")
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
@knife.name_args << @version
end
- it 'should download the desired version' do
+ it "should download the desired version" do
expect(@noauth_rest).to receive(:get).
with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data['file'], true).
+ with(@cookbook_data["file"], true).
and_return(@temp_file)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index 9779de4a64..c2ffe4bb14 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -28,14 +28,14 @@ describe Chef::Knife::CookbookSiteInstall do
:merge_updates_from => true) }
let(:install_path) {
if Chef::Platform.windows?
- 'C:/tmp/chef'
+ "C:/tmp/chef"
else
- '/var/tmp/chef'
+ "/var/tmp/chef"
end
}
before(:each) do
- require 'chef/knife/core/cookbook_scm_repo'
+ require "chef/knife/core/cookbook_scm_repo"
allow(knife.ui).to receive(:stdout).and_return(stdout)
knife.config = {}
diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb
index 14ade10e09..5cd90bc0c4 100644
--- a/spec/unit/knife/cookbook_site_share_spec.rb
+++ b/spec/unit/knife/cookbook_site_share_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/cookbook_uploader'
-require 'chef/cookbook_site_streaming_uploader'
+require "chef/cookbook_uploader"
+require "chef/cookbook_site_streaming_uploader"
describe Chef::Knife::CookbookSiteShare do
@@ -27,11 +27,11 @@ describe Chef::Knife::CookbookSiteShare do
@knife = Chef::Knife::CookbookSiteShare.new
# Merge default settings in.
@knife.merge_configs
- @knife.name_args = ['cookbook_name', 'AwesomeSausage']
+ @knife.name_args = ["cookbook_name", "AwesomeSausage"]
- @cookbook = Chef::CookbookVersion.new('cookbook_name')
+ @cookbook = Chef::CookbookVersion.new("cookbook_name")
- @cookbook_loader = double('Chef::CookbookLoader')
+ @cookbook_loader = double("Chef::CookbookLoader")
allow(@cookbook_loader).to receive(:cookbook_exists?).and_return(true)
allow(@cookbook_loader).to receive(:[]).and_return(@cookbook)
allow(Chef::CookbookLoader).to receive(:new).and_return(@cookbook_loader)
@@ -39,7 +39,7 @@ describe Chef::Knife::CookbookSiteShare do
@noauth_rest = double(Chef::ServerAPI)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
- @cookbook_uploader = Chef::CookbookUploader.new('herpderp', :rest => "norest")
+ @cookbook_uploader = Chef::CookbookUploader.new("herpderp", :rest => "norest")
allow(Chef::CookbookUploader).to receive(:new).and_return(@cookbook_uploader)
allow(@cookbook_uploader).to receive(:validate_cookbooks).and_return(true)
allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir)
@@ -49,7 +49,7 @@ describe Chef::Knife::CookbookSiteShare do
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
- describe 'run' do
+ describe "run" do
before(:each) do
allow(@knife).to receive(:do_upload).and_return(true)
@@ -65,39 +65,39 @@ describe Chef::Knife::CookbookSiteShare do
}
end
- it 'should set true to config[:dry_run] as default' do
+ it "should set true to config[:dry_run] as default" do
expect(@knife.config[:dry_run]).to be_falsey
end
- it 'should should print usage and exit when given no arguments' do
+ it "should should print usage and exit when given no arguments" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should not fail when given only 1 argument and can determine category' do
- @knife.name_args = ['cookbook_name']
+ it "should not fail when given only 1 argument and can determine category" do
+ @knife.name_args = ["cookbook_name"]
expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name").and_return(@category_response)
expect(@knife).to receive(:do_upload)
@knife.run
end
- it 'should print error and exit when given only 1 argument and cannot determine category' do
- @knife.name_args = ['cookbook_name']
+ it "should print error and exit when given only 1 argument and cannot determine category" do
+ @knife.name_args = ["cookbook_name"]
expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name").and_return(@bad_category_response)
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should print error and exit when given only 1 argument and Chef::ServerAPI throws an exception' do
- @knife.name_args = ['cookbook_name']
+ it "should print error and exit when given only 1 argument and Chef::ServerAPI throws an exception" do
+ @knife.name_args = ["cookbook_name"]
expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Errno::ECONNREFUSED, "Connection refused" }
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should check if the cookbook exists' do
+ it "should check if the cookbook exists" do
expect(@cookbook_loader).to receive(:cookbook_exists?)
@knife.run
end
@@ -108,15 +108,15 @@ describe Chef::Knife::CookbookSiteShare do
expect { @knife.run }.to raise_error(SystemExit)
end
- if File.exists?('/usr/bin/gnutar') || File.exists?('/bin/gnutar')
- it 'should use gnutar to make a tarball of the cookbook' do
+ if File.exists?("/usr/bin/gnutar") || File.exists?("/bin/gnutar")
+ it "should use gnutar to make a tarball of the cookbook" do
expect(@knife).to receive(:shell_out!) do |args|
expect(args.to_s).to match(/gnutar -czf/)
end
@knife.run
end
else
- it 'should make a tarball of the cookbook' do
+ it "should make a tarball of the cookbook" do
expect(@knife).to receive(:shell_out!) do |args|
expect(args.to_s).to match(/tar -czf/)
end
@@ -124,13 +124,13 @@ describe Chef::Knife::CookbookSiteShare do
end
end
- it 'should exit and log to error when the tarball creation fails' do
+ it "should exit and log to error when the tarball creation fails" do
allow(@knife).to receive(:shell_out!).and_raise(Chef::Exceptions::Exec)
expect(@knife.ui).to receive(:error)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should upload the cookbook and clean up the tarball' do
+ it "should upload the cookbook and clean up the tarball" do
expect(@knife).to receive(:do_upload)
expect(FileUtils).to receive(:rm_rf)
@knife.run
@@ -140,7 +140,7 @@ describe Chef::Knife::CookbookSiteShare do
before do
allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
@knife.config = { :dry_run => true }
- allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return('file')
+ allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file")
end
it "should list files in the tarball" do
@@ -158,10 +158,10 @@ describe Chef::Knife::CookbookSiteShare do
end
end
- describe 'do_upload' do
+ describe "do_upload" do
before(:each) do
- @upload_response = double('Net::HTTPResponse')
+ @upload_response = double("Net::HTTPResponse")
allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response)
@stdout = StringIO.new
@@ -172,22 +172,22 @@ 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())
@knife.run
end
- it 'should alert the user when a version already exists' do
- response_text = Chef::JSONCompat.to_json({:error_messages => ['Version already exists']})
+ it "should alert the user when a version already exists" do
+ 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)
expect(@stderr.string).to match(/ERROR(.+)cookbook already exists/)
end
- it 'should pass any errors on to the user' do
+ it "should pass any errors on to the user" do
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)
@@ -195,7 +195,7 @@ describe Chef::Knife::CookbookSiteShare do
expect(@stderr.string).to match("ERROR(.*)You're holding it wrong")
end
- it 'should print the body if no errors are exposed on failure' do
+ 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"})
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(500)
diff --git a/spec/unit/knife/cookbook_site_unshare_spec.rb b/spec/unit/knife/cookbook_site_unshare_spec.rb
index aafb7c1507..d8c67aae20 100644
--- a/spec/unit/knife/cookbook_site_unshare_spec.rb
+++ b/spec/unit/knife/cookbook_site_unshare_spec.rb
@@ -17,26 +17,26 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::CookbookSiteUnshare do
before(:each) do
@knife = Chef::Knife::CookbookSiteUnshare.new
- @knife.name_args = ['cookbook_name']
+ @knife.name_args = ["cookbook_name"]
allow(@knife).to receive(:confirm).and_return(true)
- @rest = double('Chef::ServerAPI')
+ @rest = double("Chef::ServerAPI")
allow(@rest).to receive(:delete).and_return(true)
allow(@knife).to receive(:rest).and_return(@rest)
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
- describe 'run' do
+ describe "run" do
- describe 'with no cookbook argument' do
- it 'should print the usage and exit' do
+ describe "with no cookbook argument" do
+ it "should print the usage and exit" do
@knife.name_args = []
expect(@knife.ui).to receive(:fatal)
expect(@knife).to receive(:show_usage)
@@ -44,30 +44,30 @@ describe Chef::Knife::CookbookSiteUnshare do
end
end
- it 'should confirm you want to unshare the cookbook' do
+ it "should confirm you want to unshare the cookbook" do
expect(@knife).to receive(:confirm)
@knife.run
end
- it 'should send a delete request to the cookbook site' do
+ it "should send a delete request to the cookbook site" do
expect(@rest).to receive(:delete)
@knife.run
end
- it 'should log an error and exit when forbidden' do
- exception = double('403 "Forbidden"', :code => '403')
+ it "should log an error and exit when forbidden" do
+ exception = double('403 "Forbidden"', :code => "403")
allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception))
expect(@knife.ui).to receive(:error)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'should re-raise any non-forbidden errors on delete' do
- exception = double('500 "Application Error"', :code => '500')
+ it "should re-raise any non-forbidden errors on delete" do
+ exception = double('500 "Application Error"', :code => "500")
allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception))
expect { @knife.run }.to raise_error(Net::HTTPServerException)
end
- it 'should log a success message' do
+ it "should log a success message" do
expect(@knife.ui).to receive(:info)
@knife.run
end
diff --git a/spec/unit/knife/cookbook_test_spec.rb b/spec/unit/knife/cookbook_test_spec.rb
index ce74bcaa5d..3587de0c78 100644
--- a/spec/unit/knife/cookbook_test_spec.rb
+++ b/spec/unit/knife/cookbook_test_spec.rb
@@ -18,14 +18,14 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::CookbookTest.load_deps
describe Chef::Knife::CookbookTest do
before(:each) do
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 ecee34f308..666974a817 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -19,11 +19,11 @@
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
-require 'chef/cookbook_uploader'
-require 'timeout'
+require "chef/cookbook_uploader"
+require "timeout"
describe Chef::Knife::CookbookUpload do
- let(:cookbook) { Chef::CookbookVersion.new('test_cookbook', '/tmp/blah.txt') }
+ let(:cookbook) { Chef::CookbookVersion.new("test_cookbook", "/tmp/blah.txt") }
let(:cookbooks_by_name) do
{cookbook.name => cookbook}
@@ -40,7 +40,7 @@ describe Chef::Knife::CookbookUpload do
let(:output) { StringIO.new }
- let(:name_args) { ['test_cookbook'] }
+ let(:name_args) { ["test_cookbook"] }
let(:knife) do
k = Chef::Knife::CookbookUpload.new
@@ -54,11 +54,11 @@ describe Chef::Knife::CookbookUpload do
allow(Chef::CookbookLoader).to receive(:new).and_return(cookbook_loader)
end
- describe 'with --concurrency' do
- it 'should upload cookbooks with predefined concurrency' do
+ describe "with --concurrency" do
+ it "should upload cookbooks with predefined concurrency" do
allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({})
knife.config[:concurrency] = 3
- test_cookbook = Chef::CookbookVersion.new('test_cookbook', '/tmp/blah')
+ test_cookbook = Chef::CookbookVersion.new("test_cookbook", "/tmp/blah")
allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook)
allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"])
expect(Chef::CookbookUploader).to receive(:new).
@@ -68,35 +68,35 @@ describe Chef::Knife::CookbookUpload do
end
end
- describe 'run' do
+ describe "run" do
before(:each) do
allow(Chef::CookbookUploader).to receive_messages(:new => cookbook_uploader)
allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({})
end
- it 'should print usage and exit when a cookbook name is not provided' do
+ it "should print usage and exit when a cookbook name is not provided" do
knife.name_args = []
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
expect { knife.run }.to raise_error(SystemExit)
end
- describe 'when specifying a cookbook name' do
- it 'should upload the cookbook' do
+ describe "when specifying a cookbook name" do
+ it "should upload the cookbook" do
expect(knife).to receive(:upload).once
knife.run
end
- it 'should report on success' do
+ it "should report on success" do
expect(knife).to receive(:upload).once
expect(knife.ui).to receive(:info).with(/Uploaded 1 cookbook/)
knife.run
end
end
- describe 'when specifying the same cookbook name twice' do
- it 'should upload the cookbook only once' do
- knife.name_args = ['test_cookbook', 'test_cookbook']
+ describe "when specifying the same cookbook name twice" do
+ it "should upload the cookbook only once" do
+ knife.name_args = ["test_cookbook", "test_cookbook"]
expect(knife).to receive(:upload).once
knife.run
end
@@ -105,9 +105,9 @@ describe Chef::Knife::CookbookUpload do
context "when uploading a cookbook that uses deprecated overlays" do
before do
- allow(cookbook_loader).to receive(:merged_cookbooks).and_return(['test_cookbook'])
+ 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
@@ -127,19 +127,19 @@ E
end
end
- describe 'when specifying a cookbook name among many' do
- let(:name_args) { ['test_cookbook1'] }
+ describe "when specifying a cookbook name among many" do
+ let(:name_args) { ["test_cookbook1"] }
let(:cookbooks_by_name) do
{
- 'test_cookbook1' => Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah'),
- 'test_cookbook2' => Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah'),
- 'test_cookbook3' => Chef::CookbookVersion.new('test_cookbook3', '/tmp/blah'),
+ "test_cookbook1" => Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah"),
+ "test_cookbook2" => Chef::CookbookVersion.new("test_cookbook2", "/tmp/blah"),
+ "test_cookbook3" => Chef::CookbookVersion.new("test_cookbook3", "/tmp/blah"),
}
end
it "should read only one cookbook" do
- expect(cookbook_loader).to receive(:[]).once.with('test_cookbook1').and_call_original
+ expect(cookbook_loader).to receive(:[]).once.with("test_cookbook1").and_call_original
knife.run
end
@@ -155,7 +155,7 @@ E
end
# This is testing too much. We should break it up.
- describe 'when specifying a cookbook name with dependencies' do
+ describe "when specifying a cookbook name with dependencies" do
let(:name_args) { ["test_cookbook2"] }
let(:cookbooks_by_name) do
@@ -164,16 +164,16 @@ E
"test_cookbook3" => test_cookbook3 }
end
- let(:test_cookbook1) { Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah') }
+ let(:test_cookbook1) { Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah") }
let(:test_cookbook2) do
- c = Chef::CookbookVersion.new('test_cookbook2')
+ c = Chef::CookbookVersion.new("test_cookbook2")
c.metadata.depends("test_cookbook3")
c
end
let(:test_cookbook3) do
- c = Chef::CookbookVersion.new('test_cookbook3')
+ c = Chef::CookbookVersion.new("test_cookbook3")
c.metadata.depends("test_cookbook1")
c.metadata.depends("test_cookbook2")
c
@@ -191,8 +191,8 @@ E
end
end
- describe 'when specifying a cookbook name with missing dependencies' do
- let(:cookbook_dependency) { Chef::CookbookVersion.new('dependency', '/tmp/blah') }
+ describe "when specifying a cookbook name with missing dependencies" do
+ let(:cookbook_dependency) { Chef::CookbookVersion.new("dependency", "/tmp/blah") }
before(:each) do
cookbook.metadata.depends("dependency")
@@ -205,22 +205,22 @@ E
knife.ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {})
end
- it 'should exit and not upload the cookbook' do
- expect(cookbook_loader).to receive(:[]).once.with('test_cookbook')
+ it "should exit and not upload the cookbook" do
+ 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)
end
- it 'should output a message for a single missing dependency' do
+ it "should output a message for a single missing dependency" do
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("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'")
end
- it 'should output a message for a multiple missing dependencies which are concatenated' do
- cookbook_dependency2 = Chef::CookbookVersion.new('dependency2')
+ 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|
{ "test_cookbook" => cookbook,
@@ -229,8 +229,8 @@ E
end
allow(knife).to receive(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"])
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("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:")
expect(@stderr.string).to include("'dependency' version '>= 0.0.0'")
expect(@stderr.string).to include("'dependency2' version '>= 0.0.0'")
@@ -243,31 +243,31 @@ E
knife.run
end
- describe 'with -a or --all' do
+ describe "with -a or --all" do
before(:each) do
knife.config[:all] = true
end
- context 'when cookbooks exist in the cookbook path' do
+ context "when cookbooks exist in the cookbook path" do
before(:each) do
- @test_cookbook1 = Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah')
- @test_cookbook2 = Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah')
+ @test_cookbook1 = Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah")
+ @test_cookbook2 = Chef::CookbookVersion.new("test_cookbook2", "/tmp/blah")
allow(cookbook_loader).to receive(:each).and_yield("test_cookbook1", @test_cookbook1).and_yield("test_cookbook2", @test_cookbook2)
allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook1", "test_cookbook2"])
end
- it 'should upload all cookbooks' do
+ it "should upload all cookbooks" do
expect(knife).to receive(:upload).once
knife.run
end
- it 'should report on success' do
+ it "should report on success" do
expect(knife).to receive(:upload).once
expect(knife.ui).to receive(:info).with(/Uploaded all cookbooks/)
knife.run
end
- it 'should update the version constraints for an environment' do
+ it "should update the version constraints for an environment" do
allow(knife).to receive(:assert_environment_valid!).and_return(true)
knife.config[:environment] = "production"
expect(knife).to receive(:update_version_constraints).once
@@ -275,28 +275,28 @@ E
end
end
- context 'when no cookbooks exist in the cookbook path' do
+ context "when no cookbooks exist in the cookbook path" do
before(:each) do
allow(cookbook_loader).to receive(:each)
end
- it 'should not upload any cookbooks' do
+ it "should not upload any cookbooks" do
expect(knife).to_not receive(:upload)
knife.run
end
- context 'when cookbook path is an array' do
- it 'should warn users that no cookbooks exist' do
- knife.config[:cookbook_path] = ['/chef-repo/cookbooks', '/home/user/cookbooks']
+ context "when cookbook path is an array" do
+ it "should warn users that no cookbooks exist" do
+ knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"]
expect(knife.ui).to receive(:warn).with(
/Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./)
knife.run
end
end
- context 'when cookbook path is a string' do
- it 'should warn users that no cookbooks exist' do
- knife.config[:cookbook_path] = '/chef-repo/cookbooks'
+ context "when cookbook path is a string" do
+ it "should warn users that no cookbooks exist" do
+ knife.config[:cookbook_path] = "/chef-repo/cookbooks"
expect(knife.ui).to receive(:warn).with(
/Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./)
knife.run
@@ -305,8 +305,8 @@ E
end
end
- describe 'when a frozen cookbook exists on the server' do
- it 'should fail to replace it' do
+ describe "when a frozen cookbook exists on the server" do
+ it "should fail to replace it" do
exception = Chef::Exceptions::CookbookFrozen.new
expect(cookbook_uploader).to receive(:upload_cookbooks).
and_raise(exception)
@@ -315,7 +315,7 @@ E
expect { knife.run }.to raise_error(SystemExit)
end
- it 'should not update the version constraints for an environment' do
+ it "should not update the version constraints for an environment" do
allow(knife).to receive(:assert_environment_valid!).and_return(true)
knife.config[:environment] = "production"
allow(knife).to receive(:upload).and_raise(Chef::Exceptions::CookbookFrozen)
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 1d93f64e32..7ecade338a 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -16,17 +16,17 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/core/bootstrap_context'
+require "spec_helper"
+require "chef/knife/core/bootstrap_context"
describe Chef::Knife::Core::BootstrapContext do
let(:config) { {:foo => :bar, :color => true} }
- let(:run_list) { Chef::RunList.new('recipe[tmux]', 'role[base]') }
+ let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") }
let(:chef_config) do
{
- :validation_key => File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'),
- :chef_server_url => 'http://chef.example.com:4444',
- :validation_client_name => 'chef-validator-testing',
+ :validation_key => File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"),
+ :chef_server_url => "http://chef.example.com:4444",
+ :validation_client_name => "chef-validator-testing",
}
end
@@ -57,7 +57,7 @@ describe Chef::Knife::Core::BootstrapContext do
end
it "reads the validation key" do
- expect(bootstrap_context.validation_key).to eq IO.read(File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'))
+ expect(bootstrap_context.validation_key).to eq IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"))
end
it "generates the config file data" do
@@ -75,23 +75,23 @@ 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']))
+ 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"]))
bootstrap_context.validation_key
end
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
@@ -100,7 +100,7 @@ EXPECTED
describe "when bootstrapping into a specific environment" do
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')
+ expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic")
end
end
diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
index 2d66df31c1..b29091188e 100644
--- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb
+++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/core/cookbook_scm_repo'
+require "spec_helper"
+require "chef/knife/core/cookbook_scm_repo"
describe Chef::Knife::CookbookSCMRepo do
before do
- @repo_path = File.join(CHEF_SPEC_DATA, 'cookbooks')
+ @repo_path = File.join(CHEF_SPEC_DATA, "cookbooks")
@stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new
@ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {})
- @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => 'master')
+ @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "master")
@branch_list = Mixlib::ShellOut.new
@branch_list.stdout.replace(<<-BRANCHES)
@@ -43,7 +43,7 @@ BRANCHES
end
it "has a default branch" do
- expect(@cookbook_repo.default_branch).to eq('master')
+ expect(@cookbook_repo.default_branch).to eq("master")
end
describe "when sanity checking the repo" do
@@ -64,12 +64,12 @@ BRANCHES
describe "and the repo is a git repo" do
before do
- allow(::File).to receive(:directory?).with(File.join(@repo_path, '.git')).and_return(true)
+ allow(::File).to receive(:directory?).with(File.join(@repo_path, ".git")).and_return(true)
end
it "exits when the default branch doesn't exist" do
@nobranches = Mixlib::ShellOut.new.tap {|s|s.stdout.replace "\n"}
- expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@nobranches)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches)
expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
end
@@ -85,14 +85,14 @@ BRANCHES
@dirty_status.stdout.replace(<<-DIRTY)
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).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status)
expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit)
end
describe "and the repo is clean" do
before do
@clean_status = Mixlib::ShellOut.new.tap {|s| s.stdout.replace("\n")}
- allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain', :cwd => @repo_path).and_return(@clean_status)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status)
end
it "passes the sanity check" do
@@ -106,35 +106,35 @@ DIRTY
end
it "resets to default state by checking out the default branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with('git checkout master', :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", :cwd => @repo_path)
@cookbook_repo.reset_to_default_state
end
it "determines if a the pristine copy branch exists" do
- expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
expect(@cookbook_repo.branch_exists?("chef-vendor-apache2")).to be_truthy
- expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
expect(@cookbook_repo.branch_exists?("chef-vendor-nginx")).to be_falsey
end
it "determines if a the branch not exists correctly without substring search" do
- expect(@cookbook_repo).to receive(:shell_out!).twice.with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
expect(@cookbook_repo).not_to be_branch_exists("chef-vendor-absent")
expect(@cookbook_repo).to be_branch_exists("chef-vendor-absent-new")
end
describe "when the pristine copy branch does not exist" do
it "prepares for import by creating the pristine copy branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list)
- expect(@cookbook_repo).to receive(:shell_out!).with('git checkout -b chef-vendor-nginx', :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", :cwd => @repo_path)
@cookbook_repo.prepare_to_import("nginx")
end
end
describe "when the pristine copy branch does exist" do
it "prepares for import by checking out the pristine copy branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list)
- expect(@cookbook_repo).to receive(:shell_out!).with('git checkout chef-vendor-apache2', :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", :cwd => @repo_path)
@cookbook_repo.prepare_to_import("apache2")
end
end
@@ -143,15 +143,15 @@ DIRTY
before do
@updates = Mixlib::ShellOut.new
@updates.stdout.replace("\n")
- allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain -- apache2', :cwd => @repo_path).and_return(@updates)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates)
end
it "shows no changes in the pristine copy" do
- expect(@cookbook_repo.updated?('apache2')).to be_falsey
+ expect(@cookbook_repo.updated?("apache2")).to be_falsey
end
it "does nothing to finalize the updates" do
- expect(@cookbook_repo.finalize_updates_to('apache2', '1.2.3')).to be_falsey
+ expect(@cookbook_repo.finalize_updates_to("apache2", "1.2.3")).to be_falsey
end
end
@@ -159,11 +159,11 @@ DIRTY
before do
@updates = Mixlib::ShellOut.new
@updates.stdout.replace(" M cookbooks/apache2/recipes/default.rb\n")
- allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain -- apache2', :cwd => @repo_path).and_return(@updates)
+ allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates)
end
it "shows changes in the pristine copy" do
- expect(@cookbook_repo.updated?('apache2')).to be_truthy
+ expect(@cookbook_repo.updated?("apache2")).to be_truthy
end
it "commits the changes to the repo and tags the commit" do
@@ -176,11 +176,11 @@ DIRTY
describe "when a custom default branch is specified" do
before do
- @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => 'develop')
+ @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "develop")
end
it "resets to default state by checking out the default branch" do
- expect(@cookbook_repo).to receive(:shell_out!).with('git checkout develop', :cwd => @repo_path)
+ expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", :cwd => @repo_path)
@cookbook_repo.reset_to_default_state
end
end
diff --git a/spec/unit/knife/core/custom_manifest_loader_spec.rb b/spec/unit/knife/core/custom_manifest_loader_spec.rb
index 1edbedd3c8..f15710274c 100644
--- a/spec/unit/knife/core/custom_manifest_loader_spec.rb
+++ b/spec/unit/knife/core/custom_manifest_loader_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::SubcommandLoader::CustomManifestLoader do
let(:ec2_server_create_plugin) { "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_server_create.rb" }
@@ -30,7 +30,7 @@ describe Chef::Knife::SubcommandLoader::CustomManifestLoader do
}
end
let(:loader) do
- Chef::Knife::SubcommandLoader::CustomManifestLoader.new(File.join(CHEF_SPEC_DATA, 'knife-site-subcommands'),
+ Chef::Knife::SubcommandLoader::CustomManifestLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands"),
manifest_content)
end
diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb
index 89de9f98e4..671fabf695 100644
--- a/spec/unit/knife/core/gem_glob_loader_spec.rb
+++ b/spec/unit/knife/core/gem_glob_loader_spec.rb
@@ -15,12 +15,12 @@
# limitations under the License.
#
-require 'spec_helper'
+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 }
@@ -39,15 +39,15 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
end
it "finds files installed via rubygems" do
- expect(loader.find_subcommands_via_rubygems).to include('chef/knife/node_create')
+ 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/.+])}
end
it "finds files from latest version of installed gems" do
- gems = [ double('knife-ec2-0.5.12') ]
+ gems = [ double("knife-ec2-0.5.12") ]
gem_files = [
- '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb',
- '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb',
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb",
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb",
]
expect($LOAD_PATH).to receive(:map).and_return([])
if Gem::Specification.respond_to? :latest_specs
@@ -55,26 +55,26 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
expect(gems[0]).to receive(:matches_for_glob).with(/chef\/knife\/\*\.rb\{(.*),\.rb,(.*)\}/).and_return(gem_files)
else
expect(Gem.source_index).to receive(:latest_specs).with(true).and_return(gems)
- expect(gems[0]).to receive(:require_paths).twice.and_return(['lib'])
- expect(gems[0]).to receive(:full_gem_path).and_return('/usr/lib/ruby/gems/knife-ec2-0.5.12')
- expect(Dir).to receive(:[]).with('/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb').and_return(gem_files)
+ expect(gems[0]).to receive(:require_paths).twice.and_return(["lib"])
+ expect(gems[0]).to receive(:full_gem_path).and_return("/usr/lib/ruby/gems/knife-ec2-0.5.12")
+ expect(Dir).to receive(:[]).with("/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb").and_return(gem_files)
end
expect(loader).to receive(:find_subcommands_via_dirglob).and_return({})
expect(loader.subcommand_files.select { |file| file =~ /knife-ec2/ }.sort).to eq(gem_files)
end
it "finds files using a dirglob when rubygems is not available" do
- expect(loader.find_subcommands_via_dirglob).to include('chef/knife/node_create')
+ 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/.+])}
end
it "finds user-specific subcommands in the user's ~/.chef directory" do
- expected_command = File.join(home, '.chef', 'plugins', 'knife', 'example_home_subcommand.rb')
+ expected_command = File.join(home, ".chef", "plugins", "knife", "example_home_subcommand.rb")
expect(loader.site_subcommands).to include(expected_command)
end
it "finds repo specific subcommands by searching for a .chef directory" do
- expected_command = File.join(CHEF_SPEC_DATA, 'knife-site-subcommands', 'plugins', 'knife', 'example_subcommand.rb')
+ expected_command = File.join(CHEF_SPEC_DATA, "knife-site-subcommands", "plugins", "knife", "example_subcommand.rb")
expect(loader.site_subcommands).to include(expected_command)
end
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 1a6c2f42b7..45ee377ac6 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
before do
@@ -42,7 +42,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
}
let(:loader) { Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
- File.join(CHEF_SPEC_DATA, 'knife-site-subcommands'),
+ File.join(CHEF_SPEC_DATA, "knife-site-subcommands"),
plugin_manifest)}
describe "#list_commands" do
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index 52e3aeadd5..2c1beb6ccb 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -16,34 +16,34 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/core/node_editor'
+require "spec_helper"
+require "chef/knife/core/node_editor"
describe Chef::Knife::NodeEditor do
let(:node_data) do
- { 'name' => 'test_node',
- 'chef_environment' => 'production',
- 'automatic' => { 'foo' => 'bar' },
- 'default' => { 'alpha' => { 'bravo' => 'charlie', 'delta' => 'echo' } },
- 'normal' => { 'alpha' => { 'bravo' => 'hotel' }, 'tags' => [] },
- 'override' => { 'alpha' => { 'bravo' => 'foxtrot', 'delta' => 'golf' } },
- 'policy_name' => nil,
- 'policy_group' => nil,
- 'run_list' => %w(role[comedy] role[drama] recipe[mystery])
+ { "name" => "test_node",
+ "chef_environment" => "production",
+ "automatic" => { "foo" => "bar" },
+ "default" => { "alpha" => { "bravo" => "charlie", "delta" => "echo" } },
+ "normal" => { "alpha" => { "bravo" => "hotel" }, "tags" => [] },
+ "override" => { "alpha" => { "bravo" => "foxtrot", "delta" => "golf" } },
+ "policy_name" => nil,
+ "policy_group" => nil,
+ "run_list" => %w(role[comedy] role[drama] recipe[mystery]),
}
end
let(:node) { Chef::Node.from_hash(node_data) }
- let(:ui) { double 'ui' }
- let(:base_config) { { editor: 'cat' } }
+ let(:ui) { double "ui" }
+ let(:base_config) { { editor: "cat" } }
let(:config) { base_config.merge(all_attributes: false) }
subject { described_class.new(node, ui, config) }
describe '#view' do
- it 'returns a Hash with only the name, chef_environment, normal, ' +
- 'policy_name, policy_group, and run_list properties' do
+ it "returns a Hash with only the name, chef_environment, normal, " +
+ "policy_name, policy_group, and run_list properties" do
expected = node_data.select do |key,|
%w[ name chef_environment normal
policy_name policy_group run_list ].include?(key)
@@ -52,7 +52,7 @@ describe Chef::Knife::NodeEditor do
expect(subject.view).to eq(expected)
end
- context 'when config[:all_attributes] == true' do
+ context "when config[:all_attributes] == true" do
let(:config) { base_config.merge(all_attributes: true) }
it 'returns a Hash with all of the node\'s properties' do
@@ -62,49 +62,49 @@ describe Chef::Knife::NodeEditor do
end
describe '#apply_updates' do
- context 'when the node name is changed' do
+ context "when the node name is changed" do
before(:each) do
allow(ui).to receive(:warn)
allow(ui).to receive(:confirm).and_return(true)
end
- it 'emits a warning and prompts for confirmation' do
- data = subject.view.merge('name' => 'foo_new_name_node')
+ it "emits a warning and prompts for confirmation" do
+ data = subject.view.merge("name" => "foo_new_name_node")
updated_node = subject.apply_updates(data)
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.'
+ .with "Changing the name of a node results in a new node being " +
+ "created, test_node will not be modified or removed."
expect(ui).to have_received(:confirm)
- .with('Proceed with creation of new node')
+ .with("Proceed with creation of new node")
expect(updated_node).to be_a(Chef::Node)
end
end
- context 'when config[:all_attributes] == false' do
+ context "when config[:all_attributes] == false" do
let(:config) { base_config.merge(all_attributes: false) }
let(:updated_data) do
subject.view.merge(
- 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] },
- 'policy_name' => 'mypolicy',
- 'policy_group' => 'prod',
- 'run_list' => %w(role[drama] recipe[mystery])
+ "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] },
+ "policy_name" => "mypolicy",
+ "policy_group" => "prod",
+ "run_list" => %w(role[drama] recipe[mystery]),
)
end
- it 'returns a node with run_list and normal_attrs changed' do
+ it "returns a node with run_list and normal_attrs changed" do
updated_node = subject.apply_updates(updated_data)
expect(updated_node).to be_a(Chef::Node)
# Expected to have been changed
- expect(updated_node.chef_environment).to eql(updated_data['chef_environment'])
- expect(updated_node.normal_attrs).to eql(updated_data['normal'])
- expect(updated_node.policy_name).to eql(updated_data['policy_name'])
- expect(updated_node.policy_group).to eql(updated_data['policy_group'])
- expect(updated_node.run_list.map(&:to_s)).to eql(updated_data['run_list'])
+ expect(updated_node.chef_environment).to eql(updated_data["chef_environment"])
+ expect(updated_node.normal_attrs).to eql(updated_data["normal"])
+ expect(updated_node.policy_name).to eql(updated_data["policy_name"])
+ expect(updated_node.policy_group).to eql(updated_data["policy_group"])
+ expect(updated_node.run_list.map(&:to_s)).to eql(updated_data["run_list"])
# Expected not to have changed
expect(updated_node.default_attrs).to eql(node.default_attrs)
@@ -113,57 +113,57 @@ describe Chef::Knife::NodeEditor do
end
end
- context 'when config[:all_attributes] == true' do
+ context "when config[:all_attributes] == true" do
let(:config) { base_config.merge(all_attributes: true) }
let(:updated_data) do
subject.view.merge(
- 'default' => { 'alpha' => { 'bravo' => 'charlie2', 'delta' => 'echo2' } },
- 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] },
- 'override' => { 'alpha' => { 'bravo' => 'foxtrot2', 'delta' => 'golf2' } },
- 'policy_name' => 'mypolicy',
- 'policy_group' => 'prod',
- 'run_list' => %w(role[drama] recipe[mystery])
+ "default" => { "alpha" => { "bravo" => "charlie2", "delta" => "echo2" } },
+ "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] },
+ "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } },
+ "policy_name" => "mypolicy",
+ "policy_group" => "prod",
+ "run_list" => %w(role[drama] recipe[mystery]),
)
end
- it 'returns a node with all editable properties changed' do
+ it "returns a node with all editable properties changed" do
updated_node = subject.apply_updates(updated_data)
expect(updated_node).to be_a(Chef::Node)
- expect(updated_node.chef_environment).to eql(updated_data['chef_environment'])
- expect(updated_node.automatic_attrs).to eql(updated_data['automatic'])
- expect(updated_node.normal_attrs).to eql(updated_data['normal'])
- expect(updated_node.default_attrs).to eql(updated_data['default'])
- expect(updated_node.override_attrs).to eql(updated_data['override'])
- expect(updated_node.policy_name).to eql(updated_data['policy_name'])
- expect(updated_node.policy_group).to eql(updated_data['policy_group'])
- expect(updated_node.run_list.map(&:to_s)).to eql(updated_data['run_list'])
+ expect(updated_node.chef_environment).to eql(updated_data["chef_environment"])
+ expect(updated_node.automatic_attrs).to eql(updated_data["automatic"])
+ expect(updated_node.normal_attrs).to eql(updated_data["normal"])
+ expect(updated_node.default_attrs).to eql(updated_data["default"])
+ expect(updated_node.override_attrs).to eql(updated_data["override"])
+ expect(updated_node.policy_name).to eql(updated_data["policy_name"])
+ expect(updated_node.policy_group).to eql(updated_data["policy_group"])
+ expect(updated_node.run_list.map(&:to_s)).to eql(updated_data["run_list"])
end
end
end
describe '#updated?' do
- context 'before the node has been edited' do
- it 'returns false' do
+ context "before the node has been edited" do
+ it "returns false" do
expect(subject.updated?).to be false
end
end
- context 'after the node has been edited' do
- context 'and changes were made' do
+ context "after the node has been edited" do
+ context "and changes were made" do
let(:updated_data) do
subject.view.merge(
- 'default' => { 'alpha' => { 'bravo' => 'charlie2', 'delta' => 'echo2' } },
- 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] },
- 'override' => { 'alpha' => { 'bravo' => 'foxtrot2', 'delta' => 'golf2' } },
- 'policy_name' => 'mypolicy',
- 'policy_group' => 'prod',
- 'run_list' => %w(role[drama] recipe[mystery])
+ "default" => { "alpha" => { "bravo" => "charlie2", "delta" => "echo2" } },
+ "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] },
+ "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } },
+ "policy_name" => "mypolicy",
+ "policy_group" => "prod",
+ "run_list" => %w(role[drama] recipe[mystery]),
)
end
- context 'and changes affect only editable properties' do
+ context "and changes affect only editable properties" do
before(:each) do
allow(ui).to receive(:edit_data)
.with(subject.view)
@@ -172,14 +172,14 @@ describe Chef::Knife::NodeEditor do
subject.edit_node
end
- it 'returns an array of the changed property names' do
+ it "returns an array of the changed property names" do
expect(subject.updated?).to eql %w[ normal policy_name policy_group run_list ]
end
end
- context 'and the changes include non-editable properties' do
+ context "and the changes include non-editable properties" do
before(:each) do
- data = updated_data.merge('bad_property' => 'bad_value')
+ data = updated_data.merge("bad_property" => "bad_value")
allow(ui).to receive(:edit_data)
.with(subject.view)
@@ -189,13 +189,13 @@ 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
end
- context 'and changes were not made' do
+ context "and changes were not made" do
before(:each) do
allow(ui).to receive(:edit_data)
.with(subject.view)
diff --git a/spec/unit/knife/core/object_loader_spec.rb b/spec/unit/knife/core/object_loader_spec.rb
index 0b572cc1f0..50f358379e 100644
--- a/spec/unit/knife/core/object_loader_spec.rb
+++ b/spec/unit/knife/core/object_loader_spec.rb
@@ -17,15 +17,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/core/object_loader'
+require "spec_helper"
+require "chef/knife/core/object_loader"
describe Chef::Knife::Core::ObjectLoader do
before(:each) do
@knife = Chef::Knife.new
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
- Dir.chdir(File.join(CHEF_SPEC_DATA, 'object_loader'))
+ Dir.chdir(File.join(CHEF_SPEC_DATA, "object_loader"))
end
shared_examples_for "Chef object" do |chef_class|
@@ -34,14 +34,14 @@ describe Chef::Knife::Core::ObjectLoader do
end
it "should has a attribute 'name'" do
- expect(@object.name).to eql('test')
+ expect(@object.name).to eql("test")
end
end
{
- 'nodes' => Chef::Node,
- 'roles' => Chef::Role,
- 'environments' => Chef::Environment,
+ "nodes" => Chef::Node,
+ "roles" => Chef::Role,
+ "environments" => Chef::Environment,
}.each do |repo_location, chef_class|
describe "when the file is a #{chef_class}" do
@@ -51,7 +51,7 @@ describe Chef::Knife::Core::ObjectLoader do
describe "when the file is a Ruby" do
before do
- @object = @loader.load_from(repo_location, 'test.rb')
+ @object = @loader.load_from(repo_location, "test.rb")
end
it_behaves_like "Chef object", chef_class
@@ -61,7 +61,7 @@ describe Chef::Knife::Core::ObjectLoader do
describe "when the file is a JSON" do
describe "and it has defined 'json_class'" do
before do
- @object = @loader.load_from(repo_location, 'test_json_class.json')
+ @object = @loader.load_from(repo_location, "test_json_class.json")
end
it_behaves_like "Chef object", chef_class
@@ -69,7 +69,7 @@ describe Chef::Knife::Core::ObjectLoader do
describe "and it has not defined 'json_class'" do
before do
- @object = @loader.load_from(repo_location, 'test.json')
+ @object = @loader.load_from(repo_location, "test.json")
end
it_behaves_like "Chef object", chef_class
diff --git a/spec/unit/knife/core/subcommand_loader_spec.rb b/spec/unit/knife/core/subcommand_loader_spec.rb
index 2386465c75..c1712c297e 100644
--- a/spec/unit/knife/core/subcommand_loader_spec.rb
+++ b/spec/unit/knife/core/subcommand_loader_spec.rb
@@ -15,12 +15,12 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::SubcommandLoader do
- let(:loader) { Chef::Knife::SubcommandLoader.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.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 }
@@ -31,29 +31,29 @@ describe Chef::Knife::SubcommandLoader do
Chef::Util::PathHelper.class_variable_set(:@@home_dir, nil)
end
- let(:config_dir) { File.join(CHEF_SPEC_DATA, 'knife-site-subcommands') }
+ let(:config_dir) { File.join(CHEF_SPEC_DATA, "knife-site-subcommands") }
describe "#for_config" do
context "when ~/.chef/plugin_manifest.json exists" do
before do
- allow(File).to receive(:exist?).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return(true)
+ allow(File).to receive(:exist?).with(File.join(home, ".chef", "plugin_manifest.json")).and_return(true)
end
it "creates a HashedCommandLoader with the manifest has _autogenerated_command_paths" do
- allow(File).to receive(:read).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return("{ \"_autogenerated_command_paths\": {}}")
+ allow(File).to receive(:read).with(File.join(home, ".chef", "plugin_manifest.json")).and_return("{ \"_autogenerated_command_paths\": {}}")
expect(Chef::Knife::SubcommandLoader.for_config(config_dir)).to be_a Chef::Knife::SubcommandLoader::HashedCommandLoader
end
it "creates a CustomManifestLoader with then manifest has a key other than _autogenerated_command_paths" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- allow(File).to receive(:read).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return("{ \"plugins\": {}}")
+ allow(File).to receive(:read).with(File.join(home, ".chef", "plugin_manifest.json")).and_return("{ \"plugins\": {}}")
expect(Chef::Knife::SubcommandLoader.for_config(config_dir)).to be_a Chef::Knife::SubcommandLoader::CustomManifestLoader
end
end
context "when ~/.chef/plugin_manifest.json does not exist" do
before do
- allow(File).to receive(:exist?).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return(false)
+ allow(File).to receive(:exist?).with(File.join(home, ".chef", "plugin_manifest.json")).and_return(false)
end
it "creates a GemGlobLoader" do
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 2c3b067e4f..b5b6a0a179 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -19,7 +19,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UI do
before do
@@ -33,10 +33,10 @@ describe Chef::Knife::UI do
end
describe "edit" do
- ruby_for_json = { 'foo' => 'bar' }
+ ruby_for_json = { "foo" => "bar" }
json_from_ruby = "{\n \"foo\": \"bar\"\n}"
json_from_editor = "{\n \"bar\": \"foo\"\n}"
- ruby_from_editor = { 'bar' => 'foo' }
+ ruby_from_editor = { "bar" => "foo" }
my_editor = "veeeye"
temp_path = "/tmp/bar/baz"
@@ -66,12 +66,12 @@ describe Chef::Knife::UI do
before do
@ui.config[:disable_editing] = false
@ui.config[:editor] = my_editor
- @mock = double('Tempfile')
+ @mock = double("Tempfile")
expect(@mock).to receive(:sync=).with(true)
expect(@mock).to receive(:puts).with(json_from_ruby)
expect(@mock).to receive(:close)
expect(@mock).to receive(:path).at_least(:once).and_return(temp_path)
- expect(Tempfile).to receive(:open).with([ 'knife-edit-', '.json' ]).and_yield(@mock)
+ expect(Tempfile).to receive(:open).with([ "knife-edit-", ".json" ]).and_yield(@mock)
end
context "and the editor works" do
before do
@@ -114,8 +114,8 @@ describe Chef::Knife::UI do
before do
@ui.config[:disable_editing] = false
@ui.config[:editor] = my_editor
- @tempfile = Tempfile.new([ 'knife-edit-', '.json' ])
- expect(Tempfile).to receive(:open).with([ 'knife-edit-', '.json' ]).and_yield(@tempfile)
+ @tempfile = Tempfile.new([ "knife-edit-", ".json" ])
+ expect(Tempfile).to receive(:open).with([ "knife-edit-", ".json" ]).and_yield(@tempfile)
end
context "and the editor works" do
@@ -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
@@ -205,7 +205,7 @@ EOM
end
it "formats arrays appropriately" do
- @ui.output([ 'a', 'b' ])
+ @ui.output([ "a", "b" ])
expect(@out.string).to eq <<EOM
a
b
@@ -218,17 +218,17 @@ EOM
end
it "formats single-member arrays appropriately" do
- @ui.output([ 'a' ])
+ @ui.output([ "a" ])
expect(@out.string).to eq("a\n")
end
it "formats nested single-member arrays appropriately" do
- @ui.output([ [ 'a' ] ])
+ @ui.output([ [ "a" ] ])
expect(@out.string).to eq("a\n")
end
it "formats nested arrays appropriately" do
- @ui.output([ [ 'a', 'b' ], [ 'c', 'd' ]])
+ @ui.output([ [ "a", "b" ], [ "c", "d" ]])
expect(@out.string).to eq <<EOM
a
b
@@ -239,7 +239,7 @@ EOM
end
it "formats nested arrays with single- and empty subarrays appropriately" do
- @ui.output([ [ 'a', 'b' ], [ 'c' ], [], [ 'd', 'e' ]])
+ @ui.output([ [ "a", "b" ], [ "c" ], [], [ "d", "e" ]])
expect(@out.string).to eq <<EOM
a
b
@@ -253,7 +253,7 @@ EOM
end
it "formats arrays of hashes with extra lines in between for readability" do
- @ui.output([ { 'a' => 'b', 'c' => 'd' }, { 'x' => 'y' }, { 'm' => 'n', 'o' => 'p' }])
+ @ui.output([ { "a" => "b", "c" => "d" }, { "x" => "y" }, { "m" => "n", "o" => "p" }])
expect(@out.string).to eq <<EOM
a: b
c: d
@@ -266,7 +266,7 @@ EOM
end
it "formats hashes with empty array members appropriately" do
- @ui.output({ 'a' => [], 'b' => 'c' })
+ @ui.output({ "a" => [], "b" => "c" })
expect(@out.string).to eq <<EOM
a:
b: c
@@ -274,7 +274,7 @@ EOM
end
it "formats hashes with single-member array values appropriately" do
- @ui.output({ 'a' => [ 'foo' ], 'b' => 'c' })
+ @ui.output({ "a" => [ "foo" ], "b" => "c" })
expect(@out.string).to eq <<EOM
a: foo
b: c
@@ -282,7 +282,7 @@ EOM
end
it "formats hashes with array members appropriately" do
- @ui.output({ 'a' => [ 'foo', 'bar' ], 'b' => 'c' })
+ @ui.output({ "a" => [ "foo", "bar" ], "b" => "c" })
expect(@out.string).to eq <<EOM
a:
foo
@@ -292,7 +292,7 @@ EOM
end
it "formats hashes with single-member nested array values appropriately" do
- @ui.output({ 'a' => [ [ 'foo' ] ], 'b' => 'c' })
+ @ui.output({ "a" => [ [ "foo" ] ], "b" => "c" })
expect(@out.string).to eq <<EOM
a:
foo
@@ -301,14 +301,14 @@ EOM
end
it "formats hashes with nested array values appropriately" do
- @ui.output({ 'a' => [ [ 'foo', 'bar' ], [ 'baz', 'bjork' ] ], 'b' => 'c' })
+ @ui.output({ "a" => [ [ "foo", "bar" ], [ "baz", "bjork" ] ], "b" => "c" })
# XXX: using a HEREDOC at this point results in a line with required spaces which auto-whitespace removal settings
# on editors will remove and will break this test.
expect(@out.string).to eq("a:\n foo\n bar\n \n baz\n bjork\nb: c\n")
end
it "formats hashes with hash values appropriately" do
- @ui.output({ 'a' => { 'aa' => 'bb', 'cc' => 'dd' }, 'b' => 'c' })
+ @ui.output({ "a" => { "aa" => "bb", "cc" => "dd" }, "b" => "c" })
expect(@out.string).to eq <<EOM
a:
aa: bb
@@ -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
@@ -432,7 +432,7 @@ EOM
context "when running on Windows" do
before(:each) do
- stdout = double('StringIO', :tty? => true)
+ stdout = double("StringIO", :tty? => true)
allow(@ui).to receive(:stdout).and_return(stdout)
allow(ChefConfig).to receive(:windows?) { true }
Chef::Config.reset
@@ -464,7 +464,7 @@ EOM
let(:output) {stdout.string}
let(:question) { "monkeys rule" }
- let(:answer) { 'y' }
+ let(:answer) { "y" }
let(:default_choice) { nil }
let(:append_instructions) { true }
@@ -583,7 +583,7 @@ EOM
out = StringIO.new
allow(@ui).to receive(:stdout).and_return(out)
allow(@ui).to receive(:stdin).and_return(StringIO.new(" \n"))
- expect(@ui.ask_question("your chef server URL? ", :default => 'http://localhost:4000')).to eq("http://localhost:4000")
+ expect(@ui.ask_question("your chef server URL? ", :default => "http://localhost:4000")).to eq("http://localhost:4000")
expect(out.string).to eq("your chef server URL? [http://localhost:4000] ")
end
end
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index d022cc7f7d..3cca61be6b 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
describe Chef::Knife::DataBagCreate do
let(:knife) do
@@ -47,7 +47,7 @@ describe Chef::Knife::DataBagCreate do
end
it "tries to create a data bag with an invalid name when given one argument" do
- knife.name_args = ['invalid&char']
+ 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)
end
@@ -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
diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb
index f1bcae990b..4e55a9386e 100644
--- a/spec/unit/knife/data_bag_edit_spec.rb
+++ b/spec/unit/knife/data_bag_edit_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
describe Chef::Knife::DataBagEdit do
before do
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index ddf877d9f7..387dfc7554 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/data_bag_item'
-require 'chef/encrypted_data_bag_item'
-require 'tempfile'
+require "chef/data_bag_item"
+require "chef/encrypted_data_bag_item"
+require "tempfile"
Chef::Knife::DataBagFromFile.load_deps
diff --git a/spec/unit/knife/data_bag_secret_options_spec.rb b/spec/unit/knife/data_bag_secret_options_spec.rb
index 0a2d8ca4bf..71a6bf7af5 100644
--- a/spec/unit/knife/data_bag_secret_options_spec.rb
+++ b/spec/unit/knife/data_bag_secret_options_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife'
-require 'chef/config'
-require 'tempfile'
+require "spec_helper"
+require "chef/knife"
+require "chef/config"
+require "tempfile"
class ExampleDataBagCommand < Chef::Knife
include Chef::Knife::DataBagSecretOptions
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 48a0071b49..427d3e4d1b 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -17,12 +17,12 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/data_bag_item'
-require 'chef/encrypted_data_bag_item'
-require 'chef/json_compat'
-require 'tempfile'
+require "chef/data_bag_item"
+require "chef/encrypted_data_bag_item"
+require "chef/json_compat"
+require "tempfile"
describe Chef::Knife::DataBagShow do
diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb
index 14dc5c52cf..bf2c2c15f0 100644
--- a/spec/unit/knife/environment_compare_spec.rb
+++ b/spec/unit/knife/environment_compare_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentCompare do
before(:each) do
@@ -40,15 +40,15 @@ describe Chef::Knife::EnvironmentCompare do
allow(@knife).to receive(:cookbook_list).and_return(@cookbooks)
- @rest_double = double('rest')
+ @rest_double = double("rest")
allow(@knife).to receive(:rest).and_return(@rest_double)
- @cookbook_names = ['apache2', 'mysql', 'foo', 'bar', 'dummy', 'chef_handler']
- @base_url = 'https://server.example.com/cookbooks'
+ @cookbook_names = ["apache2", "mysql", "foo", "bar", "dummy", "chef_handler"]
+ @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
allow(@rest_double).to receive(:get).with("/cookbooks?num_versions=1").and_return(@cookbook_data)
@@ -57,25 +57,25 @@ describe Chef::Knife::EnvironmentCompare do
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
- describe 'run' do
- it 'should display only cookbooks with version constraints' do
- @knife.config[:format] = 'summary'
+ describe "run" do
+ it "should display only cookbooks with version constraints" do
+ @knife.config[:format] = "summary"
@knife.run
@environments.each do |item, url|
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'
+ it "should display 4 number of lines" do
+ @knife.config[:format] = "summary"
@knife.run
expect(@stdout.string.lines.count).to be 4
end
end
- describe 'with -m or --mismatch' do
- it 'should display only cookbooks that have mismatching version constraints' do
- @knife.config[:format] = 'summary'
+ describe "with -m or --mismatch" do
+ it "should display only cookbooks that have mismatching version constraints" do
+ @knife.config[:format] = "summary"
@knife.config[:mismatch] = true
@knife.run
@constraints.each do |item, ver|
@@ -83,17 +83,17 @@ describe Chef::Knife::EnvironmentCompare do
end
end
- it 'should display 3 number of lines' do
- @knife.config[:format] = 'summary'
+ it "should display 3 number of lines" do
+ @knife.config[:format] = "summary"
@knife.config[:mismatch] = true
@knife.run
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'
+ describe "with -a or --all" do
+ it "should display all cookbooks" do
+ @knife.config[:format] = "summary"
@knife.config[:all] = true
@knife.run
@constraints.each do |item, ver|
@@ -101,8 +101,8 @@ describe Chef::Knife::EnvironmentCompare do
end
end
- it 'should display 8 number of lines' do
- @knife.config[:format] = 'summary'
+ it "should display 8 number of lines" do
+ @knife.config[:format] = "summary"
@knife.config[:all] = true
@knife.run
expect(@stdout.string.lines.count).to be 8
diff --git a/spec/unit/knife/environment_create_spec.rb b/spec/unit/knife/environment_create_spec.rb
index 04e45048ef..7cee275499 100644
--- a/spec/unit/knife/environment_create_spec.rb
+++ b/spec/unit/knife/environment_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentCreate do
before(:each) do
diff --git a/spec/unit/knife/environment_delete_spec.rb b/spec/unit/knife/environment_delete_spec.rb
index 95df6e15fe..262c87dcc6 100644
--- a/spec/unit/knife/environment_delete_spec.rb
+++ b/spec/unit/knife/environment_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentDelete do
before(:each) do
diff --git a/spec/unit/knife/environment_edit_spec.rb b/spec/unit/knife/environment_edit_spec.rb
index 61c2663a41..d23aa7234c 100644
--- a/spec/unit/knife/environment_edit_spec.rb
+++ b/spec/unit/knife/environment_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentEdit do
before(:each) do
diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb
index 11ad23c919..9ff2aceb6a 100644
--- a/spec/unit/knife/environment_from_file_spec.rb
+++ b/spec/unit/knife/environment_from_file_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::EnvironmentFromFile.load_deps
@@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentFromFile do
describe "run" do
it "loads the environment data from a file and saves it" do
- expect(@knife.loader).to receive(:load_from).with('environments', 'spec.rb').and_return(@environment)
+ expect(@knife.loader).to receive(:load_from).with("environments", "spec.rb").and_return(@environment)
expect(@environment).to receive(:save)
@knife.run
end
diff --git a/spec/unit/knife/environment_list_spec.rb b/spec/unit/knife/environment_list_spec.rb
index 1d5462257d..b01c0e57ed 100644
--- a/spec/unit/knife/environment_list_spec.rb
+++ b/spec/unit/knife/environment_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentList do
before(:each) do
diff --git a/spec/unit/knife/environment_show_spec.rb b/spec/unit/knife/environment_show_spec.rb
index caac958f8e..1c9d687d8c 100644
--- a/spec/unit/knife/environment_show_spec.rb
+++ b/spec/unit/knife/environment_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::EnvironmentShow do
before(:each) do
diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb
index 6c1ff7b98e..187f77ee1c 100644
--- a/spec/unit/knife/index_rebuild_spec.rb
+++ b/spec/unit/knife/index_rebuild_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::IndexRebuild do
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 039dba7a44..4958f20321 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/user_key_create'
-require 'chef/knife/client_key_create'
-require 'chef/knife/key_create'
-require 'chef/key'
+require "spec_helper"
+require "chef/knife/user_key_create"
+require "chef/knife/client_key_create"
+require "chef/knife/key_create"
+require "chef/key"
describe "key create commands that inherit knife" do
shared_examples_for "a key create command" do
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index 1d4b9f825f..65250df69f 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/user_key_delete'
-require 'chef/knife/client_key_delete'
-require 'chef/knife/key_delete'
-require 'chef/key'
+require "spec_helper"
+require "chef/knife/user_key_delete"
+require "chef/knife/client_key_delete"
+require "chef/knife/key_delete"
+require "chef/key"
describe "key delete commands that inherit knife" do
shared_examples_for "a key delete command" do
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 06b31ce71c..18f2cd45be 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/user_key_edit'
-require 'chef/knife/client_key_edit'
-require 'chef/knife/key_edit'
-require 'chef/key'
+require "spec_helper"
+require "chef/knife/user_key_edit"
+require "chef/knife/client_key_edit"
+require "chef/knife/key_edit"
+require "chef/key"
describe "key edit commands that inherit knife" do
shared_examples_for "a key edit command" do
diff --git a/spec/unit/knife/key_helper.rb b/spec/unit/knife/key_helper.rb
index 36ababc09a..6a972d1e7b 100644
--- a/spec/unit/knife/key_helper.rb
+++ b/spec/unit/knife/key_helper.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
shared_examples_for "a knife key command" do
let(:stderr) { StringIO.new }
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 775a7cdfb1..70caa249bb 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/user_key_list'
-require 'chef/knife/client_key_list'
-require 'chef/knife/key_list'
-require 'chef/key'
+require "spec_helper"
+require "chef/knife/user_key_list"
+require "chef/knife/client_key_list"
+require "chef/knife/key_list"
+require "chef/key"
describe "key list commands that inherit knife" do
shared_examples_for "a key list command" do
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index f4923ef235..03b3062e62 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/user_key_show'
-require 'chef/knife/client_key_show'
-require 'chef/knife/key_show'
-require 'chef/key'
+require "spec_helper"
+require "chef/knife/user_key_show"
+require "chef/knife/client_key_show"
+require "chef/knife/key_show"
+require "chef/key"
describe "key show commands that inherit knife" do
shared_examples_for "a key show command" do
@@ -113,14 +113,14 @@ describe Chef::Knife::KeyShow do
context "when load_method is :load_by_user" do
it_should_behave_like "key show run command" do
let(:load_method) { :load_by_user }
- let(:actor_field_name) { 'user' }
+ let(:actor_field_name) { "user" }
end
end
context "when load_method is :load_by_client" do
it_should_behave_like "key show run command" do
let(:load_method) { :load_by_client }
- let(:actor_field_name) { 'user' }
+ let(:actor_field_name) { "user" }
end
end
end
diff --git a/spec/unit/knife/knife_help.rb b/spec/unit/knife/knife_help.rb
index 293bae17f4..d357239e6a 100644
--- a/spec/unit/knife/knife_help.rb
+++ b/spec/unit/knife/knife_help.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Help do
before(:each) do
diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb
index 57a8d0bf64..7106fdfc7b 100644
--- a/spec/unit/knife/node_bulk_delete_spec.rb
+++ b/spec/unit/knife/node_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeBulkDelete do
before(:each) do
@@ -78,10 +78,10 @@ describe Chef::Knife::NodeBulkDelete do
end
it "should only delete nodes that match the regex" do
- @knife.name_args = ['adam']
- expect(@inflatedish_list['adam']).to receive(:destroy)
- expect(@inflatedish_list['brent']).not_to receive(:destroy)
- expect(@inflatedish_list['jacob']).not_to receive(:destroy)
+ @knife.name_args = ["adam"]
+ expect(@inflatedish_list["adam"]).to receive(:destroy)
+ expect(@inflatedish_list["brent"]).not_to receive(:destroy)
+ expect(@inflatedish_list["jacob"]).not_to receive(:destroy)
@knife.run
end
diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb
index 0941d850e5..b2fd54219c 100644
--- a/spec/unit/knife/node_delete_spec.rb
+++ b/spec/unit/knife/node_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeDelete do
before(:each) do
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index be42a15ee7..c7a99517a4 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::NodeEdit.load_deps
describe Chef::Knife::NodeEdit do
@@ -30,7 +30,7 @@ describe Chef::Knife::NodeEdit do
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::NodeEdit.new
@knife.config = {
- :editor => 'cat',
+ :editor => "cat",
:attribute => nil,
:print_after => nil,
}
diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index 10267915d7..0888af05e9 100644
--- a/spec/unit/knife/node_environment_set_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeEnvironmentSet do
before(:each) do
@@ -39,7 +39,7 @@ describe Chef::Knife::NodeEnvironmentSet do
it "should update the environment" do
@knife.run
- expect(@node.chef_environment).to eq('bar')
+ expect(@node.chef_environment).to eq("bar")
end
it "should save the node" do
diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb
index 623904753e..19ee8b52ff 100644
--- a/spec/unit/knife/node_from_file_spec.rb
+++ b/spec/unit/knife/node_from_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::NodeFromFile.load_deps
@@ -39,7 +39,7 @@ describe Chef::Knife::NodeFromFile do
describe "run" do
it "should load from a file" do
- expect(@knife.loader).to receive(:load_from).with('nodes', 'adam.rb').and_return(@node)
+ expect(@knife.loader).to receive(:load_from).with("nodes", "adam.rb").and_return(@node)
@knife.run
end
diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb
index ec694cb040..c043d47b29 100644
--- a/spec/unit/knife/node_list_spec.rb
+++ b/spec/unit/knife/node_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeList do
before(:each) do
diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb
index 92fbfd23fe..e309878a22 100644
--- a/spec/unit/knife/node_run_list_add_spec.rb
+++ b/spec/unit/knife/node_run_list_add_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeRunListAdd do
before(:each) do
@@ -40,7 +40,7 @@ describe Chef::Knife::NodeRunListAdd do
it "should add to the run list" do
@knife.run
- expect(@node.run_list[0]).to eq('role[monkey]')
+ expect(@node.run_list[0]).to eq("role[monkey]")
end
it "should save the node" do
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index a279a59635..f450dd8016 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeRunListRemove do
before(:each) do
@@ -43,7 +43,7 @@ describe Chef::Knife::NodeRunListRemove do
it "should remove the item from the run list" do
@knife.run
- expect(@node.run_list[0]).not_to eq('role[monkey]')
+ expect(@node.run_list[0]).not_to eq("role[monkey]")
end
it "should save the node" do
@@ -53,50 +53,50 @@ describe Chef::Knife::NodeRunListRemove do
it "should print the run list" do
@knife.config[:print_after] = true
- expect(@knife.ui).to receive(:output).with({ "knifetest-node" => { 'run_list' => [] } })
+ expect(@knife.ui).to receive(:output).with({ "knifetest-node" => { "run_list" => [] } })
@knife.run
end
describe "run with a list of roles and recipes" do
it "should remove the items from the run list" do
- @node.run_list << 'role[monkey]'
- @node.run_list << 'recipe[duck::type]'
- @knife.name_args = [ 'adam', 'role[monkey],recipe[duck::type]' ]
+ @node.run_list << "role[monkey]"
+ @node.run_list << "recipe[duck::type]"
+ @knife.name_args = [ "adam", "role[monkey],recipe[duck::type]" ]
@knife.run
- expect(@node.run_list).not_to include('role[monkey]')
- expect(@node.run_list).not_to include('recipe[duck::type]')
+ expect(@node.run_list).not_to include("role[monkey]")
+ expect(@node.run_list).not_to include("recipe[duck::type]")
end
it "should remove the items from the run list when name args contains whitespace" do
- @node.run_list << 'role[monkey]'
- @node.run_list << 'recipe[duck::type]'
- @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]' ]
+ @node.run_list << "role[monkey]"
+ @node.run_list << "recipe[duck::type]"
+ @knife.name_args = [ "adam", "role[monkey], recipe[duck::type]" ]
@knife.run
- expect(@node.run_list).not_to include('role[monkey]')
- expect(@node.run_list).not_to include('recipe[duck::type]')
+ expect(@node.run_list).not_to include("role[monkey]")
+ expect(@node.run_list).not_to include("recipe[duck::type]")
end
it "should remove the items from the run list when name args contains multiple run lists" do
- @node.run_list << 'role[blah]'
- @node.run_list << 'recipe[duck::type]'
- @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]', 'role[blah]' ]
+ @node.run_list << "role[blah]"
+ @node.run_list << "recipe[duck::type]"
+ @knife.name_args = [ "adam", "role[monkey], recipe[duck::type]", "role[blah]" ]
@knife.run
- expect(@node.run_list).not_to include('role[monkey]')
- expect(@node.run_list).not_to include('recipe[duck::type]')
+ expect(@node.run_list).not_to include("role[monkey]")
+ expect(@node.run_list).not_to include("recipe[duck::type]")
end
it "should warn when the thing to remove is not in the runlist" do
- @node.run_list << 'role[blah]'
- @node.run_list << 'recipe[duck::type]'
- @knife.name_args = [ 'adam', 'role[blork]' ]
+ @node.run_list << "role[blah]"
+ @node.run_list << "recipe[duck::type]"
+ @knife.name_args = [ "adam", "role[blork]" ]
expect(@knife.ui).to receive(:warn).with("role[blork] is not in the run list")
@knife.run
end
it "should warn even more when the thing to remove is not in the runlist and unqualified" do
- @node.run_list << 'role[blah]'
- @node.run_list << 'recipe[duck::type]'
- @knife.name_args = [ 'adam', 'blork' ]
+ @node.run_list << "role[blah]"
+ @node.run_list << "recipe[duck::type]"
+ @knife.name_args = [ "adam", "blork" ]
expect(@knife.ui).to receive(:warn).with("blork is not in the run list")
expect(@knife.ui).to receive(:warn).with(/did you forget recipe\[\] or role\[\]/)
@knife.run
diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb
index 68daaafd70..75eecfeb27 100644
--- a/spec/unit/knife/node_run_list_set_spec.rb
+++ b/spec/unit/knife/node_run_list_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeRunListSet do
before(:each) do
@@ -38,7 +38,7 @@ describe Chef::Knife::NodeRunListSet do
it "should set the run list" do
@knife.run
- expect(@node.run_list[0]).to eq('role[monkey]')
+ expect(@node.run_list[0]).to eq("role[monkey]")
end
it "should save the node" do
diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb
index 4806354b60..afc90dc1ed 100644
--- a/spec/unit/knife/node_show_spec.rb
+++ b/spec/unit/knife/node_show_spec.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::NodeShow do
let(:node) do
node = Chef::Node.new()
node.name("adam")
- node.run_list = ['role[base]']
+ node.run_list = ["role[base]"]
node
end
@@ -54,10 +54,10 @@ describe Chef::Knife::NodeShow do
end
it "should pretty print json" do
- knife.config[:format] = 'json'
+ knife.config[:format] = "json"
stdout = StringIO.new
allow(knife.ui).to receive(:stdout).and_return(stdout)
- expect(Chef::Node).to receive(:load).with('adam').and_return(node)
+ expect(Chef::Node).to receive(:load).with("adam").and_return(node)
knife.run
expect(stdout.string).to eql("{\n \"name\": \"adam\",\n \"chef_environment\": \"_default\",\n \"run_list\": [\n\n]\n,\n \"normal\": {\n\n }\n}\n")
end
diff --git a/spec/unit/knife/osc_user_create_spec.rb b/spec/unit/knife/osc_user_create_spec.rb
index e4ed78fe2b..006d50484d 100644
--- a/spec/unit/knife/osc_user_create_spec.rb
+++ b/spec/unit/knife/osc_user_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::OscUserCreate.load_deps
@@ -34,13 +34,13 @@ describe Chef::Knife::OscUserCreate do
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
- @knife.name_args = [ 'a_user' ]
+ @knife.name_args = [ "a_user" ]
@knife.config[:user_password] = "foobar"
@user = Chef::User.new
@user.name "a_user"
@user_with_private_key = Chef::User.new
@user_with_private_key.name "a_user"
- @user_with_private_key.private_key 'private_key'
+ @user_with_private_key.private_key "private_key"
allow(@user).to receive(:create).and_return(@user_with_private_key)
allow(Chef::User).to receive(:new).and_return(@user)
allow(Chef::User).to receive(:from_hash).and_return(@user)
@@ -61,7 +61,7 @@ describe Chef::Knife::OscUserCreate do
end
it "exits with an error if password is blank" do
- @knife.config[:user_password] = ''
+ @knife.config[:user_password] = ""
expect { @knife.run }.to raise_error SystemExit
expect(@stderr.string).to match /You must specify a non-blank password/
end
@@ -86,7 +86,7 @@ describe Chef::Knife::OscUserCreate do
it "writes the private key to a file when --file is specified" do
@knife.config[:file] = "/tmp/a_file"
filehandle = double("filehandle")
- expect(filehandle).to receive(:print).with('private_key')
+ expect(filehandle).to receive(:print).with("private_key")
expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle)
@knife.run
end
diff --git a/spec/unit/knife/osc_user_delete_spec.rb b/spec/unit/knife/osc_user_delete_spec.rb
index 4a3ec4228f..c0e3b0fbf9 100644
--- a/spec/unit/knife/osc_user_delete_spec.rb
+++ b/spec/unit/knife/osc_user_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# DEPRECATION NOTE
# This code only remains to support users still operating with
@@ -27,15 +27,15 @@ describe Chef::Knife::OscUserDelete do
before(:each) do
Chef::Knife::OscUserDelete.load_deps
@knife = Chef::Knife::OscUserDelete.new
- @knife.name_args = [ 'my_user' ]
+ @knife.name_args = [ "my_user" ]
end
- it 'deletes the user' do
- expect(@knife).to receive(:delete_object).with(Chef::User, 'my_user')
+ it "deletes the user" do
+ expect(@knife).to receive(:delete_object).with(Chef::User, "my_user")
@knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/osc_user_edit_spec.rb b/spec/unit/knife/osc_user_edit_spec.rb
index 279f2e30ef..55574bdc38 100644
--- a/spec/unit/knife/osc_user_edit_spec.rb
+++ b/spec/unit/knife/osc_user_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# DEPRECATION NOTE
# This code only remains to support users still operating with
@@ -32,18 +32,18 @@ describe Chef::Knife::OscUserEdit do
@knife = Chef::Knife::OscUserEdit.new
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
- @knife.name_args = [ 'my_user' ]
+ @knife.name_args = [ "my_user" ]
@knife.config[:disable_editing] = true
end
- it 'loads and edits the user' do
+ it "loads and edits the user" do
data = { :name => "my_user" }
allow(Chef::User).to receive(:load).with("my_user").and_return(data)
expect(@knife).to receive(:edit_data).with(data).and_return(data)
@knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/osc_user_list_spec.rb b/spec/unit/knife/osc_user_list_spec.rb
index f496a414b8..bc86e4ce97 100644
--- a/spec/unit/knife/osc_user_list_spec.rb
+++ b/spec/unit/knife/osc_user_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# DEPRECATION NOTE
# This code only remains to support users still operating with
@@ -29,7 +29,7 @@ describe Chef::Knife::OscUserList do
@knife = Chef::Knife::OscUserList.new
end
- it 'lists the users' do
+ it "lists the users" do
expect(Chef::User).to receive(:list)
expect(@knife).to receive(:format_list_for_display)
@knife.run
diff --git a/spec/unit/knife/osc_user_reregister_spec.rb b/spec/unit/knife/osc_user_reregister_spec.rb
index 989eb180f1..95fa2c2dc8 100644
--- a/spec/unit/knife/osc_user_reregister_spec.rb
+++ b/spec/unit/knife/osc_user_reregister_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# DEPRECATION NOTE
# This code only remains to support users still operating with
@@ -27,31 +27,31 @@ describe Chef::Knife::OscUserReregister do
before(:each) do
Chef::Knife::OscUserReregister.load_deps
@knife = Chef::Knife::OscUserReregister.new
- @knife.name_args = [ 'a_user' ]
- @user_mock = double('user_mock', :private_key => "private_key")
+ @knife.name_args = [ "a_user" ]
+ @user_mock = double("user_mock", :private_key => "private_key")
allow(Chef::User).to receive(:load).and_return(@user_mock)
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
expect { @knife.run }.to raise_error(SystemExit)
end
- it 'reregisters the user and prints the key' do
+ it "reregisters the user and prints the key" do
expect(@user_mock).to receive(:reregister).and_return(@user_mock)
@knife.run
expect(@stdout.string).to match( /private_key/ )
end
- it 'writes the private key to a file when --file is specified' do
+ it "writes the private key to a file when --file is specified" do
expect(@user_mock).to receive(:reregister).and_return(@user_mock)
- @knife.config[:file] = '/tmp/a_file'
+ @knife.config[:file] = "/tmp/a_file"
filehandle = StringIO.new
- expect(File).to receive(:open).with('/tmp/a_file', 'w').and_yield(filehandle)
+ expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle)
@knife.run
expect(filehandle.string).to eq("private_key")
end
diff --git a/spec/unit/knife/osc_user_show_spec.rb b/spec/unit/knife/osc_user_show_spec.rb
index 18d2086099..12f3bb069e 100644
--- a/spec/unit/knife/osc_user_show_spec.rb
+++ b/spec/unit/knife/osc_user_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
# DEPRECATION NOTE
# This code only remains to support users still operating with
@@ -27,17 +27,17 @@ describe Chef::Knife::OscUserShow do
before(:each) do
Chef::Knife::OscUserShow.load_deps
@knife = Chef::Knife::OscUserShow.new
- @knife.name_args = [ 'my_user' ]
- @user_mock = double('user_mock')
+ @knife.name_args = [ "my_user" ]
+ @user_mock = double("user_mock")
end
- it 'loads and displays the user' do
- expect(Chef::User).to receive(:load).with('my_user').and_return(@user_mock)
+ it "loads and displays the user" do
+ expect(Chef::User).to receive(:load).with("my_user").and_return(@user_mock)
expect(@knife).to receive(:format_for_display).with(@user_mock)
@knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
@knife.name_args = []
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb
index ab929abd39..14cdfbd614 100644
--- a/spec/unit/knife/raw_spec.rb
+++ b/spec/unit/knife/raw_spec.rb
@@ -15,11 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Raw do
let(:rest) do
- r = double('Chef::Knife::Raw::RawInputServerAPI')
+ r = double("Chef::Knife::Raw::RawInputServerAPI")
allow(Chef::Knife::Raw::RawInputServerAPI).to receive(:new).and_return(r)
r
end
@@ -35,8 +35,8 @@ describe Chef::Knife::Raw do
it "should set the x-ops-request-source header when --proxy-auth is set" do
knife.config[:proxy_auth] = true
expect(rest).to receive(:request).with(:GET, "/nodes",
- { 'Content-Type' => 'application/json',
- 'x-ops-request-source' => 'web'}, false)
+ { "Content-Type" => "application/json",
+ "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 5b79e52a04..55bf05e806 100644
--- a/spec/unit/knife/role_bulk_delete_spec.rb
+++ b/spec/unit/knife/role_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleBulkDelete do
before(:each) do
diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb
index fb748c51f6..23c747efc9 100644
--- a/spec/unit/knife/role_create_spec.rb
+++ b/spec/unit/knife/role_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleCreate do
before(:each) do
diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb
index b1a0d90410..6d7d0d964e 100644
--- a/spec/unit/knife/role_delete_spec.rb
+++ b/spec/unit/knife/role_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleDelete do
before(:each) do
diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb
index 0975c6458d..8026d8a21d 100644
--- a/spec/unit/knife/role_edit_spec.rb
+++ b/spec/unit/knife/role_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEdit do
before(:each) do
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 f286d5fd0d..743aa55d9d 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEnvRunListAdd do
before(:each) do
@@ -48,7 +48,7 @@ describe Chef::Knife::RoleEnvRunListAdd do
it "should have a QA environment" do
@knife.run
- expect(@role.active_run_list_for('QA')).to eq('QA')
+ expect(@role.active_run_list_for("QA")).to eq("QA")
end
it "should load the role named will" do
@@ -58,7 +58,7 @@ describe Chef::Knife::RoleEnvRunListAdd do
it "should be able to add an environment specific run list" do
@knife.run
- expect(@role.run_list_for('QA')[0]).to eq('role[monkey]')
+ expect(@role.run_list_for("QA")[0]).to eq("role[monkey]")
end
it "should save the role" do
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 525376c358..6a5157d5d4 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEnvRunListClear do
before(:each) do
@@ -60,7 +60,7 @@ describe Chef::Knife::RoleEnvRunListClear do
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_for("QA")[0]).to be_nil
expect(@role.run_list[0]).to be_nil
end
@@ -82,15 +82,15 @@ describe Chef::Knife::RoleEnvRunListClear do
@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.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]')
+ 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
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 a15d0af691..329ac2aff0 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEnvRunListRemove do
before(:each) do
@@ -60,8 +60,8 @@ describe Chef::Knife::RoleEnvRunListRemove do
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_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
@@ -83,22 +83,22 @@ describe Chef::Knife::RoleEnvRunListRemove do
@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.name_args = [ "will", "QA", "role[monkey]" ]
@knife.run
- @knife.name_args = [ 'will', 'QA', 'recipe[duck::type]' ]
+ @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]')
+ 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
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 ea48601b8d..bb7b79e3f0 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEnvRunListReplace do
before(:each) do
@@ -60,8 +60,8 @@ describe Chef::Knife::RoleEnvRunListReplace do
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_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
@@ -83,24 +83,24 @@ describe Chef::Knife::RoleEnvRunListReplace do
@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.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ]
@knife.run
- @knife.name_args = [ 'will', 'QA', 'recipe[duck::type]', 'recipe[duck::mallard]' ]
+ @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_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
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 f3abb86fcf..0932b07ffd 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleEnvRunListSet do
before(:each) do
@@ -60,9 +60,9 @@ 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')[2]).to be_nil
+ 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
@@ -86,15 +86,15 @@ describe Chef::Knife::RoleEnvRunListSet do
@setup.run
@knife.name_args = [ "will", "QA", "role[coke]", "role[pepsi]" ]
@knife.run
- expect(@role.run_list_for('QA')[0]).to eq("role[coke]")
- expect(@role.run_list_for('QA')[1]).to eq("role[pepsi]")
- expect(@role.run_list_for('QA')[2]).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]')
+ expect(@role.run_list_for("QA")[0]).to eq("role[coke]")
+ expect(@role.run_list_for("QA")[1]).to eq("role[pepsi]")
+ expect(@role.run_list_for("QA")[2]).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]")
expect(@role.run_list[0]).to be_nil
end
end
diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb
index 9379f08de3..b08d4bfc59 100644
--- a/spec/unit/knife/role_from_file_spec.rb
+++ b/spec/unit/knife/role_from_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::RoleFromFile.load_deps
@@ -39,7 +39,7 @@ describe Chef::Knife::RoleFromFile do
describe "run" do
it "should load from a file" do
- expect(@knife.loader).to receive(:load_from).with('roles', 'adam.rb').and_return(@role)
+ expect(@knife.loader).to receive(:load_from).with("roles", "adam.rb").and_return(@role)
@knife.run
end
@@ -60,8 +60,8 @@ describe Chef::Knife::RoleFromFile do
describe "run with multiple arguments" do
it "should load each file" do
@knife.name_args = [ "adam.rb", "caleb.rb" ]
- expect(@knife.loader).to receive(:load_from).with('roles', 'adam.rb').and_return(@role)
- expect(@knife.loader).to receive(:load_from).with('roles', 'caleb.rb').and_return(@role)
+ expect(@knife.loader).to receive(:load_from).with("roles", "adam.rb").and_return(@role)
+ expect(@knife.loader).to receive(:load_from).with("roles", "caleb.rb").and_return(@role)
@knife.run
end
end
diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb
index 65c4f94ff2..0cb4e08337 100644
--- a/spec/unit/knife/role_list_spec.rb
+++ b/spec/unit/knife/role_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleList do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index d61c114912..425dd0a9a1 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleRunListAdd do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index e5a6e18673..42980467e2 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleRunListClear do
before(:each) do
@@ -78,7 +78,7 @@ describe Chef::Knife::RoleRunListClear 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.name_args = [ "will" ]
@knife.run
expect(@role.run_list[0]).to be_nil
end
diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb
index 0f4adf253b..5c3da5c3f7 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleRunListRemove do
before(:each) do
@@ -59,7 +59,7 @@ describe Chef::Knife::RoleRunListRemove do
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[0]).to eq("role[person]")
expect(@role.run_list[1]).to be_nil
end
@@ -79,16 +79,16 @@ describe Chef::Knife::RoleRunListRemove 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.name_args = [ "will", "role[monkey]" ]
@knife.run
- @knife.name_args = [ 'will', 'recipe[duck::type]' ]
+ @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]')
+ 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
diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb
index 2ff38f573c..44fb3caabc 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleRunListReplace do
before(:each) do
@@ -59,10 +59,10 @@ describe Chef::Knife::RoleRunListReplace do
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[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
@@ -82,18 +82,18 @@ describe Chef::Knife::RoleRunListReplace 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.name_args = [ "will", "role[monkey]", "role[gibbon]" ]
@knife.run
- @knife.name_args = [ 'will', 'recipe[duck::type]', 'recipe[duck::mallard]' ]
+ @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).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
diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb
index 1350741f10..73d42cf2a2 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleRunListSet do
before(:each) do
diff --git a/spec/unit/knife/role_show_spec.rb b/spec/unit/knife/role_show_spec.rb
index b086136186..2b5b0eec18 100644
--- a/spec/unit/knife/role_show_spec.rb
+++ b/spec/unit/knife/role_show_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::RoleShow do
- let(:role) { 'base' }
+ let(:role) { "base" }
let(:knife) do
knife = Chef::Knife::RoleShow.new
@@ -27,21 +27,21 @@ describe Chef::Knife::RoleShow do
knife
end
- let(:role_mock) { double('role_mock') }
+ let(:role_mock) { double("role_mock") }
- describe 'run' do
- it 'should list the role' do
- expect(Chef::Role).to receive(:load).with('base').and_return(role_mock)
+ describe "run" do
+ it "should list the role" do
+ expect(Chef::Role).to receive(:load).with("base").and_return(role_mock)
expect(knife).to receive(:format_for_display).with(role_mock)
knife.run
end
- it 'should pretty print json' do
- knife.config[:format] = 'json'
+ it "should pretty print json" do
+ knife.config[:format] = "json"
stdout = StringIO.new
allow(knife.ui).to receive(:stdout).and_return(stdout)
fake_role_contents = {"foo"=>"bar", "baz"=>"qux"}
- expect(Chef::Role).to receive(:load).with('base').and_return(fake_role_contents)
+ 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
@@ -49,7 +49,7 @@ describe Chef::Knife::RoleShow do
context "without a role name" do
let(:role) { }
- it 'should print usage and exit when a role name is not provided' do
+ it "should print usage and exit when a role name is not provided" do
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
expect { knife.run }.to raise_error(SystemExit)
diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb
index 197dc4ca77..adaa8829a5 100644
--- a/spec/unit/knife/ssh_spec.rb
+++ b/spec/unit/knife/ssh_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'net/ssh'
-require 'net/ssh/multi'
+require "spec_helper"
+require "net/ssh"
+require "net/ssh/multi"
describe Chef::Knife::Ssh do
before(:each) do
@@ -54,7 +54,7 @@ describe Chef::Knife::Ssh do
@knife.config[:attribute] = "ipaddress"
Chef::Config[:knife][:ssh_attribute] = "ipaddress" # this value will be in the config file
configure_query([@node_foo, @node_bar])
- expect(@knife).to receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]])
+ expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]])
@knife.configure_session
end
@@ -62,7 +62,7 @@ describe Chef::Knife::Ssh do
Chef::Config[:knife][:ssh_attribute] = "config_file" # this value will be in the config file
@knife.config[:attribute] = "ipaddress" # this is the value of the command line via #configure_attribute
configure_query([@node_foo, @node_bar])
- expect(@knife).to receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]])
+ expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]])
@knife.configure_session
end
end
@@ -70,8 +70,8 @@ describe Chef::Knife::Ssh do
it "searchs for and returns an array of fqdns" do
configure_query([@node_foo, @node_bar])
expect(@knife).to receive(:session_from_list).with([
- ['foo.example.org', nil],
- ['bar.example.org', nil],
+ ["foo.example.org", nil],
+ ["bar.example.org", nil],
])
@knife.configure_session
end
@@ -86,8 +86,8 @@ describe Chef::Knife::Ssh do
it "returns an array of cloud public hostnames" do
configure_query([@node_foo, @node_bar])
expect(@knife).to receive(:session_from_list).with([
- ['ec2-10-0-0-1.compute-1.amazonaws.com', nil],
- ['ec2-10-0-0-2.compute-1.amazonaws.com', nil],
+ ["ec2-10-0-0-1.compute-1.amazonaws.com", nil],
+ ["ec2-10-0-0-2.compute-1.amazonaws.com", nil],
])
@knife.configure_session
end
@@ -97,15 +97,15 @@ describe Chef::Knife::Ssh do
context "when cloud hostnames are available but empty" do
before do
- @node_foo.automatic_attrs[:cloud][:public_hostname] = ''
- @node_bar.automatic_attrs[:cloud][:public_hostname] = ''
+ @node_foo.automatic_attrs[:cloud][:public_hostname] = ""
+ @node_bar.automatic_attrs[:cloud][:public_hostname] = ""
end
it "returns an array of fqdns" do
configure_query([@node_foo, @node_bar])
expect(@knife).to receive(:session_from_list).with([
- ['foo.example.org', nil],
- ['bar.example.org', nil],
+ ["foo.example.org", nil],
+ ["bar.example.org", nil],
])
@knife.configure_session
end
@@ -143,7 +143,7 @@ describe Chef::Knife::Ssh do
it "returns an array of provided values" do
@knife.instance_variable_set(:@name_args, ["foo.example.org bar.example.org"])
- expect(@knife).to receive(:session_from_list).with(['foo.example.org', 'bar.example.org'])
+ expect(@knife).to receive(:session_from_list).with(["foo.example.org", "bar.example.org"])
@knife.configure_session
end
end
@@ -159,7 +159,7 @@ describe Chef::Knife::Ssh do
Chef::Config[:knife][:ssh_attribute] = nil
@knife.config[:attribute] = nil
@node_foo.automatic_attrs[:cloud][:public_hostname] = "ec2-10-0-0-1.compute-1.amazonaws.com"
- @node_bar.automatic_attrs[:cloud][:public_hostname] = ''
+ @node_bar.automatic_attrs[:cloud][:public_hostname] = ""
end
it "should return fqdn by default" do
@@ -190,21 +190,21 @@ describe Chef::Knife::Ssh do
before :each do
@knife.instance_variable_set(:@longest, 0)
ssh_config = {:timeout => 50, :user => "locutus", :port => 23 }
- allow(Net::SSH).to receive(:configuration_for).with('the.b.org').and_return(ssh_config)
+ allow(Net::SSH).to receive(:configuration_for).with("the.b.org").and_return(ssh_config)
end
it "uses the port from an ssh config file" do
- @knife.session_from_list([['the.b.org', nil]])
+ @knife.session_from_list([["the.b.org", nil]])
expect(@knife.session.servers[0].port).to eq(23)
end
it "uses the port from a cloud attr" do
- @knife.session_from_list([['the.b.org', 123]])
+ @knife.session_from_list([["the.b.org", 123]])
expect(@knife.session.servers[0].port).to eq(123)
end
it "uses the user from an ssh config file" do
- @knife.session_from_list([['the.b.org', 123]])
+ @knife.session_from_list([["the.b.org", 123]])
expect(@knife.session.servers[0].user).to eq("locutus")
end
end
@@ -279,7 +279,7 @@ describe Chef::Knife::Ssh do
expect(@query).to receive(:search).and_return([[@node_foo]])
allow(Chef::Search::Query).to receive(:new).and_return(@query)
allow(@knife).to receive(:ssh_command).and_return(exit_code)
- @knife.name_args = ['*:*', 'false']
+ @knife.name_args = ["*:*", "false"]
end
context "with an error" do
diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb
index feeb85c8af..5fe1b18cb7 100644
--- a/spec/unit/knife/ssl_check_spec.rb
+++ b/spec/unit/knife/ssl_check_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-require 'stringio'
+require "stringio"
describe Chef::Knife::SslCheck do
diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb
index 5982ed9470..be098e4834 100644
--- a/spec/unit/knife/ssl_fetch_spec.rb
+++ b/spec/unit/knife/ssl_fetch_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/knife/ssl_fetch'
+require "spec_helper"
+require "chef/knife/ssl_fetch"
describe Chef::Knife::SslFetch do
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 11728a6f9b..c2866dc0f6 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::Status do
before(:each) do
diff --git a/spec/unit/knife/tag_create_spec.rb b/spec/unit/knife/tag_create_spec.rb
index 586ec118bd..6a3ced3f5b 100644
--- a/spec/unit/knife/tag_create_spec.rb
+++ b/spec/unit/knife/tag_create_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::TagCreate do
before(:each) do
diff --git a/spec/unit/knife/tag_delete_spec.rb b/spec/unit/knife/tag_delete_spec.rb
index e7fa108947..3095eda191 100644
--- a/spec/unit/knife/tag_delete_spec.rb
+++ b/spec/unit/knife/tag_delete_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::TagDelete do
before(:each) do
diff --git a/spec/unit/knife/tag_list_spec.rb b/spec/unit/knife/tag_list_spec.rb
index 9c71d22f06..97cd8e7efa 100644
--- a/spec/unit/knife/tag_list_spec.rb
+++ b/spec/unit/knife/tag_list_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::TagList do
before(:each) do
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index fa5c8324b4..e05d518c1a 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
Chef::Knife::UserCreate.load_deps
@@ -41,7 +41,7 @@ describe Chef::Knife::UserCreate do
# delete this once OSC11 support is gone
context "when only one name_arg is passed" do
before do
- knife.name_args = ['some_user']
+ knife.name_args = ["some_user"]
allow(knife).to receive(:run_osc_11_user_create).and_raise(SystemExit)
end
@@ -61,7 +61,7 @@ describe Chef::Knife::UserCreate do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
let(:name_args) { [] }
- let(:fieldname) { 'username' }
+ let(:fieldname) { "username" }
end
end
@@ -79,38 +79,38 @@ describe Chef::Knife::UserCreate do
context "when FIRST_NAME isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ['some_user', 'some_display_name'] }
- let(:fieldname) { 'first name' }
+ let(:name_args) { ["some_user", "some_display_name"] }
+ let(:fieldname) { "first name" }
end
end
context "when LAST_NAME isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ['some_user', 'some_display_name', 'some_first_name'] }
- let(:fieldname) { 'last name' }
+ let(:name_args) { ["some_user", "some_display_name", "some_first_name"] }
+ let(:fieldname) { "last name" }
end
end
context "when EMAIL isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ['some_user', 'some_display_name', 'some_first_name', 'some_last_name'] }
- let(:fieldname) { 'email' }
+ let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name"] }
+ let(:fieldname) { "email" }
end
end
context "when PASSWORD isn't specified" do
# from spec/support/shared/unit/knife_shared.rb
it_should_behave_like "mandatory field missing" do
- let(:name_args) { ['some_user', 'some_display_name', 'some_first_name', 'some_last_name', 'some_email'] }
- let(:fieldname) { 'password' }
+ let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email"] }
+ let(:fieldname) { "password" }
end
end
context "when all mandatory fields are validly specified" do
before do
- knife.name_args = ['some_user', 'some_display_name', 'some_first_name', 'some_last_name', 'some_email', 'some_password']
+ knife.name_args = ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email", "some_password"]
allow(knife).to receive(:edit_data).and_return(knife.user.to_hash)
allow(knife).to receive(:create_user_from_hash).and_return(knife.user)
end
@@ -122,12 +122,12 @@ describe Chef::Knife::UserCreate do
it "sets all the mandatory fields" do
knife.run
- expect(knife.user.username).to eq('some_user')
- expect(knife.user.display_name).to eq('some_display_name')
- expect(knife.user.first_name).to eq('some_first_name')
- expect(knife.user.last_name).to eq('some_last_name')
- expect(knife.user.email).to eq('some_email')
- expect(knife.user.password).to eq('some_password')
+ expect(knife.user.username).to eq("some_user")
+ expect(knife.user.display_name).to eq("some_display_name")
+ expect(knife.user.first_name).to eq("some_first_name")
+ expect(knife.user.last_name).to eq("some_last_name")
+ expect(knife.user.email).to eq("some_email")
+ expect(knife.user.password).to eq("some_password")
end
context "when user_key and prevent_keygen are passed" do
@@ -166,14 +166,14 @@ describe Chef::Knife::UserCreate do
context "when --user-key is passed" do
before do
- knife.config[:user_key] = 'some_key'
- allow(File).to receive(:read).and_return('some_key')
+ knife.config[:user_key] = "some_key"
+ allow(File).to receive(:read).and_return("some_key")
allow(File).to receive(:expand_path)
end
it "sets user.public_key" do
knife.run
- expect(knife.user.public_key).to eq('some_key')
+ expect(knife.user.public_key).to eq("some_key")
end
end
@@ -191,20 +191,20 @@ describe Chef::Knife::UserCreate do
context "when --file is passed" do
before do
- knife.config[:file] = '/some/path'
+ knife.config[:file] = "/some/path"
end
it "creates a new file of the path passed" do
- filehandle = double('filehandle')
- expect(filehandle).to receive(:print).with('some_private_key')
- expect(File).to receive(:open).with('/some/path', 'w').and_yield(filehandle)
+ filehandle = double("filehandle")
+ expect(filehandle).to receive(:print).with("some_private_key")
+ expect(File).to receive(:open).with("/some/path", "w").and_yield(filehandle)
knife.run
end
end
context "when --file is not passed" do
it "prints the private key to stdout" do
- expect(knife.ui).to receive(:msg).with('some_private_key')
+ expect(knife.ui).to receive(:msg).with("some_private_key")
knife.run
end
end
diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb
index a24160624a..f2f8b1537d 100644
--- a/spec/unit/knife/user_delete_spec.rb
+++ b/spec/unit/knife/user_delete_spec.rb
@@ -16,18 +16,18 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UserDelete do
let(:knife) { Chef::Knife::UserDelete.new }
- let(:user) { double('user_object') }
+ let(:user) { double("user_object") }
let(:stdout) { StringIO.new }
before(:each) do
Chef::Knife::UserDelete.load_deps
- knife.name_args = [ 'my_user' ]
+ knife.name_args = [ "my_user" ]
allow(Chef::UserV1).to receive(:load).and_return(user)
- allow(user).to receive(:username).and_return('my_user')
+ allow(user).to receive(:username).and_return("my_user")
allow(knife.ui).to receive(:stderr).and_return(stdout)
allow(knife.ui).to receive(:stdout).and_return(stdout)
end
@@ -50,13 +50,13 @@ describe Chef::Knife::UserDelete do
end
end
- it 'deletes the user' do
+ it "deletes the user" do
#expect(knife).to receive(:delete_object).with(Chef::UserV1, 'my_user')
- expect(knife).to receive(:delete_object).with('my_user')
+ expect(knife).to receive(:delete_object).with("my_user")
knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
knife.name_args = []
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb
index a21d982d29..072a27be01 100644
--- a/spec/unit/knife/user_edit_spec.rb
+++ b/spec/unit/knife/user_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UserEdit do
let(:knife) { Chef::Knife::UserEdit.new }
@@ -28,7 +28,7 @@ describe Chef::Knife::UserEdit do
Chef::Knife::UserEdit.load_deps
allow(knife.ui).to receive(:stderr).and_return(@stderr)
allow(knife.ui).to receive(:stdout).and_return(@stdout)
- knife.name_args = [ 'my_user' ]
+ knife.name_args = [ "my_user" ]
knife.config[:disable_editing] = true
end
@@ -50,14 +50,14 @@ describe Chef::Knife::UserEdit do
end
end
- it 'loads and edits the user' do
+ it "loads and edits the user" do
data = { "username" => "my_user" }
allow(Chef::UserV1).to receive(:load).with("my_user").and_return(data)
expect(knife).to receive(:edit_data).with(data).and_return(data)
knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
knife.name_args = []
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife/user_list_spec.rb b/spec/unit/knife/user_list_spec.rb
index fa2bac426e..753929e250 100644
--- a/spec/unit/knife/user_list_spec.rb
+++ b/spec/unit/knife/user_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UserList do
let(:knife) { Chef::Knife::UserList.new }
@@ -28,7 +28,7 @@ describe Chef::Knife::UserList do
allow(knife.ui).to receive(:stdout).and_return(stdout)
end
- it 'lists the users' do
+ it "lists the users" do
expect(Chef::UserV1).to receive(:list)
expect(knife).to receive(:format_list_for_display)
knife.run
diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb
index 89aa6726cd..1907b5fa50 100644
--- a/spec/unit/knife/user_reregister_spec.rb
+++ b/spec/unit/knife/user_reregister_spec.rb
@@ -16,20 +16,20 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UserReregister do
let(:knife) { Chef::Knife::UserReregister.new }
- let(:user_mock) { double('user_mock', :private_key => "private_key") }
+ let(:user_mock) { double("user_mock", :private_key => "private_key") }
let(:stdout) { StringIO.new }
before do
Chef::Knife::UserReregister.load_deps
- knife.name_args = [ 'a_user' ]
+ knife.name_args = [ "a_user" ]
allow(Chef::UserV1).to receive(:load).and_return(user_mock)
allow(knife.ui).to receive(:stdout).and_return(stdout)
allow(knife.ui).to receive(:stderr).and_return(stdout)
- allow(user_mock).to receive(:username).and_return('a_user')
+ allow(user_mock).to receive(:username).and_return("a_user")
end
# delete this once OSC11 support is gone
@@ -50,24 +50,24 @@ describe Chef::Knife::UserReregister do
end
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
knife.name_args = []
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
expect { knife.run }.to raise_error(SystemExit)
end
- it 'reregisters the user and prints the key' do
+ it "reregisters the user and prints the key" do
expect(user_mock).to receive(:reregister).and_return(user_mock)
knife.run
expect(stdout.string).to match( /private_key/ )
end
- it 'writes the private key to a file when --file is specified' do
+ it "writes the private key to a file when --file is specified" do
expect(user_mock).to receive(:reregister).and_return(user_mock)
- knife.config[:file] = '/tmp/a_file'
+ knife.config[:file] = "/tmp/a_file"
filehandle = StringIO.new
- expect(File).to receive(:open).with('/tmp/a_file', 'w').and_yield(filehandle)
+ expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle)
knife.run
expect(filehandle.string).to eq("private_key")
end
diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb
index 7c39e428c0..12e8424af2 100644
--- a/spec/unit/knife/user_show_spec.rb
+++ b/spec/unit/knife/user_show_spec.rb
@@ -16,17 +16,17 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Knife::UserShow do
let(:knife) { Chef::Knife::UserShow.new }
- let(:user_mock) { double('user_mock') }
+ let(:user_mock) { double("user_mock") }
let(:stdout) { StringIO.new }
before do
Chef::Knife::UserShow.load_deps
- knife.name_args = [ 'my_user' ]
- allow(user_mock).to receive(:username).and_return('my_user')
+ knife.name_args = [ "my_user" ]
+ allow(user_mock).to receive(:username).and_return("my_user")
allow(knife.ui).to receive(:stderr).and_return(stdout)
allow(knife.ui).to receive(:stdout).and_return(stdout)
end
@@ -35,7 +35,7 @@ describe Chef::Knife::UserShow do
context "when the username field is not supported by the server" do
before do
allow(knife).to receive(:run_osc_11_user_show).and_raise(SystemExit)
- allow(Chef::UserV1).to receive(:load).with('my_user').and_return(user_mock)
+ allow(Chef::UserV1).to receive(:load).with("my_user").and_return(user_mock)
allow(user_mock).to receive(:username).and_return(nil)
end
@@ -50,13 +50,13 @@ describe Chef::Knife::UserShow do
end
end
- it 'loads and displays the user' do
- expect(Chef::UserV1).to receive(:load).with('my_user').and_return(user_mock)
+ it "loads and displays the user" do
+ expect(Chef::UserV1).to receive(:load).with("my_user").and_return(user_mock)
expect(knife).to receive(:format_for_display).with(user_mock)
knife.run
end
- it 'prints usage and exits when a user name is not provided' do
+ it "prints usage and exits when a user name is not provided" do
knife.name_args = []
expect(knife).to receive(:show_usage)
expect(knife.ui).to receive(:fatal)
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 55b4f5c88a..06892af905 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -21,8 +21,8 @@
module KnifeSpecs
end
-require 'spec_helper'
-require 'uri'
+require "spec_helper"
+require "uri"
describe Chef::Knife do
@@ -81,28 +81,28 @@ describe Chef::Knife do
KnifeSpecs.send(:remove_const, :TestExplicitCategory)
end
- Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_name_mapping.rb'))
- Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_explicit_category.rb'))
+ Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_name_mapping.rb"))
+ Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_explicit_category.rb"))
end
it "has a category based on its name" do
- expect(KnifeSpecs::TestNameMapping.subcommand_category).to eq('test')
+ expect(KnifeSpecs::TestNameMapping.subcommand_category).to eq("test")
end
it "has an explicitly defined category if set" do
- expect(KnifeSpecs::TestExplicitCategory.subcommand_category).to eq('cookbook site')
+ expect(KnifeSpecs::TestExplicitCategory.subcommand_category).to eq("cookbook site")
end
it "can reference the subcommand by its snake cased name" do
- expect(Chef::Knife.subcommands['test_name_mapping']).to equal(KnifeSpecs::TestNameMapping)
+ expect(Chef::Knife.subcommands["test_name_mapping"]).to equal(KnifeSpecs::TestNameMapping)
end
it "lists subcommands by category" do
- expect(Chef::Knife.subcommands_by_category['test']).to include('test_name_mapping')
+ expect(Chef::Knife.subcommands_by_category["test"]).to include("test_name_mapping")
end
it "lists subcommands by category when the subcommands have explicit categories" do
- expect(Chef::Knife.subcommands_by_category['cookbook site']).to include('test_explicit_category')
+ expect(Chef::Knife.subcommands_by_category["cookbook site"]).to include("test_explicit_category")
end
it "has empty dependency_loader list by default" do
@@ -137,9 +137,9 @@ describe Chef::Knife do
it "guesses a category from a given ARGV" do
Chef::Knife.subcommands_by_category["cookbook"] << :cookbook
Chef::Knife.subcommands_by_category["cookbook site"] << :cookbook_site
- expect(Chef::Knife.guess_category(%w{cookbook foo bar baz})).to eq('cookbook')
- expect(Chef::Knife.guess_category(%w{cookbook site foo bar baz})).to eq('cookbook site')
- expect(Chef::Knife.guess_category(%w{cookbook site --help})).to eq('cookbook site')
+ expect(Chef::Knife.guess_category(%w{cookbook foo bar baz})).to eq("cookbook")
+ expect(Chef::Knife.guess_category(%w{cookbook site foo bar baz})).to eq("cookbook site")
+ expect(Chef::Knife.guess_category(%w{cookbook site --help})).to eq("cookbook site")
end
it "finds a subcommand class based on ARGV" do
@@ -154,7 +154,7 @@ describe Chef::Knife 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,
+ "X-Chef-Version" => Chef::VERSION,
"Host"=>"api.opscode.piab",
"X-REMOTE-REQUEST-ID"=>request_id,
}}
@@ -195,7 +195,7 @@ describe Chef::Knife do
if KnifeSpecs.const_defined?(:TestYourself)
KnifeSpecs.send :remove_const, :TestYourself
end
- Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb'))
+ Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) }
end
@@ -210,7 +210,7 @@ describe Chef::Knife do
if KnifeSpecs.const_defined?(:TestYourself)
KnifeSpecs.send :remove_const, :TestYourself
end
- Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb'))
+ Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) }
end
@@ -349,12 +349,12 @@ describe Chef::Knife do
before do
unless KnifeSpecs.const_defined?(:TestYourself)
- Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb'))
+ Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb"))
end
end
it "it parses the options passed to it" do
- expect(knife.config[:scro]).to eq('scrogramming')
+ expect(knife.config[:scro]).to eq("scrogramming")
end
it "extracts its command specific args from the full arg list" do
@@ -431,9 +431,9 @@ describe Chef::Knife do
allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("406 Not Acceptable", response))
knife.run_with_pretty_exceptions
- expect(stderr.string).to include('The request that Knife sent was using API version 10000000')
- expect(stderr.string).to include('The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1')
- expect(stderr.string).to include('Please either update your Chef client or server to be a compatible set')
+ expect(stderr.string).to include("The request that Knife sent was using API version 10000000")
+ expect(stderr.string).to include("The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1")
+ expect(stderr.string).to include("Please either update your Chef client or server to be a compatible set")
end
it "formats 500s nicely" do
@@ -485,7 +485,7 @@ describe Chef::Knife do
end
it "formats missing private key errors nicely" do
- allow(knife).to receive(:run).and_raise(Chef::Exceptions::PrivateKeyMissing.new('key not there'))
+ allow(knife).to receive(:run).and_raise(Chef::Exceptions::PrivateKeyMissing.new("key not there"))
allow(knife).to receive(:api_key).and_return("/home/root/.chef/no-key-here.pem")
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r[ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem])
@@ -493,7 +493,7 @@ describe Chef::Knife do
end
it "formats connection refused errors nicely" do
- allow(knife).to receive(:run).and_raise(Errno::ECONNREFUSED.new('y u no shut up'))
+ allow(knife).to receive(:run).and_raise(Errno::ECONNREFUSED.new("y u no shut up"))
knife.run_with_pretty_exceptions
# Errno::ECONNREFUSED message differs by platform
# *nix = Errno::ECONNREFUSED: Connection refused
diff --git a/spec/unit/log/syslog_spec.rb b/spec/unit/log/syslog_spec.rb
index 3db90e50c6..440b4f018e 100644
--- a/spec/unit/log/syslog_spec.rb
+++ b/spec/unit/log/syslog_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef'
+require "spec_helper"
+require "chef"
describe "Chef::Log::Syslog", :unix_only => true do
let(:syslog) { Chef::Log::Syslog.new }
diff --git a/spec/unit/log/winevt_spec.rb b/spec/unit/log/winevt_spec.rb
index 867ef55900..c20aeaf4bf 100644
--- a/spec/unit/log/winevt_spec.rb
+++ b/spec/unit/log/winevt_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Log::WinEvt do
let(:evtlog) { instance_double("Win32::EventLog")}
diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb
index 7be40f77e6..288a827035 100644
--- a/spec/unit/log_spec.rb
+++ b/spec/unit/log_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'tempfile'
-require 'logger'
-require 'spec_helper'
+require "tempfile"
+require "logger"
+require "spec_helper"
describe Chef::Log do
end
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 13d9f6acc7..8900743c75 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tmpdir'
-require 'fileutils'
-require 'chef/mixin/convert_to_class_name'
+require "spec_helper"
+require "tmpdir"
+require "fileutils"
+require "chef/mixin/convert_to_class_name"
module LwrpConstScopingConflict
end
@@ -57,21 +57,21 @@ describe "LWRP" do
end
it "should not skip loading a resource when there's a top level symbol of the same name" do
- Object.const_set('LwrpFoo', Class.new)
+ Object.const_set("LwrpFoo", Class.new)
file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA)
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
expect(Chef::Log).not_to receive(:debug).with(/anymore/)
Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil)
- Object.send(:remove_const, 'LwrpFoo')
+ Object.send(:remove_const, "LwrpFoo")
end
it "should not skip loading a provider when there's a top level symbol of the same name" do
- Object.const_set('LwrpBuckPasser', Class.new)
+ Object.const_set("LwrpBuckPasser", Class.new)
file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA)
expect(Chef::Log).not_to receive(:info).with(/Skipping/)
expect(Chef::Log).not_to receive(:debug).with(/anymore/)
Chef::Provider::LWRPBase.build_from_file("lwrp", file, nil)
- Object.send(:remove_const, 'LwrpBuckPasser')
+ Object.send(:remove_const, "LwrpBuckPasser")
end
# @todo: we need a before block to manually remove_const all of the LWRPs that we
@@ -246,19 +246,19 @@ describe "LWRP" do
let(:klass) do
Class.new(Chef::Resource::LWRPBase) do
self.resource_name = :sample_resource
- attribute :food, :default => lazy { 'BACON!'*3 }
+ attribute :food, :default => lazy { "BACON!"*3 }
attribute :drink, :default => lazy { |r| "Drink after #{r.food}!"}
end
end
- let(:instance) { klass.new('kitchen') }
+ let(:instance) { klass.new("kitchen") }
it "evaluates the default value when requested" do
- expect(instance.food).to eq('BACON!BACON!BACON!')
+ expect(instance.food).to eq("BACON!BACON!BACON!")
end
it "evaluates yields self to the block" do
- expect(instance.drink).to eq('Drink after BACON!BACON!BACON!!')
+ expect(instance.drink).to eq("Drink after BACON!BACON!BACON!!")
end
end
end
@@ -325,7 +325,7 @@ describe "LWRP" do
end
def raise_if_deprecated!
- if Chef::VERSION.split('.').first.to_i > 12
+ if Chef::VERSION.split(".").first.to_i > 12
raise "This test should be removed and the associated code should be removed!"
end
end
@@ -344,7 +344,7 @@ describe "LWRP" do
end
end
let(:resource) do
- resource_class.new('blah')
+ resource_class.new("blah")
end
it "actions includes those actions" do
expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ]
@@ -364,7 +364,7 @@ describe "LWRP" do
end
end
let(:resource) do
- resource_class.new('blah')
+ resource_class.new("blah")
end
it "actions includes those actions" do
expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ]
@@ -383,7 +383,7 @@ describe "LWRP" do
let(:node) do
Chef::Node.new.tap do |n|
n.automatic[:platform] = :ubuntu
- n.automatic[:platform_version] = '8.10'
+ n.automatic[:platform_version] = "8.10"
end
end
@@ -483,8 +483,8 @@ describe "LWRP" do
Chef::Runner.new(run_context).converge
expect(run_context.resource_collection[0]).to eql(injector)
- expect(run_context.resource_collection[1].name).to eql('prepared_thumbs')
- expect(run_context.resource_collection[2].name).to eql('twiddled_thumbs')
+ expect(run_context.resource_collection[1].name).to eql("prepared_thumbs")
+ expect(run_context.resource_collection[2].name).to eql("twiddled_thumbs")
expect(run_context.resource_collection[3]).to eql(dummy)
end
@@ -507,12 +507,12 @@ describe "LWRP" do
Chef::Runner.new(run_context).converge
expect(run_context.resource_collection[0]).to eql(injector)
- expect(run_context.resource_collection[1].name).to eql('prepared_thumbs')
- expect(run_context.resource_collection[2].name).to eql('twiddled_thumbs')
+ expect(run_context.resource_collection[1].name).to eql("prepared_thumbs")
+ expect(run_context.resource_collection[2].name).to eql("twiddled_thumbs")
expect(run_context.resource_collection[3]).to eql(dummy)
expect(run_context.resource_collection[4]).to eql(injector2)
- expect(run_context.resource_collection[5].name).to eql('prepared_eyes')
- expect(run_context.resource_collection[6].name).to eql('dried_paint_watched')
+ expect(run_context.resource_collection[5].name).to eql("prepared_eyes")
+ expect(run_context.resource_collection[6].name).to eql("dried_paint_watched")
end
it "should properly handle a new_resource reference" do
@@ -535,7 +535,7 @@ describe "LWRP" do
#provider = @runner.build_provider(resource)
provider.action_twiddle_thumbs
- expect(provider.enclosed_resource.monkey).to eq('bob, the monkey')
+ expect(provider.enclosed_resource.monkey).to eq("bob, the monkey")
end
describe "when using inline compilation" do
@@ -603,7 +603,7 @@ describe "LWRP" do
end
it "get_lwrp(:lwrp_once).new is a Chef::Resource::LwrpOnce" do
- lwrp = get_lwrp(:lwrp_once).new('hi')
+ lwrp = get_lwrp(:lwrp_once).new("hi")
expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy
expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
@@ -611,7 +611,7 @@ describe "LWRP" do
end
it "Chef::Resource::LwrpOnce.new is a get_lwrp(:lwrp_once)" do
- lwrp = Chef::Resource::LwrpOnce.new('hi')
+ lwrp = Chef::Resource::LwrpOnce.new("hi")
expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy
expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
@@ -639,35 +639,35 @@ describe "LWRP" do
end
it "subclass.new is a subclass" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(subclass)).to be_truthy
expect(lwrp.is_a?(subclass)).to be_truthy
expect(subclass === lwrp).to be_truthy
expect(lwrp.class === subclass)
end
it "subclass.new is a Chef::Resource::LwrpOnce" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy
expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy
expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy
expect(lwrp.class === Chef::Resource::LwrpOnce)
end
it "subclass.new is a get_lwrp(:lwrp_once)" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy
expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
expect(lwrp.class === get_lwrp(:lwrp_once))
end
it "Chef::Resource::LwrpOnce.new is *not* a subclass" do
- lwrp = Chef::Resource::LwrpOnce.new('hi')
+ lwrp = Chef::Resource::LwrpOnce.new("hi")
expect(lwrp.kind_of?(subclass)).to be_falsey
expect(lwrp.is_a?(subclass)).to be_falsey
expect(subclass === lwrp.class).to be_falsey
expect(subclass === Chef::Resource::LwrpOnce).to be_falsey
end
it "get_lwrp(:lwrp_once).new is *not* a subclass" do
- lwrp = get_lwrp(:lwrp_once).new('hi')
+ lwrp = get_lwrp(:lwrp_once).new("hi")
expect(lwrp.kind_of?(subclass)).to be_falsey
expect(lwrp.is_a?(subclass)).to be_falsey
expect(subclass === lwrp.class).to be_falsey
@@ -681,35 +681,35 @@ describe "LWRP" do
end
it "subclass.new is a subclass" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(subclass)).to be_truthy
expect(lwrp.is_a?(subclass)).to be_truthy
expect(subclass === lwrp).to be_truthy
expect(lwrp.class === subclass)
end
it "subclass.new is a Chef::Resource::LwrpOnce" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy
expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy
expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy
expect(lwrp.class === Chef::Resource::LwrpOnce)
end
it "subclass.new is a get_lwrp(:lwrp_once)" do
- lwrp = subclass.new('hi')
+ lwrp = subclass.new("hi")
expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy
expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy
expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy
expect(lwrp.class === get_lwrp(:lwrp_once))
end
it "Chef::Resource::LwrpOnce.new is *not* a subclass" do
- lwrp = Chef::Resource::LwrpOnce.new('hi')
+ lwrp = Chef::Resource::LwrpOnce.new("hi")
expect(lwrp.kind_of?(subclass)).to be_falsey
expect(lwrp.is_a?(subclass)).to be_falsey
expect(subclass === lwrp.class).to be_falsey
expect(subclass === Chef::Resource::LwrpOnce).to be_falsey
end
it "get_lwrp(:lwrp_once).new is *not* a subclass" do
- lwrp = get_lwrp(:lwrp_once).new('hi')
+ lwrp = get_lwrp(:lwrp_once).new("hi")
expect(lwrp.kind_of?(subclass)).to be_falsey
expect(lwrp.is_a?(subclass)).to be_falsey
expect(subclass === lwrp.class).to be_falsey
diff --git a/spec/unit/mash_spec.rb b/spec/unit/mash_spec.rb
index b8f4c2d5aa..59904816f6 100644
--- a/spec/unit/mash_spec.rb
+++ b/spec/unit/mash_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mash'
+require "spec_helper"
+require "chef/mash"
describe Mash do
it "should duplicate a simple key/value mash to a new mash" do
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index fc42d76d72..ac1122bbcf 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Mixin::ApiVersionRequestHandling do
let(:dummy_class) { Class.new { include Chef::Mixin::ApiVersionRequestHandling } }
@@ -27,7 +27,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when the response code is not 406" do
- let(:response) { OpenStruct.new(:code => '405') }
+ let(:response) { OpenStruct.new(:code => "405") }
let(:exception) { Net::HTTPServerException.new("405 Something Else", response) }
it "returns nil" do
@@ -38,7 +38,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
end # when the response code is not 406
context "when the response code is 406" do
- let(:response) { OpenStruct.new(:code => '406') }
+ let(:response) { OpenStruct.new(:code => "406") }
let(:exception) { Net::HTTPServerException.new("406 Not Acceptable", response) }
context "when x-ops-server-api-version header does not exist" do
@@ -59,7 +59,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
}
before(:each) do
- allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash))
+ allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash))
end
context "when there is no intersection between client and server versions" do
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index 864b15f2bc..080220ec81 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/checksum'
-require 'stringio'
+require "spec_helper"
+require "chef/mixin/checksum"
+require "stringio"
class Chef::CMCCheck
include Chef::Mixin::Checksum
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb
index cedabcbe49..8a4bb1acbf 100644
--- a/spec/unit/mixin/command_spec.rb
+++ b/spec/unit/mixin/command_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Mixin::Command, :volatile do
diff --git a/spec/unit/mixin/convert_to_class_name_spec.rb b/spec/unit/mixin/convert_to_class_name_spec.rb
index 4cf6728d64..cf90cf31a0 100644
--- a/spec/unit/mixin/convert_to_class_name_spec.rb
+++ b/spec/unit/mixin/convert_to_class_name_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class ConvertToClassTestHarness
include Chef::Mixin::ConvertToClassName
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb
index d107323f32..1212ff2b53 100644
--- a/spec/unit/mixin/deep_merge_spec.rb
+++ b/spec/unit/mixin/deep_merge_spec.rb
@@ -22,26 +22,26 @@
# available under the MIT license from
# http://trac.misuse.org/science/wiki/DeepMerge
-require 'spec_helper'
+require "spec_helper"
# Test coverage from the original author converted to rspec
describe Chef::Mixin::DeepMerge, "deep_merge!" do
before do
@dm = Chef::Mixin::DeepMerge
- @field_ko_prefix = '!merge'
+ @field_ko_prefix = "!merge"
end
# 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)
@@ -181,10 +181,10 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do
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
@@ -247,13 +247,13 @@ 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
diff --git a/spec/unit/mixin/deprecation_spec.rb b/spec/unit/mixin/deprecation_spec.rb
index 6d9f39af9f..3ac0936f60 100644
--- a/spec/unit/mixin/deprecation_spec.rb
+++ b/spec/unit/mixin/deprecation_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/deprecation'
+require "spec_helper"
+require "chef/mixin/deprecation"
describe Chef::Mixin do
describe "deprecating constants (Class/Module)" do
@@ -46,7 +46,7 @@ describe Chef::Mixin::Deprecation::DeprecatedInstanceVariable do
before do
Chef::Log.logger = Logger.new(StringIO.new)
- @deprecated_ivar = Chef::Mixin::Deprecation::DeprecatedInstanceVariable.new('value', 'an_ivar')
+ @deprecated_ivar = Chef::Mixin::Deprecation::DeprecatedInstanceVariable.new("value", "an_ivar")
end
it "forward method calls to the target object" do
diff --git a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
index 408926293e..9da7270bc3 100644
--- a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
+++ b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'etc'
-require 'ostruct'
+require "spec_helper"
+require "etc"
+require "ostruct"
describe Chef::Mixin::EnforceOwnershipAndPermissions do
@@ -52,8 +52,8 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do
allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes)
passwd_struct = OpenStruct.new(:name => "root", :passwd => "x",
- :uid => 0, :gid => 0, :dir => '/root',
- :shell => '/bin/bash')
+ :uid => 0, :gid => 0, :dir => "/root",
+ :shell => "/bin/bash")
group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
allow(Etc).to receive(:getpwuid).and_return(passwd_struct)
@@ -76,8 +76,8 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do
allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes)
passwd_struct = OpenStruct.new(:name => "root", :passwd => "x",
- :uid => 0, :gid => 0, :dir => '/root',
- :shell => '/bin/bash')
+ :uid => 0, :gid => 0, :dir => "/root",
+ :shell => "/bin/bash")
group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
allow(Etc).to receive(:getpwuid).and_return(passwd_struct)
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb
index 57b89720dc..77e37a030c 100644
--- a/spec/unit/mixin/homebrew_user_spec.rb
+++ b/spec/unit/mixin/homebrew_user_spec.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/mixin/homebrew_user'
+require "spec_helper"
+require "chef/mixin/homebrew_user"
class ExampleHomebrewUser
include Chef::Mixin::HomebrewUser
@@ -24,22 +24,22 @@ end
describe Chef::Mixin::HomebrewUser do
before(:each) do
- node.default['homebrew']['owner'] = nil
+ node.default["homebrew"]["owner"] = nil
end
let(:homebrew_user) { ExampleHomebrewUser.new }
let(:node) { Chef::Node.new }
- describe 'when the homebrew user is provided' do
+ describe "when the homebrew user is provided" do
let(:uid) { 1001 }
let(:user) { "foo" }
- it 'returns the homebrew user without looking at the file when uid is provided' do
+ it "returns the homebrew user without looking at the file when uid is provided" do
expect(File).to receive(:exist?).exactly(0).times
expect(homebrew_user.find_homebrew_uid(uid)).to eq(uid)
end
- it 'returns the homebrew user without looking at the file when name is provided' do
+ it "returns the homebrew user without looking at the file when name is provided" do
expect(File).to receive(:exist?).exactly(0).times
allow(Etc).to receive_message_chain(:getpwnam, :uid).and_return(uid)
expect(homebrew_user.find_homebrew_uid(user)).to eq(uid)
@@ -50,7 +50,7 @@ describe Chef::Mixin::HomebrewUser do
shared_examples "successfully find executable" do
let(:user) { nil }
let(:brew_owner) { 2001 }
- let(:default_brew_path) { '/usr/local/bin/brew' }
+ let(:default_brew_path) { "/usr/local/bin/brew" }
let(:stat_double) {
d = double()
expect(d).to receive(:uid).and_return(brew_owner)
@@ -63,13 +63,13 @@ describe Chef::Mixin::HomebrewUser do
expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name"))
end
- it 'returns the owner of the brew executable when it is at a default location' do
+ it "returns the owner of the brew executable when it is at a default location" do
expect(File).to receive(:exist?).with(default_brew_path).and_return(true)
expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double)
expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
end
- it 'returns the owner of the brew executable when it is not at a default location' do
+ it "returns the owner of the brew executable when it is not at a default location" do
expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("/foo")
expect(File).to receive(:stat).with("/foo").and_return(stat_double)
@@ -79,9 +79,9 @@ describe Chef::Mixin::HomebrewUser do
end
end
- describe 'when the homebrew user is not provided' do
+ describe "when the homebrew user is not provided" do
- it 'raises an error if no executable is found' do
+ it "raises an error if no executable is found" do
expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("")
expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner)
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index 99d5230a75..15f99d98f8 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class TinyClass
include Chef::Mixin::ParamsValidate
@@ -372,12 +372,12 @@ describe Chef::Mixin::ParamsValidate do
end
it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do
- value = Chef::DelayedEvaluator.new{ 'test' }
+ 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' }
+ 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})
@@ -385,22 +385,22 @@ describe Chef::Mixin::ParamsValidate do
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'
+ value = "fubar"
@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')
- value = 'fauxbar'
- expect(@vo.set_or_return(:test, nil, {})).to eq('fauxbar')
+ expect(@vo.set_or_return(:test, nil, {})).to eq("fubar")
+ value = "foobar"
+ expect(@vo.set_or_return(:test, nil, {})).to eq("foobar")
+ value = "fauxbar"
+ expect(@vo.set_or_return(:test, nil, {})).to eq("fauxbar")
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 3a924b9538..547c78f706 100644
--- a/spec/unit/mixin/path_sanity_spec.rb
+++ b/spec/unit/mixin/path_sanity_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class PathSanityTestHarness
include Chef::Mixin::PathSanity
@@ -31,10 +31,10 @@ describe Chef::Mixin::PathSanity do
describe "when enforcing path sanity" do
before do
Chef::Config[:enforce_path_sanity] = true
- @ruby_bindir = '/some/ruby/bin'
- @gem_bindir = '/some/gem/bin'
+ @ruby_bindir = "/some/ruby/bin"
+ @gem_bindir = "/some/gem/bin"
allow(Gem).to receive(:bindir).and_return(@gem_bindir)
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return(@ruby_bindir)
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(@ruby_bindir)
allow(ChefConfig).to receive(:windows?).and_return(false)
end
@@ -63,10 +63,10 @@ describe Chef::Mixin::PathSanity do
end
it "does not create entries for Ruby/Gem bindirs if they exist in SANE_PATH or PATH" do
- ruby_bindir = '/usr/bin'
- gem_bindir = '/yo/gabba/gabba'
+ ruby_bindir = "/usr/bin"
+ 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)
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_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")
@@ -76,7 +76,7 @@ describe Chef::Mixin::PathSanity do
ruby_bindir = 'C:\ruby\bin'
gem_bindir = 'C:\gems\bin'
allow(Gem).to receive(:bindir).and_return(gem_bindir)
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return(ruby_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'}
@sanity.enforce_path_sanity(env)
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index 79faf8127d..e8ba6036c5 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -15,8 +15,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/powershell_out'
+require "spec_helper"
+require "chef/mixin/powershell_out"
describe Chef::Mixin::PowershellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } }
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index 988c3926c1..7f49784e8b 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/powershell_type_coercions'
-require 'base64'
+require "spec_helper"
+require "chef/mixin/powershell_type_coercions"
+require "base64"
class Chef::PSTypeTester
include Chef::Mixin::PowershellTypeCoercions
@@ -28,45 +28,45 @@ describe Chef::Mixin::PowershellTypeCoercions do
let (:test_class) { Chef::PSTypeTester.new }
describe '#translate_type' do
- it 'should single quote a string' do
- expect(test_class.translate_type('foo')).to eq("'foo'")
+ it "should single quote a string" do
+ expect(test_class.translate_type("foo")).to eq("'foo'")
end
- ["'", '"', '#', '`'].each do |c|
+ ["'", '"', '#', "`"].each do |c|
it "should base64 encode a string that contains #{c}" do
expect(test_class.translate_type("#{c}")).to match(Base64.strict_encode64(c))
end
end
- it 'should not quote an integer' do
- expect(test_class.translate_type(123)).to eq('123')
+ it "should not quote an integer" do
+ expect(test_class.translate_type(123)).to eq("123")
end
- it 'should not quote a floating point number' do
- expect(test_class.translate_type(123.4)).to eq('123.4')
+ it "should not quote a floating point number" do
+ expect(test_class.translate_type(123.4)).to eq("123.4")
end
- it 'should return $false when an instance of FalseClass is provided' do
- expect(test_class.translate_type(false)).to eq('$false')
+ it "should return $false when an instance of FalseClass is provided" do
+ expect(test_class.translate_type(false)).to eq("$false")
end
- it 'should return $true when an instance of TrueClass is provided' do
- expect(test_class.translate_type(true)).to eq('$true')
+ it "should return $true when an instance of TrueClass is provided" do
+ expect(test_class.translate_type(true)).to eq("$true")
end
- it 'should translate all members of a hash and wrap them in @{} separated by ;' do
+ it "should translate 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
})).to eq("@{a=1;b=1.2;c=$false;d=$true}")
end
- it 'should translat all members of an array and them by a ,' do
- expect(test_class.translate_type([true, false])).to eq('@($true,$false)')
+ it "should translat all members of an array and them by a ," do
+ expect(test_class.translate_type([true, false])).to eq("@($true,$false)")
end
- it 'should fall back :to_psobject if we have not defined at explicit rule' do
+ it "should fall back :to_psobject if we have not defined at explicit rule" do
ps_obj = double("PSObject")
- expect(ps_obj).to receive(:to_psobject).and_return('$true')
- expect(test_class.translate_type(ps_obj)).to eq('($true)')
+ expect(ps_obj).to receive(:to_psobject).and_return("$true")
+ expect(test_class.translate_type(ps_obj)).to eq("($true)")
end
end
end
diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb
index 18178619e4..00e339a221 100644
--- a/spec/unit/mixin/properties_spec.rb
+++ b/spec/unit/mixin/properties_spec.rb
@@ -1,5 +1,5 @@
-require 'support/shared/integration/integration_helper'
-require 'chef/mixin/properties'
+require "support/shared/integration/integration_helper"
+require "chef/mixin/properties"
module ChefMixinPropertiesSpec
describe "Chef::Resource.property" do
@@ -8,46 +8,46 @@ module ChefMixinPropertiesSpec
context "with a base class A with properties a, ab, and ac" do
class A
include Chef::Mixin::Properties
- property :a, 'a', default: 'a'
- property :ab, ['a', 'b'], default: 'a'
- property :ac, ['a', 'c'], default: 'a'
+ property :a, "a", default: "a"
+ property :ab, ["a", "b"], default: "a"
+ property :ac, ["a", "c"], default: "a"
end
context "and a module B with properties b, ab and bc" do
module B
include Chef::Mixin::Properties
- property :b, 'b', default: 'b'
- property :ab, default: 'b'
- property :bc, ['b', 'c'], default: 'c'
+ property :b, "b", default: "b"
+ property :ab, default: "b"
+ property :bc, ["b", "c"], default: "c"
end
context "and a derived class C < A with properties c, ac and bc" do
class C < A
include B
- property :c, 'c', default: 'c'
- property :ac, default: 'c'
- property :bc, default: 'c'
+ property :c, "c", default: "c"
+ property :ac, default: "c"
+ property :bc, default: "c"
end
it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do
expect(A.properties.keys).to eq [ :a, :ab, :ac ]
- expect(A.properties[:a].validation_options[:is]).to eq 'a'
- expect(A.properties[:ab].validation_options[:is]).to eq [ 'a', 'b' ]
- expect(A.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ]
+ expect(A.properties[:a].validation_options[:is]).to eq "a"
+ expect(A.properties[:ab].validation_options[:is]).to eq [ "a", "b" ]
+ expect(A.properties[:ac].validation_options[:is]).to eq [ "a", "c" ]
end
it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do
expect(B.properties.keys).to eq [ :b, :ab, :bc ]
- expect(B.properties[:b].validation_options[:is]).to eq 'b'
+ expect(B.properties[:b].validation_options[:is]).to eq "b"
expect(B.properties[:ab].validation_options[:is]).to be_nil
- expect(B.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ]
+ expect(B.properties[:bc].validation_options[:is]).to eq [ "b", "c" ]
end
it "C.properties has a, b, c, ac and bc with merged types" do
expect(C.properties.keys).to eq [ :a, :ab, :ac, :b, :bc, :c ]
- expect(C.properties[:a].validation_options[:is]).to eq 'a'
- expect(C.properties[:b].validation_options[:is]).to eq 'b'
- expect(C.properties[:c].validation_options[:is]).to eq 'c'
- expect(C.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ]
- expect(C.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ]
+ expect(C.properties[:a].validation_options[:is]).to eq "a"
+ expect(C.properties[:b].validation_options[:is]).to eq "b"
+ expect(C.properties[:c].validation_options[:is]).to eq "c"
+ expect(C.properties[:ac].validation_options[:is]).to eq [ "a", "c" ]
+ expect(C.properties[:bc].validation_options[:is]).to eq [ "b", "c" ]
end
it "C.properties has ab with a non-merged type (from B)" do
expect(C.properties[:ab].validation_options[:is]).to be_nil
@@ -57,12 +57,12 @@ module ChefMixinPropertiesSpec
let(:c) { C.new }
it "all properties can be retrieved and merged properties default to ab->b, ac->c, bc->c" do
- expect(c.a).to eq('a')
- expect(c.b).to eq('b')
- expect(c.c).to eq('c')
- expect(c.ab).to eq('b')
- expect(c.ac).to eq('c')
- expect(c.bc).to eq('c')
+ expect(c.a).to eq("a")
+ expect(c.b).to eq("b")
+ expect(c.c).to eq("c")
+ expect(c.ab).to eq("b")
+ expect(c.ac).to eq("c")
+ expect(c.bc).to eq("c")
end
end
end
diff --git a/spec/unit/mixin/proxified_socket_spec.rb b/spec/unit/mixin/proxified_socket_spec.rb
index 88f71ae48b..70c1ff95cd 100644
--- a/spec/unit/mixin/proxified_socket_spec.rb
+++ b/spec/unit/mixin/proxified_socket_spec.rb
@@ -63,8 +63,8 @@ describe Chef::Mixin::ProxifiedSocket do
before do
# I'm purposefully setting both of these because we prefer the https
# variable
- ENV['https_proxy'] = https_uri
- ENV['http_proxy'] = http_uri
+ ENV["https_proxy"] = https_uri
+ ENV["http_proxy"] = http_uri
end
let(:proxy_uri) { https_uri }
@@ -74,7 +74,7 @@ describe Chef::Mixin::ProxifiedSocket do
# This is testing that no_proxy is also provided to Proxified
# when it is set
before do
- ENV['no_proxy'] = no_proxy_spec
+ ENV["no_proxy"] = no_proxy_spec
end
let(:no_proxy_spec) { "somehost1,somehost2" }
@@ -84,7 +84,7 @@ describe Chef::Mixin::ProxifiedSocket do
context "when http_proxy is set" do
before do
- ENV['http_proxy'] = http_uri
+ ENV["http_proxy"] = http_uri
end
let(:proxy_uri) { http_uri }
diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb
index 33d5eb2141..d52dcd7cbe 100644
--- a/spec/unit/mixin/securable_spec.rb
+++ b/spec/unit/mixin/securable_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Mixin::Securable do
@@ -59,32 +59,32 @@ describe Chef::Mixin::Securable do
end
it "should accept group/owner names that are a single character or digit" do
- expect { @securable.group 'v' }.not_to raise_error
- expect { @securable.group '1' }.not_to raise_error
- expect { @securable.owner 'v' }.not_to raise_error
- expect { @securable.owner '1' }.not_to raise_error
+ expect { @securable.group "v" }.not_to raise_error
+ expect { @securable.group "1" }.not_to raise_error
+ expect { @securable.owner "v" }.not_to raise_error
+ expect { @securable.owner "1" }.not_to raise_error
end
it "should not accept group/owner names starting with '-', '+', or '~'" do
- expect { @securable.group '-test' }.to raise_error(ArgumentError)
- expect { @securable.group '+test' }.to raise_error(ArgumentError)
- expect { @securable.group '~test' }.to raise_error(ArgumentError)
- expect { @securable.group 'te-st' }.not_to raise_error
- expect { @securable.group 'te+st' }.not_to raise_error
- expect { @securable.group 'te~st' }.not_to raise_error
- expect { @securable.owner '-test' }.to raise_error(ArgumentError)
- expect { @securable.owner '+test' }.to raise_error(ArgumentError)
- expect { @securable.owner '~test' }.to raise_error(ArgumentError)
- expect { @securable.owner 'te-st' }.not_to raise_error
- expect { @securable.owner 'te+st' }.not_to raise_error
- expect { @securable.owner 'te~st' }.not_to raise_error
+ expect { @securable.group "-test" }.to raise_error(ArgumentError)
+ expect { @securable.group "+test" }.to raise_error(ArgumentError)
+ expect { @securable.group "~test" }.to raise_error(ArgumentError)
+ expect { @securable.group "te-st" }.not_to raise_error
+ expect { @securable.group "te+st" }.not_to raise_error
+ expect { @securable.group "te~st" }.not_to raise_error
+ expect { @securable.owner "-test" }.to raise_error(ArgumentError)
+ expect { @securable.owner "+test" }.to raise_error(ArgumentError)
+ expect { @securable.owner "~test" }.to raise_error(ArgumentError)
+ expect { @securable.owner "te-st" }.not_to raise_error
+ expect { @securable.owner "te+st" }.not_to raise_error
+ expect { @securable.owner "te~st" }.not_to raise_error
end
it "should not accept group/owner names containing ':', ',' or non-space whitespace" do
- expect { @securable.group ':test' }.to raise_error(ArgumentError)
- expect { @securable.group 'te:st' }.to raise_error(ArgumentError)
- expect { @securable.group ',test' }.to raise_error(ArgumentError)
- expect { @securable.group 'te,st' }.to raise_error(ArgumentError)
+ expect { @securable.group ":test" }.to raise_error(ArgumentError)
+ expect { @securable.group "te:st" }.to raise_error(ArgumentError)
+ expect { @securable.group ",test" }.to raise_error(ArgumentError)
+ expect { @securable.group "te,st" }.to raise_error(ArgumentError)
expect { @securable.group "\ttest" }.to raise_error(ArgumentError)
expect { @securable.group "te\tst" }.to raise_error(ArgumentError)
expect { @securable.group "\rtest" }.to raise_error(ArgumentError)
@@ -93,10 +93,10 @@ describe Chef::Mixin::Securable do
expect { @securable.group "te\fst" }.to raise_error(ArgumentError)
expect { @securable.group "\0test" }.to raise_error(ArgumentError)
expect { @securable.group "te\0st" }.to raise_error(ArgumentError)
- expect { @securable.owner ':test' }.to raise_error(ArgumentError)
- expect { @securable.owner 'te:st' }.to raise_error(ArgumentError)
- expect { @securable.owner ',test' }.to raise_error(ArgumentError)
- expect { @securable.owner 'te,st' }.to raise_error(ArgumentError)
+ expect { @securable.owner ":test" }.to raise_error(ArgumentError)
+ expect { @securable.owner "te:st" }.to raise_error(ArgumentError)
+ expect { @securable.owner ",test" }.to raise_error(ArgumentError)
+ expect { @securable.owner "te,st" }.to raise_error(ArgumentError)
expect { @securable.owner "\ttest" }.to raise_error(ArgumentError)
expect { @securable.owner "te\tst" }.to raise_error(ArgumentError)
expect { @securable.owner "\rtest" }.to raise_error(ArgumentError)
@@ -124,10 +124,10 @@ describe Chef::Mixin::Securable do
end
it "should accept group/owner names in UTF-8" do
- expect { @securable.group 'tëst' }.not_to raise_error
- expect { @securable.group 'ë' }.not_to raise_error
- expect { @securable.owner 'tëst' }.not_to raise_error
- expect { @securable.owner 'ë' }.not_to raise_error
+ expect { @securable.group "tëst" }.not_to raise_error
+ expect { @securable.group "ë" }.not_to raise_error
+ expect { @securable.owner "tëst" }.not_to raise_error
+ expect { @securable.owner "ë" }.not_to raise_error
end
it "should accept a unix file mode in string form as an octal number" do
@@ -262,19 +262,19 @@ describe Chef::Mixin::Securable do
expect { @securable.rights :read, "The Dude", :applies_to_children => true }.not_to raise_error
expect { @securable.rights :read, "The Dude", :applies_to_children => :containers_only }.not_to raise_error
expect { @securable.rights :read, "The Dude", :applies_to_children => :objects_only }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => 'poop' }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", :applies_to_children => "poop" }.to raise_error(ArgumentError)
end
it "should allow you to specify whether the permissions applies_to_self with true/false" do
expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error
expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_self => 'poop' }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", :applies_to_self => "poop" }.to raise_error(ArgumentError)
end
it "should allow you to specify whether the permissions applies one_level_deep with true/false" do
expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error
expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error
- expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => 'poop' }.to raise_error(ArgumentError)
+ expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => "poop" }.to raise_error(ArgumentError)
end
it "should allow multiple rights and deny_rights declarations" do
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index c22d45e5fd..8a2fea651a 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -20,7 +20,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Mixin::ShellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } }
@@ -34,25 +34,25 @@ describe Chef::Mixin::ShellOut do
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
+ context "without options" do
let(:command_args) { [ cmd ] }
- it 'should not edit command args' do
+ it "should not edit command args" do
is_expected.to eql(command_args)
end
end
- context 'without deprecated options' do
+ context "without deprecated options" do
let(:options) { { :environment => environment } }
- let(:environment) { { 'LC_ALL' => 'C', 'LANG' => 'C', 'LANGUAGE' => 'C' } }
+ let(:environment) { { "LC_ALL" => "C", "LANG" => "C", "LANGUAGE" => "C" } }
- it 'should not edit command args' do
+ it "should not edit command args" do
is_expected.to eql(command_args)
end
end
def self.should_emit_deprecation_warning_about(old_option, new_option)
- it 'should emit a deprecation warning' do
+ it "should emit a deprecation warning" do
assume_deprecation_log_level and capture_log_output
subject
expect(output.string).to match /DEPRECATION:/
@@ -61,22 +61,22 @@ describe Chef::Mixin::ShellOut do
end
end
- context 'with :command_log_level option' do
+ context "with :command_log_level option" do
let(:options) { { :command_log_level => command_log_level } }
let(:command_log_level) { :warn }
- it 'should convert :command_log_level to :log_level' do
+ it "should convert :command_log_level to :log_level" do
is_expected.to eql [ cmd, { :log_level => command_log_level } ]
end
should_emit_deprecation_warning_about :command_log_level, :log_level
end
- context 'with :command_log_prepend option' do
+ context "with :command_log_prepend option" do
let(:options) { { :command_log_prepend => command_log_prepend } }
- let(:command_log_prepend) { 'PROVIDER:' }
+ let(:command_log_prepend) { "PROVIDER:" }
- it 'should convert :command_log_prepend to :log_tag' do
+ it "should convert :command_log_prepend to :log_tag" do
is_expected.to eql [ cmd, { :log_tag => command_log_prepend } ]
end
@@ -84,7 +84,7 @@ describe Chef::Mixin::ShellOut do
end
context "with 'command_log_level' option" do
- let(:options) { { 'command_log_level' => command_log_level } }
+ let(:options) { { "command_log_level" => command_log_level } }
let(:command_log_level) { :warn }
it "should convert 'command_log_level' to :log_level" do
@@ -95,8 +95,8 @@ describe Chef::Mixin::ShellOut do
end
context "with 'command_log_prepend' option" do
- let(:options) { { 'command_log_prepend' => command_log_prepend } }
- let(:command_log_prepend) { 'PROVIDER:' }
+ let(:options) { { "command_log_prepend" => command_log_prepend } }
+ let(:command_log_prepend) { "PROVIDER:" }
it "should convert 'command_log_prepend' to :log_tag" do
is_expected.to eql [ cmd, { :log_tag => command_log_prepend } ]
@@ -124,95 +124,95 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is a Hash" do
describe "and environment is an option" do
it "should not change environment language settings when they are set to nil" do
- options = { :environment => { 'LC_ALL' => nil, 'LANGUAGE' => nil, 'LANG' => nil } }
+ options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
it "should not change environment language settings when they are set to non-nil" do
- options = { :environment => { 'LC_ALL' => 'en_US.UTF-8', 'LANGUAGE' => 'en_US.UTF-8', 'LANG' => 'en_US.UTF-8' } }
+ options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.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
it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :environment => { 'HOME' => '/Users/morty' } }
+ options = { :environment => { "HOME" => "/Users/morty" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
:environment => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
}
},).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
it "should not mutate the options hash when it adds language settings" do
- options = { :environment => { 'HOME' => '/Users/morty' } }
+ options = { :environment => { "HOME" => "/Users/morty" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
:environment => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
}
},).and_return(true)
shell_out_obj.shell_out(cmd, options)
- expect(options[:environment].has_key?('LC_ALL')).to be false
+ expect(options[:environment].has_key?("LC_ALL")).to be false
end
end
describe "and env is an option" do
it "should not change env when langauge options are set to nil" do
- options = { :env => { 'LC_ALL' => nil, 'LANG' => nil, 'LANGUAGE' => nil } }
+ options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
it "should not change env when language options are set to non-nil" do
- options = { :env => { 'LC_ALL' => 'de_DE.UTF-8', 'LANG' => 'de_DE.UTF-8', 'LANGUAGE' => 'de_DE.UTF-8' }}
+ 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
it "should set environment language settings to the configured internal locale when they are not present" do
- options = { :env => { 'HOME' => '/Users/morty' } }
+ options = { :env => { "HOME" => "/Users/morty" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
:env => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
}
},).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
it "should not mutate the options hash when it adds language settings" do
- options = { :env => { 'HOME' => '/Users/morty' } }
+ options = { :env => { "HOME" => "/Users/morty" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
:env => {
- 'HOME' => '/Users/morty',
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "HOME" => "/Users/morty",
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
}
},).and_return(true)
shell_out_obj.shell_out(cmd, options)
- expect(options[:env].has_key?('LC_ALL')).to be false
+ expect(options[:env].has_key?("LC_ALL")).to be false
end
end
describe "and no env/environment option is present" do
it "should set environment language settings to the configured internal locale" do
- options = { :user => 'morty' }
+ options = { :user => "morty" }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
- :user => 'morty',
+ :user => "morty",
:environment => {
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
},
},).and_return(true)
shell_out_obj.shell_out(cmd, options)
@@ -224,9 +224,9 @@ describe Chef::Mixin::ShellOut do
it "should set environment language settings to the configured internal locale" do
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
:environment => {
- 'LC_ALL' => Chef::Config[:internal_locale],
- 'LANG' => Chef::Config[:internal_locale],
- 'LANGUAGE' => Chef::Config[:internal_locale],
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
}
},).and_return(true)
shell_out_obj.shell_out(cmd)
@@ -240,19 +240,19 @@ describe Chef::Mixin::ShellOut do
describe "when the last argument is a Hash" do
describe "and environment is an option" do
it "should not change environment['LC_ALL'] when set to nil" do
- options = { :environment => { 'LC_ALL' => nil } }
+ options = { :environment => { "LC_ALL" => nil } }
expect(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
it "should not change environment['LC_ALL'] when set to non-nil" do
- options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
+ options = { :environment => { "LC_ALL" => "en_US.UTF-8" } }
expect(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
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :environment => { 'HOME' => '/Users/morty' } }
+ options = { :environment => { "HOME" => "/Users/morty" } }
expect(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
@@ -260,19 +260,19 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when set to nil" do
- options = { :env => { 'LC_ALL' => nil } }
+ options = { :env => { "LC_ALL" => nil } }
expect(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
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
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
- options = { :env => { 'HOME' => '/Users/morty' } }
+ options = { :env => { "HOME" => "/Users/morty" } }
expect(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
@@ -280,7 +280,7 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
- options = { :user => 'morty' }
+ options = { :user => "morty" }
expect(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/subclass_directive_spec.rb b/spec/unit/mixin/subclass_directive_spec.rb
index 552f26c0c1..38357883d3 100644
--- a/spec/unit/mixin/subclass_directive_spec.rb
+++ b/spec/unit/mixin/subclass_directive_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class SubclassDirectiveParent
extend Chef::Mixin::SubclassDirective
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 95d0eb6711..2fb384866d 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'cgi'
+require "cgi"
describe Chef::Mixin::Template, "render_template" do
let(:sep) { Chef::Platform.windows? ? "\r\n" : "\n" }
@@ -85,10 +85,10 @@ describe Chef::Mixin::Template, "render_template" do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
- @rendered_file_location = Dir.tmpdir + '/openldap_stuff.conf'
+ @rendered_file_location = Dir.tmpdir + "/openldap_stuff.conf"
@resource = Chef::Resource::Template.new(@rendered_file_location)
- @resource.cookbook_name = 'openldap'
+ @resource.cookbook_name = "openldap"
@current_resource = @resource.dup
@content_provider = Chef::Provider::Template::Content.new(@resource, @current_resource, @run_context)
@@ -117,7 +117,7 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should render partials from a different cookbook" do
- @template_context[:template_finder] = Chef::Provider::TemplateFinder.new(@run_context, 'apache2', @node)
+ @template_context[:template_finder] = Chef::Provider::TemplateFinder.new(@run_context, "apache2", @node)
output = @template_context.render_template_from_string("before {<%= render('test.erb', :cookbook => 'openldap').strip %>} after")
expect(output).to eq("before {We could be diving for pearls!} after")
@@ -144,7 +144,7 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should pass the original variables to partials" do
- @template_context[:secret] = 'candy'
+ @template_context[:secret] = "candy"
output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb' %>} after")
output == "before {super secret is candy} after"
@@ -161,7 +161,7 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should pass variables to partials even if they are named the same" do
- @template_context[:secret] = 'one'
+ @template_context[:secret] = "one"
output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb', :variables => {:secret => 'two' } %>} after <%= @secret %>")
expect(output).to eq("before {super secret is two} after one")
@@ -206,7 +206,7 @@ describe Chef::Mixin::Template, "render_template" do
def render_template_from_string
end
end
- ['node', 'render', 'render_template', 'render_template_from_string'].each do |method_name|
+ ["node", "render", "render_template", "render_template_from_string"].each do |method_name|
expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/)
end
@template_context._extend_modules([mod])
diff --git a/spec/unit/mixin/unformatter_spec.rb b/spec/unit/mixin/unformatter_spec.rb
index 2eae0ac9bb..c63ed62b8d 100644
--- a/spec/unit/mixin/unformatter_spec.rb
+++ b/spec/unit/mixin/unformatter_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/unformatter'
+require "spec_helper"
+require "chef/mixin/unformatter"
class Chef::UnformatterTest
include Chef::Mixin::Unformatter
diff --git a/spec/unit/mixin/uris_spec.rb b/spec/unit/mixin/uris_spec.rb
index d4985c4f67..7012ecd861 100644
--- a/spec/unit/mixin/uris_spec.rb
+++ b/spec/unit/mixin/uris_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/uris'
+require "spec_helper"
+require "chef/mixin/uris"
class Chef::UrisTest
include Chef::Mixin::Uris
@@ -28,19 +28,19 @@ describe Chef::Mixin::Uris do
describe "#uri_scheme?" do
it "matches 'scheme://foo.com'" do
- expect(uris.uri_scheme?('scheme://foo.com')).to eq(true)
+ expect(uris.uri_scheme?("scheme://foo.com")).to eq(true)
end
it "does not match 'c:/foo.com'" do
- expect(uris.uri_scheme?('c:/foo.com')).to eq(false)
+ expect(uris.uri_scheme?("c:/foo.com")).to eq(false)
end
it "does not match '/usr/bin/foo.com'" do
- expect(uris.uri_scheme?('/usr/bin/foo.com')).to eq(false)
+ expect(uris.uri_scheme?("/usr/bin/foo.com")).to eq(false)
end
it "does not match 'c:/foo.com://bar.com'" do
- expect(uris.uri_scheme?('c:/foo.com://bar.com')).to eq(false)
+ expect(uris.uri_scheme?("c:/foo.com://bar.com")).to eq(false)
end
end
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 55eca28dc2..58e1927ea7 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -17,8 +17,8 @@
#
-require 'spec_helper'
-require 'chef/mixin/windows_architecture_helper'
+require "spec_helper"
+require "chef/mixin/windows_architecture_helper"
diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb
index c5156cfb7b..a3f4bc839e 100644
--- a/spec/unit/mixin/xml_escape_spec.rb
+++ b/spec/unit/mixin/xml_escape_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class XMLEscapingTestHarness
include Chef::Mixin::XMLEscape
diff --git a/spec/unit/monkey_patches/uri_spec.rb b/spec/unit/monkey_patches/uri_spec.rb
index 9aca1fc9f1..e8ff1a3592 100644
--- a/spec/unit/monkey_patches/uri_spec.rb
+++ b/spec/unit/monkey_patches/uri_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe URI do
describe "when a URI contains an IPv6 literal" do
diff --git a/spec/unit/monologger_spec.rb b/spec/unit/monologger_spec.rb
index 8689ea0aaa..92381afffd 100644
--- a/spec/unit/monologger_spec.rb
+++ b/spec/unit/monologger_spec.rb
@@ -15,9 +15,9 @@
# limitations under the License.
#
-require 'chef/monologger'
-require 'tempfile'
-require 'spec_helper'
+require "chef/monologger"
+require "tempfile"
+require "spec_helper"
describe MonoLogger do
it "should disable buffering when passed an IO stream" do
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 9956ef1ec9..dfa6f33122 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/node/attribute'
+require "spec_helper"
+require "chef/node/attribute"
describe Chef::Node::Attribute do
before(:each) do
@@ -488,31 +488,31 @@ describe Chef::Node::Attribute do
end
it "should create a deep copy of the node attribute" do
- @attributes.default['foo']['bar']['baz'] = 'fizz'
- hash = @attributes['foo'].to_hash
+ @attributes.default["foo"]["bar"]["baz"] = "fizz"
+ hash = @attributes["foo"].to_hash
expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
- hash['bar']['baz'] = 'buzz'
+ hash["bar"]["baz"] = "buzz"
expect(hash).to eql({"bar"=>{"baz"=>"buzz"}})
- expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}})
+ 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' ]})
- hash['bar'].push('buzz')
- expect(hash).to eql({"bar"=>[ 'fizz', 'buzz' ]})
- expect(@attributes.default['foo']).to eql({"bar"=>[ 'fizz' ]})
+ @attributes.default["foo"]["bar"] = ["fizz"]
+ hash = @attributes["foo"].to_hash
+ 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" ]})
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
+ @attributes.default["foo"]["bar"]["baz"] = "fizz"
+ hash = @attributes["foo"].to_hash
expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
- hash['bar']['baz'] << 'buzz'
+ hash["bar"]["baz"] << "buzz"
expect(hash).to eql({"bar"=>{"baz"=>"fizzbuzz"}})
- expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}})
+ expect(@attributes.default["foo"]).to eql({"bar"=>{"baz"=>"fizz"}})
end
end
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index 73165c1fba..07176beb76 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
require "chef/node/immutable_collections"
describe Chef::Node::ImmutableMash do
@@ -64,19 +64,19 @@ describe Chef::Node::ImmutableMash do
end
it "converts an immutable nested mash to a new mutable hash" do
- expect(@copy['top_level_4']['level2']).to be_instance_of(Hash)
+ expect(@copy["top_level_4"]["level2"]).to be_instance_of(Hash)
end
it "converts an immutable nested array to a new mutable array" do
- expect(@copy['top_level_2']).to be_instance_of(Array)
+ expect(@copy["top_level_2"]).to be_instance_of(Array)
end
it "should create a mash with the same content" do
expect(@copy).to eq(@immutable_mash)
end
- it 'should allow mutation' do
- expect { @copy['m'] = 'm' }.not_to raise_error
+ it "should allow mutation" do
+ expect { @copy["m"] = "m" }.not_to raise_error
end
end
@@ -113,7 +113,7 @@ 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_mash = Chef::Node::ImmutableMash.new({:m => "m"})
@immutable_nested_array = Chef::Node::ImmutableArray.new(["level1",@immutable_array, immutable_mash])
end
@@ -189,8 +189,8 @@ describe Chef::Node::ImmutableArray do
expect(@copy).to eq(@immutable_nested_array)
end
- it 'should allow mutation' do
- expect { @copy << 'm' }.not_to raise_error
+ it "should allow mutation" do
+ expect { @copy << "m" }.not_to raise_error
end
end
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 7b37ea59f4..ec7c042e4e 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/node_map'
+require "spec_helper"
+require "chef/node_map"
describe Chef::NodeMap do
@@ -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
@@ -156,7 +156,7 @@ describe Chef::NodeMap do
expect(node_map.get(node, :chef_gem)).to eql(:foo)
end
it "should handle :on_platforms => [ 'windows' ]" do
- node_map.set(:dsc_script, :foo, :on_platforms => [ 'windows' ])
+ node_map.set(:dsc_script, :foo, :on_platforms => [ "windows" ])
allow(node).to receive(:[]).with(:platform).and_return("windows")
expect(node_map.get(node, :dsc_script)).to eql(:foo)
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 39ef684f31..dcee5f8eb5 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Node do
@@ -27,32 +27,32 @@ describe Chef::Node do
it_behaves_like "a platform introspector"
it "creates a node and assigns it a name" do
- node = Chef::Node.build('solo-node')
- expect(node.name).to eq('solo-node')
+ node = Chef::Node.build("solo-node")
+ expect(node.name).to eq("solo-node")
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
- n1 = Chef::Node.build('alpha')
- n2 = Chef::Node.build('beta')
- n3 = Chef::Node.build('omega')
+ n1 = Chef::Node.build("alpha")
+ n2 = Chef::Node.build("beta")
+ n3 = Chef::Node.build("omega")
expect([n3, n1, n2].sort).to eq([n1, n2, n3])
end
it "should share identity only with others of the same name" do
- n1 = Chef::Node.build('foo')
- n2 = Chef::Node.build('foo')
- n3 = Chef::Node.build('bar')
+ n1 = Chef::Node.build("foo")
+ n2 = Chef::Node.build("foo")
+ n3 = Chef::Node.build("bar")
expect(n1).to eq(n2)
expect(n1).not_to eq(n3)
end
describe "when the node does not exist on the server" do
before do
- response = OpenStruct.new(:code => '404')
+ response = OpenStruct.new(:code => "404")
exception = Net::HTTPServerException.new("404 not found", response)
allow(Chef::Node).to receive(:load).and_raise(exception)
node.name("created-node")
@@ -62,19 +62,19 @@ describe Chef::Node do
allow(Chef::Node).to receive(:new).and_return(node)
expect(node).to receive(:create).and_return(node)
node = Chef::Node.find_or_create("created-node")
- expect(node.name).to eq('created-node')
+ expect(node.name).to eq("created-node")
expect(node).to equal(node)
end
end
describe "when the node exists on the server" do
before do
- node.name('existing-node')
+ node.name("existing-node")
allow(Chef::Node).to receive(:load).and_return(node)
end
it "loads the node via the REST API for find_or_create" do
- expect(Chef::Node.find_or_create('existing-node')).to equal(node)
+ expect(Chef::Node.find_or_create("existing-node")).to equal(node)
end
end
@@ -88,7 +88,7 @@ describe Chef::Node do
describe "initialize" do
it "should default to the '_default' chef_environment" do
n = Chef::Node.new
- expect(n.chef_environment).to eq('_default')
+ expect(n.chef_environment).to eq("_default")
end
end
@@ -147,7 +147,7 @@ describe Chef::Node do
end
it "allows policy_name with every valid character" do
- expect { node.policy_name = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:.' }.to_not raise_error
+ expect { node.policy_name = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:." }.to_not raise_error
end
it "sets policy_name when given an argument" do
@@ -183,7 +183,7 @@ describe Chef::Node do
end
it "allows policy_group with every valid character" do
- expect { node.policy_group = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:.' }.to_not raise_error
+ expect { node.policy_group = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:." }.to_not raise_error
end
it "sets an environment with chef_environment(something)" do
@@ -291,9 +291,9 @@ describe Chef::Node do
end
it "should let you use tag as a convience method for the tags attribute" do
- node.normal['tags'] = ['one', 'two']
- node.tag('three', 'four')
- expect(node['tags']).to eq(['one', 'two', 'three', 'four'])
+ node.normal["tags"] = ["one", "two"]
+ node.tag("three", "four")
+ expect(node["tags"]).to eq(["one", "two", "three", "four"])
end
end
@@ -706,25 +706,25 @@ describe Chef::Node do
#
describe "deep merge attribute cache edge conditions" do
it "does not error with complicated attribute substitution" do
- node.default['chef_attribute_hell']['attr1'] = "attribute1"
- node.default['chef_attribute_hell']['attr2'] = "#{node.chef_attribute_hell.attr1}/attr2"
- expect { node.default['chef_attribute_hell']['attr3'] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error
+ node.default["chef_attribute_hell"]["attr1"] = "attribute1"
+ node.default["chef_attribute_hell"]["attr2"] = "#{node.chef_attribute_hell.attr1}/attr2"
+ expect { node.default["chef_attribute_hell"]["attr3"] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error
end
it "caches both strings and symbols correctly" do
- node.force_default[:solr][:version] = '4.10.2'
+ node.force_default[:solr][:version] = "4.10.2"
node.force_default[:solr][:data_dir] = "/opt/solr-#{node['solr'][:version]}/example/solr"
node.force_default[:solr][:xms] = "512M"
expect(node[:solr][:xms]).to eql("512M")
- expect(node['solr'][:xms]).to eql("512M")
+ expect(node["solr"][:xms]).to eql("512M")
end
it "method interpolation syntax also works" do
- node.default['passenger']['version'] = '4.0.57'
- node.default['passenger']['root_path'] = "passenger-#{node['passenger']['version']}"
- node.default['passenger']['root_path_2'] = "passenger-#{node.passenger['version']}"
- expect(node['passenger']['root_path_2']).to eql("passenger-4.0.57")
- expect(node[:passenger]['root_path_2']).to eql("passenger-4.0.57")
+ node.default["passenger"]["version"] = "4.0.57"
+ node.default["passenger"]["root_path"] = "passenger-#{node['passenger']['version']}"
+ node.default["passenger"]["root_path_2"] = "passenger-#{node.passenger['version']}"
+ expect(node["passenger"]["root_path_2"]).to eql("passenger-4.0.57")
+ expect(node[:passenger]["root_path_2"]).to eql("passenger-4.0.57")
end
end
@@ -749,7 +749,7 @@ describe Chef::Node do
describe "consuming json" do
before do
- @ohai_data = {:platform => 'foo', :platform_version => 'bar'}
+ @ohai_data = {:platform => "foo", :platform_version => "bar"}
end
it "consumes the run list portion of a collection of attributes and returns the remainder" do
@@ -762,7 +762,7 @@ describe Chef::Node do
attrs = { "chef_environment" => "foo_environment", "bar" => "baz" }
expect(node.consume_chef_environment(attrs)).to eq({ "bar" => "baz" })
expect(node.chef_environment).to eq("foo_environment")
- expect(node['chef_environment']).to be nil
+ expect(node["chef_environment"]).to be nil
end
it "should overwrites the run list with the run list it consumes" do
@@ -805,7 +805,7 @@ describe Chef::Node do
end
it "should set the tags attribute to an empty array if it is nil" do
- node.attributes.normal = { 'tags' => nil }
+ node.attributes.normal = { "tags" => nil }
node.consume_external_attrs(@ohai_data, {})
expect(node.tags).to eql([])
end
@@ -841,22 +841,22 @@ describe Chef::Node do
describe "preparing for a chef client run" do
before do
- @ohai_data = {:platform => 'foobuntu', :platform_version => '23.42'}
+ @ohai_data = {:platform => "foobuntu", :platform_version => "23.42"}
end
it "sets its platform according to platform detection" do
node.consume_external_attrs(@ohai_data, {})
- expect(node.automatic_attrs[:platform]).to eq('foobuntu')
- expect(node.automatic_attrs[:platform_version]).to eq('23.42')
+ expect(node.automatic_attrs[:platform]).to eq("foobuntu")
+ expect(node.automatic_attrs[:platform_version]).to eq("23.42")
end
it "consumes the run list from provided json attributes" do
- node.consume_external_attrs(@ohai_data, {"run_list" => ['recipe[unicorn]']})
- expect(node.run_list).to eq(['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', [])
+ 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.expand!
@@ -868,7 +868,7 @@ describe Chef::Node do
describe "when expanding its run list and merging attributes" do
before do
@environment = Chef::Environment.new.tap do |e|
- e.name('rspec_env')
+ e.name("rspec_env")
e.default_attributes("env default key" => "env default value")
e.override_attributes("env override key" => "env override value")
end
@@ -879,15 +879,15 @@ describe Chef::Node do
end
it "sets the 'recipes' automatic attribute to the recipes in the expanded run_list" do
- @expansion.recipes << 'recipe[chef::client]' << 'recipe[nginx::default]'
+ @expansion.recipes << "recipe[chef::client]" << "recipe[nginx::default]"
node.expand!
- expect(node.automatic_attrs[:recipes]).to eq(['recipe[chef::client]', 'recipe[nginx::default]'])
+ expect(node.automatic_attrs[:recipes]).to eq(["recipe[chef::client]", "recipe[nginx::default]"])
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'])
+ expect(node.automatic_attrs[:roles].sort).to eq(["arf", "countersnark"])
end
it "applies default attributes from the environment as environment defaults" do
@@ -1152,7 +1152,7 @@ describe Chef::Node do
expect(h["chef_environment"]).to eq("dev")
end
- it 'should return an empty array for empty run_list' do
+ it "should return an empty array for empty run_list" do
expect(node.to_hash["run_list"]).to eq([])
end
end
@@ -1170,11 +1170,11 @@ describe Chef::Node do
expect(json).to match(/run_list/)
end
- it 'should serialize valid json with a run list', :json => true 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
diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb
index 97e1b87704..cc5c9b45b7 100644
--- a/spec/unit/org_spec.rb
+++ b/spec/unit/org_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/org'
-require 'tempfile'
+require "chef/org"
+require "tempfile"
describe Chef::Org do
let(:org) { Chef::Org.new("an_org") }
@@ -135,7 +135,7 @@ describe Chef::Org do
describe "API Interactions" do
let(:rest) do
Chef::Config[:chef_server_root] = "http://www.example.com"
- r = double('rest')
+ r = double("rest")
allow(Chef::ServerAPI).to receive(:new).and_return(r)
r
end
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index d18b6f7902..3905b15071 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe "Chef::Platform#windows_server_2003?" do
it "returns false early when not on windows" do
@@ -51,8 +51,8 @@ describe "Chef::Platform#windows_nano_server?" do
end
after do
- Win32::Registry.send(:remove_const, 'HKEY_LOCAL_MACHINE') if defined?(Win32::Registry::HKEY_LOCAL_MACHINE)
- Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE)
+ Win32::Registry.send(:remove_const, "HKEY_LOCAL_MACHINE") if defined?(Win32::Registry::HKEY_LOCAL_MACHINE)
+ Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE)
end
it "returns false early when not on windows" do
@@ -63,7 +63,7 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns true when the registry value is 1" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_yield(registry)
@@ -73,7 +73,7 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns false when the registry value is not 1" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_yield(registry)
@@ -83,7 +83,7 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns false when the registry value does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_yield(registry)
@@ -94,7 +94,7 @@ describe "Chef::Platform#windows_nano_server?" do
it "returns false when the registry key does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
@@ -122,8 +122,8 @@ describe "Chef::Platform#supports_msi?" do
end
after do
- Win32::Registry.send(:remove_const, 'HKEY_LOCAL_MACHINE') if defined?(Win32::Registry::HKEY_LOCAL_MACHINE)
- Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE)
+ Win32::Registry.send(:remove_const, "HKEY_LOCAL_MACHINE") if defined?(Win32::Registry::HKEY_LOCAL_MACHINE)
+ Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE)
end
it "returns false early when not on windows" do
@@ -134,7 +134,7 @@ describe "Chef::Platform#supports_msi?" do
it "returns true when the registry key exists" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_yield(registry)
@@ -143,7 +143,7 @@ describe "Chef::Platform#supports_msi?" do
it "returns false when the registry key does not exist" do
allow(ChefConfig).to receive(:windows?).and_return(true)
- allow(Chef::Platform).to receive(:require).with('win32/registry')
+ allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).
with(key, access).
and_raise(Win32::Registry::Error, "The system cannot find the file specified.")
@@ -152,12 +152,12 @@ describe "Chef::Platform#supports_msi?" do
end
describe 'Chef::Platform#supports_dsc?' do
- it 'returns false if powershell is not present' do
+ it "returns false if powershell is not present" do
node = Chef::Node.new
expect(Chef::Platform.supports_dsc?(node)).to be_falsey
end
- ['1.0', '2.0', '3.0'].each do |version|
+ ["1.0", "2.0", "3.0"].each do |version|
it "returns false for Powershell #{version}" do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = version
@@ -165,7 +165,7 @@ describe 'Chef::Platform#supports_dsc?' do
end
end
- ['4.0', '5.0'].each do |version|
+ ["4.0", "5.0"].each do |version|
it "returns true for Powershell #{version}" do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = version
@@ -175,12 +175,12 @@ describe 'Chef::Platform#supports_dsc?' do
end
describe 'Chef::Platform#supports_dsc_invoke_resource?' do
- it 'returns false if powershell is not present' do
+ it "returns false if powershell is not present" do
node = Chef::Node.new
expect(Chef::Platform.supports_dsc_invoke_resource?(node)).to be_falsey
end
- ['1.0', '2.0', '3.0', '4.0', '5.0.10017.9'].each do |version|
+ ["1.0", "2.0", "3.0", "4.0", "5.0.10017.9"].each do |version|
it "returns false for Powershell #{version}" do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = version
@@ -196,16 +196,16 @@ describe 'Chef::Platform#supports_dsc_invoke_resource?' do
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(:node) { instance_double("Chef::Node") }
+ let(:cmdlet) { instance_double("Chef::Util::Powershell::Cmdlet") }
+ let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult")}
it "returns true when RefreshMode is Disabled" do
expect(Chef::Util::Powershell::Cmdlet).to receive(:new).
with(node, "Get-DscLocalConfigurationManager", :object).
and_return(cmdlet)
expect(cmdlet).to receive(:run!).and_return(cmdlet_result)
- expect(cmdlet_result).to receive(:return_value).and_return({ 'RefreshMode' => 'Disabled' })
+ expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "Disabled" })
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true
end
@@ -214,7 +214,7 @@ describe 'Chef::Platform#dsc_refresh_mode_disabled?' do
with(node, "Get-DscLocalConfigurationManager", :object).
and_return(cmdlet)
expect(cmdlet).to receive(:run!).and_return(cmdlet_result)
- expect(cmdlet_result).to receive(:return_value).and_return({ 'RefreshMode' => 'LaLaLa' })
+ expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "LaLaLa" })
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false
end
end
diff --git a/spec/unit/platform_spec.rb b/spec/unit/platform_spec.rb
index d16294a8aa..9785108124 100644
--- a/spec/unit/platform_spec.rb
+++ b/spec/unit/platform_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Platform do
@@ -175,7 +175,7 @@ describe Chef::Platform do
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 aff19f4d11..dd819e59b1 100644
--- a/spec/unit/policy_builder/dynamic_spec.rb
+++ b/spec/unit/policy_builder/dynamic_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/policy_builder'
+require "spec_helper"
+require "chef/policy_builder"
describe Chef::PolicyBuilder::Dynamic do
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb
index 944d4d3387..824e17091b 100644
--- a/spec/unit/policy_builder/expand_node_object_spec.rb
+++ b/spec/unit/policy_builder/expand_node_object_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/policy_builder'
+require "spec_helper"
+require "chef/policy_builder"
describe Chef::PolicyBuilder::ExpandNodeObject do
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 98515a4102..8900bc27c4 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/policy_builder'
+require "spec_helper"
+require "chef/policy_builder"
describe Chef::PolicyBuilder::Policyfile do
diff --git a/spec/unit/policy_builder_spec.rb b/spec/unit/policy_builder_spec.rb
index 506911452c..01a507a8f4 100644
--- a/spec/unit/policy_builder_spec.rb
+++ b/spec/unit/policy_builder_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/policy_builder'
+require "spec_helper"
+require "chef/policy_builder"
describe Chef::PolicyBuilder do
diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb
index 032b0aba52..3dce632570 100644
--- a/spec/unit/property/state_spec.rb
+++ b/spec/unit/property/state_spec.rb
@@ -1,4 +1,4 @@
-require 'support/shared/integration/integration_helper'
+require "support/shared/integration/integration_helper"
describe "Chef::Resource#identity and #state" do
include IntegrationSupport
@@ -26,7 +26,7 @@ describe "Chef::Resource#identity and #state" do
end
def self.english_join(values)
- return '<nothing>' if values.size == 0
+ return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
"#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
end
@@ -55,8 +55,8 @@ describe "Chef::Resource#identity and #state" do
it "name is the default identity" do
expect(resource_class.identity_properties).to eq [ Chef::Resource.properties[:name] ]
expect(Chef::Resource.properties[:name].identity?).to be_falsey
- expect(resource.name).to eq 'blah'
- expect(resource.identity).to eq 'blah'
+ expect(resource.name).to eq "blah"
+ expect(resource.identity).to eq "blah"
end
it "identity_properties :x changes the identity" do
@@ -65,11 +65,11 @@ describe "Chef::Resource#identity and #state" do
expect(Chef::Resource.properties[:name].identity?).to be_falsey
expect(resource_class.properties[:x].identity?).to be_truthy
- expect(resource.x 'woo').to eq 'woo'
- expect(resource.x).to eq 'woo'
+ expect(resource.x "woo").to eq "woo"
+ expect(resource.x).to eq "woo"
- expect(resource.name).to eq 'blah'
- expect(resource.identity).to eq 'woo'
+ expect(resource.name).to eq "blah"
+ expect(resource.identity).to eq "woo"
end
with_property ":y, identity: true" do
@@ -81,19 +81,19 @@ describe "Chef::Resource#identity and #state" do
end
it "only returns :x as identity" do
- resource.x 'foo'
- resource.y 'bar'
+ resource.x "foo"
+ resource.y "bar"
expect(resource_class.identity_properties).to eq [ resource_class.properties[:x] ]
- expect(resource.identity).to eq 'foo'
+ expect(resource.identity).to eq "foo"
end
it "does not flip y.desired_state off" do
- resource.x 'foo'
- resource.y 'bar'
+ resource.x "foo"
+ resource.y "bar"
expect(resource_class.state_properties).to eq [
resource_class.properties[:x],
resource_class.properties[:y],
]
- expect(resource.state_for_resource_reporter).to eq(x: 'foo', y: 'bar')
+ expect(resource.state_for_resource_reporter).to eq(x: "foo", y: "bar")
end
end
end
@@ -106,14 +106,14 @@ describe "Chef::Resource#identity and #state" do
end
end
let(:subresource) do
- subresource_class.new('sub')
+ subresource_class.new("sub")
end
it "name is the default identity on the subclass" do
expect(subresource_class.identity_properties).to eq [ Chef::Resource.properties[:name] ]
expect(Chef::Resource.properties[:name].identity?).to be_falsey
- expect(subresource.name).to eq 'sub'
- expect(subresource.identity).to eq 'sub'
+ expect(subresource.name).to eq "sub"
+ expect(subresource.identity).to eq "sub"
end
context "With identity_properties :x on the superclass" do
@@ -128,8 +128,8 @@ describe "Chef::Resource#identity and #state" do
expect(Chef::Resource.properties[:name].identity?).to be_falsey
expect(subresource_class.properties[:x].identity?).to be_truthy
- subresource.x 'foo'
- expect(subresource.identity).to eq 'foo'
+ subresource.x "foo"
+ expect(subresource.identity).to eq "foo"
end
context "With property :y, identity: true on the subclass" do
@@ -143,9 +143,9 @@ describe "Chef::Resource#identity and #state" do
subresource_class.properties[:x],
subresource_class.properties[:y],
]
- subresource.x 'foo'
- subresource.y 'bar'
- expect(subresource.identity).to eq(x: 'foo', y: 'bar')
+ subresource.x "foo"
+ subresource.y "bar"
+ expect(subresource.identity).to eq(x: "foo", y: "bar")
end
end
@@ -157,9 +157,9 @@ describe "Chef::Resource#identity and #state" do
end
end
it "y is part of state" do
- subresource.x 'foo'
- subresource.y 'bar'
- expect(subresource.state_for_resource_reporter).to eq(x: 'foo', y: 'bar')
+ subresource.x "foo"
+ subresource.y "bar"
+ expect(subresource.state_for_resource_reporter).to eq(x: "foo", y: "bar")
expect(subresource_class.state_properties).to eq [
subresource_class.properties[:x],
subresource_class.properties[:y],
@@ -167,9 +167,9 @@ describe "Chef::Resource#identity and #state" do
end
it "y is the identity" do
expect(subresource_class.identity_properties).to eq [ subresource_class.properties[:y] ]
- subresource.x 'foo'
- subresource.y 'bar'
- expect(subresource.identity).to eq 'bar'
+ subresource.x "foo"
+ subresource.y "bar"
+ expect(subresource.identity).to eq "bar"
end
it "y still has validation" do
expect { subresource.y 12 }.to raise_error Chef::Exceptions::ValidationFailed
@@ -191,8 +191,8 @@ describe "Chef::Resource#identity and #state" do
with_property ":x, desired_state: false" do
it "identity_properties does not change desired_state" do
resource_class.identity_properties :x
- resource.x 'hi'
- expect(resource.identity).to eq 'hi'
+ resource.x "hi"
+ expect(resource.identity).to eq "hi"
expect(resource_class.properties[:x].desired_state?).to be_falsey
expect(resource_class.state_properties).to eq []
expect(resource.state_for_resource_reporter).to eq({})
@@ -247,8 +247,8 @@ describe "Chef::Resource#identity and #state" do
with_property ":x, identity: true" do
it "name is only part of the identity if an identity attribute is defined" do
expect(resource_class.identity_properties).to eq [ resource_class.properties[:x] ]
- resource.x 'woo'
- expect(resource.identity).to eq 'woo'
+ resource.x "woo"
+ expect(resource.identity).to eq "woo"
end
end
@@ -262,29 +262,29 @@ describe "Chef::Resource#identity and #state" do
expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError
end
it "identity returns all identity values in a hash if multiple are defined" do
- resource.x 'foo'
- resource.y 'bar'
- resource.z 'baz'
- expect(resource.identity).to eq(x: 'foo', y: 'bar', z: 'baz')
+ resource.x "foo"
+ resource.y "bar"
+ resource.z "baz"
+ expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz")
end
it "identity returns all values whether any value is set or not" do
- expect(resource.identity).to eq(x: 'xxx', y: 'yyy', z: 'zzz')
+ expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz")
end
it "identity_properties wipes out any other identity attributes if multiple are defined" do
resource_class.identity_properties :y
- resource.x 'foo'
- resource.y 'bar'
- resource.z 'baz'
- expect(resource.identity).to eq 'bar'
+ resource.x "foo"
+ resource.y "bar"
+ resource.z "baz"
+ expect(resource.identity).to eq "bar"
end
end
with_property ":x, identity: true, name_property: true" do
it "identity when x is not defined returns the value of x" do
- expect(resource.identity).to eq 'blah'
+ expect(resource.identity).to eq "blah"
end
it "state when x is not defined returns the value of x" do
- expect(resource.state_for_resource_reporter).to eq(x: 'blah')
+ expect(resource.state_for_resource_reporter).to eq(x: "blah")
end
end
end
@@ -397,7 +397,7 @@ describe "Chef::Resource#identity and #state" do
end
it "state_properties(:x) does not turn off validation" do
resource_class.state_properties(:x)
- expect { resource.x 'ouch' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { resource.x "ouch" }.to raise_error Chef::Exceptions::ValidationFailed
end
it "state_properties(:x) does not turn off identity" do
resource_class.state_properties(:x)
@@ -459,7 +459,7 @@ describe "Chef::Resource#identity and #state" do
end
end
let(:subresource) do
- subresource_class.new('blah')
+ subresource_class.new("blah")
end
it "state_properties(:x) adds x to desired state" do
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb
index fef983ccf4..7e84a651e2 100644
--- a/spec/unit/property/validation_spec.rb
+++ b/spec/unit/property/validation_spec.rb
@@ -1,4 +1,4 @@
-require 'support/shared/integration/integration_helper'
+require "support/shared/integration/integration_helper"
describe "Chef::Resource.property validation" do
include IntegrationSupport
@@ -49,7 +49,7 @@ describe "Chef::Resource.property validation" do
end
def self.english_join(values)
- return '<nothing>' if values.size == 0
+ return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
"#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
end
@@ -79,7 +79,7 @@ describe "Chef::Resource.property validation" do
end
success_values.each do |v|
it "value #{v.inspect} is valid" do
- resource.instance_eval { @x = 'default' }
+ resource.instance_eval { @x = "default" }
expect(resource.x v).to eq v
expect(resource.x).to eq v
end
@@ -87,16 +87,16 @@ describe "Chef::Resource.property validation" do
failure_values.each do |v|
it "value #{v.inspect} is invalid" do
expect { resource.x v }.to raise_error Chef::Exceptions::ValidationFailed
- resource.instance_eval { @x = 'default' }
+ resource.instance_eval { @x = "default" }
expect { resource.x v }.to raise_error Chef::Exceptions::ValidationFailed
end
end
getter_values.each do |v|
it "setting value to #{v.inspect} does not change the value" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource.instance_eval { @x = 'default' }
- expect(resource.x v).to eq 'default'
- expect(resource.x).to eq 'default'
+ resource.instance_eval { @x = "default" }
+ expect(resource.x v).to eq "default"
+ expect(resource.x).to eq "default"
end
end
end
@@ -106,14 +106,14 @@ describe "Chef::Resource.property validation" do
with_property ":x, kind_of: String" do
context "when the variable already has a value" do
before do
- resource.instance_eval { @x = 'default' }
+ resource.instance_eval { @x = "default" }
end
it "get succeeds" do
- expect(resource.x).to eq 'default'
+ expect(resource.x).to eq "default"
end
it "set to valid value succeeds" do
- expect(resource.x 'str').to eq 'str'
- expect(resource.x).to eq 'str'
+ expect(resource.x "str").to eq "str"
+ expect(resource.x).to eq "str"
end
it "set to invalid value raises ValidationFailed" do
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
@@ -121,9 +121,9 @@ describe "Chef::Resource.property validation" do
it "set to nil emits a deprecation warning and does a get" do
expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource.x 'str'
- expect(resource.x nil).to eq 'str'
- expect(resource.x).to eq 'str'
+ resource.x "str"
+ expect(resource.x nil).to eq "str"
+ expect(resource.x).to eq "str"
end
end
context "when the variable does not have an initial value" do
@@ -131,8 +131,8 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to be_nil
end
it "set to valid value succeeds" do
- expect(resource.x 'str').to eq 'str'
- expect(resource.x).to eq 'str'
+ expect(resource.x "str").to eq "str"
+ expect(resource.x).to eq "str"
end
it "set to invalid value raises ValidationFailed" do
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
@@ -145,18 +145,18 @@ describe "Chef::Resource.property validation" do
with_property ":x, [ String, nil ]" do
context "when the variable already has a value" do
before do
- resource.instance_eval { @x = 'default' }
+ resource.instance_eval { @x = "default" }
end
it "get succeeds" do
- expect(resource.x).to eq 'default'
+ expect(resource.x).to eq "default"
end
it "set(nil) sets the value" do
expect(resource.x nil).to be_nil
expect(resource.x).to be_nil
end
it "set to valid value succeeds" do
- expect(resource.x 'str').to eq 'str'
- expect(resource.x).to eq 'str'
+ expect(resource.x "str").to eq "str"
+ expect(resource.x).to eq "str"
end
it "set to invalid value raises ValidationFailed" do
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
@@ -171,8 +171,8 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to be_nil
end
it "set to valid value succeeds" do
- expect(resource.x 'str').to eq 'str'
- expect(resource.x).to eq 'str'
+ expect(resource.x "str").to eq "str"
+ expect(resource.x).to eq "str"
end
it "set to invalid value raises ValidationFailed" do
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
@@ -183,45 +183,45 @@ describe "Chef::Resource.property validation" do
# Bare types
context "bare types" do
- validation_test 'String',
- [ 'hi' ],
+ validation_test "String",
+ [ "hi" ],
[ 10 ],
[ nil ]
- validation_test ':a',
+ validation_test ":a",
[ :a ],
[ :b ],
[ nil ]
- validation_test ':a, is: :b',
+ validation_test ":a, is: :b",
[ :a, :b ],
[ :c ],
[ nil ]
- validation_test ':a, is: [ :b, :c ]',
+ validation_test ":a, is: [ :b, :c ]",
[ :a, :b, :c ],
[ :d ],
[ nil ]
- validation_test '[ :a, :b ], is: :c',
+ validation_test "[ :a, :b ], is: :c",
[ :a, :b, :c ],
[ :d ],
[ nil ]
- validation_test '[ :a, :b ], is: [ :c, :d ]',
+ validation_test "[ :a, :b ], is: [ :c, :d ]",
[ :a, :b, :c, :d ],
[ :e ],
[ nil ]
- validation_test 'nil',
+ validation_test "nil",
[ nil ],
[ :a ]
- validation_test '[ nil ]',
+ validation_test "[ nil ]",
[ nil ],
[ :a ]
- validation_test '[]',
+ validation_test "[]",
[],
[ :a ],
[ nil ]
@@ -230,35 +230,35 @@ describe "Chef::Resource.property validation" do
# is
context "is" do
# Class
- validation_test 'is: String',
- [ 'a', '' ],
+ validation_test "is: String",
+ [ "a", "" ],
[ :a, 1 ],
[ nil ]
# Value
- validation_test 'is: :a',
+ validation_test "is: :a",
[ :a ],
[ :b ],
[ nil ]
- validation_test 'is: [ :a, :b ]',
+ validation_test "is: [ :a, :b ]",
[ :a, :b ],
[ [ :a, :b ] ],
[ nil ]
- validation_test 'is: [ [ :a, :b ] ]',
+ validation_test "is: [ [ :a, :b ] ]",
[ [ :a, :b ] ],
[ :a, :b ],
[ nil ]
# Regex
- validation_test 'is: /abc/',
- [ 'abc', 'wowabcwow' ],
- [ '', 'abac' ],
+ validation_test "is: /abc/",
+ [ "abc", "wowabcwow" ],
+ [ "", "abac" ],
[ nil ]
# Property
- validation_test 'is: Chef::Property.new(is: :a)',
+ validation_test "is: Chef::Property.new(is: :a)",
[ :a ],
[ :b, nil ]
@@ -273,24 +273,24 @@ describe "Chef::Resource.property validation" do
[ nil ]
# Proc
- validation_test 'is: proc { |x| x }',
+ validation_test "is: proc { |x| x }",
[ true, 1 ],
[ false ],
[ nil ]
- validation_test 'is: proc { |x| x > blah }',
+ validation_test "is: proc { |x| x > blah }",
[ 10 ],
[ -1 ]
- validation_test 'is: nil',
+ validation_test "is: nil",
[ nil ],
- [ 'a' ]
+ [ "a" ]
- validation_test 'is: [ String, nil ]',
- [ 'a', nil ],
+ validation_test "is: [ String, nil ]",
+ [ "a", nil ],
[ :b ]
- validation_test 'is: []',
+ validation_test "is: []",
[],
[ :a ],
[ nil ]
@@ -299,45 +299,45 @@ describe "Chef::Resource.property validation" do
# Combination
context "combination" do
validation_test 'kind_of: String, equal_to: "a"',
- [ 'a' ],
- [ 'b' ],
+ [ "a" ],
+ [ "b" ],
[ nil ]
end
# equal_to
context "equal_to" do
# Value
- validation_test 'equal_to: :a',
+ validation_test "equal_to: :a",
[ :a ],
[ :b ],
[ nil ]
- validation_test 'equal_to: [ :a, :b ]',
+ validation_test "equal_to: [ :a, :b ]",
[ :a, :b ],
[ [ :a, :b ] ],
[ nil ]
- validation_test 'equal_to: [ [ :a, :b ] ]',
+ validation_test "equal_to: [ [ :a, :b ] ]",
[ [ :a, :b ] ],
[ :a, :b ],
[ nil ]
- validation_test 'equal_to: nil',
+ validation_test "equal_to: nil",
[ ],
- [ 'a' ],
+ [ "a" ],
[ nil ]
validation_test 'equal_to: [ "a", nil ]',
- [ 'a' ],
- [ 'b' ],
+ [ "a" ],
+ [ "b" ],
[ nil ]
validation_test 'equal_to: [ nil, "a" ]',
- [ 'a' ],
- [ 'b' ],
+ [ "a" ],
+ [ "b" ],
[ nil ]
- validation_test 'equal_to: []',
+ validation_test "equal_to: []",
[],
[ :a ],
[ nil ]
@@ -345,37 +345,37 @@ describe "Chef::Resource.property validation" do
# kind_of
context "kind_of" do
- validation_test 'kind_of: String',
- [ 'a' ],
+ validation_test "kind_of: String",
+ [ "a" ],
[ :b ],
[ nil ]
- validation_test 'kind_of: [ String, Symbol ]',
- [ 'a', :b ],
+ validation_test "kind_of: [ String, Symbol ]",
+ [ "a", :b ],
[ 1 ],
[ nil ]
- validation_test 'kind_of: [ Symbol, String ]',
- [ 'a', :b ],
+ validation_test "kind_of: [ Symbol, String ]",
+ [ "a", :b ],
[ 1 ],
[ nil ]
- validation_test 'kind_of: NilClass',
+ validation_test "kind_of: NilClass",
[ ],
- [ 'a' ],
+ [ "a" ],
[ nil ]
- validation_test 'kind_of: [ NilClass, String ]',
- [ 'a' ],
+ validation_test "kind_of: [ NilClass, String ]",
+ [ "a" ],
[ :a ],
[ nil ]
- validation_test 'kind_of: []',
+ validation_test "kind_of: []",
[],
[ :a ],
[ nil ]
- validation_test 'kind_of: nil',
+ validation_test "kind_of: nil",
[],
[ :a ],
[ nil ]
@@ -383,32 +383,32 @@ describe "Chef::Resource.property validation" do
# regex
context "regex" do
- validation_test 'regex: /abc/',
- [ 'xabcy' ],
- [ 'gbh', 123 ],
+ validation_test "regex: /abc/",
+ [ "xabcy" ],
+ [ "gbh", 123 ],
[ nil ]
- validation_test 'regex: [ /abc/, /z/ ]',
- [ 'xabcy', 'aza' ],
- [ 'gbh', 123 ],
+ validation_test "regex: [ /abc/, /z/ ]",
+ [ "xabcy", "aza" ],
+ [ "gbh", 123 ],
[ nil ]
- validation_test 'regex: [ /z/, /abc/ ]',
- [ 'xabcy', 'aza' ],
- [ 'gbh', 123 ],
+ validation_test "regex: [ /z/, /abc/ ]",
+ [ "xabcy", "aza" ],
+ [ "gbh", 123 ],
[ nil ]
- validation_test 'regex: [ [ /z/, /abc/ ], [ /n/ ] ]',
- [ 'xabcy', 'aza', 'ana' ],
- [ 'gbh', 123 ],
+ validation_test "regex: [ [ /z/, /abc/ ], [ /n/ ] ]",
+ [ "xabcy", "aza", "ana" ],
+ [ "gbh", 123 ],
[ nil ]
- validation_test 'regex: []',
+ validation_test "regex: []",
[],
[ :a ],
[ nil ]
- validation_test 'regex: nil',
+ validation_test "regex: nil",
[],
[ :a ],
[ nil ]
@@ -426,10 +426,10 @@ describe "Chef::Resource.property validation" do
validation_test 'callbacks: { "a" => proc { |x| x.nil? } }',
[ ],
- [ 'a' ],
+ [ "a" ],
[ nil ]
- validation_test 'callbacks: {}',
+ validation_test "callbacks: {}",
[ :a ],
[],
[ nil ]
@@ -437,49 +437,49 @@ describe "Chef::Resource.property validation" do
# respond_to
context "respond_to" do
- validation_test 'respond_to: :split',
- [ 'hi' ],
+ validation_test "respond_to: :split",
+ [ "hi" ],
[ 1 ],
[ nil ]
validation_test 'respond_to: "split"',
- [ 'hi' ],
+ [ "hi" ],
[ 1 ],
[ nil ]
- validation_test 'respond_to: :to_s',
+ validation_test "respond_to: :to_s",
[ :a ],
[],
[ nil ]
- validation_test 'respond_to: [ :split, :to_s ]',
- [ 'hi' ],
+ validation_test "respond_to: [ :split, :to_s ]",
+ [ "hi" ],
[ 1 ],
[ nil ]
- validation_test 'respond_to: %w(split to_s)',
- [ 'hi' ],
+ validation_test "respond_to: %w(split to_s)",
+ [ "hi" ],
[ 1 ],
[ nil ]
- validation_test 'respond_to: [ :to_s, :split ]',
- [ 'hi' ],
+ validation_test "respond_to: [ :to_s, :split ]",
+ [ "hi" ],
[ 1 ],
[ nil ]
- validation_test 'respond_to: []',
+ validation_test "respond_to: []",
[ :a ],
[],
[ nil ]
- validation_test 'respond_to: nil',
+ validation_test "respond_to: nil",
[ :a ],
[],
[ nil ]
end
context "cannot_be" do
- validation_test 'cannot_be: :empty',
+ validation_test "cannot_be: :empty",
[ 1, [1,2], { a: 10 } ],
[ [] ],
[ nil ]
@@ -489,7 +489,7 @@ describe "Chef::Resource.property validation" do
[ [] ],
[ nil ]
- validation_test 'cannot_be: [ :empty, :nil ]',
+ validation_test "cannot_be: [ :empty, :nil ]",
[ 1, [1,2], { a: 10 } ],
[ [] ],
[ nil ]
@@ -499,22 +499,22 @@ describe "Chef::Resource.property validation" do
[ [] ],
[ nil ]
- validation_test 'cannot_be: [ :nil, :empty ]',
+ validation_test "cannot_be: [ :nil, :empty ]",
[ 1, [1,2], { a: 10 } ],
[ [] ],
[ nil ]
- validation_test 'cannot_be: [ :empty, :nil, :blahblah ]',
+ validation_test "cannot_be: [ :empty, :nil, :blahblah ]",
[ 1, [1,2], { a: 10 } ],
[ [] ],
[ nil ]
- validation_test 'cannot_be: []',
+ validation_test "cannot_be: []",
[ :a ],
[],
[ nil ]
- validation_test 'cannot_be: nil',
+ validation_test "cannot_be: nil",
[ :a ],
[],
[ nil ]
@@ -522,7 +522,7 @@ describe "Chef::Resource.property validation" do
end
context "required" do
- with_property ':x, required: true' do
+ with_property ":x, required: true" do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
@@ -545,7 +545,7 @@ describe "Chef::Resource.property validation" do
end
end
- with_property ':x, [String, nil], required: true' do
+ with_property ":x, [String, nil], required: true" do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
@@ -554,17 +554,17 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to be_nil
end
it "value '1' is valid" do
- expect(resource.x '1').to eq '1'
- expect(resource.x).to eq '1'
+ expect(resource.x "1").to eq "1"
+ expect(resource.x).to eq "1"
end
it "value 1 is invalid" do
expect { resource.x 1 }.to raise_error Chef::Exceptions::ValidationFailed
end
end
- with_property ':x, name_property: true, required: true' do
+ with_property ":x, name_property: true, required: true" do
it "if x is not specified, the name property is returned" do
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
end
it "value 1 is valid" do
expect(resource.x 1).to eq 1
@@ -579,7 +579,7 @@ describe "Chef::Resource.property validation" do
end
end
- with_property ':x, default: 10, required: true' do
+ with_property ":x, default: 10, required: true" do
it "if x is not specified, the default is returned" do
expect(resource.x).to eq 10
end
@@ -602,7 +602,7 @@ describe "Chef::Resource.property validation" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
end
- with_property ':x, blarghle: 1' do
+ with_property ":x, blarghle: 1" do
context "and a class that implements _pv_blarghle" do
before do
resource_class.class_eval do
@@ -621,7 +621,7 @@ describe "Chef::Resource.property validation" do
it "value '1' is invalid" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed
end
it "value nil does a get" do
@@ -633,7 +633,7 @@ describe "Chef::Resource.property validation" do
end
end
- with_property ':x, blarghle: 1' do
+ with_property ":x, blarghle: 1" do
context "and a class that implements _pv_blarghle" do
before do
resource_class.class_eval do
@@ -651,7 +651,7 @@ describe "Chef::Resource.property validation" do
end
it "value '1' is invalid" do
- expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed
end
it "value nil does a get" do
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 095dcc8e98..1fe8abc706 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -1,4 +1,4 @@
-require 'support/shared/integration/integration_helper'
+require "support/shared/integration/integration_helper"
describe "Chef::Resource.property" do
include IntegrationSupport
@@ -46,7 +46,7 @@ describe "Chef::Resource.property" do
end
def self.english_join(values)
- return '<nothing>' if values.size == 0
+ return "<nothing>" if values.size == 0
return values[0].inspect if values.size == 1
"#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}"
end
@@ -74,7 +74,7 @@ describe "Chef::Resource.property" do
end
# Basic properties
- with_property ':bare_property' do
+ with_property ":bare_property" do
it "can be set" do
expect(resource.bare_property 10).to eq 10
expect(resource.bare_property).to eq 10
@@ -116,7 +116,7 @@ describe "Chef::Resource.property" do
end
end
let(:subresource) do
- subresource_class.new('blah')
+ subresource_class.new("blah")
end
context "with property :x on the subclass" do
@@ -127,7 +127,7 @@ describe "Chef::Resource.property" do
end
it "x is still name_property" do
- expect(subresource.x).to eq 'blah'
+ expect(subresource.x).to eq "blah"
end
end
@@ -166,7 +166,7 @@ describe "Chef::Resource.property" do
end
end
let(:subresource) do
- subresource_class.new('blah')
+ subresource_class.new("blah")
end
it "x is inherited" do
@@ -178,7 +178,7 @@ describe "Chef::Resource.property" do
end
it "x's validation is inherited" do
- expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed
end
context "with property :y on the subclass" do
@@ -225,7 +225,7 @@ describe "Chef::Resource.property" do
end
it "x's validation is inherited" do
- expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed
end
end
@@ -250,7 +250,7 @@ describe "Chef::Resource.property" do
end
it "x's validation is inherited" do
- expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed
end
end
@@ -272,12 +272,12 @@ describe "Chef::Resource.property" do
it "x's validation is overwritten" do
expect { subresource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
- expect(subresource.x 'ohno').to eq 'ohno'
- expect(subresource.x).to eq 'ohno'
+ expect(subresource.x "ohno").to eq "ohno"
+ expect(subresource.x).to eq "ohno"
end
it "the superclass's validation for x is still there" do
- expect { resource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { resource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed
expect(resource.x 10).to eq 10
expect(resource.x).to eq 10
end
@@ -297,7 +297,7 @@ describe "Chef::Resource.property" do
expect { resource.reset_property(:x) }.to raise_error(ArgumentError)
end
- with_property ':x' do
+ with_property ":x" do
it "when the resource is newly created, reset_property(:x) does nothing" do
expect(resource.property_is_set?(:x)).to be_falsey
resource.reset_property(:x)
@@ -313,7 +313,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, Integer' do
+ with_property ":x, Integer" do
it "when the resource is newly created, reset_property(:x) does nothing" do
expect(resource.property_is_set?(:x)).to be_falsey
resource.reset_property(:x)
@@ -329,7 +329,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: 10' do
+ with_property ":x, default: 10" do
it "when the resource is newly created, reset_property(:x) does nothing" do
expect(resource.property_is_set?(:x)).to be_falsey
resource.reset_property(:x)
@@ -344,7 +344,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: lazy { 10 }' do
+ with_property ":x, default: lazy { 10 }" do
it "when the resource is newly created, reset_property(:x) does nothing" do
expect(resource.property_is_set?(:x)).to be_falsey
resource.reset_property(:x)
@@ -369,7 +369,7 @@ describe "Chef::Resource.property" do
expect { resource.property_is_set?(:x) }.to raise_error(ArgumentError)
end
- with_property ':x' do
+ with_property ":x" do
it "when the resource is newly created, property_is_set?(:x) is false" do
expect(resource.property_is_set?(:x)).to be_falsey
end
@@ -391,7 +391,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: 10' do
+ with_property ":x, default: 10" do
it "when the resource is newly created, property_is_set?(:x) is false" do
expect(resource.property_is_set?(:x)).to be_falsey
end
@@ -413,7 +413,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: nil' do
+ with_property ":x, default: nil" do
it "when the resource is newly created, property_is_set?(:x) is false" do
expect(resource.property_is_set?(:x)).to be_falsey
end
@@ -435,7 +435,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: lazy { 10 }' do
+ with_property ":x, default: lazy { 10 }" do
it "when the resource is newly created, property_is_set?(:x) is false" do
expect(resource.property_is_set?(:x)).to be_falsey
end
@@ -455,7 +455,7 @@ describe "Chef::Resource.property" do
end
context "Chef::Resource::Property#default" do
- with_property ':x, default: 10' do
+ with_property ":x, default: 10" do
it "when x is set, it returns its value" do
expect(resource.x 20).to eq 20
expect(resource.property_is_set?(:x)).to be_truthy
@@ -479,33 +479,33 @@ describe "Chef::Resource.property" do
resource_name new_resource_name
end
end
- let(:subresource) { subresource_class.new('blah') }
+ let(:subresource) { subresource_class.new("blah") }
it "The default is inherited" do
expect(subresource.x).to eq 10
end
end
end
- with_property ':x, default: 10, identity: true' do
+ with_property ":x, default: 10, identity: true" do
it "when x is not set, it is included in identity" do
expect(resource.identity).to eq(10)
end
end
- with_property ':x, default: 1, identity: true', ':y, default: 2, identity: true' do
+ with_property ":x, default: 1, identity: true", ":y, default: 2, identity: true" do
it "when x is not set, it is still included in identity" do
resource.y 20
expect(resource.identity).to eq(x: 1, y: 20)
end
end
- with_property ':x, default: nil' do
+ with_property ":x, default: nil" do
it "when x is not set, it returns nil" do
expect(resource.x).to be_nil
end
end
- with_property ':x' do
+ with_property ":x" do
it "when x is not set, it returns nil" do
expect(resource.x).to be_nil
end
@@ -515,7 +515,7 @@ describe "Chef::Resource.property" do
context "(deprecations allowed)" do
before { Chef::Config[:treat_deprecation_warnings_as_errors] = false }
- with_property ':x, default: {}' do
+ with_property ":x, default: {}" do
it "when x is not set, it returns {}" do
expect(resource.x).to eq({})
end
@@ -525,12 +525,12 @@ describe "Chef::Resource.property" do
expect(resource.x.object_id).to eq(value.object_id)
end
it "Multiple instances of x receive the exact same value" do
- expect(resource.x.object_id).to eq(resource_class.new('blah2').x.object_id)
+ expect(resource.x.object_id).to eq(resource_class.new("blah2").x.object_id)
end
end
end
- with_property ':x, default: lazy { {} }' do
+ with_property ":x, default: lazy { {} }" do
it "when x is not set, it returns {}" do
expect(resource.x).to eq({})
end
@@ -540,7 +540,7 @@ describe "Chef::Resource.property" do
# expect(resource.x.object_id).not_to eq(value.object_id)
# end
it "Multiple instances of x receive different values" do
- expect(resource.x.object_id).not_to eq(resource_class.new('blah2').x.object_id)
+ expect(resource.x.object_id).not_to eq(resource_class.new("blah2").x.object_id)
end
end
end
@@ -549,7 +549,7 @@ describe "Chef::Resource.property" do
before do
resource_class.class_eval do
def self.blah
- 'class'
+ "class"
end
def blah
"#{name}#{next_index}"
@@ -557,13 +557,13 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, default: lazy { blah }' do
+ with_property ":x, default: lazy { blah }" do
it "x is run in context of the instance" do
expect(resource.x).to eq "blah1"
end
it "x is run in the context of each instance it is run in" do
expect(resource.x).to eq "blah1"
- expect(resource_class.new('another').x).to eq "another2"
+ expect(resource_class.new("another").x).to eq "another2"
# expect(resource.x).to eq "blah3"
end
end
@@ -574,20 +574,20 @@ describe "Chef::Resource.property" do
end
it "x is passed the value of each instance it is run in" do
expect(resource.x).to eq "classblah1"
- expect(resource_class.new('another').x).to eq "classanother2"
+ expect(resource_class.new("another").x).to eq "classanother2"
# expect(resource.x).to eq "classblah3"
end
end
end
context "validation of defaults" do
- with_property ':x, String, default: 10' do
+ with_property ":x, String, default: 10" do
it "when the resource is created, no error is raised" do
resource
end
it "when x is set, no error is raised" do
- expect(resource.x 'hi').to eq 'hi'
- expect(resource.x).to eq 'hi'
+ expect(resource.x "hi").to eq "hi"
+ expect(resource.x).to eq "hi"
end
it "when x is retrieved, no validation error is raised" do
expect(resource.x).to eq 10
@@ -602,8 +602,8 @@ describe "Chef::Resource.property" do
resource
end
it "when x is set, no error is raised" do
- expect(resource.x 'hi').to eq 'hi'
- expect(resource.x).to eq 'hi'
+ expect(resource.x "hi").to eq "hi"
+ expect(resource.x).to eq "hi"
end
it "when x is retrieved, no validation error is raised" do
expect(resource.x).to eq 1
@@ -617,7 +617,7 @@ describe "Chef::Resource.property" do
with_property ":x, default: lazy { Namer.next_index.to_s }, is: proc { |v| Namer.next_index; true }" do
it "validation is not run at all on the default value" do
- expect(resource.x).to eq '1'
+ expect(resource.x).to eq "1"
expect(Namer.current_index).to eq 1
end
# it "validation is run each time" do
@@ -630,7 +630,7 @@ describe "Chef::Resource.property" do
with_property ":x, default: lazy { Namer.next_index.to_s.freeze }, is: proc { |v| Namer.next_index; true }" do
it "validation is not run at all on the default value" do
- expect(resource.x).to eq '1'
+ expect(resource.x).to eq "1"
expect(Namer.current_index).to eq 1
end
# it "validation is only run the first time" do
@@ -650,13 +650,13 @@ describe "Chef::Resource.property" do
expect(Namer.current_index).to eq 0
end
it "when x is set, coercion is run" do
- expect(resource.x 'hi').to eq 'hi1'
- expect(resource.x).to eq 'hi1'
+ expect(resource.x "hi").to eq "hi1"
+ expect(resource.x).to eq "hi1"
expect(Namer.current_index).to eq 1
end
it "when x is retrieved, coercion is run exactly once" do
- expect(resource.x).to eq '101'
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
end
end
@@ -668,13 +668,13 @@ describe "Chef::Resource.property" do
expect(Namer.current_index).to eq 0
end
it "when x is set, coercion is run" do
- expect(resource.x 'hi').to eq 'hi1'
- expect(resource.x).to eq 'hi1'
+ expect(resource.x "hi").to eq "hi1"
+ expect(resource.x).to eq "hi1"
expect(Namer.current_index).to eq 1
end
it "when x is retrieved, coercion is run each time" do
- expect(resource.x).to eq '101'
- expect(resource.x).to eq '102'
+ expect(resource.x).to eq "101"
+ expect(resource.x).to eq "102"
expect(Namer.current_index).to eq 2
end
end
@@ -686,13 +686,13 @@ describe "Chef::Resource.property" do
expect(Namer.current_index).to eq 0
end
it "when x is set, coercion is run" do
- expect(resource.x 'hi').to eq 'hi1'
- expect(resource.x).to eq 'hi1'
+ expect(resource.x "hi").to eq "hi1"
+ expect(resource.x).to eq "hi1"
expect(Namer.current_index).to eq 1
end
it "when x is retrieved, coercion is run exactly once" do
- expect(resource.x).to eq '101'
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
end
end
@@ -704,13 +704,13 @@ describe "Chef::Resource.property" do
expect(Namer.current_index).to eq 0
end
it "when x is set, coercion is run" do
- expect(resource.x 'hi').to eq 'hi1'
- expect(resource.x).to eq 'hi1'
+ expect(resource.x "hi").to eq "hi1"
+ expect(resource.x).to eq "hi1"
expect(Namer.current_index).to eq 1
end
it "when x is retrieved, coercion is run each time" do
- expect(resource.x).to eq '101'
- expect(resource.x).to eq '102'
+ expect(resource.x).to eq "101"
+ expect(resource.x).to eq "102"
expect(Namer.current_index).to eq 2
end
end
@@ -718,9 +718,9 @@ describe "Chef::Resource.property" do
with_property ':x, proc { |v| Namer.next_index; true }, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
it "coercion is only run the first time x is retrieved, and validation is not run" do
expect(Namer.current_index).to eq 0
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
end
end
@@ -728,12 +728,12 @@ describe "Chef::Resource.property" do
context "validation and coercion of defaults" do
with_property ':x, String, coerce: proc { |v| "#{v}#{next_index}" }, default: 10' do
it "when x is retrieved, it is coerced before validating and passes" do
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
end
end
with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: 10' do
it "when x is retrieved, it is coerced and not validated" do
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
end
# it "when x is retrieved, it is coerced before validating and fails" do
# expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
@@ -741,12 +741,12 @@ describe "Chef::Resource.property" do
end
with_property ':x, String, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
it "when x is retrieved, it is coerced before validating and passes" do
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
end
end
with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
it "when x is retrieved, it is coerced and not validated" do
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
end
# it "when x is retrieved, it is coerced before validating and fails" do
# expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
@@ -755,9 +755,9 @@ describe "Chef::Resource.property" do
with_property ':x, proc { |v| Namer.next_index; true }, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
it "coercion is only run the first time x is retrieved, and validation is not run" do
expect(Namer.current_index).to eq 0
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
- expect(resource.x).to eq '101'
+ expect(resource.x).to eq "101"
expect(Namer.current_index).to eq 1
end
end
@@ -766,7 +766,7 @@ describe "Chef::Resource.property" do
end
context "Chef::Resource#lazy" do
- with_property ':x' do
+ with_property ":x" do
it "setting x to a lazy value does not run it immediately" do
resource.x lazy { Namer.next_index }
expect(Namer.current_index).to eq 0
@@ -861,7 +861,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, String' do
+ with_property ":x, String" do
it "lazy values are not validated on set" do
resource.x lazy { Namer.next_index }
expect(Namer.current_index).to eq 0
@@ -873,7 +873,7 @@ describe "Chef::Resource.property" do
end
end
- with_property ':x, is: proc { |v| Namer.next_index; true }' do
+ with_property ":x, is: proc { |v| Namer.next_index; true }" do
it "lazy values are validated on each access" do
resource.x lazy { Namer.next_index }
expect(resource.x).to eq 1
@@ -936,7 +936,7 @@ describe "Chef::Resource.property" do
expect(Namer.current_index).to eq 2
end
end
- with_property ':x, coerce: proc { |x| x }' do
+ with_property ":x, coerce: proc { |x| x }" do
it "does not emit a deprecation warning if set to nil" do
expect(resource.x nil).to be_nil
end
@@ -946,19 +946,19 @@ describe "Chef::Resource.property" do
resource.x 20
expect(resource.x).to eq 20
expect(Namer.current_index).to eq 2
- expect { resource.x 10 }.to raise_error 'hi'
+ expect { resource.x 10 }.to raise_error "hi"
expect(resource.x).to eq 20
expect(Namer.current_index).to eq 3
end
it "validation does not run if coercion fails" do
- expect { resource.x 10 }.to raise_error 'hi'
+ expect { resource.x 10 }.to raise_error "hi"
expect(Namer.current_index).to eq 1
end
end
end
context "Chef::Resource::Property validation" do
- with_property ':x, is: proc { |v| Namer.next_index; v.is_a?(Integer) }' do
+ with_property ":x, is: proc { |v| Namer.next_index; v.is_a?(Integer) }" do
it "validation runs on set" do
expect(resource.x 10).to eq 10
expect(Namer.current_index).to eq 1
@@ -977,31 +977,31 @@ describe "Chef::Resource.property" do
it "failed validation fails to set the value" do
expect(resource.x 10).to eq 10
expect(Namer.current_index).to eq 1
- expect { resource.x 'blah' }.to raise_error Chef::Exceptions::ValidationFailed
+ expect { resource.x "blah" }.to raise_error Chef::Exceptions::ValidationFailed
expect(resource.x).to eq 10
expect(Namer.current_index).to eq 2
end
end
end
- [ 'name_attribute', 'name_property' ].each do |name|
+ [ "name_attribute", "name_property" ].each do |name|
context "Chef::Resource::Property##{name}" do
with_property ":x, #{name}: true" do
it "defaults x to resource.name" do
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
end
it "does not pick up resource.name if set" do
expect(resource.x 10).to eq 10
expect(resource.x).to eq 10
end
it "binds to the latest resource.name when run" do
- resource.name 'foo'
- expect(resource.x).to eq 'foo'
+ resource.name "foo"
+ expect(resource.x).to eq "foo"
end
it "caches resource.name" do
- expect(resource.x).to eq 'blah'
- resource.name 'foo'
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
+ resource.name "foo"
+ expect(resource.x).to eq "blah"
end
end
@@ -1045,17 +1045,17 @@ describe "Chef::Resource.property" do
end
with_property ":x, default: nil, #{name}: true" do
it "chooses #{name} over default" do
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
end
end
with_property ":x, #{name}: true, default: 10" do
it "chooses #{name} over default" do
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
end
end
with_property ":x, #{name}: true, default: nil" do
it "chooses #{name} over default" do
- expect(resource.x).to eq 'blah'
+ expect(resource.x).to eq "blah"
end
end
end
@@ -1117,7 +1117,7 @@ describe "Chef::Resource.property" do
end
end
let(:subresource) do
- subresource_class.new('blah')
+ subresource_class.new("blah")
end
context "with property :x, default: 10 on the subclass" do
diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb
index 386e5a1d17..58dc4649c4 100644
--- a/spec/unit/provider/breakpoint_spec.rb
+++ b/spec/unit/provider/breakpoint_spec.rb
@@ -17,7 +17,7 @@
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Breakpoint do
before do
diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb
index 6946966153..8c66f3fcc4 100644
--- a/spec/unit/provider/cookbook_file/content_spec.rb
+++ b/spec/unit/provider/cookbook_file/content_spec.rb
@@ -16,24 +16,24 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::CookbookFile::Content do
- let(:new_resource) { double('Chef::Resource::CookbookFile (new)', :cookbook_name => 'apache2', :cookbook => 'apache2') }
+ let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") }
let(:content) do
- @run_context = double('Chef::RunContext')
- @current_resource = double('Chef::Resource::CookbookFile (current)')
+ @run_context = double("Chef::RunContext")
+ @current_resource = double("Chef::Resource::CookbookFile (current)")
Chef::Provider::CookbookFile::Content.new(new_resource, @current_resource, @run_context)
end
it "prefers the explicit cookbook name on the resource to the implicit one" do
- allow(new_resource).to receive(:cookbook).and_return('nginx')
- expect(content.send(:resource_cookbook)).to eq('nginx')
+ allow(new_resource).to receive(:cookbook).and_return("nginx")
+ expect(content.send(:resource_cookbook)).to eq("nginx")
end
it "falls back to the implicit cookbook name on the resource" do
- expect(content.send(:resource_cookbook)).to eq('apache2')
+ expect(content.send(:resource_cookbook)).to eq("apache2")
end
end
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index a7cbba97cb..bc52cf2f00 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -17,15 +17,15 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
-require 'support/shared/unit/provider/file'
+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(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
}
@@ -44,12 +44,12 @@ describe Chef::Provider::CookbookFile do
let(:resource) do
resource = Chef::Resource::CookbookFile.new("seattle", @run_context)
resource.path(resource_path)
- resource.cookbook_name = 'apache2'
+ resource.cookbook_name = "apache2"
resource
end
let(:content) do
- content = double('Chef::Provider::CookbookFile::Content')
+ content = double("Chef::Provider::CookbookFile::Content")
end
it_behaves_like Chef::Provider::File
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index 3d7a5675fc..615ae608f2 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Cron::Unix do
@@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do
end
end
- let(:status) { double('Process::Status', :exitstatus => exitstatus) }
+ let(:status) { double("Process::Status", :exitstatus => exitstatus) }
let(:exitstatus) { 0 }
- let(:shell_out) { double('Mixlib::ShellOut', :status => status, :stdout => stdout, :stderr => stderr) }
+ let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) }
it "is a Chef::Provider:Cron" do
expect(provider).to be_a(Chef::Provider::Cron)
@@ -61,12 +61,12 @@ describe Chef::Provider::Cron::Unix do
before do
allow(Chef::Log).to receive(:debug)
allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
- allow(provider).to receive(:shell_out).with('/usr/bin/crontab -l', :user => username).and_return(shell_out)
+ allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out)
end
it "should call crontab -l with the user" do
provider.send(:read_crontab)
- expect(provider).to have_received(:shell_out).with('/usr/bin/crontab -l', :user => username)
+ expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username)
end
it "should return the contents of the crontab" do
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 7a917a4f27..cf9680775c 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Cron do
describe "when with special time string" do
@@ -56,7 +56,7 @@ CRONTAB
it "should pull the details out of the cron line" do
cron = @provider.load_current_resource
expect(cron.time).to eq(:reboot)
- expect(cron.command).to eq('/bin/true param1 param2')
+ expect(cron.command).to eq("/bin/true param1 param2")
end
it "should pull env vars out" do
@@ -75,12 +75,12 @@ HOME=/home/foo
# Another comment
CRONTAB
cron = @provider.load_current_resource
- expect(cron.mailto).to eq('foo@example.com')
- expect(cron.shell).to eq('/bin/foosh')
- expect(cron.path).to eq('/bin:/foo')
- expect(cron.home).to eq('/home/foo')
+ expect(cron.mailto).to eq("foo@example.com")
+ expect(cron.shell).to eq("/bin/foosh")
+ expect(cron.path).to eq("/bin:/foo")
+ expect(cron.home).to eq("/home/foo")
expect(cron.time).to eq(:reboot)
- expect(cron.command).to eq('/bin/true param1 param2')
+ expect(cron.command).to eq("/bin/true param1 param2")
end
it "should parse and load generic and standard environment variables from cron entry" do
@@ -227,13 +227,13 @@ CRONTAB
it "should pull the details out of the cron line" do
cron = @provider.load_current_resource
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('5')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('1')
- expect(cron.weekday).to eq('*')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("5")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("1")
+ expect(cron.weekday).to eq("*")
expect(cron.time).to eq(nil)
- expect(cron.command).to eq('/bin/true param1 param2')
+ expect(cron.command).to eq("/bin/true param1 param2")
end
it "should pull env vars out" do
@@ -252,17 +252,17 @@ HOME=/home/foo
# Another comment
CRONTAB
cron = @provider.load_current_resource
- expect(cron.mailto).to eq('foo@example.com')
- expect(cron.shell).to eq('/bin/foosh')
- expect(cron.path).to eq('/bin:/foo')
- expect(cron.home).to eq('/home/foo')
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('5')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('1')
- expect(cron.weekday).to eq('*')
+ expect(cron.mailto).to eq("foo@example.com")
+ expect(cron.shell).to eq("/bin/foosh")
+ expect(cron.path).to eq("/bin:/foo")
+ expect(cron.home).to eq("/home/foo")
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("5")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("1")
+ expect(cron.weekday).to eq("*")
expect(cron.time).to eq(nil)
- expect(cron.command).to eq('/bin/true param1 param2')
+ expect(cron.command).to eq("/bin/true param1 param2")
end
it "should parse and load generic and standard environment variables from cron entry" do
@@ -290,8 +290,8 @@ ENVIRONMENT=production
CRONTAB
cron = @provider.load_current_resource
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('5')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("5")
expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
end
@@ -323,12 +323,12 @@ CRONTAB
it "should pull the details out of the cron line" do
cron = @provider.load_current_resource
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('5')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('Jan')
- expect(cron.weekday).to eq('Mon')
- expect(cron.command).to eq('/bin/true param1 param2')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("5")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("Jan")
+ expect(cron.weekday).to eq("Mon")
+ expect(cron.command).to eq("/bin/true param1 param2")
end
it "should report the match" do
@@ -346,11 +346,11 @@ CRONTAB
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('*')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('*')
- expect(cron.weekday).to eq('*')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("*")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("*")
+ expect(cron.weekday).to eq("*")
expect(cron.time).to eq(nil)
expect(cron.command).to eq(nil)
end
@@ -364,11 +364,11 @@ CRONTAB
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('*')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('*')
- expect(cron.weekday).to eq('*')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("*")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("*")
+ expect(cron.weekday).to eq("*")
expect(cron.time).to eq(nil)
expect(cron.command).to eq(nil)
end
@@ -386,11 +386,11 @@ CRONTAB
CRONTAB
cron = @provider.load_current_resource
expect(@provider.cron_exists).to eq(true)
- expect(cron.minute).to eq('*')
- expect(cron.hour).to eq('*')
- expect(cron.day).to eq('*')
- expect(cron.month).to eq('*')
- expect(cron.weekday).to eq('*')
+ expect(cron.minute).to eq("*")
+ expect(cron.hour).to eq("*")
+ expect(cron.day).to eq("*")
+ expect(cron.month).to eq("*")
+ expect(cron.weekday).to eq("*")
expect(cron.time).to eq(nil)
expect(cron.command).to eq(nil)
end
@@ -455,10 +455,10 @@ CRONTAB
end
it "should include env variables that are set" do
- @new_resource.mailto 'foo@example.com'
- @new_resource.path '/usr/bin:/my/custom/path'
- @new_resource.shell '/bin/foosh'
- @new_resource.home '/home/foo'
+ @new_resource.mailto "foo@example.com"
+ @new_resource.path "/usr/bin:/my/custom/path"
+ @new_resource.shell "/bin/foosh"
+ @new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
# Chef Name: cronhole some stuff
@@ -511,10 +511,10 @@ TEST=LOL
end
it "should include env variables that are set" do
- @new_resource.mailto 'foo@example.com'
- @new_resource.path '/usr/bin:/my/custom/path'
- @new_resource.shell '/bin/foosh'
- @new_resource.home '/home/foo'
+ @new_resource.mailto "foo@example.com"
+ @new_resource.path "/usr/bin:/my/custom/path"
+ @new_resource.shell "/bin/foosh"
+ @new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
0 2 * * * /some/other/command
@@ -576,10 +576,10 @@ TEST=LOL
end
it "should include env variables that are set" do
- @new_resource.mailto 'foo@example.com'
- @new_resource.path '/usr/bin:/my/custom/path'
- @new_resource.shell '/bin/foosh'
- @new_resource.home '/home/foo'
+ @new_resource.mailto "foo@example.com"
+ @new_resource.path "/usr/bin:/my/custom/path"
+ @new_resource.shell "/bin/foosh"
+ @new_resource.home "/home/foo"
@new_resource.environment "TEST" => "LOL"
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
0 2 * * * /some/other/command
@@ -671,10 +671,10 @@ HOME=/home/foo
# Another comment
CRONTAB
- @new_resource.mailto 'foo@example.com'
- @new_resource.path '/usr/bin:/my/custom/path'
- @new_resource.shell '/bin/foosh'
- @new_resource.home '/home/foo'
+ @new_resource.mailto "foo@example.com"
+ @new_resource.path "/usr/bin:/my/custom/path"
+ @new_resource.shell "/bin/foosh"
+ @new_resource.home "/home/foo"
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
0 2 * * * /some/other/command
diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb
index caa60878e1..1b77c472e0 100644
--- a/spec/unit/provider/deploy/revision_spec.rb
+++ b/spec/unit/provider/deploy/revision_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Deploy::Revision do
diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb
index b189d33502..b665ac3101 100644
--- a/spec/unit/provider/deploy/timestamped_spec.rb
+++ b/spec/unit/provider/deploy/timestamped_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Deploy::Timestamped do
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index adcb9431eb..a7f7375752 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Deploy do
@@ -163,9 +163,9 @@ describe Chef::Provider::Deploy do
end
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(:all_releases).and_return(["previous_release"])
allow(@provider).to receive(:deploy){ raise "Unexpected error" }
- allow(@provider).to receive(:previous_release_path).and_return('previous_release')
+ allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).not_to receive(:rollback)
expect {
@provider.run_action(:deploy)
@@ -174,9 +174,9 @@ 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(:all_releases).and_return(["previous_release"])
allow(@provider).to receive(:deploy){ raise "Unexpected error" }
- allow(@provider).to receive(:previous_release_path).and_return('previous_release')
+ allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).to receive(:rollback)
expect {
@provider.run_action(:deploy)
@@ -552,7 +552,7 @@ describe Chef::Provider::Deploy do
expect(@provider).to receive(:execute).with("iGoToHell4this").and_return(mock_execution)
@resource.user("notCoolMan")
@resource.group("Ggroup")
- @resource.environment("APP_ENV" => 'staging')
+ @resource.environment("APP_ENV" => "staging")
@resource.deploy_to("/my/app")
expect(mock_execution).to receive(:user).with("notCoolMan")
expect(mock_execution).to receive(:group).with("Ggroup")
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb
index 4fad8c8906..6157c6c200 100644
--- a/spec/unit/provider/directory_spec.rb
+++ b/spec/unit/provider/directory_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tmpdir'
+require "spec_helper"
+require "tmpdir"
describe Chef::Provider::Directory do
let(:tmp_dir) { Dir.mktmpdir }
@@ -200,14 +200,14 @@ describe Chef::Provider::Directory do
describe "on OS X" do
before do
- allow(node).to receive(:[]).with("platform").and_return('mac_os_x')
+ allow(node).to receive(:[]).with("platform").and_return("mac_os_x")
new_resource.path "/usr/bin/chef_test"
new_resource.recursive false
allow_any_instance_of(Chef::Provider::File).to receive(:do_selinux)
end
it "os x 10.10 can write to sip locations" do
- allow(node).to receive(:[]).with("platform_version").and_return('10.10')
+ allow(node).to receive(:[]).with("platform_version").and_return("10.10")
allow(Dir).to receive(:mkdir).and_return([true], [])
allow(::File).to receive(:directory?).and_return(true)
allow(Chef::FileAccessControl).to receive(:writable?).and_return(true)
@@ -216,7 +216,7 @@ describe Chef::Provider::Directory do
end
it "os x 10.11 cannot write to sip locations" do
- allow(node).to receive(:[]).with("platform_version").and_return('10.11')
+ 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)
@@ -224,7 +224,7 @@ describe Chef::Provider::Directory do
it "os x 10.11 can write to sip exlcusions" do
new_resource.path "/usr/local/chef_test"
- allow(node).to receive(:[]).with("platform_version").and_return('10.11')
+ allow(node).to receive(:[]).with("platform_version").and_return("10.11")
allow(::File).to receive(:directory?).and_return(true)
allow(Dir).to receive(:mkdir).and_return([true], [])
allow(Chef::FileAccessControl).to receive(:writable?).and_return(false)
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 46cdbd93a6..afa8ce3975 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -16,8 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'chef'
-require 'spec_helper'
+require "chef"
+require "spec_helper"
describe Chef::Provider::DscResource do
let (:events) { Chef::EventDispatch::Dispatcher.new }
@@ -27,41 +27,41 @@ describe Chef::Provider::DscResource do
Chef::Provider::DscResource.new(resource, run_context)
end
- context 'when Powershell does not support Invoke-DscResource' do
+ context "when Powershell does not support Invoke-DscResource" do
let (:node) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '4.0'
+ node.automatic[:languages][:powershell][:version] = "4.0"
node
}
- it 'raises a ProviderNotFound exception' do
+ it "raises a ProviderNotFound exception" do
expect(provider).not_to receive(:meta_configuration)
expect{provider.run_action(:run)}.to raise_error(
Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/)
end
end
- context 'when Powershell supports Invoke-DscResource' do
+ context "when Powershell supports Invoke-DscResource" do
- context 'when RefreshMode is not set to Disabled' do
- context 'and the WMF 5 is a preview release' do
+ context "when RefreshMode is not set to Disabled" do
+ context "and the WMF 5 is a preview release" do
let (:node) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
+ node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
}
- it 'raises an exception' do
+ it "raises an exception" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
expect { provider.run_action(:run) }.to raise_error(
Chef::Exceptions::ProviderNotFound, /Disabled/)
end
end
- context 'and the WMF is 5 RTM or newer' do
+ context "and the WMF is 5 RTM or newer" do
let (:node) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '5.0.10586.0'
+ node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
node
}
- it 'does not raises an exception' do
+ it "does not raises an exception" do
expect(provider).to receive(:test_resource)
expect(provider).to receive(:set_resource)
expect(provider).to receive(:reboot_if_required)
@@ -71,21 +71,21 @@ describe Chef::Provider::DscResource do
end
end
- context 'when the LCM supports Invoke-DscResource' do
+ context "when the LCM supports Invoke-DscResource" do
let (:node) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
+ node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
}
- it 'does not update the resource if it is up to date' do
+ it "does not update the resource if it is up to date" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
expect(provider).to receive(:test_resource).and_return(true)
provider.run_action(:run)
expect(resource).not_to be_updated
end
- it 'converges the resource if it is not up to date' do
+ it "converges the resource if it is not up to date" 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(:set_resource)
@@ -93,21 +93,21 @@ describe Chef::Provider::DscResource do
expect(resource).to be_updated
end
- it 'flags the resource as reboot required when required' do
+ 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(: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
+ 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(:return_dsc_resource_result).and_return(false)
expect(provider).to_not receive(:create_reboot_resource)
provider.run_action(:run)
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index 76589e71c1..ebde817010 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -17,15 +17,15 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/dsc/resource_info'
-require 'spec_helper'
+require "chef"
+require "chef/util/dsc/resource_info"
+require "spec_helper"
describe Chef::Provider::DscScript do
- context 'when DSC is available' do
+ context "when DSC is available" do
let (:node) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '4.0'
+ node.automatic[:languages][:powershell][:version] = "4.0"
node
}
let (:events) { Chef::EventDispatch::Dispatcher.new }
@@ -39,75 +39,75 @@ describe Chef::Provider::DscScript do
it "describes the resource as converged if there were 0 DSC resources" do
allow(provider).to receive(:run_configuration).with(:test).and_return([])
provider.load_current_resource
- expect(provider.instance_variable_get('@resource_converged')).to be_truthy
+ expect(provider.instance_variable_get("@resource_converged")).to be_truthy
end
it "describes the resource as not converged if there is 1 DSC resources that is converged" do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
provider.load_current_resource
- expect(provider.instance_variable_get('@resource_converged')).to be_truthy
+ expect(provider.instance_variable_get("@resource_converged")).to be_truthy
end
it "describes the resource as not converged if there is 1 DSC resources that is not converged" do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
provider.load_current_resource
- expect(provider.instance_variable_get('@resource_converged')).to be_falsey
+ expect(provider.instance_variable_get("@resource_converged")).to be_falsey
end
it "describes the resource as not converged if there are any DSC resources that are not converged" do
- dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
- dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
+ dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"])
+ dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
provider.load_current_resource
- expect(provider.instance_variable_get('@resource_converged')).to be_falsey
+ expect(provider.instance_variable_get("@resource_converged")).to be_falsey
end
it "describes the resource as converged if all DSC resources that are converged" do
- dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
- dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
+ dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
+ dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
provider.load_current_resource
- expect(provider.instance_variable_get('@resource_converged')).to be_truthy
+ expect(provider.instance_variable_get("@resource_converged")).to be_truthy
end
end
describe '#generate_configuration_document' do
# I think integration tests should cover these cases
- it 'uses configuration_document_from_script_path when a dsc script file is given' do
+ it "uses configuration_document_from_script_path when a dsc script file is given" do
allow(provider).to receive(:load_current_resource)
resource.command("path_to_script")
- generator = double('Chef::Util::DSC::ConfigurationGenerator')
+ generator = double("Chef::Util::DSC::ConfigurationGenerator")
expect(generator).to receive(:configuration_document_from_script_path)
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
- provider.send(:generate_configuration_document, 'tmp', nil)
+ provider.send(:generate_configuration_document, "tmp", nil)
end
- it 'uses configuration_document_from_script_code when a the dsc resource is given' do
+ it "uses configuration_document_from_script_code when a the dsc resource is given" do
allow(provider).to receive(:load_current_resource)
resource.code("ImADSCResource{}")
- generator = double('Chef::Util::DSC::ConfigurationGenerator')
+ generator = double("Chef::Util::DSC::ConfigurationGenerator")
expect(generator).to receive(:configuration_document_from_script_code)
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
- provider.send(:generate_configuration_document, 'tmp', nil)
+ provider.send(:generate_configuration_document, "tmp", nil)
end
- it 'should noop if neither code or command are provided' do
+ it "should noop if neither code or command are provided" do
allow(provider).to receive(:load_current_resource)
- generator = double('Chef::Util::DSC::ConfigurationGenerator')
- expect(generator).to receive(:configuration_document_from_script_code).with('', anything(), anything(), anything())
+ generator = double("Chef::Util::DSC::ConfigurationGenerator")
+ expect(generator).to receive(:configuration_document_from_script_code).with("", anything(), anything(), anything())
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
- provider.send(:generate_configuration_document, 'tmp', nil)
+ provider.send(:generate_configuration_document, "tmp", nil)
end
end
- describe 'action_run' do
- it 'should converge the script if it is not converged' do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
+ describe "action_run" do
+ it "should converge the script if it is not converged" do
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"])
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
allow(provider).to receive(:run_configuration).with(:set)
@@ -115,7 +115,7 @@ describe Chef::Provider::DscScript do
expect(resource).to be_updated
end
- it 'should not converge if the script is already converged' 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)
@@ -124,35 +124,35 @@ describe Chef::Provider::DscScript do
end
describe '#generate_description' do
- it 'removes the resource name from the beginning of any log line from the LCM' do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline'])
- provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
+ it "removes the resource name from the beginning of any log line from the LCM" do
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
+ provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/)
end
- it 'ignores the last line' do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline'])
- provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
+ it "ignores the last line" do
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"])
+ provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
expect(provider.send(:generate_description)[1]).not_to match(/lastline/)
end
- it 'reports a dsc resource has not been changed if the LCM reported no change was required' do
- dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', false, ['resourcename does nothing', 'lastline'])
- provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
+ it "reports a dsc resource has not been changed if the LCM reported no change was required" do
+ dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"])
+ provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info])
expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/)
end
end
end
- context 'when Dsc is not available' do
+ context "when Dsc is not available" do
let (:node) { Chef::Node.new }
let (:events) { Chef::EventDispatch::Dispatcher.new }
let (:run_context) { Chef::RunContext.new(node, {}, events) }
- let (:resource) { Chef::Resource::DscScript.new('script', run_context) }
+ let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
let (:provider) { Chef::Provider::DscScript.new(resource, run_context) }
- describe 'action_run' do
- ['1.0', '2.0', '3.0'].each do |version|
+ describe "action_run" do
+ ["1.0", "2.0", "3.0"].each do |version|
it "raises an exception for powershell version '#{version}'" do
node.automatic[:languages][:powershell][:version] = version
@@ -162,7 +162,7 @@ describe Chef::Provider::DscScript do
end
end
- it 'raises an exception if Powershell is not present' do
+ it "raises an exception if Powershell is not present" do
expect {
provider.run_action(:run)
}.to raise_error(Chef::Exceptions::ProviderNotFound)
diff --git a/spec/unit/provider/env/windows_spec.rb b/spec/unit/provider/env/windows_spec.rb
index 99f33d392a..b72e41884f 100644
--- a/spec/unit/provider/env/windows_spec.rb
+++ b/spec/unit/provider/env/windows_spec.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Env::Windows, :windows_only do
let(:node) { Chef::Node.new }
let(:events) {Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
- context 'when environment variable is not PATH' do
+ context "when environment variable is not PATH" do
let(:new_resource) {
new_resource = Chef::Resource::Env.new("CHEF_WINDOWS_ENV_TEST")
new_resource.value("foo")
@@ -31,71 +31,71 @@ describe Chef::Provider::Env::Windows, :windows_only do
}
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)
+ allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object)
provider
}
describe "action_create" do
before do
- ENV.delete('CHEF_WINDOWS_ENV_TEST')
+ ENV.delete("CHEF_WINDOWS_ENV_TEST")
provider.key_exists = false
end
it "should update the ruby ENV object when it creates the key" do
provider.action_create
- expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql('foo')
+ expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql("foo")
end
end
describe "action_modify" do
before do
- ENV['CHEF_WINDOWS_ENV_TEST'] = 'foo'
+ ENV["CHEF_WINDOWS_ENV_TEST"] = "foo"
end
it "should update the ruby ENV object when it updates the value" do
expect(provider).to receive(:requires_modify_or_create?).and_return(true)
new_resource.value("foobar")
provider.action_modify
- expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql('foobar')
+ expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql("foobar")
end
describe "action_delete" do
before do
- ENV['CHEF_WINDOWS_ENV_TEST'] = 'foo'
+ ENV["CHEF_WINDOWS_ENV_TEST"] = "foo"
end
it "should update the ruby ENV object when it deletes the key" do
provider.action_delete
- expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql(nil)
+ expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql(nil)
end
end
end
end
- context 'when environment is PATH' 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 = Chef::Resource::Env.new("PATH")
new_resource.value(system_root)
new_resource
}
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)
+ 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
expect(provider).to receive(:requires_modify_or_create?).and_return(true)
expect(provider).to receive(:expand_path).with(system_root).and_return(system_root_value)
provider.action_modify
- expect(ENV['PATH']).to eql(system_root_value)
+ expect(ENV["PATH"]).to eql(system_root_value)
end
end
diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb
index 230603dcb3..f0e74f347f 100644
--- a/spec/unit/provider/env_spec.rb
+++ b/spec/unit/provider/env_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Env do
diff --git a/spec/unit/provider/erl_call_spec.rb b/spec/unit/provider/erl_call_spec.rb
index 2fb7e5b737..6526de0087 100644
--- a/spec/unit/provider/erl_call_spec.rb
+++ b/spec/unit/provider/erl_call_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::ErlCall do
before(:each) do
@@ -33,7 +33,7 @@ describe Chef::Provider::ErlCall do
allow(@provider).to receive(:popen4).and_return(@status)
@stdin = StringIO.new
- @stdout = StringIO.new('{ok, woohoo}')
+ @stdout = StringIO.new("{ok, woohoo}")
@stderr = StringIO.new
@pid = 2342999
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 8a55025d9e..c656607ca7 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Execute do
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index 0a45d15bc9..7271772e2c 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::File::Content do
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index 504ae045d9..4e8b4507ba 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'support/shared/unit/provider/file'
+require "support/shared/unit/provider/file"
describe Chef::Provider::File do
@@ -29,12 +29,12 @@ describe Chef::Provider::File do
end
let(:content) do
- content = double('Chef::Provider::File::Content')
+ content = double("Chef::Provider::File::Content")
end
- let(:node) { double('Chef::Node') }
- let(:events) { double('Chef::Events').as_null_object } # mock all the methods
- let(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
}
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 41536a450f..4ec0439092 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -17,7 +17,7 @@
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Git do
before(:each) do
@@ -59,7 +59,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 +67,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
@@ -206,7 +206,7 @@ d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8
b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
SHAS
- @resource.revision ''
+ @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.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
end
@@ -284,8 +284,8 @@ SHAS
it "compiles a clone command using --depth for shallow cloning" do
@resource.depth 5
expected_cmd = "git clone --depth 5 \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
- version_response = double('shell_out')
- allow(version_response).to receive(:stdout) { 'git version 1.7.9' }
+ version_response = double("shell_out")
+ allow(version_response).to receive(:stdout) { "git version 1.7.9" }
expect(@provider).to receive(:shell_out!).with("git --version",
:log_tag => "git[web2.0 app]").and_return(version_response)
expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
@@ -295,8 +295,8 @@ SHAS
it "compiles a clone command using --no-single-branch for shallow cloning when git >= 1.7.10" do
@resource.depth 5
expected_cmd = "git clone --depth 5 --no-single-branch \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\""
- version_response = double('shell_out')
- allow(version_response).to receive(:stdout) { 'git version 1.7.10' }
+ version_response = double("shell_out")
+ allow(version_response).to receive(:stdout) { "git version 1.7.10" }
expect(@provider).to receive(:shell_out!).with("git --version",
:log_tag => "git[web2.0 app]").and_return(version_response)
expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]")
@@ -311,9 +311,9 @@ SHAS
end
it "runs a checkout command with default options" do
- expect(@provider).to receive(:shell_out!).with('git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c', :cwd => "/my/deploy/dir",
+ expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]").ordered
- expect(@provider).to receive(:shell_out!).with('git checkout deploy', :cwd => "/my/deploy/dir",
+ expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir",
:log_tag => "git[web2.0 app]").ordered
@provider.checkout
end
@@ -372,7 +372,7 @@ SHAS
context "configuring remote tracking branches" do
it "checks if a remote with this name already exists" do
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
@@ -390,7 +390,7 @@ SHAS
@resource.user("whois")
@resource.group("thisis")
allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois"))
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 1 }
expected_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(expected_command,
@@ -412,7 +412,7 @@ SHAS
describe "when a remote with a given name hasn't been configured yet" do
it "adds a new remote " do
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 1 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
@@ -429,7 +429,7 @@ SHAS
describe "when a remote with a given name has already been configured" do
it "updates remote url when the url is different" do
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
allow(command_response).to receive(:stdout) { "some_other_url" }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
@@ -445,7 +445,7 @@ SHAS
end
it "doesn't update remote url when the url is the same" do
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
allow(command_response).to receive(:stdout) { @resource.repository }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
@@ -461,7 +461,7 @@ SHAS
end
it "resets remote url when it has multiple values" do
- command_response = double('shell_out')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 2 }
check_remote_command = "git config --get remote.#{@resource.remote}.url"
expect(@provider).to receive(:shell_out!).with(check_remote_command,
@@ -488,7 +488,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 +504,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 +519,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 +534,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)
@@ -546,7 +546,7 @@ SHAS
it "syncs the code by updating the source when the repo has already been checked out" do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- expect(@provider).to receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ expect(@provider).to receive(:find_current_revision).exactly(1).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c")
expect(@provider).not_to receive(:fetch_updates)
expect(@provider).to receive(:add_remotes)
@provider.run_action(:sync)
@@ -557,8 +557,8 @@ SHAS
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
# invoked twice - first time from load_current_resource
- expect(@provider).to receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
- allow(@provider).to receive(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a')
+ expect(@provider).to receive(:find_current_revision).exactly(1).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c")
+ allow(@provider).to receive(:target_revision).and_return("28af684d8460ba4793eda3e7ac238c864a5d029a")
expect(@provider).to receive(:fetch_updates)
expect(@provider).to receive(:enable_submodules)
expect(@provider).to receive(:add_remotes)
@@ -569,8 +569,8 @@ SHAS
it "does not fetch any updates if the remote revision matches the current revision" do
expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
- allow(@provider).to receive(:find_current_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
- allow(@provider).to receive(:target_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ allow(@provider).to receive(:find_current_revision).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c")
+ allow(@provider).to receive(:target_revision).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c")
expect(@provider).not_to receive(:fetch_updates)
expect(@provider).to receive(:add_remotes)
@provider.run_action(:sync)
@@ -609,7 +609,7 @@ SHAS
@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')
+ command_response = double("shell_out")
allow(command_response).to receive(:exitstatus) { 0 }
@resource.additional_remotes.each_pair do |remote_name, remote_url|
expect(@provider).to receive(:setup_remote_tracking_branches).with(remote_name, remote_url)
@@ -620,7 +620,7 @@ SHAS
describe "calling multiple_remotes?" do
before(:each) do
- @command_response = double('shell_out')
+ @command_response = double("shell_out")
end
describe "when check remote command returns with status 2" do
@@ -647,7 +647,7 @@ SHAS
describe "calling remote_matches?" do
before(:each) do
- @command_response = double('shell_out')
+ @command_response = double("shell_out")
end
describe "when output of the check remote command matches the repository url" do
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index d84e4e1d57..1a61fc2383 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Dscl do
before do
@@ -293,7 +293,7 @@ describe Chef::Provider::Group::Dscl do
end
end
-describe 'Test DSCL loading' do
+describe "Test DSCL loading" do
before do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@@ -320,12 +320,12 @@ EOF
end
- it 'should parse gid properly' do
+ it "should parse gid properly" do
allow(File).to receive(:exists?).and_return(true)
expect(@current_resource.gid).to eq("999")
end
- it 'should parse members properly' do
+ it "should parse members properly" do
allow(File).to receive(:exists?).and_return(true)
- expect(@current_resource.members).to eq(['waka', 'bar'])
+ expect(@current_resource.members).to eq(["waka", "bar"])
end
end
diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb
index 55d978fa7e..a24424182d 100644
--- a/spec/unit/provider/group/gpasswd_spec.rb
+++ b/spec/unit/provider/group/gpasswd_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
before do
diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb
index 47021a9af3..8cdc096c68 100644
--- a/spec/unit/provider/group/groupadd_spec.rb
+++ b/spec/unit/provider/group/groupadd_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Groupadd, "set_options" do
before do
diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb
index 496d1e28fa..a69774a309 100644
--- a/spec/unit/provider/group/groupmod_spec.rb
+++ b/spec/unit/provider/group/groupmod_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Groupmod do
before do
diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb
index 531d0a52a2..ed1f06efe0 100644
--- a/spec/unit/provider/group/pw_spec.rb
+++ b/spec/unit/provider/group/pw_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Pw do
before do
diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb
index 6c4c4d2e07..cd532f8b8d 100644
--- a/spec/unit/provider/group/usermod_spec.rb
+++ b/spec/unit/provider/group/usermod_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Group::Usermod do
before do
diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb
index 23dfa8315f..4f071f3b94 100644
--- a/spec/unit/provider/group/windows_spec.rb
+++ b/spec/unit/provider/group/windows_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef
class Util
@@ -94,7 +94,7 @@ describe Chef::Provider::Group::Windows, "NetGroup" do
@new_resource = Chef::Resource::Group.new("Creating a new group")
@new_resource.group_name "Remote Desktop Users"
end
- it 'sets group_name correctly' do
+ it "sets group_name correctly" do
expect(Chef::Util::Windows::NetGroup).to receive(:new).with("Remote Desktop Users")
Chef::Provider::Group::Windows.new(@new_resource, @run_context)
end
diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb
index 55a2f97aa5..957e7b14df 100644
--- a/spec/unit/provider/group_spec.rb
+++ b/spec/unit/provider/group_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::User do
@@ -41,7 +41,7 @@ describe Chef::Provider::User do
:gid => 20,
:mem => [ "root", "aj" ],
)
- allow(Etc).to receive(:getgrnam).with('wheel').and_return(@pw_group)
+ allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group)
end
it "assumes the group exists by default" do
@@ -52,7 +52,7 @@ describe Chef::Provider::User do
it "sets the group name of the current resource to the group name of the new resource" do
@provider.load_current_resource
- expect(@provider.current_resource.group_name).to eq('wheel')
+ expect(@provider.current_resource.group_name).to eq("wheel")
end
it "does not modify the desired gid if set" do
diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb
index 980458abd3..33c9167c33 100644
--- a/spec/unit/provider/http_request_spec.rb
+++ b/spec/unit/provider/http_request_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::HttpRequest do
before(:each) do
@@ -24,7 +24,7 @@ describe Chef::Provider::HttpRequest do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::HttpRequest.new('adam')
+ @new_resource = Chef::Resource::HttpRequest.new("adam")
@new_resource.name "adam"
@new_resource.url "http://www.opscode.com/"
@new_resource.message "is cool"
diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb
index 0b6fa33614..6213de4803 100644
--- a/spec/unit/provider/ifconfig/aix_spec.rb
+++ b/spec/unit/provider/ifconfig/aix_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/exceptions'
+require "spec_helper"
+require "chef/exceptions"
describe Chef::Provider::Ifconfig::Aix do
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index 0c02ae9cd4..b116ecf127 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/exceptions'
+require "spec_helper"
+require "chef/exceptions"
describe Chef::Provider::Ifconfig::Debian do
diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb
index 620fd341d7..bdcaa57330 100644
--- a/spec/unit/provider/ifconfig/redhat_spec.rb
+++ b/spec/unit/provider/ifconfig/redhat_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/exceptions'
+require "spec_helper"
+require "chef/exceptions"
describe Chef::Provider::Ifconfig::Redhat do
before do
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index 90109ca1c0..e4335ed3e7 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -17,8 +17,8 @@
#
#require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
-require 'spec_helper'
-require 'chef/exceptions'
+require "spec_helper"
+require "chef/exceptions"
describe Chef::Provider::Ifconfig do
before do
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 0f95ce997e..80ebc62f2a 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -17,12 +17,12 @@
# limitations under the License.
#
-require 'ostruct'
+require "ostruct"
-require 'spec_helper'
+require "spec_helper"
if Chef::Platform.windows?
- require 'chef/win32/file' #probably need this in spec_helper
+ require "chef/win32/file" #probably need this in spec_helper
end
describe Chef::Resource::Link, :not_supported_on_win2k3 do
@@ -39,7 +39,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
end
def canonicalize(path)
- Chef::Platform.windows? ? path.gsub('/', '\\') : path
+ Chef::Platform.windows? ? path.gsub("/", '\\') : path
end
describe "when the target is a symlink" do
@@ -80,13 +80,13 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
# We test create in unit tests because there is no other way to ensure
# it does no work. Other create and delete scenarios are covered in
# the functional tests for links.
- context 'when the desired state is identical' do
+ context "when the desired state is identical" do
let(:new_resource) do
result = Chef::Resource::Link.new("#{CHEF_SPEC_DATA}/fofile-link")
result.to "#{CHEF_SPEC_DATA}/fofile"
result
end
- it 'create does no work' do
+ it "create does no work" do
expect(provider.access_controls).not_to receive(:set_all)
provider.run_action(:create)
end
@@ -164,7 +164,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
expect(provider.current_resource.target_file).to eq("#{CHEF_SPEC_DATA}/fofile-link")
end
it "should update the current source of the existing link with an empty string" do
- expect(provider.current_resource.to).to eq('')
+ expect(provider.current_resource.to).to eq("")
end
it "should not set the owner" do
expect(provider.current_resource.owner).to eq(nil)
@@ -191,7 +191,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
expect(provider.current_resource.target_file).to eq("#{CHEF_SPEC_DATA}/fofile-link")
end
it "should update the current source of the existing link with an empty string" do
- expect(provider.current_resource.to).to eq('')
+ expect(provider.current_resource.to).to eq("")
end
it "should not set the owner" do
expect(provider.current_resource.owner).to eq(nil)
@@ -233,14 +233,14 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
# We test create in unit tests because there is no other way to ensure
# it does no work. Other create and delete scenarios are covered in
# the functional tests for links.
- context 'when the desired state is identical' do
+ context "when the desired state is identical" do
let(:new_resource) do
result = Chef::Resource::Link.new("#{CHEF_SPEC_DATA}/fofile-link")
result.to "#{CHEF_SPEC_DATA}/fofile"
result.link_type :hard
result
end
- it 'create does no work' do
+ it "create does no work" do
expect(provider.file_class).not_to receive(:symlink)
expect(provider.file_class).not_to receive(:link)
expect(provider.access_controls).not_to receive(:set_all)
diff --git a/spec/unit/provider/log_spec.rb b/spec/unit/provider/log_spec.rb
index 1ecc633ce1..5aadcbf7cd 100644
--- a/spec/unit/provider/log_spec.rb
+++ b/spec/unit/provider/log_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Log::ChefLog do
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 38401b7225..ec5f6237d1 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Mdadm do
@@ -25,7 +25,7 @@ describe Chef::Provider::Mdadm do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::Mdadm.new('/dev/md1')
+ @new_resource = Chef::Resource::Mdadm.new("/dev/md1")
@new_resource.devices ["/dev/sdz1","/dev/sdz2","/dev/sdz3"]
@provider = Chef::Provider::Mdadm.new(@new_resource, @run_context)
end
@@ -34,8 +34,8 @@ describe Chef::Provider::Mdadm do
it "should set the current resources mount point to the new resources mount point" do
allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
- expect(@provider.current_resource.name).to eq('/dev/md1')
- expect(@provider.current_resource.raid_device).to eq('/dev/md1')
+ expect(@provider.current_resource.name).to eq("/dev/md1")
+ expect(@provider.current_resource.raid_device).to eq("/dev/md1")
end
it "determines that the metadevice exists when mdadm exit code is zero" do
@@ -53,7 +53,7 @@ describe Chef::Provider::Mdadm do
describe "after the metadevice status is known" do
before(:each) do
- @current_resource = Chef::Resource::Mdadm.new('/dev/md1')
+ @current_resource = Chef::Resource::Mdadm.new("/dev/md1")
@new_resource.level 5
allow(@provider).to receive(:load_current_resource).and_return(true)
@provider.current_resource = @current_resource
@@ -69,7 +69,7 @@ describe Chef::Provider::Mdadm do
it "should specify a bitmap only if set" do
@current_resource.exists(false)
- @new_resource.bitmap('grow')
+ @new_resource.bitmap("grow")
expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --bitmap=grow --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3"
expect(@provider).to receive(:shell_out!).with(expected_command)
@provider.run_action(:create)
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index e232592275..1aa64967af 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Mount::Aix do
@@ -114,7 +114,7 @@ ENABLED
expect(@provider.current_resource.mounted).to be_truthy
expect(@provider.current_resource.mount_point).to eql(@new_resource.mount_point)
expect(@provider.current_resource.fstype).to eql("jfs2")
- expect(@provider.current_resource.options).to eql(['rw'])
+ expect(@provider.current_resource.options).to eql(["rw"])
end
describe "mount_fs" do
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 124d51b367..c267dc706c 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Mount::Mount do
before(:each) do
@@ -42,15 +42,15 @@ describe Chef::Provider::Mount::Mount do
describe "when discovering the current fs state" do
before do
- allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => ''))
+ allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => ""))
allow(::File).to receive(:foreach).with("/etc/fstab")
end
it "should create a current resource with the same mount point and device" do
@provider.load_current_resource
- expect(@provider.current_resource.name).to eq('/tmp/foo')
- expect(@provider.current_resource.mount_point).to eq('/tmp/foo')
- expect(@provider.current_resource.device).to eq('/dev/sdz1')
+ expect(@provider.current_resource.name).to eq("/tmp/foo")
+ expect(@provider.current_resource.mount_point).to eq("/tmp/foo")
+ expect(@provider.current_resource.device).to eq("/dev/sdz1")
end
it "should accecpt device_type :uuid", :not_supported_on_solaris do
@@ -134,7 +134,7 @@ describe Chef::Provider::Mount::Mount do
it "should set mounted true if the symlink target of the device is found in the mounts list" do
# expand the target path to correct specs on Windows
- target = ::File.expand_path('/dev/mapper/target')
+ target = ::File.expand_path("/dev/mapper/target")
allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true)
allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target)
@@ -266,7 +266,7 @@ describe Chef::Provider::Mount::Mount do
fstab = "#{@new_resource.device} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
- expect(@provider.current_resource.options).to eq(options.split(','))
+ expect(@provider.current_resource.options).to eq(options.split(","))
end
it "should not mangle the mount options if the symlink target is in fstab" do
@@ -279,7 +279,7 @@ describe Chef::Provider::Mount::Mount do
fstab = "#{target} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n"
allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab
@provider.load_current_resource
- expect(@provider.current_resource.options).to eq(options.split(','))
+ expect(@provider.current_resource.options).to eq(options.split(","))
end
end
@@ -311,7 +311,7 @@ describe Chef::Provider::Mount::Mount do
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@new_resource.device_type :uuid
allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
- @stdout_mock = double('stdout mock')
+ @stdout_mock = double("stdout mock")
allow(@stdout_mock).to receive(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}")
expect(@provider).to receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}").and_return(@stdout_mock)
@provider.mount_fs()
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 9a9b09b531..707a06ceee 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
# Do not run these tests on windows because some path handling
# code is not implemented to handle windows paths.
@@ -57,7 +57,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
}
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
@@ -84,7 +84,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
}
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t0d0s0 on / type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
/dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
@@ -215,7 +215,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when loading a normal UFS filesystem with noauto, don't mount at boot" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
@@ -245,12 +245,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the device is an smbfs mount" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
//solarsystem/tmp on /mnt type smbfs read/write/setuid/devices/dev=5080000 on Tue Mar 29 11:40:18 2011
EOF
}
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
//WORKGROUP;username:password@host/share - /mountpoint smbfs - no fileperms=0777,dirperms=0777
EOF
}
@@ -264,13 +264,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the device is an NFS mount" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
cartman:/share2 on /cartman type nfs rsize=32768,wsize=32768,NFSv4,dev=4000004 on Tue Mar 29 11:40:18 2011
EOF
}
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
cartman:/share2 - /cartman nfs - yes rw,soft
EOF
}
@@ -335,13 +335,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
let(:target) { "/dev/mapper/target" }
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#{target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
}
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#{target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
}
@@ -372,13 +372,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
let(:absolute_target) { File.expand_path(target, File.dirname(device)) }
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#{absolute_target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
}
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#{absolute_target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
}
@@ -405,7 +405,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the matching mount point is last in the mounts list" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
/dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
@@ -418,7 +418,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the matching mount point is not last in the mounts list" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
/dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012
EOF
@@ -431,7 +431,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the matching mount point is not in the mounts list (mountpoint wrong)" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 on /mnt/foob type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
}
@@ -443,7 +443,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the matching mount point is not in the mounts list (raw device wrong)" do
let(:mount_output) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s72 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012
EOF
}
@@ -455,7 +455,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mount point is last in fstab" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
@@ -469,7 +469,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mount point is not last in fstab and is a substring of another mount" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
/dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo/bar ufs 2 yes -
EOF
@@ -483,7 +483,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mount point is not last in fstab" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
/dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s72 /mnt/foo ufs 2 yes -
EOF
@@ -497,7 +497,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mount point is not in fstab, but the mountpoint is a substring of one that is" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foob ufs 2 yes -
EOF
}
@@ -510,7 +510,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mount point is not in fstab, but the device is a substring of one that is" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
}
@@ -523,7 +523,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "when the mountpoint line is commented out" do
let(:vfstab_file_contents) {
- <<-EOF.gsub /^\s*/, ''
+ <<-EOF.gsub /^\s*/, ""
#/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
}
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index 2de6f11d43..c3c1934fa0 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef
class Util
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index cc2a456440..3d36a921b3 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Mount do
@@ -28,7 +28,7 @@ describe Chef::Provider::Mount do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:new_resource) do
- new_resource = Chef::Resource::Mount.new('/tmp/foo')
+ new_resource = Chef::Resource::Mount.new("/tmp/foo")
new_resource.device "/dev/sdz1"
new_resource.name "/tmp/foo"
new_resource.mount_point "/tmp/foo"
@@ -38,7 +38,7 @@ describe Chef::Provider::Mount do
let(:current_resource) do
# this abstract superclass has no load_current_resource to call
- current_resource = Chef::Resource::Mount.new('/tmp/foo')
+ current_resource = Chef::Resource::Mount.new("/tmp/foo")
current_resource.device "/dev/sdz1"
current_resource.name "/tmp/foo"
current_resource.mount_point "/tmp/foo"
diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb
index 4072487f35..b5ce1e8fc5 100644
--- a/spec/unit/provider/ohai_spec.rb
+++ b/spec/unit/provider/ohai_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/run_context'
+require "chef/run_context"
describe Chef::Provider::Ohai do
before(:each) do
@@ -63,22 +63,22 @@ describe Chef::Provider::Ohai do
describe "when reloading ohai" do
before do
- @node.automatic_attrs[:origdata] = 'somevalue'
+ @node.automatic_attrs[:origdata] = "somevalue"
end
it "applies updated ohai data to the node" do
- expect(@node[:origdata]).to eq('somevalue')
+ expect(@node[:origdata]).to eq("somevalue")
expect(@node[:newdata]).to be_nil
@provider.run_action(:reload)
- expect(@node[:origdata]).to eq('somevalue')
- expect(@node[:newdata]).to eq('somevalue')
+ expect(@node[:origdata]).to eq("somevalue")
+ expect(@node[:newdata]).to eq("somevalue")
end
it "should reload a specific plugin and cause node to pick up new values" do
@new_resource.plugin "someplugin"
@provider.run_action(:reload)
- expect(@node[:origdata]).to eq('somevalue')
- expect(@node[:newdata]).to eq('somevalue')
+ expect(@node[:origdata]).to eq("somevalue")
+ expect(@node[:newdata]).to eq("somevalue")
end
end
end
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index 2e87faeb48..76bfc3b4eb 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::OsxProfile do
let(:shell_out_success) do
- double('shell_out', :exitstatus => 0, :error? => false)
+ double("shell_out", :exitstatus => 0, :error? => false)
end
- describe 'action_create' do
+ describe "action_create" do
let(:node) { Chef::Node.new }
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
@@ -74,28 +74,28 @@ describe Chef::Provider::OsxProfile do
# ProfileUUID in all_profiles to match the new config specific UUID
let(:test_profile) do
{
- 'PayloadIdentifier' => 'com.testprofile.screensaver',
- 'PayloadRemovalDisallowed' => false,
- 'PayloadScope' => 'System',
- 'PayloadType' => 'Configuration',
- 'PayloadUUID' => '1781fbec-3325-565f-9022-8aa28135c3cc',
- 'PayloadOrganization' => 'Chef',
- 'PayloadVersion' => 1,
- 'PayloadDisplayName' => 'Screensaver Settings',
- 'PayloadContent'=> [
+ "PayloadIdentifier" => "com.testprofile.screensaver",
+ "PayloadRemovalDisallowed" => false,
+ "PayloadScope" => "System",
+ "PayloadType" => "Configuration",
+ "PayloadUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc",
+ "PayloadOrganization" => "Chef",
+ "PayloadVersion" => 1,
+ "PayloadDisplayName" => "Screensaver Settings",
+ "PayloadContent"=> [
{
- 'PayloadType' => 'com.apple.ManagedClient.preferences',
- 'PayloadVersion' => 1,
- 'PayloadIdentifier' => 'com.testprofile.screensaver',
- 'PayloadUUID' => '73fc30e0-1e57-0131-c32d-000c2944c108',
- 'PayloadEnabled' => true,
- 'PayloadDisplayName' => 'com.apple.screensaver',
- 'PayloadContent' => {
- 'com.apple.screensaver' => {
- 'Forced' => [
+ "PayloadType" => "com.apple.ManagedClient.preferences",
+ "PayloadVersion" => 1,
+ "PayloadIdentifier" => "com.testprofile.screensaver",
+ "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108",
+ "PayloadEnabled" => true,
+ "PayloadDisplayName" => "com.apple.screensaver",
+ "PayloadContent" => {
+ "com.apple.screensaver" => {
+ "Forced" => [
{
- 'mcx_preference_settings' => {
- 'idleTime' => 0
+ "mcx_preference_settings" => {
+ "idleTime" => 0
}
},
]
@@ -111,16 +111,16 @@ describe Chef::Provider::OsxProfile do
before(:each) do
allow(provider).to receive(:cookbook_file_available?).and_return(true)
- allow(provider).to receive(:cache_cookbook_profile).and_return('/tmp/test.mobileconfig.remote')
+ allow(provider).to receive(:cache_cookbook_profile).and_return("/tmp/test.mobileconfig.remote")
allow(provider).to receive(:get_new_profile_hash).and_return(test_profile)
allow(provider).to receive(:get_installed_profiles).and_return(all_profiles)
allow(provider).to receive(:read_plist).and_return(all_profiles)
allow(::File).to receive(:unlink).and_return(true)
end
- it 'should build the get all profiles shellout command correctly' do
- profile_name = 'com.testprofile.screensaver.mobileconfig'
- tempfile = '/tmp/allprofiles.plist'
+ it "should build the get all profiles shellout command correctly" do
+ profile_name = "com.testprofile.screensaver.mobileconfig"
+ tempfile = "/tmp/allprofiles.plist"
new_resource.profile_name profile_name
allow(provider).to receive(:generate_tempfile).and_return(tempfile)
allow(provider).to receive(:get_installed_profiles).and_call_original
@@ -129,29 +129,29 @@ describe Chef::Provider::OsxProfile do
provider.load_current_resource
end
- it 'should use profile name as profile when no profile is set' do
- profile_name = 'com.testprofile.screensaver.mobileconfig'
+ it "should use profile name as profile when no profile is set" do
+ profile_name = "com.testprofile.screensaver.mobileconfig"
new_resource.profile_name profile_name
provider.load_current_resource
expect(new_resource.profile_name).to eql(profile_name)
end
- it 'should use identifier from specified profile' do
+ it "should use identifier from specified profile" do
new_resource.profile test_profile
provider.load_current_resource
expect(
provider.instance_variable_get(:@new_profile_identifier)
- ).to eql(test_profile['PayloadIdentifier'])
+ ).to eql(test_profile["PayloadIdentifier"])
end
- it 'should install when not installed' do
+ it "should install when not installed" do
new_resource.profile test_profile
allow(provider).to receive(:get_installed_profiles).and_return(no_profiles)
provider.load_current_resource
expect { provider.run_action(:install) }.to_not raise_error
end
- it 'does not install if the profile is already installed' do
+ it "does not install if the profile is already installed" do
new_resource.profile test_profile
allow(provider).to receive(:get_installed_profiles).and_return(all_profiles)
provider.load_current_resource
@@ -159,40 +159,40 @@ describe Chef::Provider::OsxProfile do
expect { provider.action_install }.to_not raise_error
end
- it 'should install when installed but uuid differs' do
+ it "should install when installed but uuid differs" do
new_resource.profile test_profile
- all_profiles['_computerlevel'][1]['ProfileUUID'] = '1781fbec-3325-565f-9022-9bb39245d4dd'
+ all_profiles["_computerlevel"][1]["ProfileUUID"] = "1781fbec-3325-565f-9022-9bb39245d4dd"
provider.load_current_resource
expect { provider.run_action(:install) }.to_not raise_error
end
- it 'should build the shellout install command correctly' do
- profile_path = '/tmp/test.mobileconfig'
+ it "should build the shellout install command correctly" do
+ profile_path = "/tmp/test.mobileconfig"
new_resource.profile test_profile
# Change the profile so it triggers an install
- all_profiles['_computerlevel'][1]['ProfileUUID'] = '1781fbec-3325-565f-9022-9bb39245d4dd'
+ all_profiles["_computerlevel"][1]["ProfileUUID"] = "1781fbec-3325-565f-9022-9bb39245d4dd"
provider.load_current_resource
allow(provider).to receive(:write_profile_to_disk).and_return(profile_path)
expect(provider).to receive(:shell_out).with("profiles -I -F '#{profile_path}'").and_return(shell_out_success)
provider.action_install()
end
- it 'should fail if there is no identifier inside the profile' do
- test_profile.delete('PayloadIdentifier')
+ it "should fail if there is no identifier inside the profile" do
+ test_profile.delete("PayloadIdentifier")
new_resource.profile test_profile
- error_message = 'The specified profile does not seem to be valid'
+ error_message = "The specified profile does not seem to be valid"
expect{provider.run_action(:install)}.to raise_error(RuntimeError, error_message)
end
end
- describe 'action_remove' do
+ describe "action_remove" 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(:current_resource) { Chef::Resource::OsxProfile.new('Profile Test') }
+ let(:current_resource) { Chef::Resource::OsxProfile.new("Profile Test") }
let(:all_profiles) do
{"_computerlevel"=>
[{"ProfileDisplayName"=>"ScreenSaver Settings",
@@ -240,24 +240,24 @@ describe Chef::Provider::OsxProfile do
allow(provider).to receive(:get_installed_profiles).and_return(all_profiles)
end
- it 'should use resource name for identifier when not specified' do
- new_resource.profile_name 'com.testprofile.screensaver'
+ it "should use resource name for identifier when not specified" do
+ new_resource.profile_name "com.testprofile.screensaver"
new_resource.action(:remove)
provider.load_current_resource
expect(provider.instance_variable_get(:@new_profile_identifier)
).to eql(new_resource.profile_name)
end
- it 'should use specified identifier' do
- new_resource.identifier 'com.testprofile.screensaver'
+ it "should use specified identifier" do
+ new_resource.identifier "com.testprofile.screensaver"
new_resource.action(:remove)
provider.load_current_resource
expect(provider.instance_variable_get(:@new_profile_identifier)
).to eql(new_resource.identifier)
end
- it 'should build the shellout remove command correctly' do
- new_resource.identifier 'com.testprofile.screensaver'
+ it "should build the shellout remove command correctly" do
+ new_resource.identifier "com.testprofile.screensaver"
new_resource.action(:remove)
provider.load_current_resource
expect(provider).to receive(:shell_out).with("profiles -R -p '#{new_resource.identifier}'").and_return(shell_out_success)
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb
index 13992cb8d1..9eb980f5cb 100644
--- a/spec/unit/provider/package/aix_spec.rb
+++ b/spec/unit/provider/package/aix_spec.rb
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Aix do
before(:each) do
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index f1845abfb1..1f4322041d 100644
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Package::Apt do
# XXX: sorry this is ugly and was done quickly to get 12.0.2 out, this file needs a rewrite to use
@@ -356,7 +356,7 @@ mpg123 1.12.1-0ubuntu1
describe "when installing a virtual package" do
it "should install the package without specifying a version" do
- @provider.is_virtual_package['libmysqlclient-dev'] = true
+ @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 },
@@ -369,8 +369,8 @@ mpg123 1.12.1-0ubuntu1
describe "when installing multiple packages" do
it "can install a virtual package followed by a non-virtual package" do
# https://github.com/chef/chef/issues/2914
- @provider.is_virtual_package['libmysqlclient-dev'] = true
- @provider.is_virtual_package['irssi'] = false
+ @provider.is_virtual_package["libmysqlclient-dev"] = true
+ @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 },
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index b2e1d2daaf..406ebcd184 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Chocolatey do
let(:timeout) { 900 }
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index 5b77e7788b..e0bf2accde 100644
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Dpkg do
let(:node) { Chef::Node.new }
@@ -114,7 +114,7 @@ Conflicts: wget-ssl
expect(provider.current_resource.package_name).to eq(["wget"])
end
- describe 'gets the source package version from dpkg-deb' do
+ describe "gets the source package version from dpkg-deb" do
def check_version(version)
status = double(:stdout => "wget\t#{version}", :exitstatus => 0)
expect(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(status)
@@ -123,20 +123,20 @@ Conflicts: wget-ssl
expect(provider.candidate_version).to eq([version])
end
- it 'if short version provided' do
- check_version('1.11.4')
+ it "if short version provided" do
+ check_version("1.11.4")
end
- it 'if extended version provided' do
- check_version('1.11.4-1ubuntu1')
+ it "if extended version provided" do
+ check_version("1.11.4-1ubuntu1")
end
- it 'if distro-specific version provided' do
- check_version('1.11.4-1ubuntu1~lucid')
+ it "if distro-specific version provided" do
+ check_version("1.11.4-1ubuntu1~lucid")
end
- it 'returns the version if an epoch is used' do
- check_version('1:1.8.3-2')
+ it "returns the version if an epoch is used" do
+ check_version("1:1.8.3-2")
end
end
@@ -156,7 +156,7 @@ Conflicts: wget-ssl
it "gets the source package version from dpkg-deb correctly when the package version has `~', `-', `+' or `.' characters" do
provider.load_current_resource
- expect(provider.candidate_version).to eq(['1.2.3+3141592-1ubuntu1~lucid'])
+ expect(provider.candidate_version).to eq(["1.2.3+3141592-1ubuntu1~lucid"])
end
end
diff --git a/spec/unit/provider/package/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb
index 4ac325e7d4..09d295fec3 100644
--- a/spec/unit/provider/package/easy_install_spec.rb
+++ b/spec/unit/provider/package/easy_install_spec.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::EasyInstall do
before(:each) do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::EasyInstallPackage.new('boto')
- @new_resource.version('1.8d')
+ @new_resource = Chef::Resource::EasyInstallPackage.new("boto")
+ @new_resource.version("1.8d")
@provider = Chef::Provider::Package::EasyInstall.new(@new_resource, @run_context)
diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb
index d1f5a649bc..05660d196a 100644
--- a/spec/unit/provider/package/freebsd/pkg_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkg_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
before(:each) do
@@ -30,7 +30,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
@provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(false)
+ allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(false)
end
describe "when determining the current package state" do
@@ -107,7 +107,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do
end
it "should figure out the package name when we have ports" do
- allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(true)
+ allow(::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)
diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb
index 59215f855b..0052300e45 100644
--- a/spec/unit/provider/package/freebsd/pkgng_spec.rb
+++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb
@@ -17,8 +17,8 @@
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Package::Freebsd::Port do
before(:each) do
@@ -34,7 +34,7 @@ describe Chef::Provider::Package::Freebsd::Port do
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
- expect(@provider.current_resource.name).to eq('zsh')
+ expect(@provider.current_resource.name).to eq("zsh")
end
end
@@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should query specified repository when given option" do
- @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration.
+ @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0)
expect(@provider).to receive(:shell_out!).with("pkg rquery -r LocalMirror '%v' zsh", env: nil, timeout: 900).and_return(pkg_query)
expect(@provider.candidate_version).to eq("5.0.3")
@@ -106,7 +106,7 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should handle package source from file" do
@provider.new_resource.source("/nas/pkg/repo/zsh-5.0.1.txz")
expect(@provider).to receive(:shell_out!).
- with("pkg add /nas/pkg/repo/zsh-5.0.1.txz", env: { 'LC_ALL' => nil }, timeout: 900).
+ with("pkg add /nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
@@ -114,21 +114,21 @@ describe Chef::Provider::Package::Freebsd::Port do
it "should handle package source over ftp or http" do
@provider.new_resource.source("http://repo.example.com/zsh-5.0.1.txz")
expect(@provider).to receive(:shell_out!).
- with("pkg add http://repo.example.com/zsh-5.0.1.txz", env: { 'LC_ALL' => nil }, timeout: 900).
+ with("pkg add http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900).
and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name" do
expect(@provider).to receive(:shell_out!).
- with("pkg install -y zsh", env: { 'LC_ALL' => nil }, timeout: 900).and_return(@install_result)
+ with("pkg install -y zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
it "should handle a package name with a specified repo" do
- @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration.
+ @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
expect(@provider).to receive(:shell_out!).
- with("pkg install -y -r LocalMirror zsh", env: { 'LC_ALL' => nil }, timeout: 900).and_return(@install_result)
+ with("pkg install -y -r LocalMirror zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result)
@provider.install_package("zsh", "5.0.1")
end
end
@@ -146,7 +146,7 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should not include repo option in pkg delete" do
- @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration.
+ @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration.
expect(@provider).to receive(:shell_out!).
with("pkg delete -y zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result)
@provider.remove_package("zsh", "5.0.1")
diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb
index 4b23575740..958d505187 100644
--- a/spec/unit/provider/package/freebsd/port_spec.rb
+++ b/spec/unit/provider/package/freebsd/port_spec.rb
@@ -17,8 +17,8 @@
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Package::Freebsd::Port do
before(:each) do
@@ -34,7 +34,7 @@ describe Chef::Provider::Package::Freebsd::Port do
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
- expect(@provider.current_resource.name).to eq('zsh')
+ expect(@provider.current_resource.name).to eq("zsh")
end
end
@@ -80,7 +80,7 @@ describe Chef::Provider::Package::Freebsd::Port do
pkg_enabled = OpenStruct.new(:stdout => "yes\n")
[1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version|
@node.automatic_attrs[:os_version] = __freebsd_version
- expect(@new_resource).to receive(:shell_out!).with('make -V WITH_PKGNG', env: nil).and_return(pkg_enabled)
+ 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.current_installed_version).to eq("3.1.7")
end
@@ -100,15 +100,15 @@ describe Chef::Provider::Package::Freebsd::Port do
end
it "should return candidate version if port exists" do
- allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(true)
- allow(@provider).to receive(:port_dir).and_return('/usr/ports/shells/zsh')
+ 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).
and_return(@port_version)
expect(@provider.candidate_version).to eq("5.0.5")
end
it "should raise exception if ports tree not found" do
- allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(false)
+ allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(false)
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package, "Ports collection could not be found")
end
end
diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb
index 926c1a0ff0..b4a2e16f87 100644
--- a/spec/unit/provider/package/homebrew_spec.rb
+++ b/spec/unit/provider/package/homebrew_spec.rb
@@ -15,14 +15,14 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Homebrew do
let(:node) { Chef::Node.new }
- 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(: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(:provider) do
Chef::Provider::Package::Homebrew.new(new_resource, run_context)
@@ -32,85 +32,85 @@ describe Chef::Provider::Package::Homebrew do
let(:uninstalled_brew_info) do
{
- 'name' => 'emacs',
- 'homepage' => 'http://www.gnu.org/software/emacs',
- 'versions' => {
- 'stable' => '24.3',
- 'bottle' => false,
- 'devel' => nil,
- 'head' => nil,
+ "name" => "emacs",
+ "homepage" => "http://www.gnu.org/software/emacs",
+ "versions" => {
+ "stable" => "24.3",
+ "bottle" => false,
+ "devel" => nil,
+ "head" => nil,
},
- 'revision' => 0,
- 'installed' => [],
- 'linked_keg' => nil,
- 'keg_only' => nil,
- 'dependencies' => [],
- 'conflicts_with' => [],
- 'caveats' => nil,
- 'options' => [],
+ "revision" => 0,
+ "installed" => [],
+ "linked_keg" => nil,
+ "keg_only" => nil,
+ "dependencies" => [],
+ "conflicts_with" => [],
+ "caveats" => nil,
+ "options" => [],
}
end
let(:installed_brew_info) do
{
- 'name' => 'emacs',
- 'homepage' => 'http://www.gnu.org/software/emacs/',
- 'versions' => {
- 'stable' => '24.3',
- 'bottle' => false,
- 'devel' => nil,
- 'head' => 'HEAD',
+ "name" => "emacs",
+ "homepage" => "http://www.gnu.org/software/emacs/",
+ "versions" => {
+ "stable" => "24.3",
+ "bottle" => false,
+ "devel" => nil,
+ "head" => "HEAD",
},
- 'revision' => 0,
- 'installed' => [{ 'version' => '24.3' }],
- 'linked_keg' => '24.3',
- 'keg_only' => nil,
- 'dependencies' => [],
- 'conflicts_with' => [],
- 'caveats' => '',
- 'options' => [],
+ "revision" => 0,
+ "installed" => [{ "version" => "24.3" }],
+ "linked_keg" => "24.3",
+ "keg_only" => nil,
+ "dependencies" => [],
+ "conflicts_with" => [],
+ "caveats" => "",
+ "options" => [],
}
end
let(:keg_only_brew_info) do
{
- 'name' => 'emacs-kegger',
- 'homepage' => 'http://www.gnu.org/software/emacs/',
- 'versions' => {
- 'stable' => '24.3-keggy',
- 'bottle' => false,
- 'devel' => nil,
- 'head' => 'HEAD',
+ "name" => "emacs-kegger",
+ "homepage" => "http://www.gnu.org/software/emacs/",
+ "versions" => {
+ "stable" => "24.3-keggy",
+ "bottle" => false,
+ "devel" => nil,
+ "head" => "HEAD",
},
- 'revision' => 0,
- 'installed' => [{ 'version' => '24.3-keggy' }],
- 'linked_keg' => nil,
- 'keg_only' => true,
- 'dependencies' => [],
- 'conflicts_with' => [],
- 'caveats' => '',
- 'options' => [],
+ "revision" => 0,
+ "installed" => [{ "version" => "24.3-keggy" }],
+ "linked_keg" => nil,
+ "keg_only" => true,
+ "dependencies" => [],
+ "conflicts_with" => [],
+ "caveats" => "",
+ "options" => [],
}
end
let(:keg_only_uninstalled_brew_info) do
{
- 'name' => 'emacs-kegger',
- 'homepage' => 'http://www.gnu.org/software/emacs/',
- 'versions' => {
- 'stable' => '24.3-keggy',
- 'bottle' => false,
- 'devel' => nil,
- 'head' => 'HEAD',
+ "name" => "emacs-kegger",
+ "homepage" => "http://www.gnu.org/software/emacs/",
+ "versions" => {
+ "stable" => "24.3-keggy",
+ "bottle" => false,
+ "devel" => nil,
+ "head" => "HEAD",
},
- 'revision' => 0,
- 'installed' => [],
- 'linked_keg' => nil,
- 'keg_only' => true,
- 'dependencies' => [],
- 'conflicts_with' => [],
- 'caveats' => '',
- 'options' => [],
+ "revision" => 0,
+ "installed" => [],
+ "linked_keg" => nil,
+ "keg_only" => true,
+ "dependencies" => [],
+ "conflicts_with" => [],
+ "caveats" => "",
+ "options" => [],
}
end
@@ -118,174 +118,174 @@ describe Chef::Provider::Package::Homebrew do
end
- describe 'load_current_resource' do
+ describe "load_current_resource" do
before(:each) do
allow(provider).to receive(:current_installed_version).and_return(nil)
- allow(provider).to receive(:candidate_version).and_return('24.3')
+ allow(provider).to receive(:candidate_version).and_return("24.3")
end
- it 'creates a current resource with the name of the new resource' do
+ it "creates a current resource with the name of the new resource" do
provider.load_current_resource
expect(provider.current_resource).to be_a(Chef::Resource::Package)
- expect(provider.current_resource.name).to eql('emacs')
+ expect(provider.current_resource.name).to eql("emacs")
end
- it 'creates a current resource with the version if the package is installed' do
- expect(provider).to receive(:current_installed_version).and_return('24.3')
+ it "creates a current resource with the version if the package is installed" do
+ expect(provider).to receive(:current_installed_version).and_return("24.3")
provider.load_current_resource
- expect(provider.current_resource.version).to eql('24.3')
+ expect(provider.current_resource.version).to eql("24.3")
end
- it 'creates a current resource with a nil version if the package is not installed' do
+ it "creates a current resource with a nil version if the package is not installed" do
provider.load_current_resource
expect(provider.current_resource.version).to be_nil
end
- it 'sets a candidate version if one exists' do
+ it "sets a candidate version if one exists" do
provider.load_current_resource
- expect(provider.candidate_version).to eql('24.3')
+ expect(provider.candidate_version).to eql("24.3")
end
end
- describe 'current_installed_version' do
- it 'returns the latest version from brew info if the package is keg only' do
+ describe "current_installed_version" do
+ it "returns the latest version from brew info if the package is keg only" do
allow(provider).to receive(:brew_info).and_return(keg_only_brew_info)
- expect(provider.current_installed_version).to eql('24.3-keggy')
+ expect(provider.current_installed_version).to eql("24.3-keggy")
end
- it 'returns the linked keg version if the package is not keg only' do
+ it "returns the linked keg version if the package is not keg only" do
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
- expect(provider.current_installed_version).to eql('24.3')
+ expect(provider.current_installed_version).to eql("24.3")
end
- it 'returns nil if the package is not installed' do
+ it "returns nil if the package is not installed" do
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
expect(provider.current_installed_version).to be_nil
end
- it 'returns nil if the package is keg only and not installed' do
+ it "returns nil if the package is keg only and not installed" do
allow(provider).to receive(:brew_info).and_return(keg_only_uninstalled_brew_info)
expect(provider.current_installed_version).to be_nil
end
end
- describe 'brew' do
+ describe "brew" do
before do
expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid)
expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/"))
end
- it 'passes a single to the brew command and return stdout' do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'zombo'))
- expect(provider.brew).to eql('zombo')
+ it "passes a single to the brew command and return stdout" do
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ expect(provider.brew).to eql("zombo")
end
- it 'takes multiple arguments as an array' do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'homestarrunner'))
- expect(provider.brew('info', 'opts', 'bananas')).to eql('homestarrunner')
+ it "takes multiple arguments as an array" do
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner"))
+ expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner")
end
context "when new_resource is Package" do
- let(:new_resource) { Chef::Resource::Package.new('emacs') }
+ let(:new_resource) { Chef::Resource::Package.new("emacs") }
it "does not try to read homebrew_user from Package, which does not have it" do
- allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'zombo'))
- expect(provider.brew).to eql('zombo')
+ allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo"))
+ expect(provider.brew).to eql("zombo")
end
end
end
- context 'when testing actions' do
+ context "when testing actions" do
before(:each) do
provider.current_resource = current_resource
end
- describe 'install_package' do
+ describe "install_package" do
before(:each) do
- allow(provider).to receive(:candidate_version).and_return('24.3')
+ allow(provider).to receive(:candidate_version).and_return("24.3")
end
- it 'installs the named package with brew install' do
- allow(provider.new_resource).to receive(:version).and_return('24.3')
+ it "installs the named package with brew install" do
+ allow(provider.new_resource).to receive(:version).and_return("24.3")
allow(provider.current_resource).to receive(:version).and_return(nil)
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
- expect(provider).to receive(:get_response_from_command).with('brew install emacs')
- provider.install_package('emacs', '24.3')
+ expect(provider).to receive(:get_response_from_command).with("brew install emacs")
+ provider.install_package("emacs", "24.3")
end
- it 'does not do anything if the package is installed' do
- allow(provider.current_resource).to receive(:version).and_return('24.3')
+ it "does not do anything if the package is installed" do
+ allow(provider.current_resource).to receive(:version).and_return("24.3")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
expect(provider).not_to receive(:get_response_from_command)
- provider.install_package('emacs', '24.3')
+ provider.install_package("emacs", "24.3")
end
- it 'uses options to the brew command if specified' do
- allow(provider.new_resource).to receive(:options).and_return('--cocoa')
- allow(provider.current_resource).to receive(:version).and_return('24.3')
- allow(provider).to receive(:get_response_from_command).with('brew install --cocoa emacs')
- provider.install_package('emacs', '24.3')
+ it "uses options to the brew command if specified" do
+ allow(provider.new_resource).to receive(:options).and_return("--cocoa")
+ allow(provider.current_resource).to receive(:version).and_return("24.3")
+ allow(provider).to receive(:get_response_from_command).with("brew install --cocoa emacs")
+ provider.install_package("emacs", "24.3")
end
end
- describe 'upgrade_package' do
- it 'uses brew upgrade to upgrade the package if it is installed' do
- allow(provider.current_resource).to receive(:version).and_return('24')
+ describe "upgrade_package" do
+ it "uses brew upgrade to upgrade the package if it is installed" do
+ allow(provider.current_resource).to receive(:version).and_return("24")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
- expect(provider).to receive(:get_response_from_command).with('brew upgrade emacs')
- provider.upgrade_package('emacs', '24.3')
+ expect(provider).to receive(:get_response_from_command).with("brew upgrade emacs")
+ provider.upgrade_package("emacs", "24.3")
end
- it 'does not do anything if the package version is already installed' do
- allow(provider.current_resource).to receive(:version).and_return('24.3')
+ it "does not do anything if the package version is already installed" do
+ allow(provider.current_resource).to receive(:version).and_return("24.3")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
expect(provider).not_to receive(:get_response_from_command)
- provider.install_package('emacs', '24.3')
+ provider.install_package("emacs", "24.3")
end
- it 'uses brew install to install the package if it is not installed' do
+ it "uses brew install to install the package if it is not installed" do
allow(provider.current_resource).to receive(:version).and_return(nil)
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
- expect(provider).to receive(:get_response_from_command).with('brew install emacs')
- provider.upgrade_package('emacs', '24.3')
+ expect(provider).to receive(:get_response_from_command).with("brew install emacs")
+ provider.upgrade_package("emacs", "24.3")
end
- it 'uses options to the brew command if specified' do
- allow(provider.current_resource).to receive(:version).and_return('24')
+ it "uses options to the brew command if specified" do
+ allow(provider.current_resource).to receive(:version).and_return("24")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
- allow(provider.new_resource).to receive(:options).and_return('--cocoa')
- expect(provider).to receive(:get_response_from_command).with('brew upgrade --cocoa emacs')
- provider.upgrade_package('emacs', '24.3')
+ allow(provider.new_resource).to receive(:options).and_return("--cocoa")
+ expect(provider).to receive(:get_response_from_command).with("brew upgrade --cocoa emacs")
+ provider.upgrade_package("emacs", "24.3")
end
end
- describe 'remove_package' do
- it 'uninstalls the package with brew uninstall' do
- allow(provider.current_resource).to receive(:version).and_return('24.3')
+ describe "remove_package" do
+ it "uninstalls the package with brew uninstall" do
+ allow(provider.current_resource).to receive(:version).and_return("24.3")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
- expect(provider).to receive(:get_response_from_command).with('brew uninstall emacs')
- provider.remove_package('emacs', '24.3')
+ expect(provider).to receive(:get_response_from_command).with("brew uninstall emacs")
+ provider.remove_package("emacs", "24.3")
end
- it 'does not do anything if the package is not installed' do
+ it "does not do anything if the package is not installed" do
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
expect(provider).not_to receive(:get_response_from_command)
- provider.remove_package('emacs', '24.3')
+ provider.remove_package("emacs", "24.3")
end
end
- describe 'purge_package' do
- it 'uninstalls the package with brew uninstall --force' do
- allow(provider.current_resource).to receive(:version).and_return('24.3')
+ describe "purge_package" do
+ it "uninstalls the package with brew uninstall --force" do
+ allow(provider.current_resource).to receive(:version).and_return("24.3")
allow(provider).to receive(:brew_info).and_return(installed_brew_info)
- expect(provider).to receive(:get_response_from_command).with('brew uninstall --force emacs')
- provider.purge_package('emacs', '24.3')
+ expect(provider).to receive(:get_response_from_command).with("brew uninstall --force emacs")
+ provider.purge_package("emacs", "24.3")
end
- it 'does not do anything if the package is not installed' do
+ it "does not do anything if the package is not installed" do
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
expect(provider).not_to receive(:get_response_from_command)
- provider.purge_package('emacs', '24.3')
+ provider.purge_package("emacs", "24.3")
end
end
end
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index ad69dffb10..bc29e30fd8 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
# based on the apt specs
@@ -34,7 +34,7 @@ describe Chef::Provider::Package::Ips do
def local_output
stdin = StringIO.new
- stdout = ''
+ stdout = ""
stderr =<<-PKG_STATUS
pkg: info: no packages matching the following patterns you specified are
installed on the system. Try specifying -r to query remotely:
@@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM
FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z
PKG_STATUS
stdin = StringIO.new
- stderr = ''
+ stderr = ""
return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 0)
end
diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb
index eef84113b4..83b6e04be9 100644
--- a/spec/unit/provider/package/macports_spec.rb
+++ b/spec/unit/provider/package/macports_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Macports do
before(:each) do
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index 8407f83785..0801b4b233 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
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
@@ -36,24 +36,24 @@ describe Chef::Provider::Package::Openbsd do
let(:new_resource) { Chef::Resource::Package.new(name)}
before(:each) do
- ENV['PKG_PATH'] = nil
+ ENV["PKG_PATH"] = nil
end
describe "install a package" do
- let(:name) { 'ihavetoes' }
- let(:version) {'0.0'}
+ let(:name) { "ihavetoes" }
+ let(:version) {"0.0"}
- context 'when not already installed' do
+ context "when not already installed" do
before do
- allow(provider).to receive(:shell_out!).with("pkg_info -e \"#{name}->0\"", anything()).and_return(instance_double('shellout', :stdout => ''))
+ allow(provider).to receive(:shell_out!).with("pkg_info -e \"#{name}->0\"", anything()).and_return(instance_double("shellout", :stdout => ""))
end
- context 'when there is a single candidate' do
+ context "when there is a single candidate" do
- context 'when source is not provided' do
- it 'should run the installation command' do
+ context "when source is not provided" do
+ it "should run the installation command" do
expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
- instance_double('shellout', :stdout => "#{name}-#{version}\n"))
+ instance_double("shellout", :stdout => "#{name}-#{version}\n"))
expect(provider).to receive(:shell_out!).with(
"pkg_add -r #{name}-#{version}",
{:env => {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900}
@@ -63,29 +63,29 @@ describe Chef::Provider::Package::Openbsd do
end
end
- context 'when there are multiple candidates' do
- let(:flavor_a) { 'flavora' }
- let(:flavor_b) { 'flavorb' }
+ context "when there are multiple candidates" do
+ let(:flavor_a) { "flavora" }
+ let(:flavor_b) { "flavorb" }
- context 'if no version is specified' do
- it 'should raise an exception' do
+ context "if no version is specified" do
+ it "should raise an exception" do
expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
- instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
+ instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n"))
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/)
end
end
- context 'if a flavor is specified' do
+ context "if a flavor is specified" do
- let(:flavor) { 'flavora' }
- let(:package_name) {'ihavetoes' }
+ let(:flavor) { "flavora" }
+ let(:package_name) {"ihavetoes" }
let(:name) { "#{package_name}--#{flavor}" }
- context 'if no version is specified' do
- it 'should run the installation command' do
- expect(provider).to receive(:shell_out!).with("pkg_info -e \"#{package_name}->0\"", anything()).and_return(instance_double('shellout', :stdout => ''))
+ context "if no version is specified" do
+ it "should run the installation command" do
+ expect(provider).to receive(:shell_out!).with("pkg_info -e \"#{package_name}->0\"", anything()).and_return(instance_double("shellout", :stdout => ""))
expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return(
- instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor}\n"))
+ instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n"))
expect(provider).to receive(:shell_out!).with(
"pkg_add -r #{name}-#{version}-#{flavor}",
{env: {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900}
@@ -96,10 +96,10 @@ describe Chef::Provider::Package::Openbsd do
end
- context 'if a version is specified' do
- it 'should use the flavor from the version' do
+ context "if a version is specified" do
+ it "should use the flavor from the version" do
expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}-#{version}-#{flavor_b}\"", anything()).and_return(
- instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor_a}\n"))
+ instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n"))
new_resource.version("#{version}-#{flavor_b}")
expect(provider).to receive(:shell_out!).with(
@@ -115,7 +115,7 @@ describe Chef::Provider::Package::Openbsd do
describe "delete a package" do
before do
- @name = 'ihavetoes'
+ @name = "ihavetoes"
@new_resource = Chef::Resource::Package.new(@name)
@current_resource = Chef::Resource::Package.new(@name)
@provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context)
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index da27edafeb..4b715da8b6 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Pacman do
before(:each) do
diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb
index 4ed5dfc003..05c1e529b7 100644
--- a/spec/unit/provider/package/paludis_spec.rb
+++ b/spec/unit/provider/package/paludis_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
# based on the ips specs
diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb
index 55743dbeaf..a73db877b6 100644
--- a/spec/unit/provider/package/portage_spec.rb
+++ b/spec/unit/provider/package/portage_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Portage, "load_current_resource" do
before(:each) do
diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb
index ad9d694e34..409b5268ee 100644
--- a/spec/unit/provider/package/rpm_spec.rb
+++ b/spec/unit/provider/package/rpm_spec.rb
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Rpm do
let(:provider) { Chef::Provider::Package::Rpm.new(new_resource, run_context) }
@@ -35,10 +35,10 @@ describe Chef::Provider::Package::Rpm do
end
# `rpm -qp [stuff] $source`
- let(:rpm_qp_status) { instance_double('Mixlib::ShellOut', exitstatus: rpm_qp_exitstatus, stdout: rpm_qp_stdout) }
+ let(:rpm_qp_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_qp_exitstatus, stdout: rpm_qp_stdout) }
# `rpm -q [stuff] $package_name`
- let(:rpm_q_status) { instance_double('Mixlib::ShellOut', exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) }
+ let(:rpm_q_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) }
before(:each) do
allow(::File).to receive(:exists?).with("PLEASE STUB File.exists? EXACTLY").and_return(true)
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 5e4d8a6224..85de24fdb4 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'pp'
+require "pp"
module GemspecBackcompatCreator
def gemspec(name, version)
@@ -28,8 +28,8 @@ module GemspecBackcompatCreator
end
end
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
include GemspecBackcompatCreator
@@ -43,18 +43,18 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "determines the installed versions of gems from Gem.source_index" do
- gems = [gemspec('rspec-core', Gem::Version.new('1.2.9')), gemspec('rspec-core', Gem::Version.new('1.3.0'))]
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
- expect(Gem::Specification).to receive(:find_all_by_name).with('rspec-core', Gem::Dependency.new('rspec-core').requirement).and_return(gems)
+ gems = [gemspec("rspec-core", Gem::Version.new("1.2.9")), gemspec("rspec-core", Gem::Version.new("1.3.0"))]
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
+ expect(Gem::Specification).to receive(:find_all_by_name).with("rspec-core", Gem::Dependency.new("rspec-core").requirement).and_return(gems)
else
- expect(Gem.source_index).to receive(:search).with(Gem::Dependency.new('rspec-core', nil)).and_return(gems)
+ expect(Gem.source_index).to receive(:search).with(Gem::Dependency.new("rspec-core", nil)).and_return(gems)
end
- expect(@gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil))).to eq(gems)
+ expect(@gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil))).to eq(gems)
end
it "determines the installed versions of gems from the source index (part2: the unmockening)" do
- expected = ['rspec-core', Gem::Version.new(RSpec::Core::Version::STRING)]
- actual = @gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil)).map { |spec| [spec.name, spec.version] }
+ expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)]
+ actual = @gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |spec| [spec.name, spec.version] }
expect(actual).to include(expected)
end
@@ -87,16 +87,16 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "finds a matching gem candidate version" do
- dep = Gem::Dependency.new('rspec', '>= 0')
+ dep = Gem::Dependency.new("rspec", ">= 0")
dep_installer = Gem::DependencyInstaller.new
allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
latest = [[gemspec("rspec", Gem::Version.new("1.3.0")), "https://rubygems.org/"]]
expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest)
- expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to eq(Gem::Version.new('1.3.0'))
+ expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to eq(Gem::Version.new("1.3.0"))
end
it "finds a matching gem candidate version on rubygems 2.0.0+" do
- dep = Gem::Dependency.new('rspec', '>= 0')
+ dep = Gem::Dependency.new("rspec", ">= 0")
dep_installer = Gem::DependencyInstaller.new
allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
best_gem = double("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org")
@@ -104,62 +104,62 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
expect(available_set).to receive(:pick_best!)
expect(available_set).to receive(:set).and_return([best_gem])
expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(available_set)
- expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to eq(Gem::Version.new('1.3.0'))
+ expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to eq(Gem::Version.new("1.3.0"))
end
it "gives the candidate version as nil if none is found" do
- dep = Gem::Dependency.new('rspec', '>= 0')
+ dep = Gem::Dependency.new("rspec", ">= 0")
latest = []
dep_installer = Gem::DependencyInstaller.new
allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest)
- expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to be_nil
+ expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to be_nil
end
it "finds a matching candidate version from a .gem file when the path to the gem is supplied" do
- location = CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem'
- expect(@gem_env.candidate_version_from_file(Gem::Dependency.new('chef-integration-test', '>= 0'), location)).to eq(Gem::Version.new('0.1.0'))
- expect(@gem_env.candidate_version_from_file(Gem::Dependency.new('chef-integration-test', '>= 0.2.0'), location)).to be_nil
+ location = CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem"
+ expect(@gem_env.candidate_version_from_file(Gem::Dependency.new("chef-integration-test", ">= 0"), location)).to eq(Gem::Version.new("0.1.0"))
+ expect(@gem_env.candidate_version_from_file(Gem::Dependency.new("chef-integration-test", ">= 0.2.0"), location)).to be_nil
end
it "finds a matching gem from a specific gemserver when explicit sources are given" do
- dep = Gem::Dependency.new('rspec', '>= 0')
+ dep = Gem::Dependency.new("rspec", ">= 0")
latest = [[gemspec("rspec", Gem::Version.new("1.3.0")), "https://rubygems.org/"]]
- expect(@gem_env).to receive(:with_gem_sources).with('http://gems.example.com').and_yield
+ expect(@gem_env).to receive(:with_gem_sources).with("http://gems.example.com").and_yield
dep_installer = Gem::DependencyInstaller.new
allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest)
- expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>=0'), 'http://gems.example.com')).to eq(Gem::Version.new('1.3.0'))
+ expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">=0"), "http://gems.example.com")).to eq(Gem::Version.new("1.3.0"))
end
it "installs a gem with a hash of options for the dependency installer" do
dep_installer = Gem::DependencyInstaller.new
- expect(@gem_env).to receive(:dependency_installer).with(:install_dir => '/foo/bar').and_return(dep_installer)
- expect(@gem_env).to receive(:with_gem_sources).with('http://gems.example.com').and_yield
- expect(dep_installer).to receive(:install).with(Gem::Dependency.new('rspec', '>= 0'))
- @gem_env.install(Gem::Dependency.new('rspec', '>= 0'), :install_dir => '/foo/bar', :sources => ['http://gems.example.com'])
+ expect(@gem_env).to receive(:dependency_installer).with(:install_dir => "/foo/bar").and_return(dep_installer)
+ expect(@gem_env).to receive(:with_gem_sources).with("http://gems.example.com").and_yield
+ expect(dep_installer).to receive(:install).with(Gem::Dependency.new("rspec", ">= 0"))
+ @gem_env.install(Gem::Dependency.new("rspec", ">= 0"), :install_dir => "/foo/bar", :sources => ["http://gems.example.com"])
end
it "builds an uninstaller for a gem with options set to avoid requiring user input" do
# default options for uninstaller should be:
# :ignore => true, :executables => true
- expect(Gem::Uninstaller).to receive(:new).with('rspec', :ignore => true, :executables => true)
- @gem_env.uninstaller('rspec')
+ expect(Gem::Uninstaller).to receive(:new).with("rspec", :ignore => true, :executables => true)
+ @gem_env.uninstaller("rspec")
end
it "uninstalls all versions of a gem" do
- uninstaller = double('gem uninstaller')
+ uninstaller = double("gem uninstaller")
expect(uninstaller).to receive(:uninstall)
- expect(@gem_env).to receive(:uninstaller).with('rspec', :all => true).and_return(uninstaller)
- @gem_env.uninstall('rspec')
+ expect(@gem_env).to receive(:uninstaller).with("rspec", :all => true).and_return(uninstaller)
+ @gem_env.uninstall("rspec")
end
it "uninstalls a specific version of a gem" do
- uninstaller = double('gem uninstaller')
+ uninstaller = double("gem uninstaller")
expect(uninstaller).to receive(:uninstall)
- expect(@gem_env).to receive(:uninstaller).with('rspec', :version => '1.2.3').and_return(uninstaller)
- @gem_env.uninstall('rspec', '1.2.3')
+ expect(@gem_env).to receive(:uninstaller).with("rspec", :version => "1.2.3").and_return(uninstaller)
+ @gem_env.uninstall("rspec", "1.2.3")
end
end
@@ -170,54 +170,54 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
before do
Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache.clear
Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache.clear
- @gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new('/usr/weird/bin/gem')
+ @gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new("/usr/weird/bin/gem")
end
it "determines the gem paths from shelling out to gem env" do
- gem_env_output = ['/path/to/gems', '/another/path/to/gems'].join(File::PATH_SEPARATOR)
+ gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR)
shell_out_result = OpenStruct.new(:stdout => gem_env_output)
- expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env gempath').and_return(shell_out_result)
- expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems'])
+ expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
+ expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
end
it "caches the gempaths by gem_binary" do
- gem_env_output = ['/path/to/gems', '/another/path/to/gems'].join(File::PATH_SEPARATOR)
+ gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR)
shell_out_result = OpenStruct.new(:stdout => gem_env_output)
- expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env gempath').and_return(shell_out_result)
- expected = ['/path/to/gems', '/another/path/to/gems']
- expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems'])
- expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache['/usr/weird/bin/gem']).to eq(expected)
+ expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result)
+ expected = ["/path/to/gems", "/another/path/to/gems"]
+ expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"])
+ expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]).to eq(expected)
end
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
- expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems'])
+ expected = ["/path/to/gems", "/another/path/to/gems"]
+ 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
it "builds the gems source index from the gem paths" do
- allow(@gem_env).to receive(:gem_paths).and_return(['/path/to/gems', '/another/path/to/gems'])
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
+ allow(@gem_env).to receive(:gem_paths).and_return(["/path/to/gems", "/another/path/to/gems"])
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
@gem_env.gem_specification
- expect(Gem::Specification.dirs).to eq([ '/path/to/gems/specifications', '/another/path/to/gems/specifications' ])
+ expect(Gem::Specification.dirs).to eq([ "/path/to/gems/specifications", "/another/path/to/gems/specifications" ])
else
- expect(Gem::SourceIndex).to receive(:from_gems_in).with('/path/to/gems/specifications', '/another/path/to/gems/specifications')
+ expect(Gem::SourceIndex).to receive(:from_gems_in).with("/path/to/gems/specifications", "/another/path/to/gems/specifications")
@gem_env.gem_source_index
end
end
it "determines the installed versions of gems from the source index" do
- gems = [gemspec('rspec', Gem::Version.new('1.2.9')), gemspec('rspec', Gem::Version.new('1.3.0'))]
- rspec_dep = Gem::Dependency.new('rspec', nil)
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
+ gems = [gemspec("rspec", Gem::Version.new("1.2.9")), gemspec("rspec", Gem::Version.new("1.3.0"))]
+ rspec_dep = Gem::Dependency.new("rspec", nil)
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
allow(@gem_env).to receive(:gem_specification).and_return(Gem::Specification)
expect(@gem_env.gem_specification).to receive(:find_all_by_name).with(rspec_dep.name, rspec_dep.requirement).and_return(gems)
else
allow(@gem_env).to receive(:gem_source_index).and_return(Gem.source_index)
expect(@gem_env.gem_source_index).to receive(:search).with(rspec_dep).and_return(gems)
end
- expect(@gem_env.installed_versions(Gem::Dependency.new('rspec', nil))).to eq(gems)
+ expect(@gem_env.installed_versions(Gem::Dependency.new("rspec", nil))).to eq(gems)
end
it "determines the installed versions of gems from the source index (part2: the unmockening)" do
@@ -229,8 +229,8 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
end
skip("cant find your gem executable") if path_to_gem.empty?
gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new(path_to_gem)
- expected = ['rspec-core', Gem::Version.new(RSpec::Core::Version::STRING)]
- actual = gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil)).map { |s| [s.name, s.version] }
+ expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)]
+ actual = gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |s| [s.name, s.version] }
expect(actual).to include(expected)
end
@@ -262,17 +262,17 @@ RubyGems Environment:
- https://rubygems.org/
- http://gems.github.com/
JRUBY_GEM_ENV
- expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('jruby_gem_env', :stdout => gem_env_out))
- expected = ['ruby', Gem::Platform.new('universal-java-1.6')]
+ expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", :stdout => gem_env_out))
+ expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
expect(@gem_env.gem_platforms).to eq(expected)
# it should also cache the result
- expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']).to eq(expected)
+ expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]).to eq(expected)
end
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
+ expected = ["ruby", Gem::Platform.new("universal-java-1.6")]
+ Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]= expected
expect(@gem_env.gem_platforms).to eq(expected)
end
@@ -304,22 +304,22 @@ RubyGems Environment:
- https://rubygems.org/
- http://gems.github.com/
RBX_GEM_ENV
- expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('rbx_gem_env', :stdout => gem_env_out))
+ expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", :stdout => gem_env_out))
expect(@gem_env.gem_platforms).to eq(Gem.platforms)
- expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']).to eq(Gem.platforms)
+ expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]).to eq(Gem.platforms)
end
it "yields to a block while masquerading as a different gems platform" do
original_platforms = Gem.platforms
platforms_in_block = nil
begin
- @gem_env.with_gem_platforms(['ruby', Gem::Platform.new('sparc64-java-1.7')]) do
+ @gem_env.with_gem_platforms(["ruby", Gem::Platform.new("sparc64-java-1.7")]) do
platforms_in_block = Gem.platforms
raise "gem platforms should get set to the correct value even when an error occurs"
end
rescue RuntimeError
end
- expect(platforms_in_block).to eq(['ruby', Gem::Platform.new('sparc64-java-1.7')])
+ expect(platforms_in_block).to eq(["ruby", Gem::Platform.new("sparc64-java-1.7")])
expect(Gem.platforms).to eq(original_platforms)
end
@@ -336,9 +336,9 @@ describe Chef::Provider::Package::Rubygems do
@run_context = Chef::RunContext.new(@node, {}, @events)
# We choose detect omnibus via RbConfig::CONFIG['bindir'] in Chef::Provider::Package::Rubygems.new
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/usr/bin/ruby")
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/usr/bin/ruby")
# Rubygems uses this interally
- allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_call_original
+ allow(RbConfig::CONFIG).to receive(:[]).with("arch").and_call_original
@provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
end
@@ -364,45 +364,45 @@ describe Chef::Provider::Package::Rubygems do
end
it "uses the AlternateGemEnvironment implementation when a gem_binary_path is provided" do
- @new_resource.gem_binary('/usr/weird/bin/gem')
+ @new_resource.gem_binary("/usr/weird/bin/gem")
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
- expect(provider.gem_env.gem_binary_location).to eq('/usr/weird/bin/gem')
+ expect(provider.gem_env.gem_binary_location).to eq("/usr/weird/bin/gem")
end
it "recognizes chef as omnibus" do
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chef/embedded/bin")
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chef/embedded/bin")
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
expect(provider.is_omnibus?).to be true
end
it "recognizes opscode as omnibus" do
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/opscode/embedded/bin")
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/opscode/embedded/bin")
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
expect(provider.is_omnibus?).to be true
end
it "recognizes chefdk as omnibus" do
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chefdk/embedded/bin")
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chefdk/embedded/bin")
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
expect(provider.is_omnibus?).to be true
end
it "searches for a gem binary when running on Omnibus on Unix" do
platform_mock :unix do
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chef/embedded/bin")
- allow(ENV).to receive(:[]).with('PATH').and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin")
- allow(File).to receive(:exists?).with('/usr/bin/gem').and_return(false)
- allow(File).to receive(:exists?).with('/usr/sbin/gem').and_return(true)
- allow(File).to receive(:exists?).with('/opt/chef/embedded/bin/gem').and_return(true) # should not get here
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chef/embedded/bin")
+ allow(ENV).to receive(:[]).with("PATH").and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin")
+ allow(File).to receive(:exists?).with("/usr/bin/gem").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/sbin/gem").and_return(true)
+ allow(File).to receive(:exists?).with("/opt/chef/embedded/bin/gem").and_return(true) # should not get here
provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
- expect(provider.gem_env.gem_binary_location).to eq('/usr/sbin/gem')
+ expect(provider.gem_env.gem_binary_location).to eq("/usr/sbin/gem")
end
end
it "searches for a gem binary when running on Omnibus on Windows" do
platform_mock :windows do
- allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("d:/opscode/chef/embedded/bin")
- allow(ENV).to receive(:[]).with('PATH').and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin')
+ allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("d:/opscode/chef/embedded/bin")
+ allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin')
allow(File).to receive(:exists?).with('C:\\windows\\system32\\gem').and_return(false)
allow(File).to receive(:exists?).with('C:\\windows\\gem').and_return(false)
allow(File).to receive(:exists?).with('C:\\Ruby186\\bin\\gem').and_return(true)
@@ -414,15 +414,15 @@ describe Chef::Provider::Package::Rubygems do
end
it "smites you when you try to use a hash of install options with an explicit gem binary" do
- @new_resource.gem_binary('/foo/bar')
+ @new_resource.gem_binary("/foo/bar")
@new_resource.options(:fail => :burger)
expect {Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)}.to raise_error(ArgumentError)
end
it "converts the new resource into a gem dependency" do
- expect(@provider.gem_dependency).to eq(Gem::Dependency.new('rspec-core', @spec_version))
- @new_resource.version('~> 1.2.0')
- expect(@provider.gem_dependency).to eq(Gem::Dependency.new('rspec-core', '~> 1.2.0'))
+ expect(@provider.gem_dependency).to eq(Gem::Dependency.new("rspec-core", @spec_version))
+ @new_resource.version("~> 1.2.0")
+ expect(@provider.gem_dependency).to eq(Gem::Dependency.new("rspec-core", "~> 1.2.0"))
end
describe "when determining the currently installed version" do
@@ -433,7 +433,7 @@ describe Chef::Provider::Package::Rubygems do
end
it "sets the current version to the highest installed version if the requested version is not installed" do
- @new_resource.version('9000.0.2')
+ @new_resource.version("9000.0.2")
@provider.load_current_resource
expect(@provider.current_resource.version).to eq(@spec_version)
end
@@ -454,31 +454,31 @@ describe Chef::Provider::Package::Rubygems do
end
it "determines the candidate version by querying the remote gem servers" do
- @new_resource.source('http://mygems.example.com')
+ @new_resource.source("http://mygems.example.com")
@provider.load_current_resource
- @provider.current_resource.version('0.0.1')
+ @provider.current_resource.version("0.0.1")
version = Gem::Version.new(@spec_version)
expect(@provider.gem_env).to receive(:candidate_version_from_remote).
- with(Gem::Dependency.new('rspec-core', @spec_version), "http://mygems.example.com").
+ with(Gem::Dependency.new("rspec-core", @spec_version), "http://mygems.example.com").
and_return(version)
expect(@provider.candidate_version).to eq(@spec_version)
end
it "parses the gem's specification if the requested source is a file" do
- @new_resource.package_name('chef-integration-test')
- @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
- @new_resource.version('>= 0')
+ @new_resource.package_name("chef-integration-test")
+ @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
+ @new_resource.version(">= 0")
@provider.load_current_resource
- expect(@provider.candidate_version).to eq('0.1.0')
+ expect(@provider.candidate_version).to eq("0.1.0")
end
end
describe "when installing a gem" do
before do
- @current_resource = Chef::Resource::GemPackage.new('rspec-core')
+ @current_resource = Chef::Resource::GemPackage.new("rspec-core")
@provider.current_resource = @current_resource
- @gem_dep = Gem::Dependency.new('rspec-core', @spec_version)
+ @gem_dep = Gem::Dependency.new("rspec-core", @spec_version)
allow(@provider).to receive(:load_current_resource)
end
@@ -490,26 +490,26 @@ describe Chef::Provider::Package::Rubygems do
end
it "installs the gem via the gems api when a remote source is provided" do
- @new_resource.source('http://gems.example.org')
- sources = ['http://gems.example.org']
+ @new_resource.source("http://gems.example.org")
+ sources = ["http://gems.example.org"]
expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => sources)
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
it "installs the gem from file via the gems api when no explicit options are used" do
- @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
- expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
+ @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
+ expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
it "installs the gem from file via the gems api when the package is a path and the source is nil" do
- @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
+ @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
@provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- expect(@new_resource.source).to eq(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
- expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
+ expect(@new_resource.source).to eq(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
+ expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
@@ -517,14 +517,14 @@ describe Chef::Provider::Package::Rubygems do
# this catches 'gem_package "foo"' when "./foo" is a file in the cwd, and instead of installing './foo' it fetches the remote gem
it "installs the gem via the gems api, when the package has no file separator characters in it, but a matching file exists in cwd" do
allow(::File).to receive(:exists?).and_return(true)
- @new_resource.package_name('rspec-core')
+ @new_resource.package_name("rspec-core")
expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil)
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
it "installs the gem by shelling out when options are provided as a String" do
- @new_resource.options('-i /alt/install/location')
+ @new_resource.options("-i /alt/install/location")
expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" -i /alt/install/location"
expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
@provider.run_action(:install)
@@ -532,8 +532,8 @@ describe Chef::Provider::Package::Rubygems do
end
it "installs the gem with rubygems.org as an added source" do
- @new_resource.gem_binary('/foo/bar')
- @new_resource.source('http://mirror.ops.rhcloud.com/mirror/ruby')
+ @new_resource.gem_binary("/foo/bar")
+ @new_resource.source("http://mirror.ops.rhcloud.com/mirror/ruby")
expected ="/foo/bar install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" --source=#{@new_resource.source} --source=https://rubygems.org"
expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
@provider.run_action(:install)
@@ -541,8 +541,8 @@ describe Chef::Provider::Package::Rubygems do
end
it "installs the gem with cleared sources and explict source when specified" do
- @new_resource.gem_binary('/foo/bar')
- @new_resource.source('http://mirror.ops.rhcloud.com/mirror/ruby')
+ @new_resource.gem_binary("/foo/bar")
+ @new_resource.source("http://mirror.ops.rhcloud.com/mirror/ruby")
@new_resource.clear_sources(true)
expected ="/foo/bar install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" --clear-sources --source=#{@new_resource.source}"
expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
@@ -554,7 +554,7 @@ describe Chef::Provider::Package::Rubygems do
let(:target_version) { nil }
it "installs the gem by shelling out when options are provided but no version is given" do
- @new_resource.options('-i /alt/install/location')
+ @new_resource.options("-i /alt/install/location")
expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@provider.candidate_version}\" -i /alt/install/location"
expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900)
@provider.run_action(:install)
@@ -563,15 +563,15 @@ describe Chef::Provider::Package::Rubygems do
end
it "installs the gem via the gems api when options are given as a Hash" do
- @new_resource.options(:install_dir => '/alt/install/location')
- expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location')
+ @new_resource.options(:install_dir => "/alt/install/location")
+ expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => "/alt/install/location")
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
describe "at a specific version" do
before do
- @gem_dep = Gem::Dependency.new('rspec-core', @spec_version)
+ @gem_dep = Gem::Dependency.new("rspec-core", @spec_version)
end
it "installs the gem via the gems api" do
@@ -601,28 +601,28 @@ describe Chef::Provider::Package::Rubygems do
describe "in an alternate gem environment" do
it "installs the gem by shelling out to gem install" do
- @new_resource.gem_binary('/usr/weird/bin/gem')
+ @new_resource.gem_binary("/usr/weird/bin/gem")
expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\"", env: nil, timeout: 900)
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
it "installs the gem from file by shelling out to gem install" do
- @new_resource.gem_binary('/usr/weird/bin/gem')
- @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
- @new_resource.version('>= 0')
+ @new_resource.gem_binary("/usr/weird/bin/gem")
+ @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
+ @new_resource.version(">= 0")
expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", env: nil, timeout: 900)
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
end
it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
- @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
+ @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
@provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @new_resource.gem_binary('/usr/weird/bin/gem')
- @new_resource.version('>= 0')
- expect(@new_resource.source).to eq(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem')
+ @new_resource.gem_binary("/usr/weird/bin/gem")
+ @new_resource.version(">= 0")
+ expect(@new_resource.source).to eq(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem")
expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", env: nil, timeout: 900)
@provider.run_action(:install)
expect(@new_resource).to be_updated_by_last_action
@@ -635,7 +635,7 @@ describe Chef::Provider::Package::Rubygems do
before do
@new_resource = Chef::Resource::GemPackage.new("rspec")
@current_resource = @new_resource.dup
- @current_resource.version('1.2.3')
+ @current_resource.version("1.2.3")
@provider.new_resource = @new_resource
@provider.current_resource = @current_resource
end
@@ -646,7 +646,7 @@ describe Chef::Provider::Package::Rubygems do
expect(@provider.new_resource.version).to be_nil
expect(@provider.current_resource.version).not_to be_nil
# the behavior we're testing:
- expect(@provider.gem_env).to receive(:uninstall).with('rspec', nil)
+ expect(@provider.gem_env).to receive(:uninstall).with("rspec", nil)
@provider.action_remove
end
@@ -655,27 +655,27 @@ describe Chef::Provider::Package::Rubygems do
expect(@provider.new_resource.version).to be_nil
expect(@provider.current_resource.version).not_to be_nil
# the behavior we're testing:
- @new_resource.options(:install_dir => '/alt/install/location')
- expect(@provider.gem_env).to receive(:uninstall).with('rspec', nil, :install_dir => '/alt/install/location')
+ @new_resource.options(:install_dir => "/alt/install/location")
+ expect(@provider.gem_env).to receive(:uninstall).with("rspec", nil, :install_dir => "/alt/install/location")
@provider.action_remove
end
it "uninstalls via the gem command when options are given as a String" do
- @new_resource.options('-i /alt/install/location')
+ @new_resource.options("-i /alt/install/location")
expect(@provider).to receive(:shell_out!).with("gem uninstall rspec -q -x -I -a -i /alt/install/location", env: nil, timeout: 900)
@provider.action_remove
end
it "uninstalls a specific version of a gem when a version is provided" do
- @new_resource.version('1.2.3')
- expect(@provider.gem_env).to receive(:uninstall).with('rspec', '1.2.3')
+ @new_resource.version("1.2.3")
+ expect(@provider.gem_env).to receive(:uninstall).with("rspec", "1.2.3")
@provider.action_remove
end
end
describe "in an alternate gem environment" do
it "uninstalls via the gem command" do
- @new_resource.gem_binary('/usr/weird/bin/gem')
+ @new_resource.gem_binary("/usr/weird/bin/gem")
expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem uninstall rspec -q -x -I -a", env: nil, timeout: 900)
@provider.action_remove
end
diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb
index 8f2d2bb8ea..93bfcb7a39 100644
--- a/spec/unit/provider/package/smartos_spec.rb
+++ b/spec/unit/provider/package/smartos_spec.rb
@@ -18,7 +18,7 @@
#
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))
-require 'ostruct'
+require "ostruct"
describe Chef::Provider::Package::SmartOS, "load_current_resource" do
before(:each) do
@@ -81,8 +81,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
expect(search).to receive(:each_line).
and_yield("something-varnish-1.1.1 something varnish like\n").
and_yield("varnish-2.3.4 actual varnish\n")
- @shell_out = double('shell_out!', :stdout => search)
- expect(@provider).to receive(:shell_out!).with('/opt/local/bin/pkgin', 'se', 'varnish', :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out)
+ @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.candidate_version).to eq("2.3.4")
end
@@ -91,8 +91,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do
expect(search).to receive(:each_line).
and_yield("something-varnish-1.1.1;;something varnish like\n").
and_yield("varnish-2.3.4;;actual varnish\n")
- @shell_out = double('shell_out!', :stdout => search)
- expect(@provider).to receive(:shell_out!).with('/opt/local/bin/pkgin', 'se', 'varnish', :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out)
+ @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.candidate_version).to eq("2.3.4")
end
end
diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb
index ae6c96da00..722007a6b0 100644
--- a/spec/unit/provider/package/solaris_spec.rb
+++ b/spec/unit/provider/package/solaris_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Solaris do
before(:each) do
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index 6756ffa9e0..18c1c2cd5d 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/provider/package/windows/exe'
+require "spec_helper"
+require "chef/provider/package/windows/exe"
unless Chef::Platform.windows?
class Chef
@@ -41,14 +41,14 @@ describe Chef::Provider::Package::Windows::Exe do
end
let(:uninstall_hash) do
[{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => File.join("uninst_dir", "uninst_file"),
+ "DisplayVersion" => "outdated",
+ "UninstallString" => File.join("uninst_dir", "uninst_file"),
}]
end
let(:uninstall_entry) do
entries = []
uninstall_hash.each do |entry|
- entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', 'key', entry))
+ entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", "key", entry))
end
entries
end
@@ -100,8 +100,8 @@ describe Chef::Provider::Package::Windows::Exe do
end
it "returns the version attribute if given" do
- new_resource.version('v55555')
- expect(provider.package_version).to eql('v55555')
+ new_resource.version("v55555")
+ expect(provider.package_version).to eql("v55555")
end
it "returns nil if no version given" do
@@ -121,19 +121,19 @@ describe Chef::Provider::Package::Windows::Exe do
let(:uninstall_hash) do
[
{
- 'DisplayVersion' => 'v1',
- 'UninstallString' => File.join("uninst_dir1", "uninst_file1"),
+ "DisplayVersion" => "v1",
+ "UninstallString" => File.join("uninst_dir1", "uninst_file1"),
},
{
- 'DisplayVersion' => 'v2',
- 'UninstallString' => File.join("uninst_dir2", "uninst_file2"),
+ "DisplayVersion" => "v2",
+ "UninstallString" => File.join("uninst_dir2", "uninst_file2"),
},
]
end
context "version given and installed" do
it "removes given version" do
- new_resource.version('v2')
+ new_resource.version("v2")
expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \/d\"uninst_dir2\" uninst_file2 \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash))
provider.remove_package
end
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index 835bd4ad19..86067ce8c8 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/provider/package/windows/msi'
+require "spec_helper"
+require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows::MSI do
- let(:node) { double('Chef::Node') }
- let(:events) { double('Chef::Events').as_null_object } # mock all the methods
- let(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:package_name) { "calculator" }
let(:resource_source) { "calculator.msi" }
let(:resource_version) { nil }
@@ -34,14 +34,14 @@ describe Chef::Provider::Package::Windows::MSI do
end
let(:uninstall_hash) do
[{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => "MsiExec.exe /X{guid}",
+ "DisplayVersion" => "outdated",
+ "UninstallString" => "MsiExec.exe /X{guid}",
}]
end
let(:uninstall_entry) do
entries = []
uninstall_hash.each do |entry|
- entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', 'key', entry))
+ entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", "key", entry))
end
entries
end
@@ -129,12 +129,12 @@ describe Chef::Provider::Package::Windows::MSI do
let(:uninstall_hash) do
[
{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => "MsiExec.exe /X{guid}",
+ "DisplayVersion" => "outdated",
+ "UninstallString" => "MsiExec.exe /X{guid}",
},
{
- 'DisplayVersion' => 'really_outdated',
- 'UninstallString' => "MsiExec.exe /X{guid2}",
+ "DisplayVersion" => "really_outdated",
+ "UninstallString" => "MsiExec.exe /X{guid2}",
},
]
end
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index 200cc9888a..4771057133 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/provider/package/windows/exe'
-require 'chef/provider/package/windows/msi'
+require "spec_helper"
+require "chef/provider/package/windows/exe"
+require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows, :windows_only do
before(:each) do
@@ -26,11 +26,11 @@ describe Chef::Provider::Package::Windows, :windows_only do
allow(Chef::FileCache).to receive(:create_cache_path).with("package/").and_return(cache_path)
end
- let(:node) { double('Chef::Node') }
- let(:events) { double('Chef::Events').as_null_object } # mock all the methods
- let(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
- let(:resource_source) { 'calculator.msi' }
- let(:resource_name) { 'calculator' }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
+ let(:resource_source) { "calculator.msi" }
+ let(:resource_name) { "calculator" }
let(:new_resource) do
new_resource = Chef::Resource::WindowsPackage.new(resource_name)
new_resource.source(resource_source) if resource_source
@@ -47,7 +47,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
shared_examples "a local file" do
before(:each) do
allow(Chef::Util::PathHelper).to receive(:validate_path)
- allow(provider).to receive(:package_provider).and_return(double('package_provider',
+ allow(provider).to receive(:package_provider).and_return(double("package_provider",
:installed_version => "1.0", :package_version => "2.0"))
end
@@ -69,7 +69,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
end
context "when the source is a uri" do
- let(:resource_source) { 'https://foo.bar/calculator.msi' }
+ let(:resource_source) { "https://foo.bar/calculator.msi" }
context "when the source has not been downloaded" do
before(:each) do
@@ -134,7 +134,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
end
context "when the source is a uri" do
- let(:resource_source) { 'https://foo.bar/calculator.msi' }
+ let(:resource_source) { "https://foo.bar/calculator.msi" }
context "when the source has not been downloaded" do
before(:each) do
@@ -170,15 +170,15 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "there is no source" do
let(:uninstall_hash) do
[{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => "blah blah",
+ "DisplayVersion" => "outdated",
+ "UninstallString" => "blah blah",
}]
end
let(:uninstall_key) { "blah" }
let(:uninstall_entry) do
entries = []
uninstall_hash.each do |entry|
- entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', uninstall_key, entry))
+ entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", uninstall_key, entry))
end
entries
end
@@ -191,8 +191,8 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "uninstall string contains MsiExec.exe" do
let(:uninstall_hash) do
[{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => "MsiExec.exe /X{guid}",
+ "DisplayVersion" => "outdated",
+ "UninstallString" => "MsiExec.exe /X{guid}",
}]
end
@@ -204,8 +204,8 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "uninstall string ends with uninst.exe" do
let(:uninstall_hash) do
[{
- 'DisplayVersion' => 'outdated',
- 'UninstallString' => %q{"c:/hfhfheru/uninst.exe"},
+ "DisplayVersion" => "outdated",
+ "UninstallString" => %q{"c:/hfhfheru/uninst.exe"},
}]
end
@@ -237,17 +237,17 @@ describe Chef::Provider::Package::Windows, :windows_only do
end
it "sets installer_type to inno if the source contains inno" do
- allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah inno blah'))
+ allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah inno blah"))
expect(provider.installer_type).to eql(:inno)
end
it "sets installer_type to wise if the source contains wise" do
- allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah wise blah'))
+ allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah wise blah"))
expect(provider.installer_type).to eql(:wise)
end
it "sets installer_type to nsis if the source contains nsis" do
- allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah nullsoft blah'))
+ allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah nullsoft blah"))
expect(provider.installer_type).to eql(:nsis)
end
@@ -263,7 +263,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
let(:resource_source) { "setup.exe" }
it "sets installer_type to installshield" do
- allow(::Kernel).to receive(:open).and_yield(StringIO.new(''))
+ allow(::Kernel).to receive(:open).and_yield(StringIO.new(""))
expect(provider.installer_type).to eql(:installshield)
end
end
@@ -272,7 +272,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
let(:resource_source) { "tomfoolery.now" }
it "raises an error" do
- allow(::Kernel).to receive(:open).and_yield(StringIO.new(''))
+ allow(::Kernel).to receive(:open).and_yield(StringIO.new(""))
provider.new_resource.installer_type(nil)
expect { provider.installer_type }.to raise_error(Chef::Exceptions::CannotDetermineWindowsInstallerType)
end
@@ -313,7 +313,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
end
context "a version is given and none is installed" do
- before { new_resource.version('5.5.5') }
+ before { new_resource.version("5.5.5") }
it "installs given version" do
expect(provider).to receive(:install_package).with("blah", "5.5.5")
@@ -324,7 +324,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "a version is given and several are installed" do
context "given version matches an installed version" do
before do
- new_resource.version('5.5.5')
+ 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
@@ -336,7 +336,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "given version does not match an installed version" do
before do
- new_resource.version('5.5.5')
+ 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
@@ -350,7 +350,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "a version is given and one is installed" do
context "given version matches installed version" do
before do
- new_resource.version('5.5.5')
+ new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return(["5.5.5"])
end
@@ -362,7 +362,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
context "given version does not match installed version" do
before do
- new_resource.version('5.5.5')
+ new_resource.version("5.5.5")
allow(provider).to receive(:current_version_array).and_return(["5.5.0"])
end
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 70ab257a54..efbbdf6450 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -16,18 +16,18 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'securerandom'
+require "spec_helper"
+require "securerandom"
describe Chef::Provider::Package::Yum do
before(:each) do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::YumPackage.new('cups')
+ @new_resource = Chef::Resource::YumPackage.new("cups")
@status = double("Status", :exitstatus => 0)
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -77,15 +77,15 @@ describe Chef::Provider::Package::Yum do
describe "when source is provided" do
it "should set the candidate version" do
- @new_resource = Chef::Resource::YumPackage.new('testing.source')
+ @new_resource = Chef::Resource::YumPackage.new("testing.source")
@new_resource.source "chef-server-core-12.0.5-1.rpm"
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
allow(File).to receive(:exists?).with(@new_resource.source).and_return(true)
allow(@yum_cache).to receive(:installed_version).and_return(nil)
- shellout_double = double(:stdout => 'chef-server-core 12.0.5-1')
+ shellout_double = double(:stdout => "chef-server-core 12.0.5-1")
allow(@provider).to receive(:shell_out!).and_return(shellout_double)
@provider.load_current_resource
- expect(@provider.candidate_version).to eql('12.0.5-1')
+ expect(@provider.candidate_version).to eql("12.0.5-1")
end
end
@@ -113,7 +113,7 @@ describe Chef::Provider::Package::Yum do
end
it "when the new_resource is a vanilla package class and yum-deprecated exists" do
- @new_resource = Chef::Resource::Package.new('cups')
+ @new_resource = Chef::Resource::Package.new("cups")
expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(true)
expect(@yum_cache).to receive(:yum_binary=).with("yum-deprecated")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -121,7 +121,7 @@ describe Chef::Provider::Package::Yum do
end
it "when the new_resource is a vanilla package class and yum-deprecated does not exist" do
- @new_resource = Chef::Resource::Package.new('cups')
+ @new_resource = Chef::Resource::Package.new("cups")
expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(false)
expect(@yum_cache).to receive(:yum_binary=).with("yum")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -131,9 +131,9 @@ describe Chef::Provider::Package::Yum do
describe "when arch in package_name" do
it "should set the arch if no existing package_name is found and new_package_name+new_arch is available" do
- @new_resource = Chef::Resource::YumPackage.new('testing.noarch')
+ @new_resource = Chef::Resource::YumPackage.new("testing.noarch")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache'
+ "Chef::Provider::Yum::YumCache"
)
allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
@@ -157,7 +157,7 @@ describe Chef::Provider::Package::Yum do
expect(@provider.new_resource.arch).to eq("noarch")
expect(@provider.arch).to eq("noarch")
- @new_resource = Chef::Resource::YumPackage.new('testing.more.noarch')
+ @new_resource = Chef::Resource::YumPackage.new("testing.more.noarch")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
expect(@provider.new_resource.package_name).to eq("testing.more")
@@ -167,9 +167,9 @@ describe Chef::Provider::Package::Yum do
describe "when version constraint in package_name" do
it "should set package_version if no existing package_name is found and new_package_name is available" do
- @new_resource = Chef::Resource::Package.new('cups = 1.2.4-11.18.el5_2.3')
+ @new_resource = Chef::Resource::Package.new("cups = 1.2.4-11.18.el5_2.3")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
- allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == 'cups' ? true : false }
+ allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == "cups" ? true : false }
allow(@yum_cache).to receive(:packages_from_require) do |pkg|
[Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base"),
Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.2", "noarch", [], false, true, "base")]
@@ -186,9 +186,9 @@ describe Chef::Provider::Package::Yum do
end
it "should not set the arch when an existing package_name is found" do
- @new_resource = Chef::Resource::YumPackage.new('testing.beta3')
+ @new_resource = Chef::Resource::YumPackage.new("testing.beta3")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache'
+ "Chef::Provider::Yum::YumCache"
)
allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
# installed for package_name
@@ -213,7 +213,7 @@ describe Chef::Provider::Package::Yum do
expect(@provider.new_resource.arch).to eq(nil)
expect(@provider.arch).to eq(nil)
- @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more')
+ @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
expect(@provider.new_resource.package_name).to eq("testing.beta3.more")
@@ -222,9 +222,9 @@ describe Chef::Provider::Package::Yum do
end
it "should not set the arch when no existing package_name or new_package_name+new_arch is found" do
- @new_resource = Chef::Resource::YumPackage.new('testing.beta3')
+ @new_resource = Chef::Resource::YumPackage.new("testing.beta3")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache'
+ "Chef::Provider::Yum::YumCache"
)
allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
@@ -244,7 +244,7 @@ describe Chef::Provider::Package::Yum do
expect(@provider.new_resource.arch).to eq(nil)
expect(@provider.arch).to eq(nil)
- @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more')
+ @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more")
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
expect(@provider.new_resource.package_name).to eq("testing.beta3.more")
@@ -253,10 +253,10 @@ describe Chef::Provider::Package::Yum do
end
it "should ensure it doesn't clobber an existing arch if passed" do
- @new_resource = Chef::Resource::YumPackage.new('testing.i386')
+ @new_resource = Chef::Resource::YumPackage.new("testing.i386")
@new_resource.arch("x86_64")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache'
+ "Chef::Provider::Yum::YumCache"
)
allow(@yum_cache).to receive(:installed_version) do |package_name, arch|
# nothing installed for package_name/new_package_name
@@ -313,7 +313,7 @@ describe Chef::Provider::Package::Yum do
context "when the package name isn't found" do
let(:yum_cache) { double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.0.1.el5",
@@ -334,61 +334,61 @@ describe Chef::Provider::Package::Yum do
it "should search provides then set package_name to match" do
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
- expect(@new_resource.package_name).to eq('test-package')
+ expect(@new_resource.package_name).to eq("test-package")
expect(@new_resource.version).to eq(nil)
end
it "should search provides then set version to match if a requirement was passed in the package name" do
- @new_resource = Chef::Resource::YumPackage.new('test-package = 2.0.1.el5')
+ @new_resource = Chef::Resource::YumPackage.new("test-package = 2.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')
- expect(@new_resource.version).to eq('2.0.1.el5')
+ expect(@new_resource.package_name).to eq("test-package")
+ 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')
+ @new_resource = Chef::Resource::YumPackage.new("test-package")
+ @new_resource.version("= 2.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')
- expect(@new_resource.version).to eq('2.0.1.el5')
+ expect(@new_resource.package_name).to eq("test-package")
+ 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')
+ @new_resource = Chef::Resource::YumPackage.new("test-package")
+ @new_resource.version("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')
- expect(@new_resource.version).to eq('3.0.1.el5')
+ expect(@new_resource.package_name).to eq("test-package")
+ expect(@new_resource.version).to eq("3.0.1.el5")
end
it "should search provides then set versions to match if requirements were passed in the package name as an array" do
- @new_resource = Chef::Resource::YumPackage.new(['test-package = 2.0.1.el5'])
+ @new_resource = Chef::Resource::YumPackage.new(["test-package = 2.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'])
- expect(@new_resource.version).to eq(['2.0.1.el5'])
+ expect(@new_resource.package_name).to eq(["test-package"])
+ expect(@new_resource.version).to eq(["2.0.1.el5"])
end
it "should search provides and not set the versions to match if specific versions were requested in an array" do
- @new_resource = Chef::Resource::YumPackage.new(['test-package'])
- @new_resource.version(['3.0.1.el5'])
+ @new_resource = Chef::Resource::YumPackage.new(["test-package"])
+ @new_resource.version(["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'])
- expect(@new_resource.version).to eq(['3.0.1.el5'])
+ expect(@new_resource.package_name).to eq(["test-package"])
+ expect(@new_resource.version).to eq(["3.0.1.el5"])
end
end
it "should not return an error if no version number is specified in the resource" do
- @new_resource = Chef::Resource::YumPackage.new('test-package')
+ @new_resource = Chef::Resource::YumPackage.new("test-package")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.0.1.el5",
@@ -408,9 +408,9 @@ describe Chef::Provider::Package::Yum do
end
it "should give precedence to the version attribute when both a requirement in the resource name and a version attribute are specified" do
- @new_resource = Chef::Resource::YumPackage.new('test-package')
+ @new_resource = Chef::Resource::YumPackage.new("test-package")
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -423,17 +423,17 @@ describe Chef::Provider::Package::Yum do
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')
- @new_resource.version('3.0.1.el5')
+ @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5")
+ @new_resource.version("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')
- expect(@new_resource.version).to eq('3.0.1.el5')
+ expect(@new_resource.package_name).to eq("test-package")
+ expect(@new_resource.version).to eq("3.0.1.el5")
end
it "should correctly detect the installed states of an array of package names and version numbers" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.0.1.el5",
@@ -448,17 +448,17 @@ 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
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -478,7 +478,7 @@ describe Chef::Provider::Package::Yum do
it "should search provides if no package is available and not load the complete set if action is :remove or :purge" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -502,7 +502,7 @@ describe Chef::Provider::Package::Yum do
it "should search provides if no package is available - if no match in provides leave the name intact" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_provides => true,
:reload_installed => true,
:reset => true,
@@ -562,7 +562,7 @@ describe Chef::Provider::Package::Yum do
it "installs the package with the options given in the resource" do
@provider.load_current_resource
- allow(@provider).to receive(:candidate_version).and_return('11')
+ allow(@provider).to receive(:candidate_version).and_return("11")
allow(@new_resource).to receive(:options).and_return("--disablerepo epmd")
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
@@ -573,7 +573,7 @@ describe Chef::Provider::Package::Yum do
it "should raise an exception if the package is not available" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_from_cache => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -591,7 +591,7 @@ describe Chef::Provider::Package::Yum do
it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -610,7 +610,7 @@ describe Chef::Provider::Package::Yum do
it "should not raise an exception if candidate version is older than the installed version and the package is list in yum's installonlypkg option" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -634,7 +634,7 @@ describe Chef::Provider::Package::Yum do
it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do
allow(@new_resource).to receive(:allow_downgrade).and_return(true)
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -681,7 +681,7 @@ describe Chef::Provider::Package::Yum do
describe "when upgrading a package" do
it "should run yum install if the package is installed and a version is given" do
@provider.load_current_resource
- allow(@provider).to receive(:candidate_version).and_return('11')
+ allow(@provider).to receive(:candidate_version).and_return("11")
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y install cups-11"
@@ -691,8 +691,8 @@ describe Chef::Provider::Package::Yum do
it "should run yum install if the package is not installed" do
@provider.load_current_resource
- @current_resource = Chef::Resource::Package.new('cups')
- allow(@provider).to receive(:candidate_version).and_return('11')
+ @current_resource = Chef::Resource::Package.new("cups")
+ allow(@provider).to receive(:candidate_version).and_return("11")
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y install cups-11"
@@ -702,7 +702,7 @@ describe Chef::Provider::Package::Yum do
it "should raise an exception if candidate version is older than the installed version" do
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
:installed_version => "1.2.4-11.18.el5",
@@ -722,8 +722,8 @@ describe Chef::Provider::Package::Yum do
# Test our little workaround, some crossover into Chef::Provider::Package territory
it "should call action_upgrade in the parent if the current resource version is nil" do
allow(@yum_cache).to receive(:installed_version).and_return(nil)
- @current_resource = Chef::Resource::Package.new('cups')
- allow(@provider).to receive(:candidate_version).and_return('11')
+ @current_resource = Chef::Resource::Package.new("cups")
+ allow(@provider).to receive(:candidate_version).and_return("11")
expect(@provider).to receive(:upgrade_package).with(
"cups",
"11",
@@ -733,7 +733,7 @@ describe Chef::Provider::Package::Yum do
it "should call action_upgrade in the parent if the candidate version is nil" do
@provider.load_current_resource
- @current_resource = Chef::Resource::Package.new('cups')
+ @current_resource = Chef::Resource::Package.new("cups")
allow(@provider).to receive(:candidate_version).and_return(nil)
expect(@provider).not_to receive(:upgrade_package)
@provider.run_action(:upgrade)
@@ -741,8 +741,8 @@ describe Chef::Provider::Package::Yum do
it "should call action_upgrade in the parent if the candidate is newer" do
@provider.load_current_resource
- @current_resource = Chef::Resource::Package.new('cups')
- allow(@provider).to receive(:candidate_version).and_return('11')
+ @current_resource = Chef::Resource::Package.new("cups")
+ allow(@provider).to receive(:candidate_version).and_return("11")
expect(@provider).to receive(:upgrade_package).with(
"cups",
"11",
@@ -753,8 +753,8 @@ describe Chef::Provider::Package::Yum do
it "should not call action_upgrade in the parent if the candidate is older" do
allow(@yum_cache).to receive(:installed_version).and_return("12")
@provider.load_current_resource
- @current_resource = Chef::Resource::Package.new('cups')
- allow(@provider).to receive(:candidate_version).and_return('11')
+ @current_resource = Chef::Resource::Package.new("cups")
+ allow(@provider).to receive(:candidate_version).and_return("11")
expect(@provider).not_to receive(:upgrade_package)
@provider.run_action(:upgrade)
end
@@ -989,37 +989,37 @@ describe Chef::Provider::Package::Yum::RPMUtils do
end
it "tests isalnum good input" do
- [ 'a', 'z', 'A', 'Z', '0', '9' ].each do |t|
+ [ "a", "z", "A", "Z", "0", "9" ].each do |t|
expect(@rpmutils.isalnum(t)).to eq(true)
end
end
it "tests isalnum bad input" do
- [ '-', '.', '!', '^', ':', '_' ].each do |t|
+ [ "-", ".", "!", "^", ":", "_" ].each do |t|
expect(@rpmutils.isalnum(t)).to eq(false)
end
end
it "tests isalpha good input" do
- [ 'a', 'z', 'A', 'Z' ].each do |t|
+ [ "a", "z", "A", "Z" ].each do |t|
expect(@rpmutils.isalpha(t)).to eq(true)
end
end
it "tests isalpha bad input" do
- [ '0', '9', '-', '.', '!', '^', ':', '_' ].each do |t|
+ [ "0", "9", "-", ".", "!", "^", ":", "_" ].each do |t|
expect(@rpmutils.isalpha(t)).to eq(false)
end
end
it "tests isdigit good input" do
- [ '0', '9' ].each do |t|
+ [ "0", "9" ].each do |t|
expect(@rpmutils.isdigit(t)).to eq(true)
end
end
it "tests isdigit bad input" do
- [ 'A', 'z', '-', '.', '!', '^', ':', '_' ].each do |t|
+ [ "A", "z", "-", ".", "!", "^", ":", "_" ].each do |t|
expect(@rpmutils.isdigit(t)).to eq(false)
end
end
@@ -2115,18 +2115,18 @@ describe "Chef::Provider::Package::Yum - Multi" do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::Package.new(['cups', 'vim'])
+ @new_resource = Chef::Resource::Package.new(["cups", "vim"])
@status = double("Status", :exitstatus => 0)
@yum_cache = double(
- 'Chef::Provider::Yum::YumCache',
+ "Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
- :installed_version => 'XXXX',
- :candidate_version => 'YYYY',
+ :installed_version => "XXXX",
+ :candidate_version => "YYYY",
:package_available? => true,
:version_available? => true,
- :allow_multi_install => [ 'kernel' ],
- :package_repository => 'base',
+ :allow_multi_install => [ "kernel" ],
+ :package_repository => "base",
:disable_extra_repo_control => true,
)
allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache)
@@ -2139,12 +2139,12 @@ describe "Chef::Provider::Package::Yum - Multi" do
describe "when loading the current system state" do
it "should create a current resource with the name of the new_resource" do
@provider.load_current_resource
- expect(@provider.current_resource.name).to eq('cups, vim')
+ expect(@provider.current_resource.name).to eq("cups, vim")
end
it "should set the current resources package name to the new resources package name" do
@provider.load_current_resource
- expect(@provider.current_resource.package_name).to eq(['cups', 'vim'])
+ expect(@provider.current_resource.package_name).to eq(["cups", "vim"])
end
it "should set the installed version to nil on the current resource if no installed package" do
@@ -2154,21 +2154,21 @@ describe "Chef::Provider::Package::Yum - Multi" do
end
it "should set the installed version if yum has one" do
- allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0')
- allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3')
- allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5')
+ allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0")
+ allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3")
+ allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5")
@provider.load_current_resource
- expect(@provider.current_resource.version).to eq(['1.2.4-11.18.el5', '1.0'])
+ expect(@provider.current_resource.version).to eq(["1.2.4-11.18.el5", "1.0"])
end
it "should set the candidate version if yum info has one" do
- allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0')
- allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3')
- allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5')
+ allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0")
+ allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3")
+ allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5")
@provider.load_current_resource
- expect(@provider.candidate_version).to eql(['1.2.4-11.18.el5_2.3', '1.5'])
+ expect(@provider.candidate_version).to eql(["1.2.4-11.18.el5_2.3", "1.5"])
end
it "should return the current resouce" do
@@ -2177,20 +2177,20 @@ describe "Chef::Provider::Package::Yum - Multi" do
describe "when version constraint in package_name" do
it "should set package_version if no existing package_name is found and new_package_name is available" do
- @new_resource = Chef::Resource::Package.new(['cups = 1.2.4-11.18.el5_2.3', 'emacs = 24.4'])
+ @new_resource = Chef::Resource::Package.new(["cups = 1.2.4-11.18.el5_2.3", "emacs = 24.4"])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
allow(@yum_cache).to receive(:package_available?) { |pkg| %w(cups emacs).include?(pkg) ? true : false }
allow(@yum_cache).to receive(:candidate_version) do |pkg|
- if pkg == 'cups'
+ if pkg == "cups"
"1.2.4-11.18.el5_2.3"
- elsif pkg == 'emacs'
+ elsif pkg == "emacs"
"24.4"
end
end
allow(@yum_cache).to receive(:packages_from_require) do |pkg|
- if pkg.name == 'cups'
+ if pkg.name == "cups"
[Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base")]
- elsif pkg.name == 'emacs'
+ elsif pkg.name == "emacs"
[Chef::Provider::Package::Yum::RPMDbPackage.new("emacs", "24.4", "noarch", [], false, true, "base")]
end
end
@@ -2210,12 +2210,12 @@ describe "Chef::Provider::Package::Yum - Multi" do
it "should run yum install with the package name and version" do
@provider.load_current_resource
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
- allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9')
+ allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9")
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y install cups-1.2.4-11.19.el5 vim-1.0"
)
- @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0'])
+ @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"])
end
it "should run yum install with the package name, version and arch" do
@@ -2231,17 +2231,17 @@ describe "Chef::Provider::Package::Yum - Multi" do
it "installs the package with the options given in the resource" do
@provider.load_current_resource
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
- allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9')
+ allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9")
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y --disablerepo epmd install cups-1.2.4-11.19.el5 vim-1.0"
)
allow(@new_resource).to receive(:options).and_return("--disablerepo epmd")
- @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0'])
+ @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"])
end
it "should run yum install with the package name and version when name has arch" do
- @new_resource = Chef::Resource::Package.new(['cups.x86_64', 'vim'])
+ @new_resource = Chef::Resource::Package.new(["cups.x86_64", "vim"])
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
@@ -2249,20 +2249,20 @@ describe "Chef::Provider::Package::Yum - Multi" do
# and we need to craft the right response. The default mock setup above
# will just return valid versions all the time which won't work for this
# test.
- allow(@yum_cache).to receive(:installed_version).with('cups', 'x86_64').and_return('XXXX')
- allow(@yum_cache).to receive(:candidate_version).with('cups', 'x86_64').and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('cups.x86_64').and_return(nil)
- allow(@yum_cache).to receive(:candidate_version).with('cups.x86_64').and_return(nil)
+ allow(@yum_cache).to receive(:installed_version).with("cups", "x86_64").and_return("XXXX")
+ allow(@yum_cache).to receive(:candidate_version).with("cups", "x86_64").and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("cups.x86_64").and_return(nil)
+ allow(@yum_cache).to receive(:candidate_version).with("cups.x86_64").and_return(nil)
# Normal mock's for the idempotency check
- allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5')
- allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9')
+ allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5")
+ allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9")
@provider.load_current_resource
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y install cups-1.2.4-11.19.el5.x86_64 vim-1.0"
)
- @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0'])
+ @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"])
end
end
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 5fb3abe875..0f39fde5cf 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package::Zypper do
let!(:new_resource) { Chef::Resource::ZypperPackage.new("cups") }
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index cf905aeab7..ca2e545358 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Package do
let(:node) do
@@ -27,8 +27,8 @@ describe Chef::Provider::Package do
end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
- let(:new_resource) { Chef::Resource::Package.new('emacs') }
- let(:current_resource) { Chef::Resource::Package.new('emacs') }
+ let(:new_resource) { Chef::Resource::Package.new("emacs") }
+ let(:current_resource) { Chef::Resource::Package.new("emacs") }
let(:candidate_version) { "1.0" }
let(:provider) do
provider = Chef::Provider::Package.new(new_resource, run_context)
@@ -44,8 +44,8 @@ describe Chef::Provider::Package do
end
it "raises a Chef::Exceptions::InvalidResourceSpecification if both multipackage and source are provided" do
- new_resource.package_name(['a', 'b'])
- new_resource.source('foo')
+ new_resource.package_name(["a", "b"])
+ new_resource.source("foo")
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification)
end
@@ -187,12 +187,12 @@ describe Chef::Provider::Package do
describe "When removing the package" do
before(:each) do
allow(provider).to receive(:remove_package).and_return(true)
- current_resource.version '1.4.2'
+ current_resource.version "1.4.2"
end
it "should remove the package if it is installed" do
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with('emacs', nil)
+ expect(provider).to receive(:remove_package).with("emacs", nil)
provider.run_action(:remove)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
@@ -201,7 +201,7 @@ describe Chef::Provider::Package do
it "should remove the package at a specific version if it is installed at that version" do
new_resource.version "1.4.2"
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with('emacs', '1.4.2')
+ expect(provider).to receive(:remove_package).with("emacs", "1.4.2")
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
@@ -231,12 +231,12 @@ describe Chef::Provider::Package do
describe "When purging the package" do
before(:each) do
allow(provider).to receive(:purge_package).and_return(true)
- current_resource.version '1.4.2'
+ current_resource.version "1.4.2"
end
it "should purge the package if it is installed" do
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with('emacs', nil)
+ expect(provider).to receive(:purge_package).with("emacs", nil)
provider.run_action(:purge)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
@@ -245,7 +245,7 @@ describe Chef::Provider::Package do
it "should purge the package at a specific version if it is installed at that version" do
new_resource.version "1.4.2"
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with('emacs', '1.4.2')
+ expect(provider).to receive(:purge_package).with("emacs", "1.4.2")
provider.run_action(:purge)
expect(new_resource).to be_updated_by_last_action
end
@@ -280,9 +280,9 @@ describe Chef::Provider::Package do
end
it "should info log, reconfigure the package and update the resource" do
- allow(current_resource).to receive(:version).and_return('1.0')
+ allow(current_resource).to receive(:version).and_return("1.0")
allow(new_resource).to receive(:response_file).and_return(true)
- expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test')
+ expect(provider).to receive(:get_preseed_file).and_return("/var/cache/preseed-test")
allow(provider).to receive(:preseed_package).and_return(true)
allow(provider).to receive(:reconfig_package).and_return(true)
expect(Chef::Log).to receive(:info).with("package[emacs] reconfigured")
@@ -301,7 +301,7 @@ describe Chef::Provider::Package do
end
it "should debug log and not reconfigure the package if no response_file is given" do
- allow(current_resource).to receive(:version).and_return('1.0')
+ allow(current_resource).to receive(:version).and_return("1.0")
allow(new_resource).to receive(:response_file).and_return(nil)
expect(Chef::Log).to receive(:debug).with("package[emacs] no response_file provided - nothing to do")
expect(provider).not_to receive(:reconfig_package)
@@ -310,7 +310,7 @@ describe Chef::Provider::Package do
end
it "should debug log and not reconfigure the package if the response_file has not changed" do
- allow(current_resource).to receive(:version).and_return('1.0')
+ allow(current_resource).to receive(:version).and_return("1.0")
allow(new_resource).to receive(:response_file).and_return(true)
expect(provider).to receive(:get_preseed_file).and_return(false)
allow(provider).to receive(:preseed_package).and_return(false)
@@ -323,19 +323,19 @@ describe Chef::Provider::Package do
describe "when running commands to be implemented by subclasses" do
it "should raises UnsupportedAction for install" do
- expect { provider.install_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.install_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
it "should raises UnsupportedAction for upgrade" do
- expect { provider.upgrade_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.upgrade_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
it "should raises UnsupportedAction for remove" do
- expect { provider.remove_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.remove_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
it "should raises UnsupportedAction for purge" do
- expect { provider.purge_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.purge_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
it "should raise UnsupportedAction for preseed_package" do
@@ -344,7 +344,7 @@ describe Chef::Provider::Package do
end
it "should raise UnsupportedAction for reconfig" do
- expect { provider.reconfig_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ expect { provider.reconfig_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
end
@@ -360,52 +360,52 @@ describe Chef::Provider::Package do
end
let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
let(:new_resource) do
- new_resource = Chef::Resource::Package.new('emacs')
- new_resource.response_file('java.response')
- new_resource.cookbook_name = 'java'
+ new_resource = Chef::Resource::Package.new("emacs")
+ new_resource.response_file("java.response")
+ new_resource.cookbook_name = "java"
new_resource
end
describe "creating the cookbook file resource to fetch the response file" do
before do
- expect(Chef::FileCache).to receive(:create_cache_path).with('preseed/java').and_return("/tmp/preseed/java")
+ expect(Chef::FileCache).to receive(:create_cache_path).with("preseed/java").and_return("/tmp/preseed/java")
end
it "sets the preseed resource's runcontext to its own run context" do
allow(Chef::FileCache).to receive(:create_cache_path).and_return("/tmp/preseed/java")
- expect(provider.preseed_resource('java', '6').run_context).not_to be_nil
- expect(provider.preseed_resource('java', '6').run_context).to equal(provider.run_context)
+ expect(provider.preseed_resource("java", "6").run_context).not_to be_nil
+ expect(provider.preseed_resource("java", "6").run_context).to equal(provider.run_context)
end
it "should set the cookbook name of the remote file to the new resources cookbook name" do
- expect(provider.preseed_resource('java', '6').cookbook_name).to eq('java')
+ expect(provider.preseed_resource("java", "6").cookbook_name).to eq("java")
end
it "should set remote files source to the new resources response file" do
- expect(provider.preseed_resource('java', '6').source).to eq('java.response')
+ expect(provider.preseed_resource("java", "6").source).to eq("java.response")
end
it "should never back up the cached response file" do
- expect(provider.preseed_resource('java', '6').backup).to be_falsey
+ expect(provider.preseed_resource("java", "6").backup).to be_falsey
end
it "sets the install path of the resource to $file_cache/$cookbook/$pkg_name-$pkg_version.seed" do
- expect(provider.preseed_resource('java', '6').path).to eq('/tmp/preseed/java/java-6.seed')
+ expect(provider.preseed_resource("java", "6").path).to eq("/tmp/preseed/java/java-6.seed")
end
end
describe "when installing the preseed file to the cache location" do
- let(:response_file_destination) { Dir.tmpdir + '/preseed--java--java-6.seed' }
+ let(:response_file_destination) { Dir.tmpdir + "/preseed--java--java-6.seed" }
let(:response_file_resource) {
response_file_resource = Chef::Resource::CookbookFile.new(response_file_destination, run_context)
- response_file_resource.cookbook_name = 'java'
+ response_file_resource.cookbook_name = "java"
response_file_resource.backup(false)
- response_file_resource.source('java.response')
+ response_file_resource.source("java.response")
response_file_resource
}
before do
- expect(provider).to receive(:preseed_resource).with('java', '6').and_return(response_file_resource)
+ expect(provider).to receive(:preseed_resource).with("java", "6").and_return(response_file_resource)
end
after do
@@ -547,7 +547,7 @@ describe "Subclass with use_multipackage_api" do
current_resource.package_name "vim"
current_resource.version [ "1.0" ]
allow(new_resource).to receive(:response_file).and_return(true)
- expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test')
+ expect(provider).to receive(:get_preseed_file).and_return("/var/cache/preseed-test")
allow(provider).to receive(:preseed_package).and_return(true)
allow(provider).to receive(:reconfig_package).and_return(true)
expect(provider).to receive(:reconfig_package).with(
@@ -563,8 +563,8 @@ describe "Chef::Provider::Package - Multi" 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::Package.new(['emacs', 'vi']) }
- let(:current_resource) { Chef::Resource::Package.new(['emacs', 'vi']) }
+ let(:new_resource) { Chef::Resource::Package.new(["emacs", "vi"]) }
+ let(:current_resource) { Chef::Resource::Package.new(["emacs", "vi"]) }
let(:candidate_version) { [ "1.0", "6.2" ] }
let(:provider) do
provider = Chef::Provider::Package.new(new_resource, run_context)
@@ -590,30 +590,30 @@ describe "Chef::Provider::Package - Multi" do
it "installs the candidate versions when some are installed" do
expect(provider).to receive(:install_package).with(
- [ 'vi' ],
- [ '6.2' ],
+ [ "vi" ],
+ [ "6.2" ],
).and_return(true)
- current_resource.version(['1.0', nil])
+ current_resource.version(["1.0", nil])
provider.run_action(:install)
expect(new_resource).to be_updated
end
it "installs the specified version when some are out of date" do
- current_resource.version(['1.0', '6.2'])
- new_resource.version(['1.0', '6.1'])
+ current_resource.version(["1.0", "6.2"])
+ new_resource.version(["1.0", "6.1"])
provider.run_action(:install)
expect(new_resource).to be_updated
end
it "does not install any version if all are installed at the right version" do
- current_resource.version(['1.0', '6.2'])
- new_resource.version(['1.0', '6.2'])
+ current_resource.version(["1.0", "6.2"])
+ new_resource.version(["1.0", "6.2"])
provider.run_action(:install)
expect(new_resource).not_to be_updated_by_last_action
end
it "does not install any version if all are installed, and no version was specified" do
- current_resource.version(['1.0', '6.2'])
+ current_resource.version(["1.0", "6.2"])
provider.run_action(:install)
expect(new_resource).not_to be_updated_by_last_action
end
@@ -625,42 +625,42 @@ describe "Chef::Provider::Package - Multi" do
end
it "raises an exception if one is not installed and no candidates are available" do
- current_resource.version(['1.0', nil])
- provider.candidate_version = ['1.0', nil]
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = ["1.0", nil]
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
it "does not raise an exception if the packages are installed or have a candidate" do
- current_resource.version(['1.0', nil])
- provider.candidate_version = [nil, '6.2']
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = [nil, "6.2"]
expect { provider.run_action(:install) }.not_to raise_error
end
it "raises an exception if an explicit version is asked for, an old version is installed, but no candidate" do
- new_resource.version ['1.0', '6.2']
- current_resource.version(['1.0', '6.1'])
- provider.candidate_version = ['1.0', nil]
+ new_resource.version ["1.0", "6.2"]
+ current_resource.version(["1.0", "6.1"])
+ provider.candidate_version = ["1.0", nil]
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
it "does not raise an exception if an explicit version is asked for, and is installed, but no candidate" do
- new_resource.version ['1.0', '6.2']
- current_resource.version(['1.0', '6.2'])
- provider.candidate_version = ['1.0', nil]
+ new_resource.version ["1.0", "6.2"]
+ current_resource.version(["1.0", "6.2"])
+ provider.candidate_version = ["1.0", nil]
expect { provider.run_action(:install) }.not_to raise_error
end
it "raise an exception if an explicit version is asked for, and is not installed, and no candidate" do
- new_resource.version ['1.0', '6.2']
- current_resource.version(['1.0', nil])
- provider.candidate_version = ['1.0', nil]
+ new_resource.version ["1.0", "6.2"]
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = ["1.0", nil]
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
it "does not raise an exception if an explicit version is asked for, and is not installed, and there is a candidate" do
- new_resource.version ['1.0', '6.2']
- current_resource.version(['1.0', nil])
- provider.candidate_version = ['1.0', '6.2']
+ new_resource.version ["1.0", "6.2"]
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = ["1.0", "6.2"]
expect { provider.run_action(:install) }.not_to raise_error
end
end
@@ -672,7 +672,7 @@ describe "Chef::Provider::Package - Multi" do
end
it "should upgrade the package if the current versions are not the candidate version" do
- current_resource.version ['0.9', '6.1']
+ current_resource.version ["0.9", "6.1"]
expect(provider).to receive(:upgrade_package).with(
new_resource.package_name,
provider.candidate_version,
@@ -682,7 +682,7 @@ describe "Chef::Provider::Package - Multi" do
end
it "should upgrade the package if some of current versions are not the candidate versions" do
- current_resource.version ['1.0', '6.1']
+ current_resource.version ["1.0", "6.1"]
expect(provider).to receive(:upgrade_package).with(
["vi"],
["6.2"],
@@ -692,7 +692,7 @@ describe "Chef::Provider::Package - Multi" do
end
it "should not install the package if the current versions are the candidate version" do
- current_resource.version ['1.0', '6.2']
+ current_resource.version ["1.0", "6.2"]
expect(provider).not_to receive(:upgrade_package)
provider.run_action(:upgrade)
expect(new_resource).not_to be_updated_by_last_action
@@ -705,20 +705,20 @@ describe "Chef::Provider::Package - Multi" do
end
it "should raise an exception if one is not installed and no candidates are available" do
- current_resource.version(['1.0', nil])
- provider.candidate_version = ['1.0', nil]
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = ["1.0", nil]
expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
end
it "should not raise an exception if the packages are installed or have a candidate" do
- current_resource.version(['1.0', nil])
- provider.candidate_version = [nil, '6.2']
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = [nil, "6.2"]
expect { provider.run_action(:upgrade) }.not_to raise_error
end
it "should not raise an exception if the packages are installed or have a candidate" do
- current_resource.version(['1.0', nil])
- provider.candidate_version = [nil, '6.2']
+ current_resource.version(["1.0", nil])
+ provider.candidate_version = [nil, "6.2"]
expect { provider.run_action(:upgrade) }.not_to raise_error
end
end
@@ -726,44 +726,44 @@ describe "Chef::Provider::Package - Multi" do
describe "When removing multiple packages " do
before(:each) do
allow(provider).to receive(:remove_package).and_return(true)
- current_resource.version ['1.0', '6.2']
+ current_resource.version ["1.0", "6.2"]
end
it "should remove the packages if all are installed" do
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
+ expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil)
provider.run_action(:remove)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
end
it "should remove the packages if some are installed" do
- current_resource.version ['1.0', nil]
+ current_resource.version ["1.0", nil]
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil)
+ expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil)
provider.run_action(:remove)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
end
it "should remove the packages at a specific version if they are installed at that version" do
- new_resource.version ['1.0', '6.2']
+ new_resource.version ["1.0", "6.2"]
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['1.0', '6.2'])
+ expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["1.0", "6.2"])
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
it "should remove the packages at a specific version any are is installed at that version" do
- new_resource.version ['0.5', '6.2']
+ new_resource.version ["0.5", "6.2"]
expect(provider).to be_removing_package
- expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['0.5', '6.2'])
+ expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["0.5", "6.2"])
provider.run_action(:remove)
expect(new_resource).to be_updated_by_last_action
end
it "should not remove the packages at a specific version if they are not installed at that version" do
- new_resource.version ['0.5', '6.0']
+ new_resource.version ["0.5", "6.0"]
expect(provider).not_to be_removing_package
expect(provider).not_to receive(:remove_package)
provider.run_action(:remove)
@@ -782,44 +782,44 @@ describe "Chef::Provider::Package - Multi" do
describe "When purging multiple packages " do
before(:each) do
allow(provider).to receive(:purge_package).and_return(true)
- current_resource.version ['1.0', '6.2']
+ current_resource.version ["1.0", "6.2"]
end
it "should purge the packages if all are installed" do
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
+ expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil)
provider.run_action(:purge)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
end
it "should purge the packages if some are installed" do
- current_resource.version ['1.0', nil]
+ current_resource.version ["1.0", nil]
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil)
+ expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil)
provider.run_action(:purge)
expect(new_resource).to be_updated
expect(new_resource).to be_updated_by_last_action
end
it "should purge the packages at a specific version if they are installed at that version" do
- new_resource.version ['1.0', '6.2']
+ new_resource.version ["1.0", "6.2"]
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['1.0', '6.2'])
+ expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["1.0", "6.2"])
provider.run_action(:purge)
expect(new_resource).to be_updated_by_last_action
end
it "should purge the packages at a specific version any are is installed at that version" do
- new_resource.version ['0.5', '6.2']
+ new_resource.version ["0.5", "6.2"]
expect(provider).to be_removing_package
- expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['0.5', '6.2'])
+ expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["0.5", "6.2"])
provider.run_action(:purge)
expect(new_resource).to be_updated_by_last_action
end
it "should not purge the packages at a specific version if they are not installed at that version" do
- new_resource.version ['0.5', '6.0']
+ new_resource.version ["0.5", "6.0"]
expect(provider).not_to be_removing_package
expect(provider).not_to receive(:purge_package)
provider.run_action(:purge)
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index 121973763d..c4a712d69a 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::PowershellScript, "action_run" do
let(:powershell_version) { nil }
@@ -33,12 +33,12 @@ describe Chef::Provider::PowershellScript, "action_run" do
let(:provider) {
empty_events = Chef::EventDispatch::Dispatcher.new
run_context = Chef::RunContext.new(node, {}, empty_events)
- new_resource = Chef::Resource::PowershellScript.new('run some powershell code', run_context)
+ new_resource = Chef::Resource::PowershellScript.new("run some powershell code", run_context)
Chef::Provider::PowershellScript.new(new_resource, run_context)
}
- context 'when setting interpreter flags' do
- context 'on nano' do
+ context "when setting interpreter flags" do
+ context "on nano" do
before(:each) do
allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true)
allow(provider).to receive(:is_forced_32bit).and_return(false)
@@ -48,12 +48,12 @@ describe Chef::Provider::PowershellScript, "action_run" do
end
it "sets the -Command flag as the last flag" do
- flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ }
+ flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ }
expect(flags.pop).to eq("-Command")
end
end
- context 'not on nano' do
+ context "not on nano" do
before(:each) do
allow(Chef::Platform).to receive(:windows_nano_server?).and_return(false)
allow(provider).to receive(:is_forced_32bit).and_return(false)
@@ -63,36 +63,36 @@ describe Chef::Provider::PowershellScript, "action_run" do
end
it "sets the -File flag as the last flag" do
- flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ }
+ flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ }
expect(flags.pop).to eq("-File")
end
let(:execution_policy_flag) do
execution_policy_index = 0
- provider_flags = provider.flags.split(' ')
+ provider_flags = provider.flags.split(" ")
execution_policy_specified = false
provider_flags.find do | value |
execution_policy_index += 1
- execution_policy_specified = value.downcase == '-ExecutionPolicy'.downcase
+ execution_policy_specified = value.downcase == "-ExecutionPolicy".downcase
end
execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil
end
- context 'when running with an unspecified PowerShell version' do
+ context "when running with an unspecified PowerShell version" do
let(:powershell_version) { nil }
it "sets the -ExecutionPolicy flag to 'Unrestricted' by default" do
- expect(execution_policy_flag.downcase).to eq('unrestricted'.downcase)
+ expect(execution_policy_flag.downcase).to eq("unrestricted".downcase)
end
end
- { '2.0' => 'Unrestricted',
- '2.5' => 'Unrestricted',
- '3.0' => 'Bypass',
- '3.6' => 'Bypass',
- '4.0' => 'Bypass',
- '5.0' => 'Bypass' }.each do | version_policy |
+ { "2.0" => "Unrestricted",
+ "2.5" => "Unrestricted",
+ "3.0" => "Bypass",
+ "3.6" => "Bypass",
+ "4.0" => "Bypass",
+ "5.0" => "Bypass" }.each do | version_policy |
let(:powershell_version) { version_policy[0].to_f }
context "when running PowerShell version #{version_policy[0]}" do
let(:powershell_version) { version_policy[0].to_f }
diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb
index 47543ffe39..ef03ec4012 100644
--- a/spec/unit/provider/registry_key_spec.rb
+++ b/spec/unit/provider/registry_key_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
shared_examples_for "a registry key" do
before(:each) do
diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb
index 6426dafd79..0103169e84 100644
--- a/spec/unit/provider/remote_directory_spec.rb
+++ b/spec/unit/provider/remote_directory_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'digest/md5'
-require 'tmpdir'
-require 'chef/mixin/file_class'
+require "spec_helper"
+require "digest/md5"
+require "tmpdir"
+require "chef/mixin/file_class"
class Chef::CFCCheck
include Chef::Mixin::FileClass
@@ -32,7 +32,7 @@ describe Chef::Provider::RemoteDirectory do
@resource = Chef::Resource::RemoteDirectory.new(File.join(Dir.tmpdir, "tafty"))
# in CHEF_SPEC_DATA/cookbooks/openldap/files/default/remotedir
@resource.source "remotedir"
- @resource.cookbook('openldap')
+ @resource.cookbook("openldap")
@cookbook_repo = ::File.expand_path(::File.join(CHEF_SPEC_DATA, "cookbooks"))
Chef::Cookbook::FileVendor.fetch_from_disk(@cookbook_repo)
@@ -121,12 +121,12 @@ describe Chef::Provider::RemoteDirectory do
it "transfers the directory with all contents" do
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/.a_dotfile')).to be_truthy
- expect(::File.exist?(@destination_dir + '/.a_dotdir/.a_dotfile_in_a_dotdir')).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/.a_dotfile")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/.a_dotdir/.a_dotfile_in_a_dotdir")).to be_truthy
end
describe "only if it is missing" do
@@ -134,15 +134,15 @@ 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" }
- 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'))
+ 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_if_missing)
- expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy
- expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy
+ expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy
+ expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy
end
end
@@ -151,35 +151,35 @@ describe Chef::Provider::RemoteDirectory do
it "removes existing files if purge is true" do
@provider.run_action(:create)
- FileUtils.touch(@destination_dir + '/marked_for_death.txt')
- FileUtils.touch(@destination_dir + '/remotesubdir/marked_for_death_again.txt')
+ FileUtils.touch(@destination_dir + "/marked_for_death.txt")
+ FileUtils.touch(@destination_dir + "/remotesubdir/marked_for_death_again.txt")
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy
- expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy
+ expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy
- expect(::File.exist?(@destination_dir + '/marked_for_death.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/remotesubdir/marked_for_death_again.txt')).to be_falsey
+ expect(::File.exist?(@destination_dir + "/marked_for_death.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/remotesubdir/marked_for_death_again.txt")).to be_falsey
end
it "removes files in subdirectories before files above" do
@provider.run_action(:create)
- FileUtils.mkdir_p(@destination_dir + '/a/multiply/nested/directory/')
- FileUtils.touch(@destination_dir + '/a/foo.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/bar.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/nested/baz.txt')
- FileUtils.touch(@destination_dir + '/a/multiply/nested/directory/qux.txt')
+ FileUtils.mkdir_p(@destination_dir + "/a/multiply/nested/directory/")
+ FileUtils.touch(@destination_dir + "/a/foo.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/bar.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/nested/baz.txt")
+ FileUtils.touch(@destination_dir + "/a/multiply/nested/directory/qux.txt")
@provider.run_action(:create)
- expect(::File.exist?(@destination_dir + '/a/foo.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/bar.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/nested/baz.txt')).to be_falsey
- expect(::File.exist?(@destination_dir + '/a/multiply/nested/directory/qux.txt')).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/foo.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/bar.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/nested/baz.txt")).to be_falsey
+ expect(::File.exist?(@destination_dir + "/a/multiply/nested/directory/qux.txt")).to be_falsey
end
it "removes directory symlinks properly", :not_supported_on_win2k3 do
- symlinked_dir_path = @destination_dir + '/symlinked_dir'
+ symlinked_dir_path = @destination_dir + "/symlinked_dir"
@provider.action = :create
@provider.run_action
@@ -207,13 +207,13 @@ describe Chef::Provider::RemoteDirectory do
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" }
- 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'))
+ ::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)
- expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy
- expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy
+ expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy
+ expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy
end
end
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 c154c4228e..a0c200bc79 100644
--- a/spec/unit/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'uri'
+require "spec_helper"
+require "uri"
CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH = 64
CACHE_FILE_CHECKSUM_HEX_LENGTH = 32
@@ -136,7 +136,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
end
context "and it still is valid JSON" do
- let(:cache_json_data) { '' }
+ let(:cache_json_data) { "" }
it "returns empty cache control data" do
expect(cache_control_data.etag).to be_nil
@@ -214,16 +214,16 @@ 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
cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum)
- cache_control_data_truncated.send('sanitized_cache_file_basename')[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
+ cache_control_data_truncated.send("sanitized_cache_file_basename")[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
end
it "truncates the file cache path to 102 characters" do
- normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename')
+ normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename")
expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
@@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
end
it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do
- normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename')
+ normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename")
expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH)
expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true)
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 2639c39faa..c1e827887a 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::Content do
diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb
index 8bd3b7c625..10742bc671 100644
--- a/spec/unit/provider/remote_file/fetcher_spec.rb
+++ b/spec/unit/provider/remote_file/fetcher_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::Fetcher do
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index dbbddd8e84..4292a744a5 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::FTP do
let(:enclosing_directory) {
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index d9cfaa15eb..a08e65add3 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::HTTP do
diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb
index 575996a540..791d411e03 100644
--- a/spec/unit/provider/remote_file/local_file_spec.rb
+++ b/spec/unit/provider/remote_file/local_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::LocalFile do
diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb
index 3666a47468..38e0acd13f 100644
--- a/spec/unit/provider/remote_file/network_file_spec.rb
+++ b/spec/unit/provider/remote_file/network_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RemoteFile::NetworkFile do
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index de4a897847..d6381905e9 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -17,9 +17,9 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'support/shared/unit/provider/file'
+require "support/shared/unit/provider/file"
describe Chef::Provider::RemoteFile do
@@ -32,12 +32,12 @@ describe Chef::Provider::RemoteFile do
end
let(:content) do
- content = double('Chef::Provider::File::Content::RemoteFile')
+ content = double("Chef::Provider::File::Content::RemoteFile")
end
- let(:node) { double('Chef::Node') }
- let(:events) { double('Chef::Events').as_null_object } # mock all the methods
- let(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
}
diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb
index ff68eea895..0205df430c 100644
--- a/spec/unit/provider/route_spec.rb
+++ b/spec/unit/provider/route_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Route do
before do
@@ -25,9 +25,9 @@ describe Chef::Provider::Route do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
- @new_resource = Chef::Resource::Route.new('10.0.0.10')
+ @new_resource = Chef::Resource::Route.new("10.0.0.10")
@new_resource.gateway "10.0.0.9"
- @current_resource = Chef::Resource::Route.new('10.0.0.10')
+ @current_resource = Chef::Resource::Route.new("10.0.0.10")
@current_resource.gateway "10.0.0.9"
@provider = Chef::Provider::Route.new(@new_resource, @run_context)
@@ -36,14 +36,14 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "hex2ip" do
it "should return nil if ip address is invalid" do
- expect(@provider.hex2ip('foo')).to be_nil # does not even look like an ip
- expect(@provider.hex2ip('ABCDEFGH')).to be_nil # 8 chars, but invalid
+ expect(@provider.hex2ip("foo")).to be_nil # does not even look like an ip
+ expect(@provider.hex2ip("ABCDEFGH")).to be_nil # 8 chars, but invalid
end
it "should return quad-dotted notation for a valid IP" do
- expect(@provider.hex2ip('01234567')).to eq('103.69.35.1')
- expect(@provider.hex2ip('0064a8c0')).to eq('192.168.100.0')
- expect(@provider.hex2ip('00FFFFFF')).to eq('255.255.255.0')
+ expect(@provider.hex2ip("01234567")).to eq("103.69.35.1")
+ expect(@provider.hex2ip("0064a8c0")).to eq("192.168.100.0")
+ expect(@provider.hex2ip("00FFFFFF")).to eq("255.255.255.0")
end
end
@@ -51,7 +51,7 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "load_current_resource" do
context "on linux" do
before do
- @node.automatic_attrs[:os] = 'linux'
+ @node.automatic_attrs[:os] = "linux"
routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" +
"eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n"
route_file = StringIO.new(routing_table)
@@ -59,7 +59,7 @@ describe Chef::Provider::Route do
end
it "should set is_running to false when a route is not detected" do
- resource = Chef::Resource::Route.new('10.10.10.0/24')
+ resource = Chef::Resource::Route.new("10.10.10.0/24")
allow(resource).to receive(:gateway).and_return("10.0.0.1")
allow(resource).to receive(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
@@ -69,7 +69,7 @@ describe Chef::Provider::Route do
end
it "should detect existing routes and set is_running attribute correctly" do
- resource = Chef::Resource::Route.new('192.168.100.0/24')
+ resource = Chef::Resource::Route.new("192.168.100.0/24")
allow(resource).to receive(:gateway).and_return("192.168.132.9")
allow(resource).to receive(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
@@ -79,7 +79,7 @@ describe Chef::Provider::Route do
end
it "should use gateway value when matching routes" do
- resource = Chef::Resource::Route.new('192.168.100.0/24')
+ resource = Chef::Resource::Route.new("192.168.100.0/24")
allow(resource).to receive(:gateway).and_return("10.10.10.10")
allow(resource).to receive(:device).and_return("eth0")
provider = Chef::Provider::Route.new(resource, @run_context)
@@ -110,11 +110,11 @@ describe Chef::Provider::Route do
end
it "should not delete config file for :add action (CHEF-3332)" do
- @node.automatic_attrs[:platform] = 'centos'
+ @node.automatic_attrs[:platform] = "centos"
route_file = StringIO.new
expect(File).to receive(:new).and_return(route_file)
- @resource_add = Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1')
+ @resource_add = Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1")
@run_context.resource_collection << @resource_add
allow(@provider).to receive(:run_command).and_return(true)
@@ -145,7 +145,7 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "generate_command for action_add" do
it "should include a netmask when a one is specified" do
- allow(@new_resource).to receive(:netmask).and_return('255.255.0.0')
+ allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
expect(@provider.generate_command(:add)).to match(/\/\d{1,2}\s/)
end
@@ -166,7 +166,7 @@ describe Chef::Provider::Route do
describe Chef::Provider::Route, "generate_command for action_delete" do
it "should include a netmask when a one is specified" do
- allow(@new_resource).to receive(:netmask).and_return('255.255.0.0')
+ allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
expect(@provider.generate_command(:delete)).to match(/\/\d{1,2}\s/)
end
@@ -187,7 +187,7 @@ 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')
+ 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$/)
end
@@ -224,13 +224,13 @@ describe Chef::Provider::Route do
end
it "should put all routes for a device in a route config file" do
- @node.automatic_attrs[:platform] = 'centos'
+ @node.automatic_attrs[:platform] = "centos"
route_file = StringIO.new
expect(File).to receive(:new).and_return(route_file)
- @run_context.resource_collection << Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1')
- @run_context.resource_collection << Chef::Resource::Route.new('192.168.2.0/24 via 192.168.0.1')
- @run_context.resource_collection << Chef::Resource::Route.new('192.168.3.0/24 via 192.168.0.1')
+ @run_context.resource_collection << Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1")
+ @run_context.resource_collection << Chef::Resource::Route.new("192.168.2.0/24 via 192.168.0.1")
+ @run_context.resource_collection << Chef::Resource::Route.new("192.168.3.0/24 via 192.168.0.1")
@provider.action = :add
@provider.generate_config
diff --git a/spec/unit/provider/ruby_block_spec.rb b/spec/unit/provider/ruby_block_spec.rb
index 266c943367..c306d0ae9c 100644
--- a/spec/unit/provider/ruby_block_spec.rb
+++ b/spec/unit/provider/ruby_block_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::RubyBlock, "initialize" do
before(:each) do
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 7cc5abbd15..e488b0ef79 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Script, "action_run" do
let(:node) { Chef::Node.new }
@@ -26,9 +26,9 @@ describe Chef::Provider::Script, "action_run" do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:new_resource) {
- new_resource = Chef::Resource::Script.new('run some perl code')
+ new_resource = Chef::Resource::Script.new("run some perl code")
new_resource.code "$| = 1; print 'i like beans'"
- new_resource.interpreter 'perl'
+ new_resource.interpreter "perl"
new_resource
}
@@ -58,9 +58,9 @@ describe Chef::Provider::Script, "action_run" do
context "#set_owner_and_group" do
it "sets the owner and group for the script file" do
- new_resource.user 'toor'
- new_resource.group 'wheel'
- expect(FileUtils).to receive(:chown).with('toor', 'wheel', tempfile.path)
+ new_resource.user "toor"
+ new_resource.group "wheel"
+ expect(FileUtils).to receive(:chown).with("toor", "wheel", tempfile.path)
provider.set_owner_and_group
end
end
@@ -99,13 +99,13 @@ describe Chef::Provider::Script, "action_run" do
expect(provider.command).to eq(%Q{"perl" "#{tempfile.path}"})
end
- it 'should call shell_out! with the command' do
+ it "should call shell_out! with the command" do
expect(provider).to receive(:shell_out!).with(provider.command, default_opts).and_return(true)
provider.action_run
end
it "should set the command to 'interpreter flags tempfile'" do
- new_resource.flags '-f'
+ new_resource.flags "-f"
expect(provider.command).to eq(%Q{"perl" -f "#{tempfile.path}"})
end
end
diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb
index 5cca7d6f0a..abfc19d94f 100644
--- a/spec/unit/provider/service/aix_service_spec.rb
+++ b/spec/unit/provider/service/aix_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Aix do
before(:each) do
@@ -133,7 +133,7 @@ describe Chef::Provider::Service::Aix do
end
it "should call the start command for groups" do
- @provider.instance_eval('@is_resource_group = true')
+ @provider.instance_eval("@is_resource_group = true")
expect(@provider).to receive(:shell_out!).with("startsrc -g #{@new_resource.service_name}")
@provider.start_service
@@ -152,7 +152,7 @@ describe Chef::Provider::Service::Aix do
end
it "should call the stop command for groups" do
- @provider.instance_eval('@is_resource_group = true')
+ @provider.instance_eval("@is_resource_group = true")
expect(@provider).to receive(:shell_out!).with("stopsrc -g #{@new_resource.service_name}")
@provider.stop_service
@@ -171,7 +171,7 @@ describe Chef::Provider::Service::Aix do
end
it "should call the reload command for groups" do
- @provider.instance_eval('@is_resource_group = true')
+ @provider.instance_eval("@is_resource_group = true")
expect(@provider).to receive(:shell_out!).with("refresh -g #{@new_resource.service_name}")
@provider.reload_service
diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb
index 9977343daa..9274c3001b 100644
--- a/spec/unit/provider/service/aixinit_service_spec.rb
+++ b/spec/unit/provider/service/aixinit_service_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'spec_helper'
+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
@@ -127,8 +127,8 @@ describe Chef::Provider::Service::AixInit do
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
@@ -167,7 +167,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(3,'K',90)
+ expect(@provider).to receive(:create_symlink).with(3,"K",90)
@provider.disable_service
end
@@ -231,7 +231,7 @@ describe Chef::Provider::Service::AixInit do
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(:priority).with("")
@provider.set_current_resource_attributes
end
@@ -240,7 +240,7 @@ describe Chef::Provider::Service::AixInit do
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 49be0e274c..40f87b24bf 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
# most of this code has been ripped from init_service_spec.rb
# and is only slightly modified to match "arch" needs.
@@ -45,7 +45,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
it "should set the current resources service name to the new resources service name" do
allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => ""))
@provider.load_current_resource
- expect(@provider.current_resource.service_name).to eq('chef')
+ expect(@provider.current_resource.service_name).to eq("chef")
end
end
@@ -155,7 +155,7 @@ RUNNING_PS
it "should return existing entries in DAEMONS array" do
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)")
- expect(@provider.daemons).to eq(['network', '!apache', 'ssh'])
+ expect(@provider.daemons).to eq(["network", "!apache", "ssh"])
end
context "when the current service status is known" do
@@ -180,7 +180,7 @@ RUNNING_PS
it "should add chef to DAEMONS array" do
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)")
- expect(@provider).to receive(:update_daemons).with(['network', 'chef'])
+ expect(@provider).to receive(:update_daemons).with(["network", "chef"])
@provider.enable_service()
end
end
@@ -201,7 +201,7 @@ RUNNING_PS
it "should remove chef from DAEMONS array" do
allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)")
- expect(@provider).to receive(:update_daemons).with(['network', '!chef'])
+ expect(@provider).to receive(:update_daemons).with(["network", "!chef"])
@provider.disable_service()
end
end
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 346e349db7..79c51d0ea7 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'spec_helper'
+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)
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index cfc28c94d5..5bfa8ff6c0 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef::Provider::Service::Freebsd
public :service_enable_variable_name
diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb
index b4155f9628..8bfac80002 100644
--- a/spec/unit/provider/service/gentoo_service_spec.rb
+++ b/spec/unit/provider/service/gentoo_service_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Gentoo do
before(:each) do
diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb
index 827a4261e1..2594a732d9 100644
--- a/spec/unit/provider/service/init_service_spec.rb
+++ b/spec/unit/provider/service/init_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Init, "load_current_resource" do
before(:each) do
@@ -48,7 +48,7 @@ PS
it "should set the current resources service name to the new resources service name" do
@provider.load_current_resource
- expect(@current_resource.service_name).to eq('chef')
+ expect(@current_resource.service_name).to eq("chef")
end
describe "when the service supports status" do
diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb
index 3799daebb4..fccbfac2b3 100644
--- a/spec/unit/provider/service/insserv_service_spec.rb
+++ b/spec/unit/provider/service/insserv_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Insserv do
before(:each) do
diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb
index 81588c80e5..d8d860a291 100644
--- a/spec/unit/provider/service/invokercd_service_spec.rb
+++ b/spec/unit/provider/service/invokercd_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Invokercd, "load_current_resource" do
before(:each) do
@@ -48,7 +48,7 @@ PS
it "should set the current resources service name to the new resources service name" do
@provider.load_current_resource
- expect(@current_resource.service_name).to eq('chef')
+ expect(@current_resource.service_name).to eq("chef")
end
describe "when the service supports status" do
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 54183bdc3d..c3204700d7 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Macosx do
describe ".gather_plist_dirs" do
context "when HOME directory is set" do
before do
- allow(Chef::Util::PathHelper).to receive(:home).with('Library', 'LaunchAgents').and_yield('/Users/someuser/Library/LaunchAgents')
+ allow(Chef::Util::PathHelper).to receive(:home).with("Library", "LaunchAgents").and_yield("/Users/someuser/Library/LaunchAgents")
end
it "includes users's LaunchAgents folder" do
@@ -32,7 +32,7 @@ describe Chef::Provider::Service::Macosx do
context "when HOME directory is not set" do
before do
- allow(Chef::Util::PathHelper).to receive(:home).with('Library', 'LaunchAgents').and_return(nil)
+ allow(Chef::Util::PathHelper).to receive(:home).with("Library", "LaunchAgents").and_return(nil)
end
it "doesn't include user's LaunchAgents folder" do
@@ -61,20 +61,20 @@ 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'}
+ if service_type == "Agent"
+ 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(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).
@@ -263,7 +263,7 @@ SVC_LIST
end
it "starts service via launchctl if service found" do
- cmd = 'launchctl load -w ' + session + plist
+ cmd = "launchctl load -w " + session + plist
expect(provider).to receive(:shell_out_with_systems_locale).
with(/(#{su_cmd} .#{cmd}.|#{cmd})/).
and_return(0)
@@ -295,7 +295,7 @@ 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)
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index 8118e9b3ee..c08a97e7b1 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef::Provider::Service::Openbsd
public :builtin_service_enable_variable_name
@@ -52,8 +52,8 @@ describe Chef::Provider::Service::Openbsd do
let(:provider) do
events = Chef::EventDispatch::Dispatcher.new
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('')
+ 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.action = :start
provider
@@ -80,7 +80,7 @@ describe Chef::Provider::Service::Openbsd do
end
it "should set init_command to nil if it can't find anything" do
- expect(::File).to receive(:exist?).with('/etc/rc.d/sndiod').and_return(false)
+ expect(::File).to receive(:exist?).with("/etc/rc.d/sndiod").and_return(false)
expect(provider.init_command).to be nil
end
end
@@ -381,7 +381,7 @@ describe Chef::Provider::Service::Openbsd do
describe Chef::Provider::Service::Openbsd, "enable_service" do
before do
provider.current_resource = current_resource
- allow(FileUtils).to receive(:touch).with('/etc/rc.conf.local')
+ allow(FileUtils).to receive(:touch).with("/etc/rc.conf.local")
end
context "is builtin and disabled by default" do
before do
@@ -398,10 +398,10 @@ describe Chef::Provider::Service::Openbsd do
end
context "is disabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should enable the service by adding a line to rc.conf.local" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', include("#{provider.builtin_service_enable_variable_name}=\"\""))
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", include("#{provider.builtin_service_enable_variable_name}=\"\""))
expect(provider.is_enabled?).to be false
provider.enable_service
expect(provider.is_enabled?).to be true
@@ -414,7 +414,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "is enabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should not change rc.conf.local since it is already enabled" do
expect(::File).not_to receive(:write)
@@ -426,7 +426,7 @@ describe Chef::Provider::Service::Openbsd do
provider.rc_conf_local = "#{provider.builtin_service_enable_variable_name}=NO"
end
it "should enable the service by removing a line from rc.conf.local" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{provider.builtin_service_enable_variable_name})$/)
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{provider.builtin_service_enable_variable_name})$/)
expect(provider.is_enabled?).to be false
provider.enable_service
expect(provider.is_enabled?).to be true
@@ -435,7 +435,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "is not builtin" do
before do
- provider.rc_conf = ''
+ provider.rc_conf = ""
end
context "is enabled" do
before do
@@ -448,10 +448,10 @@ describe Chef::Provider::Service::Openbsd do
end
context "is disabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should enable the service by adding it to the pkg_scripts list" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', "\npkg_scripts=\"#{new_resource.service_name}\"\n")
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", "\npkg_scripts=\"#{new_resource.service_name}\"\n")
expect(provider.is_enabled?).to be false
provider.enable_service
expect(provider.is_enabled?).to be true
@@ -463,7 +463,7 @@ describe Chef::Provider::Service::Openbsd do
describe Chef::Provider::Service::Openbsd, "disable_service" do
before do
provider.current_resource = current_resource
- allow(FileUtils).to receive(:touch).with('/etc/rc.conf.local')
+ allow(FileUtils).to receive(:touch).with("/etc/rc.conf.local")
end
context "is builtin and disabled by default" do
before do
@@ -474,7 +474,7 @@ describe Chef::Provider::Service::Openbsd do
provider.rc_conf_local = "#{provider.builtin_service_enable_variable_name}=\"\""
end
it "should disable the service by removing its line from rc.conf.local" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{provider.builtin_service_enable_variable_name})$/)
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{provider.builtin_service_enable_variable_name})$/)
expect(provider.is_enabled?).to be true
provider.disable_service
expect(provider.is_enabled?).to be false
@@ -482,7 +482,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "is disabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should not change rc.conf.local since it is already disabled" do
expect(::File).not_to receive(:write)
@@ -496,10 +496,10 @@ describe Chef::Provider::Service::Openbsd do
end
context "is enabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should disable the service by adding a line to rc.conf.local" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', include("#{provider.builtin_service_enable_variable_name}=\"NO\""))
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", include("#{provider.builtin_service_enable_variable_name}=\"NO\""))
expect(provider.is_enabled?).to be true
provider.disable_service
expect(provider.is_enabled?).to be false
@@ -517,14 +517,14 @@ describe Chef::Provider::Service::Openbsd do
end
context "is not builtin" do
before do
- provider.rc_conf = ''
+ provider.rc_conf = ""
end
context "is enabled" do
before do
provider.rc_conf_local = "pkg_scripts=\"#{new_resource.service_name}\"\n"
end
it "should disable the service by removing it from the pkg_scripts list" do
- expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{new_resource.service_name})$/)
+ expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{new_resource.service_name})$/)
expect(provider.is_enabled?).to be true
provider.disable_service
expect(provider.is_enabled?).to be false
@@ -532,7 +532,7 @@ describe Chef::Provider::Service::Openbsd do
end
context "is disabled" do
before do
- provider.rc_conf_local = ''
+ provider.rc_conf_local = ""
end
it "should not change rc.conf.local since it is already disabled" do
expect(::File).not_to receive(:write)
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 5aaf54d9f5..d79e179898 100644
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -17,7 +17,7 @@
#
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))
-require 'ostruct'
+require "ostruct"
shared_examples_for "define_resource_requirements_common" do
it "should raise an error if /sbin/chkconfig does not exist" do
@@ -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)
diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb
index 895c559dff..ef5fe55a49 100644
--- a/spec/unit/provider/service/simple_service_spec.rb
+++ b/spec/unit/provider/service/simple_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Simple, "load_current_resource" do
before(:each) do
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index 4ff3e89ae3..a5f54f0830 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Solaris do
before(:each) do
@@ -24,69 +24,69 @@ describe Chef::Provider::Service::Solaris do
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::Service.new('chef')
+ @new_resource = Chef::Resource::Service.new("chef")
- @current_resource = Chef::Resource::Service.new('chef')
+ @current_resource = Chef::Resource::Service.new("chef")
@provider = Chef::Provider::Service::Solaris.new(@new_resource, @run_context)
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
# enabled / started service (svcs -l chef)
enabled_svc_stdout = [
- 'fmri svc:/application/chef:default',
- 'name chef service',
- 'enabled true',
- 'state online',
- 'next_state none',
- 'state_time April 2, 2015 04:25:19 PM EDT',
- 'logfile /var/svc/log/application-chef:default.log',
- 'restarter svc:/system/svc/restarter:default',
- 'contract_id 1115271',
- 'dependency require_all/error svc:/milestone/multi-user:default (online)',
+ "fmri svc:/application/chef:default",
+ "name chef service",
+ "enabled true",
+ "state online",
+ "next_state none",
+ "state_time April 2, 2015 04:25:19 PM EDT",
+ "logfile /var/svc/log/application-chef:default.log",
+ "restarter svc:/system/svc/restarter:default",
+ "contract_id 1115271",
+ "dependency require_all/error svc:/milestone/multi-user:default (online)",
].join("\n")
# disabled / stopped service (svcs -l chef)
disabled_svc_stdout = [
- 'fmri svc:/application/chef:default',
- 'name chef service',
- 'enabled false',
- 'state disabled',
- 'next_state none',
- 'state_time April 2, 2015 04:25:19 PM EDT',
- 'logfile /var/svc/log/application-chef:default.log',
- 'restarter svc:/system/svc/restarter:default',
- 'contract_id 1115271',
- 'dependency require_all/error svc:/milestone/multi-user:default (online)',
+ "fmri svc:/application/chef:default",
+ "name chef service",
+ "enabled false",
+ "state disabled",
+ "next_state none",
+ "state_time April 2, 2015 04:25:19 PM EDT",
+ "logfile /var/svc/log/application-chef:default.log",
+ "restarter svc:/system/svc/restarter:default",
+ "contract_id 1115271",
+ "dependency require_all/error svc:/milestone/multi-user:default (online)",
].join("\n")
# disabled / stopped service (svcs -l chef)
maintenance_svc_stdout = [
- 'fmri svc:/application/chef:default',
- 'name chef service',
- 'enabled true',
- 'state maintenance',
- 'next_state none',
- 'state_time April 2, 2015 04:25:19 PM EDT',
- 'logfile /var/svc/log/application-chef:default.log',
- 'restarter svc:/system/svc/restarter:default',
- 'contract_id 1115271',
- 'dependency require_all/error svc:/milestone/multi-user:default (online)',
+ "fmri svc:/application/chef:default",
+ "name chef service",
+ "enabled true",
+ "state maintenance",
+ "next_state none",
+ "state_time April 2, 2015 04:25:19 PM EDT",
+ "logfile /var/svc/log/application-chef:default.log",
+ "restarter svc:/system/svc/restarter:default",
+ "contract_id 1115271",
+ "dependency require_all/error svc:/milestone/multi-user:default (online)",
].join("\n")
# shell_out! return value for a service that is running
- @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => '', :stderr => '')
+ @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "")
# shell_out! return value for a service that is disabled
- @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => '', :stderr => '')
+ @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "")
# shell_out! return value for a service that is in maintenance mode
- @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => '', :stderr => '')
+ @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "")
# shell_out! return value for a service that does not exist
- @no_svc_status = double("Status", :exitstatus => 1, :stdout => '', :stdin => '', :stderr => "svcs: Pattern 'chef' doesn't match any instances\n")
+ @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n")
# shell_out! return value for a successful execution
- @success = double("clear", :exitstatus => 0, :stdout => '', :stdin => '', :stderr => '')
+ @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "")
end
it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 90b669a459..3761eb46db 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Systemd do
@@ -33,11 +33,11 @@ describe Chef::Provider::Service::Systemd do
let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
let(:shell_out_success) do
- double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false)
+ double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
end
let(:shell_out_failure) do
- double('shell_out_with_systems_locale', :exitstatus => 1, :error? => true)
+ double("shell_out_with_systems_locale", :exitstatus => 1, :error? => true)
end
let(:current_resource) { Chef::Resource::Service.new(service_name) }
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 6fb1f9fdbf..8a17e04f1a 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -16,18 +16,18 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service::Upstart do
let(:shell_out_success) do
- double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false)
+ double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
end
before(:each) do
@node =Chef::Node.new
- @node.name('upstarter')
- @node.automatic_attrs[:platform] = 'ubuntu'
- @node.automatic_attrs[:platform_version] = '9.10'
+ @node.name("upstarter")
+ @node.automatic_attrs[:platform] = "ubuntu"
+ @node.automatic_attrs[:platform_version] = "9.10"
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@@ -42,7 +42,7 @@ describe Chef::Provider::Service::Upstart do
end
it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do
- @node.automatic_attrs[:platform_version] = '9.04'
+ @node.automatic_attrs[:platform_version] = "9.04"
#Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ])
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/event.d")
@@ -50,14 +50,14 @@ describe Chef::Provider::Service::Upstart do
end
it "should return /etc/init as the upstart job directory when running on Ubuntu 9.10" do
- @node.automatic_attrs[:platform_version] = '9.10'
+ @node.automatic_attrs[:platform_version] = "9.10"
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/init")
expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq(".conf")
end
it "should return /etc/init as the upstart job directory by default" do
- @node.automatic_attrs[:platform_version] = '9000'
+ @node.automatic_attrs[:platform_version] = "9000"
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/init")
expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq(".conf")
@@ -228,7 +228,7 @@ describe Chef::Provider::Service::Upstart do
describe "enable and disable service" do
before(:each) do
- @current_resource = Chef::Resource::Service.new('rsyslog')
+ @current_resource = Chef::Resource::Service.new("rsyslog")
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
allow(Chef::Util::FileEdit).to receive(:new)
@@ -256,7 +256,7 @@ describe Chef::Provider::Service::Upstart do
describe "start and stop service" do
before(:each) do
- @current_resource = Chef::Resource::Service.new('rsyslog')
+ @current_resource = Chef::Resource::Service.new("rsyslog")
allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
@provider.current_resource = @current_resource
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 34140fdd7b..d478192c78 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'mixlib/shellout'
+require "spec_helper"
+require "mixlib/shellout"
describe Chef::Provider::Service::Windows, "load_current_resource" do
include_context "Win32"
@@ -51,14 +51,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
end
after(:each) do
- Win32::Service.send(:remove_const, 'AUTO_START') if defined?(Win32::Service::AUTO_START)
- Win32::Service.send(:remove_const, 'DEMAND_START') if defined?(Win32::Service::DEMAND_START)
- Win32::Service.send(:remove_const, 'DISABLED') if defined?(Win32::Service::DISABLED)
+ Win32::Service.send(:remove_const, "AUTO_START") if defined?(Win32::Service::AUTO_START)
+ Win32::Service.send(:remove_const, "DEMAND_START") if defined?(Win32::Service::DEMAND_START)
+ Win32::Service.send(:remove_const, "DISABLED") if defined?(Win32::Service::DISABLED)
end
it "sets the current resources service name to the new resources service name" do
provider.load_current_resource
- expect(provider.current_resource.service_name).to eq('chef')
+ expect(provider.current_resource.service_name).to eq("chef")
end
it "returns the current resource" do
diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb
index 17bade55b6..38ac37d294 100644
--- a/spec/unit/provider/service_spec.rb
+++ b/spec/unit/provider/service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Service do
before do
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index 9d4a8bd218..ff04a63b93 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Subversion do
@@ -36,7 +36,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'
+ @resource.user "deployninja"
expect(@provider.run_options).to eq({:user => "deployninja"})
end
@@ -64,7 +64,7 @@ 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 => ""))
expect(@provider.find_current_revision).to eql("11410")
@@ -73,7 +73,7 @@ describe Chef::Provider::Subversion do
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 => ""))
expect(@provider.find_current_revision).to be_nil
@@ -119,7 +119,7 @@ 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 => ""))
expect(@provider.revision_int).to eql("11410")
@@ -128,7 +128,7 @@ describe Chef::Provider::Subversion do
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")
@@ -202,7 +202,7 @@ describe Chef::Provider::Subversion 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
@@ -246,7 +246,7 @@ describe Chef::Provider::Subversion do
it "does not fetch any updates if the remote revision matches the current revision" do
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
- allow(@provider).to receive(:find_current_revision).and_return('12345')
+ allow(@provider).to receive(:find_current_revision).and_return("12345")
allow(@provider).to receive(:current_revision_matches_target_revision?).and_return(true)
@provider.run_action(:sync)
expect(@resource).not_to be_updated
@@ -267,29 +267,29 @@ describe Chef::Provider::Subversion do
it "selects 'svn' as the binary by default" do
@resource.svn_binary nil
allow(ChefConfig).to receive(:windows?) { false }
- expect(@provider).to receive(:svn_binary).and_return('svn')
+ expect(@provider).to receive(:svn_binary).and_return("svn")
expect(@provider.export_command).to eql(
- 'svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
+ "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
end
it "selects an svn binary with an exe extension on windows" do
@resource.svn_binary nil
allow(ChefConfig).to receive(:windows?) { true }
- expect(@provider).to receive(:svn_binary).and_return('svn.exe')
+ expect(@provider).to receive(:svn_binary).and_return("svn.exe")
expect(@provider.export_command).to eql(
- 'svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
+ "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
end
it "uses a custom svn binary as part of the svn command" do
- @resource.svn_binary 'teapot'
- expect(@provider).to receive(:svn_binary).and_return('teapot')
+ @resource.svn_binary "teapot"
+ expect(@provider).to receive(:svn_binary).and_return("teapot")
expect(@provider.export_command).to eql(
- 'teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
+ "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
end
it "wraps custom svn binary with quotes if it contains whitespace" do
- @resource.svn_binary 'c:/program files (x86)/subversion/svn.exe'
- expect(@provider).to receive(:svn_binary).and_return('c:/program files (x86)/subversion/svn.exe')
+ @resource.svn_binary "c:/program files (x86)/subversion/svn.exe"
+ expect(@provider).to receive(:svn_binary).and_return("c:/program files (x86)/subversion/svn.exe")
expect(@provider.export_command).to eql(
'"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
end
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 509c8cf33b..7a19f59de1 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Template::Content do
@@ -30,13 +30,13 @@ describe Chef::Provider::Template::Content do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => 'openldap',
- :recipe_name => 'default',
+ :cookbook_name => "openldap",
+ :recipe_name => "default",
:source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
:source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
:source_line_number => "2",
- :source => 'openldap_stuff.conf.erb',
- :name => 'openldap_stuff.conf',
+ :source => "openldap_stuff.conf.erb",
+ :name => "openldap_stuff.conf",
:path => resource_path,
:local => false,
:cookbook => nil,
@@ -47,8 +47,8 @@ describe Chef::Provider::Template::Content do
end
let(:rendered_file_locations) {
- [Dir.tmpdir + '/openldap_stuff.conf',
- enclosing_directory + '/openldap_stuff.conf']
+ [Dir.tmpdir + "/openldap_stuff.conf",
+ enclosing_directory + "/openldap_stuff.conf"]
}
let(:run_context) do
@@ -73,20 +73,20 @@ describe Chef::Provider::Template::Content do
end
it "finds the template file in the cookbook cache if it isn't local" do
- expect(content.template_location).to eq(CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/openldap_stuff.conf.erb')
+ expect(content.template_location).to eq(CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/openldap_stuff.conf.erb")
end
it "finds the template file locally if it is local" do
allow(new_resource).to receive(:local).and_return(true)
- allow(new_resource).to receive(:source).and_return('/tmp/its_on_disk.erb')
- expect(content.template_location).to eq('/tmp/its_on_disk.erb')
+ allow(new_resource).to receive(:source).and_return("/tmp/its_on_disk.erb")
+ expect(content.template_location).to eq("/tmp/its_on_disk.erb")
end
it "should use the cookbook name if defined in the template resource" do
- allow(new_resource).to receive(:cookbook_name).and_return('apache2')
- allow(new_resource).to receive(:cookbook).and_return('openldap')
+ allow(new_resource).to receive(:cookbook_name).and_return("apache2")
+ allow(new_resource).to receive(:cookbook).and_return("openldap")
allow(new_resource).to receive(:source).and_return("test.erb")
- expect(content.template_location).to eq(CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/test.erb')
+ expect(content.template_location).to eq(CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/test.erb")
end
it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do
@@ -130,14 +130,14 @@ describe Chef::Provider::Template::Content do
describe "when using location helpers" do
let(:new_resource) do
double("Chef::Resource::Template (new)",
- :cookbook_name => 'openldap',
- :recipe_name => 'default',
+ :cookbook_name => "openldap",
+ :recipe_name => "default",
:source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
:source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
:source_line_number => "2",
- :source => 'helpers.erb',
- :name => 'helpers.erb',
- :path => CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/helpers.erb',
+ :source => "helpers.erb",
+ :name => "helpers.erb",
+ :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb",
:local => false,
:cookbook => nil,
:variables => {},
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index 713303d818..5340cc8d12 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -17,17 +17,17 @@
# limitations under the License.
#
-require 'stringio'
-require 'spec_helper'
-require 'etc'
-require 'ostruct'
-require 'support/shared/unit/provider/file'
+require "stringio"
+require "spec_helper"
+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(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(:enclosing_directory) {
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
}
@@ -50,7 +50,7 @@ describe Chef::Provider::Template do
end
let(:content) do
- content = double('Chef::Provider::File::Content::Template', :template_location => "/foo/bar/baz")
+ content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz")
allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true)
content
end
@@ -59,9 +59,9 @@ 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(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
+ let(:node) { double("Chef::Node") }
+ let(:events) { double("Chef::Events").as_null_object } # mock all the methods
+ let(:run_context) { double("Chef::RunContext", :node => node, :events => events) }
let(: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 a9407a4d7e..8195bdfc25 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -18,9 +18,9 @@
ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus)
-require 'spec_helper'
-require 'ostruct'
-require 'mixlib/shellout'
+require "spec_helper"
+require "ostruct"
+require "mixlib/shellout"
describe Chef::Provider::User::Dscl do
before do
@@ -114,32 +114,32 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
describe "when shelling out to dscl" do
it "should run dscl with the supplied cmd /Path args" do
- shell_return = ShellCmdResult.new('stdout', 'err', 0)
+ shell_return = ShellCmdResult.new("stdout", "err", 0)
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
- expect(provider.run_dscl("cmd /Path args")).to eq('stdout')
+ expect(provider.run_dscl("cmd /Path args")).to eq("stdout")
end
it "returns an empty string from delete commands" do
- shell_return = ShellCmdResult.new('out', 'err', 23)
+ shell_return = ShellCmdResult.new("out", "err", 23)
expect(provider).to receive(:shell_out).with("dscl . -delete /Path args").and_return(shell_return)
expect(provider.run_dscl("delete /Path args")).to eq("")
end
it "should raise an exception for any other command" do
- shell_return = ShellCmdResult.new('out', 'err', 23)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path arguments').and_return(shell_return)
+ shell_return = ShellCmdResult.new("out", "err", 23)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path arguments").and_return(shell_return)
expect { provider.run_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'no such key'" do
- shell_return = ShellCmdResult.new("No such key: ", 'err', 23)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
+ shell_return = ShellCmdResult.new("No such key: ", "err", 23)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'eDSRecordNotFound'" do
- shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
end
@@ -197,7 +197,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
it "finds a valid, unused uid when none is specified" do
- expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('')
+ expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 501")
expect(provider).to receive(:get_free_uid).and_return(501)
provider.dscl_set_uid
@@ -207,7 +207,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "sets the uid specified in the resource" do
new_resource.uid(1000)
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 1000").and_return(true)
- expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('')
+ expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
provider.dscl_set_uid
end
end
@@ -219,7 +219,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
before do
new_resource.supports({ :manage_home => true })
- new_resource.home('/Users/toor')
+ new_resource.home("/Users/toor")
provider.current_resource = current_resource
end
@@ -232,25 +232,25 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do
- new_resource.home('epic-fail')
+ new_resource.home("epic-fail")
expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::InvalidHomeDirectory)
end
it "moves the users home to the new location if it exists and the target location is different" do
new_resource.supports(:manage_home => true)
- current_home = CHEF_SPEC_DATA + '/old_home_dir'
- current_home_files = [current_home + '/my-dot-emacs', current_home + '/my-dot-vim']
+ current_home = CHEF_SPEC_DATA + "/old_home_dir"
+ current_home_files = [current_home + "/my-dot-emacs", current_home + "/my-dot-vim"]
current_resource.home(current_home)
new_resource.gid(23)
- allow(::File).to receive(:exists?).with('/old/home/toor').and_return(true)
- allow(::File).to receive(:exists?).with('/Users/toor').and_return(true)
+ allow(::File).to receive(:exists?).with("/old/home/toor").and_return(true)
+ allow(::File).to receive(:exists?).with("/Users/toor").and_return(true)
- expect(FileUtils).to receive(:mkdir_p).with('/Users/toor').and_return(true)
+ 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(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
@@ -263,7 +263,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "should run ditto to copy any missing files from skel to the new home dir" do
expect(::File).to receive(:exists?).with("/System/Library/User\ Template/English.lproj").and_return(true)
- expect(FileUtils).to receive(:chown_R).with('toor', '', '/Users/toor')
+ expect(FileUtils).to receive(:chown_R).with("toor", "", "/Users/toor")
expect(provider).to receive(:shell_out!).with("ditto '/System/Library/User Template/English.lproj' '/Users/toor'")
provider.ditto_home
end
@@ -382,7 +382,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
expect(provider).to receive(:shell_out).with("dscacheutil '-flushcache'")
expect(provider).to receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
if user_plist_file.nil?
- ShellCmdResult.new('Can not find the file', 'Sorry!!', 1)
+ ShellCmdResult.new("Can not find the file", "Sorry!!", 1)
else
ShellCmdResult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/#{user_plist_file}.plist.xml")), "", 0)
end
@@ -656,7 +656,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
it "password_shadow_info should have salted-sha-512 format" do
shadow_info = provider.prepare_password_shadow_info
expect(shadow_info).to have_key("SALTED-SHA512")
- info = shadow_info["SALTED-SHA512"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512"].string.unpack("H*").first
expect(provider.salted_sha512?(info)).to be_truthy
end
end
@@ -667,7 +667,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
it "password_shadow_info should have salted-sha-512 format" do
shadow_info = provider.prepare_password_shadow_info
expect(shadow_info).to have_key("SALTED-SHA512")
- info = shadow_info["SALTED-SHA512"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512"].string.unpack("H*").first
expect(provider.salted_sha512?(info)).to be_truthy
expect(info).to eq(vagrant_sha_512)
end
@@ -689,7 +689,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations")
- info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first
expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy
end
end
@@ -705,7 +705,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations")
- info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first
expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy
expect(info).to eq(vagrant_sha_512_pbkdf2)
end
@@ -791,8 +791,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
end
it "should raise an exception when the group does not exist" do
- shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
- expect(provider).to receive(:shell_out).with('dscl . -read /Groups/newgroup PrimaryGroupID').and_return(shell_return)
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
+ expect(provider).to receive(:shell_out).with("dscl . -read /Groups/newgroup PrimaryGroupID").and_return(shell_return)
expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound)
end
end
@@ -814,8 +814,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
new_resource.username "mud"
new_resource.uid 2342
new_resource.gid 2342
- new_resource.home '/Users/death'
- new_resource.password 'goaway'
+ new_resource.home "/Users/death"
+ new_resource.password "goaway"
end
it "sets the user, comment field, uid, gid, moves the home directory, sets the shell, and sets the password" do
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index 6683a75f42..4b58fdc58e 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::User::Pw do
before(:each) do
@@ -48,11 +48,11 @@ describe Chef::Provider::User::Pw do
describe "setting options to the pw command" do
field_list = {
- 'comment' => "-c",
- 'home' => "-d",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
+ "comment" => "-c",
+ "home" => "-d",
+ "gid" => "-g",
+ "uid" => "-u",
+ "shell" => "-s",
}
field_list.each do |attribute, option|
it "should check for differences in #{attribute} between the new and current resources" do
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index a3c17a9a56..f3299aaf63 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -22,8 +22,8 @@
ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus)
-require 'mixlib/shellout'
-require 'spec_helper'
+require "mixlib/shellout"
+require "spec_helper"
describe Chef::Provider::User::Solaris do
@@ -73,63 +73,63 @@ describe Chef::Provider::User::Solaris do
end
end
- describe 'when managing user locked status' do
+ describe "when managing user locked status" do
before(:each) do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::User.new('dave')
+ @new_resource = Chef::Resource::User.new("dave")
@current_resource = @new_resource.dup
@provider = Chef::Provider::User::Solaris.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
end
- describe 'when determining if the user is locked' do
+ describe "when determining if the user is locked" do
# locked shadow lines
[
- 'dave:LK:::::::',
- 'dave:*LK*:::::::',
- 'dave:*LK*foobar:::::::',
- 'dave:*LK*bahamas10:::::::',
- 'dave:*LK*L....:::::::',
+ "dave:LK:::::::",
+ "dave:*LK*:::::::",
+ "dave:*LK*foobar:::::::",
+ "dave:*LK*bahamas10:::::::",
+ "dave:*LK*L....:::::::",
].each do |shadow|
it "should return true if user is locked with #{shadow}" do
- shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
- expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
+ shell_return = ShellCmdResult.new(shadow + "\n", "", 0)
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
expect(provider.check_lock).to eql(true)
end
end
# unlocked shadow lines
[
- 'dave:NP:::::::',
- 'dave:*NP*:::::::',
- 'dave:foobar:::::::',
- 'dave:bahamas10:::::::',
- 'dave:L...:::::::',
+ "dave:NP:::::::",
+ "dave:*NP*:::::::",
+ "dave:foobar:::::::",
+ "dave:bahamas10:::::::",
+ "dave:L...:::::::",
].each do |shadow|
it "should return false if user is unlocked with #{shadow}" do
- shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
- expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
+ shell_return = ShellCmdResult.new(shadow + "\n", "", 0)
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
expect(provider.check_lock).to eql(false)
end
end
end
- describe 'when locking the user' do
- it 'should run passwd -l with the new resources username' do
- shell_return = ShellCmdResult.new('', '', 0)
- expect(provider).to receive(:shell_out!).with('passwd', '-l', @new_resource.username).and_return(shell_return)
+ describe "when locking the user" do
+ it "should run passwd -l with the new resources username" do
+ shell_return = ShellCmdResult.new("", "", 0)
+ expect(provider).to receive(:shell_out!).with("passwd", "-l", @new_resource.username).and_return(shell_return)
provider.lock_user
end
end
- describe 'when unlocking the user' do
- it 'should run passwd -u with the new resources username' do
- shell_return = ShellCmdResult.new('', '', 0)
- expect(provider).to receive(:shell_out!).with('passwd', '-u', @new_resource.username).and_return(shell_return)
+ describe "when unlocking the user" do
+ it "should run passwd -u with the new resources username" do
+ shell_return = ShellCmdResult.new("", "", 0)
+ expect(provider).to receive(:shell_out!).with("passwd", "-u", @new_resource.username).and_return(shell_return)
provider.unlock_user
end
end
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index a295dff679..f8bcb13363 100644
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/provider/user/useradd'
+require "spec_helper"
+require "chef/provider/user/useradd"
describe Chef::Provider::User::Useradd do
@@ -30,11 +30,11 @@ describe Chef::Provider::User::Useradd do
end
supported_useradd_options = {
- 'comment' => "-c",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
- 'password' => "-p",
+ "comment" => "-c",
+ "gid" => "-g",
+ "uid" => "-u",
+ "shell" => "-s",
+ "password" => "-p",
}
include_examples "a useradd-based user provider", supported_useradd_options
diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb
index 7e08f971a9..7a8cb29963 100644
--- a/spec/unit/provider/user/windows_spec.rb
+++ b/spec/unit/provider/user/windows_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef
class Util
@@ -104,7 +104,7 @@ describe Chef::Provider::User::Windows do
end
it "marks the home_dir attribute to be updated" do
- expect(@provider.set_options[:home_dir]).to eq('/home/adam')
+ expect(@provider.set_options[:home_dir]).to eq("/home/adam")
end
it "ignores the primary_group_id attribute" do
@@ -116,11 +116,11 @@ describe Chef::Provider::User::Windows do
end
it "marks the script_path attribute to be updated" do
- expect(@provider.set_options[:script_path]).to eq('/usr/bin/zsh')
+ expect(@provider.set_options[:script_path]).to eq("/usr/bin/zsh")
end
it "marks the password attribute to be updated" do
- expect(@provider.set_options[:password]).to eq('abracadabra')
+ expect(@provider.set_options[:password]).to eq("abracadabra")
end
end
end
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb
index c38abcc049..043a67df1b 100644
--- a/spec/unit/provider/user_spec.rb
+++ b/spec/unit/provider/user_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
EtcPwnamIsh = Struct.new(:name, :passwd, :uid, :gid, :gecos, :dir, :shell, :change, :uclass, :expire)
EtcGrnamIsh = Struct.new(:name, :passwd, :gid, :mem)
@@ -83,7 +83,7 @@ describe Chef::Provider::User do
it "should create a current resource with the same name as the new resource" do
@provider.load_current_resource
- expect(@provider.current_resource.name).to eq('adam')
+ expect(@provider.current_resource.name).to eq("adam")
end
it "should set the username of the current resource to the username of the new resource" do
@@ -92,7 +92,7 @@ describe Chef::Provider::User do
end
it "should change the encoding of gecos to the encoding of the new resource" do
- @pw_user.gecos.force_encoding('ASCII-8BIT')
+ @pw_user.gecos.force_encoding("ASCII-8BIT")
@provider.load_current_resource
expect(@provider.current_resource.comment.encoding).to eq(@new_resource.comment.encoding)
end
@@ -141,8 +141,8 @@ describe Chef::Provider::User do
describe "and running assertions" do
def self.shadow_lib_unavail?
begin
- require 'rubygems'
- require 'shadow'
+ require "rubygems"
+ require "shadow"
rescue LoadError
skip "ruby-shadow gem not installed for dynamic load test"
true
@@ -165,7 +165,7 @@ describe Chef::Provider::User do
context "and we are root", :requires_root => true do
it "should pass assertions when ruby-shadow can be loaded" do
- @provider.action = 'create'
+ @provider.action = "create"
original_method = @provider.method(:require)
expect(@provider).to receive(:require) { |*args| original_method.call(*args) }
passwd_info = Struct::PasswdEntry.new(:sp_namp => "adm ", :sp_pwdp => "$1$T0N0Q.lc$nyG6pFI3Dpqa5cxUz/57j0", :sp_lstchg => 14861, :sp_min => 0, :sp_max => 99999,
@@ -192,13 +192,13 @@ describe Chef::Provider::User do
describe "compare_user" do
let(:mapping) {
{
- 'username' => ["adam", "Adam"],
- 'comment' => ["Adam Jacob", "adam jacob"],
- 'uid' => [1000, 1001],
- 'gid' => [1000, 1001],
- 'home' => ["/home/adam", "/Users/adam"],
- 'shell'=> ["/usr/bin/zsh", "/bin/bash"],
- 'password'=> ["abcd","12345"],
+ "username" => ["adam", "Adam"],
+ "comment" => ["Adam Jacob", "adam jacob"],
+ "uid" => [1000, 1001],
+ "gid" => [1000, 1001],
+ "home" => ["/home/adam", "/Users/adam"],
+ "shell"=> ["/usr/bin/zsh", "/bin/bash"],
+ "password"=> ["abcd","12345"],
}
}
@@ -441,8 +441,8 @@ describe Chef::Provider::User do
describe "convert_group_name" do
before do
- @new_resource.gid('999')
- @group = EtcGrnamIsh.new('wheel', '*', 999, [])
+ @new_resource.gid("999")
+ @group = EtcGrnamIsh.new("wheel", "*", 999, [])
end
it "should lookup the group name locally" do
diff --git a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
index 2a4dccdad7..6f8949bba3 100644
--- a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do
before(:each) do
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index cee097e715..16befad5ca 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/mixin/convert_to_class_name'
-require 'chef/provider_resolver'
-require 'chef/platform/service_helpers'
-require 'support/shared/integration/integration_helper'
-require 'tmpdir'
-require 'fileutils'
+require "spec_helper"
+require "chef/mixin/convert_to_class_name"
+require "chef/provider_resolver"
+require "chef/platform/service_helpers"
+require "support/shared/integration/integration_helper"
+require "tmpdir"
+require "fileutils"
include Chef::Mixin::ConvertToClassName
@@ -48,7 +48,7 @@ describe Chef::ProviderResolver do
node.automatic[:platform_family] = platform_family
node.automatic[:platform] = platform
node.automatic[:platform_version] = platform_version
- node.automatic[:kernel] = { machine: 'i386' }
+ node.automatic[:kernel] = { machine: "i386" }
node
end
let(:run_context) { Chef::RunContext.new(node, nil, nil) }
@@ -73,7 +73,7 @@ describe Chef::ProviderResolver do
end
def self.on_platform(platform, *tags,
- platform_version: '11.0.1',
+ platform_version: "11.0.1",
platform_family: nil,
os: nil,
&block)
@@ -147,17 +147,17 @@ describe Chef::ProviderResolver do
services.each do |service|
case service
when :debian
- file 'usr/sbin/update-rc.d', ''
+ file "usr/sbin/update-rc.d", ""
when :invokercd
- file 'usr/sbin/invoke-rc.d', ''
+ file "usr/sbin/invoke-rc.d", ""
when :insserv
- file 'sbin/insserv', ''
+ file "sbin/insserv", ""
when :upstart
- file 'sbin/initctl', ''
+ file "sbin/initctl", ""
when :redhat
- file 'sbin/chkconfig', ''
+ file "sbin/chkconfig", ""
when :systemd
- file 'proc/1/comm', "systemd\n"
+ file "proc/1/comm", "systemd\n"
else
raise ArgumentError, service
end
@@ -178,7 +178,7 @@ describe Chef::ProviderResolver do
when :usr_local_etc_rcd
file "usr/local/etc/rc.d/#{service_name}", ""
when :systemd
- file 'proc/1/comm', "systemd\n"
+ file "proc/1/comm", "systemd\n"
file "etc/systemd/system/#{service_name}.service", ""
else
raise ArgumentError, config
@@ -480,7 +480,7 @@ describe Chef::ProviderResolver do
end
end
- on_platform %w(freebsd netbsd), platform_version: '3.1.4' do
+ on_platform %w(freebsd netbsd), platform_version: "3.1.4" do
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
stub_service_providers
stub_service_configs(:usr_local_etc_rcd)
diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb
index 97b88b1732..dae5839d6c 100644
--- a/spec/unit/provider_spec.rb
+++ b/spec/unit/provider_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class NoWhyrunDemonstrator < Chef::Provider
diff --git a/spec/unit/pure_application_spec.rb b/spec/unit/pure_application_spec.rb
index 5d879a7b85..de9650e381 100644
--- a/spec/unit/pure_application_spec.rb
+++ b/spec/unit/pure_application_spec.rb
@@ -19,7 +19,7 @@
# be able to test only Chef::Application.
# Regression test for CHEF-5169
-require 'chef/application'
+require "chef/application"
describe "Chef::Application" do
let(:app) { Chef::Application.new }
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 34f852e2ce..d247a1bb5e 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -19,8 +19,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/platform/resource_priority_map'
+require "spec_helper"
+require "chef/platform/resource_priority_map"
describe Chef::Recipe do
diff --git a/spec/unit/resource/apt_package_spec.rb b/spec/unit/resource/apt_package_spec.rb
index 3c31f63dd7..cf425519b5 100644
--- a/spec/unit/resource/apt_package_spec.rb
+++ b/spec/unit/resource/apt_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::AptPackage, "initialize" do
diff --git a/spec/unit/resource/bash_spec.rb b/spec/unit/resource/bash_spec.rb
index f313900433..71805a44a2 100644
--- a/spec/unit/resource/bash_spec.rb
+++ b/spec/unit/resource/bash_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Bash do
diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb
index b8c2897f42..965e48d9fa 100644
--- a/spec/unit/resource/batch_spec.rb
+++ b/spec/unit/resource/batch_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Batch do
@@ -25,7 +25,7 @@ describe Chef::Resource::Batch do
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
- node.automatic[:os] = 'windows'
+ node.automatic[:os] = "windows"
run_context = Chef::RunContext.new(node, nil, nil)
@@ -41,7 +41,7 @@ describe Chef::Resource::Batch do
let(:resource_instance) { @resource }
let(:resource_instance_name ) { @resource.command }
let(:resource_name) { :batch }
- let(:interpreter_file_name) { 'cmd.exe' }
+ let(:interpreter_file_name) { "cmd.exe" }
it_should_behave_like "a Windows script resource"
end
diff --git a/spec/unit/resource/breakpoint_spec.rb b/spec/unit/resource/breakpoint_spec.rb
index 88ab34d568..63a1753a2f 100644
--- a/spec/unit/resource/breakpoint_spec.rb
+++ b/spec/unit/resource/breakpoint_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::Breakpoint do
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index df37779d1b..3e6002e4f2 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::ChefGem, "initialize" do
diff --git a/spec/unit/resource/chocolatey_package_spec.rb b/spec/unit/resource/chocolatey_package_spec.rb
index 38f1d2905c..b125279909 100644
--- a/spec/unit/resource/chocolatey_package_spec.rb
+++ b/spec/unit/resource/chocolatey_package_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::ChocolateyPackage do
diff --git a/spec/unit/resource/conditional_action_not_nothing_spec.rb b/spec/unit/resource/conditional_action_not_nothing_spec.rb
index d140615cfc..bc22ae7a47 100644
--- a/spec/unit/resource/conditional_action_not_nothing_spec.rb
+++ b/spec/unit/resource/conditional_action_not_nothing_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::ConditionalActionNotNothing do
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index 489c1136b1..7d153df24a 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Resource::Conditional do
before do
@@ -89,17 +89,17 @@ describe Chef::Resource::Conditional do
end
end
- describe 'after running a command which timed out' do
+ describe "after running a command which timed out" do
before do
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false")
allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
end
- it 'indicates that resource convergence should not continue' do
+ it "indicates that resource convergence should not continue" do
expect(@conditional.continue?).to be_falsey
end
- it 'should log a warning' do
+ it "should log a warning" do
expect(Chef::Log).to receive(:warn).with("Command 'false' timed out")
@conditional.continue?
end
@@ -169,17 +169,17 @@ describe Chef::Resource::Conditional do
end
end
- describe 'after running a command which timed out' do
+ describe "after running a command which timed out" do
before do
@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
- it 'indicates that resource convergence should continue' do
+ it "indicates that resource convergence should continue" do
expect(@conditional.continue?).to be_truthy
end
- it 'should log a warning' do
+ it "should log a warning" do
expect(Chef::Log).to receive(:warn).with("Command 'false' timed out")
@conditional.continue?
end
diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index bd437893ce..442e175f63 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -17,20 +17,20 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::CookbookFile do
before do
- @cookbook_file = Chef::Resource::CookbookFile.new('sourcecode_tarball.tgz')
+ @cookbook_file = Chef::Resource::CookbookFile.new("sourcecode_tarball.tgz")
end
it "uses the name parameter for the source parameter" do
- expect(@cookbook_file.name).to eq('sourcecode_tarball.tgz')
+ expect(@cookbook_file.name).to eq("sourcecode_tarball.tgz")
end
it "has a source parameter" do
- @cookbook_file.name('config_file.conf')
- expect(@cookbook_file.name).to eq('config_file.conf')
+ @cookbook_file.name("config_file.conf")
+ expect(@cookbook_file.name).to eq("config_file.conf")
end
it "defaults to a nil cookbook parameter (current cookbook will be used)" do
@@ -39,7 +39,7 @@ describe Chef::Resource::CookbookFile do
it "has a cookbook parameter" do
@cookbook_file.cookbook("munin")
- expect(@cookbook_file.cookbook).to eq('munin')
+ expect(@cookbook_file.cookbook).to eq("munin")
end
it "sets the provider to Chef::Provider::CookbookFile" do
diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb
index 0978be6930..1ba48641ed 100644
--- a/spec/unit/resource/cron_spec.rb
+++ b/spec/unit/resource/cron_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Cron do
diff --git a/spec/unit/resource/csh_spec.rb b/spec/unit/resource/csh_spec.rb
index 5fb3b00507..fee96eb75e 100644
--- a/spec/unit/resource/csh_spec.rb
+++ b/spec/unit/resource/csh_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Csh do
diff --git a/spec/unit/resource/deploy_revision_spec.rb b/spec/unit/resource/deploy_revision_spec.rb
index d136aa251e..45df9c3dc2 100644
--- a/spec/unit/resource/deploy_revision_spec.rb
+++ b/spec/unit/resource/deploy_revision_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::DeployRevision do
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb
index 2338e37173..c53978a127 100644
--- a/spec/unit/resource/deploy_spec.rb
+++ b/spec/unit/resource/deploy_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::Deploy do
diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb
index e9e80806db..a6d353ce06 100644
--- a/spec/unit/resource/directory_spec.rb
+++ b/spec/unit/resource/directory_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Directory do
diff --git a/spec/unit/resource/dpkg_package_spec.rb b/spec/unit/resource/dpkg_package_spec.rb
index 931e6763bd..4c35f0cb41 100644
--- a/spec/unit/resource/dpkg_package_spec.rb
+++ b/spec/unit/resource/dpkg_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::DpkgPackage, "initialize" do
@@ -26,7 +26,7 @@ describe Chef::Resource::DpkgPackage, "initialize" do
provider: Chef::Provider::Package::Dpkg,
name: :dpkg_package,
action: :install,
- os: 'linux',
+ os: "linux",
)
end
diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb
index 276aa74111..4c98442d13 100644
--- a/spec/unit/resource/dsc_resource_spec.rb
+++ b/spec/unit/resource/dsc_resource_spec.rb
@@ -15,18 +15,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::DscResource do
- let(:dsc_test_resource_name) { 'DSCTest' }
+ let(:dsc_test_resource_name) { "DSCTest" }
let(:dsc_test_property_name) { :DSCTestProperty }
- let(:dsc_test_property_value) { 'DSCTestValue' }
+ let(:dsc_test_property_value) { "DSCTestValue" }
let(:dsc_test_reboot_action) { :reboot_now }
let(:dsc_test_timeout) { 101 }
- context 'when Powershell supports Dsc' do
+ context "when Powershell supports Dsc" do
let(:dsc_test_run_context) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
+ node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
}
@@ -72,7 +72,7 @@ describe Chef::Resource::DscResource do
it "raises a TypeError if property_name is not a symbol" do
expect{
- dsc_test_resource.property('Foo', dsc_test_property_value)
+ dsc_test_resource.property("Foo", dsc_test_property_value)
}.to raise_error(TypeError)
end
@@ -87,7 +87,7 @@ describe Chef::Resource::DscResource do
end
end
- context 'Powershell DSL methods' do
+ context "Powershell DSL methods" do
it "responds to :ps_credential" do
expect(dsc_test_resource.respond_to?(:ps_credential)).to be true
end
diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb
index 1fa865a2d5..3afa46dd48 100644
--- a/spec/unit/resource/dsc_script_spec.rb
+++ b/spec/unit/resource/dsc_script_spec.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::DscScript do
- let(:dsc_test_resource_name) { 'DSCTest' }
+ let(:dsc_test_resource_name) { "DSCTest" }
- context 'when Powershell supports Dsc' do
+ context "when Powershell supports Dsc" do
let(:dsc_test_run_context) {
node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = '4.0'
+ node.automatic[:languages][:powershell][:version] = "4.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
}
@@ -32,10 +32,10 @@ describe Chef::Resource::DscScript do
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_name) { 'formatme' }
+ 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' }
+ let(:configuration_data_script) { "c:/myconfigs/data/safedata.psd1" }
it "has a default action of `:run`" do
expect(dsc_test_resource.action).to eq([:run])
@@ -75,9 +75,9 @@ describe Chef::Resource::DscScript do
end
context "when calling imports" do
- let(:module_name) { 'FooModule' }
- let(:module_name_b) { 'BarModule' }
- let(:dsc_resources) { ['ResourceA', 'ResourceB'] }
+ let(:module_name) { "FooModule" }
+ let(:module_name_b) { "BarModule" }
+ let(:dsc_resources) { ["ResourceA", "ResourceB"] }
it "allows an arbitrary number of resources to be set for a module to be set" do
dsc_test_resource.imports module_name, *dsc_resources
@@ -88,7 +88,7 @@ describe Chef::Resource::DscScript do
it "adds * to the imports when no resources are set for a moudle" do
dsc_test_resource.imports module_name
module_imports = dsc_test_resource.imports[module_name]
- expect(module_imports).to eq(['*'])
+ expect(module_imports).to eq(["*"])
end
it "allows an arbitrary number of modules" do
diff --git a/spec/unit/resource/easy_install_package_spec.rb b/spec/unit/resource/easy_install_package_spec.rb
index c68b026b39..52e0e91994 100644
--- a/spec/unit/resource/easy_install_package_spec.rb
+++ b/spec/unit/resource/easy_install_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::EasyInstallPackage, "initialize" do
diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb
index 60e85ac31e..8a10ca7e81 100644
--- a/spec/unit/resource/env_spec.rb
+++ b/spec/unit/resource/env_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Env do
diff --git a/spec/unit/resource/erl_call_spec.rb b/spec/unit/resource/erl_call_spec.rb
index 9abf2e7812..7cdb5bda16 100644
--- a/spec/unit/resource/erl_call_spec.rb
+++ b/spec/unit/resource/erl_call_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::ErlCall do
diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb
index 09160ddbd0..493508f08b 100644
--- a/spec/unit/resource/execute_spec.rb
+++ b/spec/unit/resource/execute_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Execute do
let(:resource_instance_name) { "some command" }
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index 6b929789c8..30956c04ba 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::File::Verification do
let(:t_block) { Proc.new { true } }
@@ -82,27 +82,27 @@ describe Chef::Resource::File::Verification do
end
it "substitutes \%{file} with the path" do
- test_command = platform_specific_verify_command('file')
+ test_command = platform_specific_verify_command("file")
v = Chef::Resource::File::Verification.new(parent_resource, test_command, {})
expect(v.verify(temp_path)).to eq(true)
end
it "warns about deprecation when \%{file} is used" do
expect(Chef::Log).to receive(:deprecation).with(/%{file} is deprecated/, /verification_spec\.rb/)
- test_command = platform_specific_verify_command('file')
+ test_command = platform_specific_verify_command("file")
Chef::Resource::File::Verification.new(parent_resource, test_command, {})
.verify(temp_path)
end
it "does not warn about deprecation when \%{file} is not used" do
expect(Chef::Log).to_not receive(:deprecation)
- test_command = platform_specific_verify_command('path')
+ test_command = platform_specific_verify_command("path")
Chef::Resource::File::Verification.new(parent_resource, test_command, {})
.verify(temp_path)
end
it "substitutes \%{path} with the path" do
- test_command = platform_specific_verify_command('path')
+ test_command = platform_specific_verify_command("path")
v = Chef::Resource::File::Verification.new(parent_resource, test_command, {})
expect(v.verify(temp_path)).to eq(true)
end
diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb
index 76beaf15e1..3dec8145a4 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::File do
diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb
index 7263d3a7ba..5c9c613771 100644
--- a/spec/unit/resource/freebsd_package_spec.rb
+++ b/spec/unit/resource/freebsd_package_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Resource::FreebsdPackage do
before(:each) do
@@ -48,7 +48,7 @@ describe Chef::Resource::FreebsdPackage do
describe "Assigning provider after creation" do
describe "if ports specified as source" do
it "should be Freebsd::Port" do
- @resource.source('ports')
+ @resource.source("ports")
@resource.after_created
expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Port)
end
diff --git a/spec/unit/resource/gem_package_spec.rb b/spec/unit/resource/gem_package_spec.rb
index 0f3eae70bb..6992d8ef17 100644
--- a/spec/unit/resource/gem_package_spec.rb
+++ b/spec/unit/resource/gem_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::GemPackage, "initialize" do
diff --git a/spec/unit/resource/git_spec.rb b/spec/unit/resource/git_spec.rb
index 6a39b3d172..5bdccc87b8 100644
--- a/spec/unit/resource/git_spec.rb
+++ b/spec/unit/resource/git_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::Git do
diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb
index a4029fc911..56db882191 100644
--- a/spec/unit/resource/group_spec.rb
+++ b/spec/unit/resource/group_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Group, "initialize" do
before(:each) do
diff --git a/spec/unit/resource/homebrew_package_spec.rb b/spec/unit/resource/homebrew_package_spec.rb
index bb248d1189..6a3f88ceed 100644
--- a/spec/unit/resource/homebrew_package_spec.rb
+++ b/spec/unit/resource/homebrew_package_spec.rb
@@ -15,10 +15,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
-describe Chef::Resource::HomebrewPackage, 'initialize' do
+describe Chef::Resource::HomebrewPackage, "initialize" do
static_provider_resolution(
resource: Chef::Resource::HomebrewPackage,
@@ -28,22 +28,22 @@ describe Chef::Resource::HomebrewPackage, 'initialize' do
os: "mac_os_x",
)
- let(:resource) { Chef::Resource::HomebrewPackage.new('emacs') }
+ let(:resource) { Chef::Resource::HomebrewPackage.new("emacs") }
- shared_examples 'home_brew user set and returned' do
- it 'returns the configured homebrew_user' do
+ shared_examples "home_brew user set and returned" do
+ it "returns the configured homebrew_user" do
resource.homebrew_user user
expect(resource.homebrew_user).to eql(user)
end
end
- context 'homebrew_user is set' do
- let(:user) { 'Captain Picard' }
- include_examples 'home_brew user set and returned'
+ context "homebrew_user is set" do
+ let(:user) { "Captain Picard" }
+ include_examples "home_brew user set and returned"
- context 'as an integer' do
+ context "as an integer" do
let(:user) { 1001 }
- include_examples 'home_brew user set and returned'
+ include_examples "home_brew user set and returned"
end
end
diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb
index aa4ce4dfbc..d8461854f9 100644
--- a/spec/unit/resource/http_request_spec.rb
+++ b/spec/unit/resource/http_request_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::HttpRequest do
diff --git a/spec/unit/resource/ifconfig_spec.rb b/spec/unit/resource/ifconfig_spec.rb
index e3e1f6daa2..9d775e7257 100644
--- a/spec/unit/resource/ifconfig_spec.rb
+++ b/spec/unit/resource/ifconfig_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Ifconfig do
@@ -49,8 +49,8 @@ describe Chef::Resource::Ifconfig do
shared_examples "being a platform based on an old Debian" do |platform, version|
before do
- @node.automatic_attrs[:os] = 'linux'
- @node.automatic_attrs[:platform_family] = 'debian'
+ @node.automatic_attrs[:os] = "linux"
+ @node.automatic_attrs[:platform_family] = "debian"
@node.automatic_attrs[:platform] = platform
@node.automatic_attrs[:platform_version] = version
end
@@ -62,8 +62,8 @@ describe Chef::Resource::Ifconfig do
shared_examples "being a platform based on RedHat" do |platform, version|
before do
- @node.automatic_attrs[:os] = 'linux'
- @node.automatic_attrs[:platform_family] = 'rhel'
+ @node.automatic_attrs[:os] = "linux"
+ @node.automatic_attrs[:platform_family] = "rhel"
@node.automatic_attrs[:platform] = platform
@node.automatic_attrs[:platform_version] = version
end
@@ -75,8 +75,8 @@ describe Chef::Resource::Ifconfig do
shared_examples "being a platform based on a recent Debian" do |platform, version|
before do
- @node.automatic_attrs[:os] = 'linux'
- @node.automatic_attrs[:platform_family] = 'debian'
+ @node.automatic_attrs[:os] = "linux"
+ @node.automatic_attrs[:platform_family] = "debian"
@node.automatic_attrs[:platform] = platform
@node.automatic_attrs[:platform_version] = version
end
diff --git a/spec/unit/resource/ips_package_spec.rb b/spec/unit/resource/ips_package_spec.rb
index 126ae00224..0725380620 100644
--- a/spec/unit/resource/ips_package_spec.rb
+++ b/spec/unit/resource/ips_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::IpsPackage, "initialize" do
diff --git a/spec/unit/resource/ksh_spec.rb b/spec/unit/resource/ksh_spec.rb
index 04bd8148fd..a188ed9802 100644
--- a/spec/unit/resource/ksh_spec.rb
+++ b/spec/unit/resource/ksh_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Ksh do
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index 220ad735bd..0ce5be1caf 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Link do
diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb
index b2af194238..d6169ae315 100644
--- a/spec/unit/resource/log_spec.rb
+++ b/spec/unit/resource/log_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Log do
diff --git a/spec/unit/resource/macports_package_spec.rb b/spec/unit/resource/macports_package_spec.rb
index 0a203b2e97..488615f594 100644
--- a/spec/unit/resource/macports_package_spec.rb
+++ b/spec/unit/resource/macports_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::MacportsPackage, "initialize" do
diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb
index 6ca99c58e5..f2d0e157af 100644
--- a/spec/unit/resource/mdadm_spec.rb
+++ b/spec/unit/resource/mdadm_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Mdadm do
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index acce26dcab..1dac2d5dd9 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Mount do
before(:each) do
@@ -54,7 +54,7 @@ describe Chef::Resource::Mount do
end
it "should set fsck_device to '-' by default" do
- expect(@resource.fsck_device).to eql('-')
+ expect(@resource.fsck_device).to eql("-")
end
it "should allow you to set the fsck_device attribute" do
diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb
index 3bc21a41d2..0bf904ab0c 100644
--- a/spec/unit/resource/ohai_spec.rb
+++ b/spec/unit/resource/ohai_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Ohai do
diff --git a/spec/unit/resource/openbsd_package_spec.rb b/spec/unit/resource/openbsd_package_spec.rb
index 95921c2f02..34de97f931 100644
--- a/spec/unit/resource/openbsd_package_spec.rb
+++ b/spec/unit/resource/openbsd_package_spec.rb
@@ -19,8 +19,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Resource::OpenbsdPackage do
diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb
index d7d72e5836..06a147ad84 100644
--- a/spec/unit/resource/osx_profile_spec.rb
+++ b/spec/unit/resource/osx_profile_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::OsxProfile do
let(:resource) { Chef::Resource::OsxProfile.new(
@@ -54,7 +54,7 @@ describe Chef::Resource::OsxProfile do
end
it "should allow you to set the profile attribute to a hash" do
- test_profile = { 'profile' => false }
+ test_profile = { "profile" => false }
resource.profile test_profile
expect(resource.profile).to be_a(Hash)
end
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index 449732a3c4..7f7a27e2b2 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Package do
diff --git a/spec/unit/resource/pacman_package_spec.rb b/spec/unit/resource/pacman_package_spec.rb
index 975863d04f..a383601d93 100644
--- a/spec/unit/resource/pacman_package_spec.rb
+++ b/spec/unit/resource/pacman_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::PacmanPackage, "initialize" do
diff --git a/spec/unit/resource/perl_spec.rb b/spec/unit/resource/perl_spec.rb
index 7247cce6e3..9a1ec22a95 100644
--- a/spec/unit/resource/perl_spec.rb
+++ b/spec/unit/resource/perl_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Perl do
diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb
index 42fcd61a58..16d2d37c9e 100644
--- a/spec/unit/resource/powershell_script_spec.rb
+++ b/spec/unit/resource/powershell_script_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::PowershellScript do
@@ -25,7 +25,7 @@ describe Chef::Resource::PowershellScript do
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
- node.automatic[:os] = 'windows'
+ node.automatic[:os] = "windows"
run_context = Chef::RunContext.new(node, nil, nil)
@@ -94,7 +94,7 @@ describe Chef::Resource::PowershellScript do
it "enables convert_boolean_return by default for guards in non-Chef::Resource::Script derived resources when no guard params are specified" do
node = Chef::Node.new
run_context = Chef::RunContext.new(node, nil, nil)
- file_resource = Chef::Resource::File.new('idontexist', run_context)
+ file_resource = Chef::Resource::File.new("idontexist", run_context)
file_resource.guard_interpreter :powershell_script
allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with(
@@ -103,21 +103,21 @@ describe Chef::Resource::PowershellScript do
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 {})
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 {})
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}
+ 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 {})
@@ -129,7 +129,7 @@ describe Chef::Resource::PowershellScript do
let(:resource_instance) { @resource }
let(:resource_instance_name ) { @resource.command }
let(:resource_name) { :powershell_script }
- let(:interpreter_file_name) { 'powershell.exe' }
+ let(:interpreter_file_name) { "powershell.exe" }
it_behaves_like "a Windows script resource"
end
diff --git a/spec/unit/resource/python_spec.rb b/spec/unit/resource/python_spec.rb
index 8a3f7e48ca..a579eacdff 100644
--- a/spec/unit/resource/python_spec.rb
+++ b/spec/unit/resource/python_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Python do
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index 2d82f1a51c..05a0f5ce83 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::RegistryKey, "initialize" do
before(:each) do
@@ -80,38 +80,38 @@ describe Chef::Resource::RegistryKey, "values" do
end
it "should allow a single proper hash of registry values" do
- @resource.values( { :name => 'poosh', :type => :string, :data => 'carmen' } )
- expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
+ @resource.values( { :name => "poosh", :type => :string, :data => "carmen" } )
+ expect(@resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
end
it "should allow an array of proper hashes of registry values" do
- @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen' } ]
- expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
+ @resource.values [ { :name => "poosh", :type => :string, :data => "carmen" } ]
+ expect(@resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
end
it "should return checksummed data if the type is unsafe" do
- @resource.values( { :name => 'poosh', :type => :binary, :data => 255.chr * 1 })
- expect(@resource.values).to eql([ { :name => 'poosh', :type => :binary, :data => 'a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89' } ])
+ @resource.values( { :name => "poosh", :type => :binary, :data => 255.chr * 1 })
+ expect(@resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ])
end
it "should throw an exception if the name field is missing" do
- expect { @resource.values [ { :type => :string, :data => 'carmen' } ] }.to raise_error(ArgumentError)
+ expect { @resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if the type field is missing" do
- expect { @resource.values [ { :name => 'poosh', :data => 'carmen' } ] }.to raise_error(ArgumentError)
+ expect { @resource.values [ { :name => "poosh", :data => "carmen" } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if the data field is missing" do
- expect { @resource.values [ { :name => 'poosh', :type => :string } ] }.to raise_error(ArgumentError)
+ expect { @resource.values [ { :name => "poosh", :type => :string } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if extra fields are present" do
- expect { @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen', :screwdriver => 'sonic' } ] }.to raise_error(ArgumentError)
+ expect { @resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError)
end
it "should not allow a string" do
- expect { @resource.send(:values, 'souffle') }.to raise_error(ArgumentError)
+ expect { @resource.send(:values, "souffle") }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
@@ -138,7 +138,7 @@ describe Chef::Resource::RegistryKey, "recursive" do
end
it "should not allow a string" do
- expect { @resource.recursive('souffle') }.to raise_error(ArgumentError)
+ expect { @resource.recursive("souffle") }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
@@ -167,7 +167,7 @@ describe Chef::Resource::RegistryKey, "architecture" do
end
it "should not allow a string" do
- expect { @resource.architecture('souffle') }.to raise_error(ArgumentError)
+ expect { @resource.architecture("souffle") }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
@@ -181,7 +181,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
end
it "should return unsafe data as-is" do
- key_values = [ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ]
+ key_values = [ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]
@resource.values(key_values)
expect(@resource.unscrubbed_values).to eql(key_values)
end
@@ -193,7 +193,7 @@ describe Chef::Resource::RegistryKey, "state" do
end
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'}] } )
+ @resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ])
+ expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89"}] } )
end
end
diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb
index 1ab75586b6..ac0cfcf8d5 100644
--- a/spec/unit/resource/remote_directory_spec.rb
+++ b/spec/unit/resource/remote_directory_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::RemoteDirectory do
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 0a379ff574..746cdb195c 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::RemoteFile do
@@ -36,13 +36,13 @@ describe Chef::Resource::RemoteFile do
it "says its provider is RemoteFile when the source is an absolute URI" do
@resource.source("http://www.google.com/robots.txt")
expect(@resource.provider).to eq(Chef::Provider::RemoteFile)
- expect(Chef::Platform.find_provider(:noplatform, 'noversion', @resource)).to eq(Chef::Provider::RemoteFile)
+ expect(Chef::Platform.find_provider(:noplatform, "noversion", @resource)).to eq(Chef::Provider::RemoteFile)
end
it "says its provider is RemoteFile when the source is a network share" do
@resource.source("\\\\fakey\\fakerton\\fake.txt")
expect(@resource.provider).to eq(Chef::Provider::RemoteFile)
- expect(Chef::Platform.find_provider(:noplatform, 'noversion', @resource)).to eq(Chef::Provider::RemoteFile)
+ expect(Chef::Platform.find_provider(:noplatform, "noversion", @resource)).to eq(Chef::Provider::RemoteFile)
end
describe "source" do
@@ -60,7 +60,7 @@ describe Chef::Resource::RemoteFile do
expect(@resource.source).to eql([ "\\\\fakey\\fakerton\\fake.txt" ])
end
- it 'should accept file URIs with spaces' do
+ it "should accept file URIs with spaces" do
@resource.source("file:///C:/foo bar")
expect(@resource.source).to eql(["file:///C:/foo bar"])
end
diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb
index 024b6f93f7..dfe5d25cec 100644
--- a/spec/unit/resource/resource_notification_spec.rb
+++ b/spec/unit/resource/resource_notification_spec.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/resource/resource_notification'
+require "spec_helper"
+require "chef/resource/resource_notification"
describe Chef::Resource::Notification do
diff --git a/spec/unit/resource/route_spec.rb b/spec/unit/resource/route_spec.rb
index ec1d369932..b38093887b 100644
--- a/spec/unit/resource/route_spec.rb
+++ b/spec/unit/resource/route_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Route do
diff --git a/spec/unit/resource/rpm_package_spec.rb b/spec/unit/resource/rpm_package_spec.rb
index b2e06f7f68..69412a8d06 100644
--- a/spec/unit/resource/rpm_package_spec.rb
+++ b/spec/unit/resource/rpm_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::RpmPackage, "initialize" do
diff --git a/spec/unit/resource/ruby_block_spec.rb b/spec/unit/resource/ruby_block_spec.rb
index 8664564ac5..d48fd9113c 100644
--- a/spec/unit/resource/ruby_block_spec.rb
+++ b/spec/unit/resource/ruby_block_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::RubyBlock do
diff --git a/spec/unit/resource/ruby_spec.rb b/spec/unit/resource/ruby_spec.rb
index e899810ab9..95078011ee 100644
--- a/spec/unit/resource/ruby_spec.rb
+++ b/spec/unit/resource/ruby_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Ruby do
diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb
index 72319277ab..fadc9a3e54 100644
--- a/spec/unit/resource/scm_spec.rb
+++ b/spec/unit/resource/scm_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Scm 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/script_spec.rb b/spec/unit/resource/script_spec.rb
index 4affee8e8c..45ad1e6cec 100644
--- a/spec/unit/resource/script_spec.rb
+++ b/spec/unit/resource/script_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Script do
let(:resource_instance_name) { "fakey_fakerton" }
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index b9e3757255..16288d7a90 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Service do
diff --git a/spec/unit/resource/smartos_package_spec.rb b/spec/unit/resource/smartos_package_spec.rb
index c2cf546dd5..24e65e6c3c 100644
--- a/spec/unit/resource/smartos_package_spec.rb
+++ b/spec/unit/resource/smartos_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::SmartosPackage, "initialize" do
diff --git a/spec/unit/resource/solaris_package_spec.rb b/spec/unit/resource/solaris_package_spec.rb
index f5d3e669a1..a97730aea6 100644
--- a/spec/unit/resource/solaris_package_spec.rb
+++ b/spec/unit/resource/solaris_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::SolarisPackage, "initialize" do
diff --git a/spec/unit/resource/subversion_spec.rb b/spec/unit/resource/subversion_spec.rb
index aa4d1ed708..b2d3689dc9 100644
--- a/spec/unit/resource/subversion_spec.rb
+++ b/spec/unit/resource/subversion_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::Subversion do
@@ -42,7 +42,7 @@ describe Chef::Resource::Subversion do
end
it "sets svn info arguments to --no-auth-cache by default" do
- expect(@svn.svn_info_args).to eq('--no-auth-cache')
+ expect(@svn.svn_info_args).to eq("--no-auth-cache")
end
it "resets svn info arguments to nil when given false in the setter" do
@@ -51,7 +51,7 @@ describe Chef::Resource::Subversion do
end
it "sets svn arguments to --no-auth-cache by default" do
- expect(@svn.svn_arguments).to eq('--no-auth-cache')
+ expect(@svn.svn_arguments).to eq("--no-auth-cache")
end
it "sets svn binary to nil by default" do
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 2fd951b72d..2e7c1781d1 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Template do
diff --git a/spec/unit/resource/timestamped_deploy_spec.rb b/spec/unit/resource/timestamped_deploy_spec.rb
index 4ebfdaf059..851cbf4f35 100644
--- a/spec/unit/resource/timestamped_deploy_spec.rb
+++ b/spec/unit/resource/timestamped_deploy_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::TimestampedDeploy, "initialize" do
@@ -25,8 +25,8 @@ describe Chef::Resource::TimestampedDeploy, "initialize" do
provider: Chef::Provider::Deploy::Timestamped,
name: :timestamped_deploy,
action: :deploy,
- os: 'linux',
- platform_family: 'rhel',
+ os: "linux",
+ platform_family: "rhel",
)
end
diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb
index 3bf7e6187b..e259653120 100644
--- a/spec/unit/resource/user_spec.rb
+++ b/spec/unit/resource/user_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::User, "initialize" do
before(:each) do
diff --git a/spec/unit/resource/windows_package_spec.rb b/spec/unit/resource/windows_package_spec.rb
index 3623c24e29..ba336a4afd 100644
--- a/spec/unit/resource/windows_package_spec.rb
+++ b/spec/unit/resource/windows_package_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::WindowsPackage, "initialize" do
before(:each) do
@@ -80,12 +80,12 @@ describe Chef::Resource::WindowsPackage, "initialize" do
end
it "supports the checksum attribute" do
- resource.checksum('somechecksum')
- expect(resource.checksum).to eq('somechecksum')
+ resource.checksum("somechecksum")
+ expect(resource.checksum).to eq("somechecksum")
end
- context 'when a URL is used' do
- let(:resource_source) { 'https://foo.bar/solitare.msi' }
+ context "when a URL is used" do
+ let(:resource_source) { "https://foo.bar/solitare.msi" }
let(:resource) { Chef::Resource::WindowsPackage.new(resource_source) }
it "should return the source unmodified" do
diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb
index 64bb05afc4..04a27090a5 100644
--- a/spec/unit/resource/windows_service_spec.rb
+++ b/spec/unit/resource/windows_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::WindowsService, "initialize" do
static_provider_resolution(
diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb
index f24f1e3405..4c175bb905 100644
--- a/spec/unit/resource/yum_package_spec.rb
+++ b/spec/unit/resource/yum_package_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/shared/unit/resource/static_provider_resolution'
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
describe Chef::Resource::YumPackage, "initialize" do
@@ -26,8 +26,8 @@ describe Chef::Resource::YumPackage, "initialize" do
provider: Chef::Provider::Package::Yum,
name: :yum_package,
action: :install,
- os: 'linux',
- platform_family: 'rhel',
+ os: "linux",
+ platform_family: "rhel",
)
end
diff --git a/spec/unit/resource_collection/resource_list_spec.rb b/spec/unit/resource_collection/resource_list_spec.rb
index 1e6c477854..a9f30f8bac 100644
--- a/spec/unit/resource_collection/resource_list_spec.rb
+++ b/spec/unit/resource_collection/resource_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::ResourceCollection::ResourceList do
let(:resource_list) { Chef::ResourceCollection::ResourceList.new() }
diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb
index 0e25934216..a5f26dd4f9 100644
--- a/spec/unit/resource_collection/resource_set_spec.rb
+++ b/spec/unit/resource_collection/resource_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::ResourceCollection::ResourceSet do
let(:collection) { Chef::ResourceCollection::ResourceSet.new }
diff --git a/spec/unit/resource_collection/stepable_iterator_spec.rb b/spec/unit/resource_collection/stepable_iterator_spec.rb
index b34b7140fe..c81139fecb 100644
--- a/spec/unit/resource_collection/stepable_iterator_spec.rb
+++ b/spec/unit/resource_collection/stepable_iterator_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::ResourceCollection::StepableIterator do
CRSI = Chef::ResourceCollection::StepableIterator
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index d52e7e2c26..ff7e111956 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::ResourceCollection do
let(:rc) { Chef::ResourceCollection.new() }
@@ -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
diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb
index 1371a8b9a6..cd4a29bd47 100644
--- a/spec/unit/resource_definition_spec.rb
+++ b/spec/unit/resource_definition_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::ResourceDefinition do
let(:defn) { Chef::ResourceDefinition.new() }
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 34d4b23106..aa162fd161 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -20,8 +20,8 @@
#
require File.expand_path("../../spec_helper", __FILE__)
-require 'chef/resource_reporter'
-require 'socket'
+require "chef/resource_reporter"
+require "socket"
describe Chef::ResourceReporter do
before(:all) do
@@ -51,7 +51,7 @@ describe Chef::ResourceReporter do
@run_context = Chef::RunContext.new(@node, {}, @events)
@run_status = Chef::RunStatus.new(@node, @events)
@run_list = Chef::RunList.new
- @run_list << 'recipe[lobster]' << 'role[rage]' << 'recipe[fist]'
+ @run_list << "recipe[lobster]" << "role[rage]" << "recipe[fist]"
@expansion = Chef::RunList::RunListExpansion.new("_default", @run_list.run_list_items)
@run_id = @run_status.run_id
allow(Time).to receive(:now).and_return(@start_time, @end_time)
@@ -446,7 +446,7 @@ describe Chef::ResourceReporter do
context "when the resource is a RegistryKey with binary data" do
let(:new_resource) do
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
- resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ])
+ resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ])
allow(resource).to receive(:cookbook_name).and_return(@cookbook_name)
allow(resource).to receive(:cookbook_version).and_return(@cookbook_version)
resource
@@ -454,7 +454,7 @@ describe Chef::ResourceReporter do
let(:current_resource) do
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
- resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ])
+ resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ])
resource
end
@@ -568,12 +568,12 @@ describe Chef::ResourceReporter do
it "sets before to {} instead of nil" do
expect(@first_update_report).to have_key("before")
- expect(@first_update_report['before']).to eq({})
+ expect(@first_update_report["before"]).to eq({})
end
it "sets after to {} instead of 'Running'" do
expect(@first_update_report).to have_key("after")
- expect(@first_update_report['after']).to eq({})
+ expect(@first_update_report["after"]).to eq({})
end
end
@@ -593,7 +593,7 @@ describe Chef::ResourceReporter do
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}).
+ {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
and_raise(@error)
end
@@ -622,7 +622,7 @@ describe Chef::ResourceReporter do
@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}).
+ {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
and_raise(@error)
end
@@ -652,7 +652,7 @@ describe Chef::ResourceReporter do
@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}).
+ {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
and_raise(@error)
end
@@ -673,7 +673,7 @@ describe Chef::ResourceReporter do
response = {"uri"=>"https://example.com/reports/nodes/spitfire/runs/@run_id"}
expect(@rest_client).to receive(:post).
with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s},
- {'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION}).
+ {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}).
and_return(response)
@resource_reporter.run_started(@run_status)
end
@@ -695,8 +695,8 @@ describe Chef::ResourceReporter do
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 b3bda9d945..05ee79144e 100644
--- a/spec/unit/resource_resolver_spec.rb
+++ b/spec/unit/resource_resolver_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/resource_resolver'
+require "spec_helper"
+require "chef/resource_resolver"
describe Chef::ResourceResolver do
@@ -29,9 +29,9 @@ describe Chef::ResourceResolver do
expect(described_class.list(:package)).to_not be_empty
end
- context 'instance methods' do
+ context "instance methods" do
let(:resolver) do
- described_class.new(Chef::Node.new, 'execute')
+ described_class.new(Chef::Node.new, "execute")
end
it '#resolve' do
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 82d224e810..53d546d059 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -19,10 +19,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource do
- let(:cookbook_repo_path) { File.join(CHEF_SPEC_DATA, 'cookbooks') }
+ let(:cookbook_repo_path) { File.join(CHEF_SPEC_DATA, "cookbooks") }
let(:cookbook_collection) { Chef::CookbookCollection.new(Chef::CookbookLoader.new(cookbook_repo_path)) }
let(:node) { Chef::Node.new }
let(:events) { Chef::EventDispatch::Dispatcher.new }
@@ -205,7 +205,7 @@ describe Chef::Resource do
end
it "coerces arrays to names" do
- expect(resource.name ['a', 'b']).to eql('a, b')
+ expect(resource.name ["a", "b"]).to eql("a, b")
end
it "should coerce objects to a string" do
@@ -252,13 +252,13 @@ describe Chef::Resource do
end
it "creates a notification for a resource that is not yet in the resource collection" do
- resource.notifies(:restart, :service => 'apache')
+ resource.notifies(:restart, :service => "apache")
expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource)
expect(resource.delayed_notifications).to include(expected_notification)
end
it "notifies another resource immediately" do
- resource.notifies_immediately(:restart, :service => 'apache')
+ resource.notifies_immediately(:restart, :service => "apache")
expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource)
expect(resource.immediate_notifications).to include(expected_notification)
end
@@ -340,7 +340,7 @@ describe Chef::Resource do
c = Class.new(Chef::Resource) do
end
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to be_nil
expect(r.resource_name).to be_nil
@@ -355,7 +355,7 @@ describe Chef::Resource do
end
end
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to be_nil
expect(r.resource_name).to eq :blah
@@ -369,7 +369,7 @@ describe Chef::Resource do
end
end
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to be_nil
expect(r.resource_name).to be_nil
@@ -379,10 +379,10 @@ describe Chef::Resource do
it "resource_name without provides is honored" do
c = Class.new(Chef::Resource) do
- resource_name 'blah'
+ resource_name "blah"
end
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to eq :blah
expect(r.resource_name).to eq :blah
@@ -394,7 +394,7 @@ describe Chef::Resource do
end
c.resource_name = :blah
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to eq :blah
expect(r.resource_name).to eq :blah
@@ -406,7 +406,7 @@ describe Chef::Resource do
provides :self_resource_name_test_3
end
- r = c.new('hi')
+ r = c.new("hi")
r.declared_type = :d
expect(c.resource_name).to eq :blah
expect(r.resource_name).to eq :blah
@@ -512,7 +512,7 @@ describe Chef::Resource do
before do
node.automatic_attrs[:platform] = "fubuntu"
- node.automatic_attrs[:platform_version] = '10.04'
+ node.automatic_attrs[:platform_version] = "10.04"
end
it "should default to not retrying if a provider fails for a resource" do
@@ -614,7 +614,7 @@ describe Chef::Resource do
}
before do
node.automatic_attrs[:platform] = "fubuntu"
- node.automatic_attrs[:platform_version] = '10.04'
+ node.automatic_attrs[:platform_version] = "10.04"
end
it "does not run only_if if no only_if command is given" do
@@ -643,8 +643,8 @@ 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'})
+ resource.only_if("true", :cwd => "/tmp")
+ expect(resource.only_if.first.command_opts).to eq({:cwd => "/tmp"})
resource.run_action(:purr)
end
@@ -656,7 +656,7 @@ describe Chef::Resource do
it "runs not_if as a block when it is a ruby block" do
expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_block).at_least(1).times
- resource.not_if { puts 'foo' }
+ resource.not_if { puts "foo" }
resource.run_action(:purr)
end
@@ -667,8 +667,8 @@ describe Chef::Resource do
end
it "accepts command options for not_if conditionals" do
- resource.not_if("pwd" , :cwd => '/tmp')
- expect(resource.not_if.first.command_opts).to eq({:cwd => '/tmp'})
+ resource.not_if("pwd" , :cwd => "/tmp")
+ expect(resource.not_if.first.command_opts).to eq({:cwd => "/tmp"})
end
it "accepts multiple not_if conditionals" do
@@ -698,7 +698,7 @@ describe Chef::Resource do
end
it "should raise Chef::Exceptions::ValidationFailed on an attempt to set the guard_interpreter attribute to something other than a Symbol" do
- expect { resource.guard_interpreter('command_dot_com') }.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { resource.guard_interpreter("command_dot_com") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should not raise an exception when setting the guard interpreter attribute to a Symbol" do
@@ -804,7 +804,7 @@ describe Chef::Resource do
}
before do
node.automatic_attrs[:platform] = "fubuntu"
- node.automatic_attrs[:platform_version] = '10.04'
+ node.automatic_attrs[:platform_version] = "10.04"
end
it "should not run only_if/not_if conditionals (CHEF-972)" do
@@ -850,21 +850,21 @@ describe Chef::Resource do
Chef::Resource.send(:remove_const, :Klz)
end
- it 'adds mappings for a single platform' do
+ it "adds mappings for a single platform" do
expect(Chef.resource_handler_map).to receive(:set).with(
- :dinobot, Chef::Resource::Klz, { platform: ['autobots'] }
+ :dinobot, Chef::Resource::Klz, { platform: ["autobots"] }
)
- klz.provides :dinobot, platform: ['autobots']
+ klz.provides :dinobot, platform: ["autobots"]
end
- it 'adds mappings for multiple platforms' 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']
+ klz.provides :energy, platform: ["autobots", "decepticons"]
end
- it 'adds mappings for all platforms' do
+ it "adds mappings for all platforms" do
expect(Chef.resource_handler_map).to receive(:set).with(
:tape_deck, Chef::Resource::Klz, {}
)
@@ -883,7 +883,7 @@ describe Chef::Resource do
node.name("bumblebee")
node.automatic[:platform] = "autobots"
node.automatic[:platform_version] = "6.1"
- Object.const_set('Soundwave', klz1)
+ Object.const_set("Soundwave", klz1)
klz1.provides :soundwave
end
@@ -905,8 +905,8 @@ describe Chef::Resource do
node.name("bumblebee")
node.automatic[:platform] = "autobots"
node.automatic[:platform_version] = "6.1"
- klz2.provides :dinobot, :platform => ['autobots']
- Object.const_set('Grimlock', klz2)
+ klz2.provides :dinobot, :platform => ["autobots"]
+ Object.const_set("Grimlock", klz2)
klz2.provides :grimlock
end
@@ -1019,7 +1019,7 @@ describe Chef::Resource do
allowed_actions(%i{one two})
end
end
- let(:resource) { resource_class.new('test', nil) }
+ let(:resource) { resource_class.new("test", nil) }
subject { resource.action }
context "with a no action" do
@@ -1041,7 +1041,7 @@ describe Chef::Resource do
end
context "with a string action" do
- before { resource.action('two') }
+ before { resource.action("two") }
it { is_expected.to eq [:two] }
end
@@ -1089,7 +1089,7 @@ describe Chef::Resource do
end
context "with a string default action" do
- let(:default_action) { 'one' }
+ let(:default_action) { "one" }
it { is_expected.to eq [:one] }
end
diff --git a/spec/unit/rest/auth_credentials_spec.rb b/spec/unit/rest/auth_credentials_spec.rb
index dc66d12a19..88da44319b 100644
--- a/spec/unit/rest/auth_credentials_spec.rb
+++ b/spec/unit/rest/auth_credentials_spec.rb
@@ -19,9 +19,9 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'uri'
-require 'net/https'
+require "spec_helper"
+require "uri"
+require "net/https"
KEY_DOT_PEM=<<-END_RSA_KEY
-----BEGIN RSA PRIVATE KEY-----
@@ -56,7 +56,7 @@ Y6S6MeZ69Rp89ma4ttMZ+kwi1+XyHqC/dlcVRW42Zl5Dc7BALRlJjQ==
describe Chef::REST::AuthCredentials do
before do
- @key_file_fixture = CHEF_SPEC_DATA + '/ssl/private_key.pem'
+ @key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key.pem"
@key = OpenSSL::PKey::RSA.new(IO.read(@key_file_fixture).strip)
@auth_credentials = Chef::REST::AuthCredentials.new("client-name", @key)
end
@@ -72,7 +72,7 @@ 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'
+ 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
end
end
@@ -131,7 +131,7 @@ describe Chef::REST::RESTRequest do
end
before do
- @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + '/ssl/private_key.pem')
+ @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",
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb
index 3ecbbd14b8..ba5f837c07 100644
--- a/spec/unit/rest_spec.rb
+++ b/spec/unit/rest_spec.rb
@@ -19,10 +19,10 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'uri'
-require 'net/https'
-require 'stringio'
+require "spec_helper"
+require "uri"
+require "net/https"
+require "stringio"
SIGNING_KEY_DOT_PEM="-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA49TA0y81ps0zxkOpmf5V4/c4IeR5yVyQFpX3JpxO4TquwnRh
@@ -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)
@@ -92,7 +92,7 @@ describe Chef::REST do
Chef::REST.new(base_url, nil, nil, options)
end
- context 'when created with a chef zero URL' do
+ context "when created with a chef zero URL" do
let(:url) { "chefzero://localhost:1" }
@@ -115,12 +115,12 @@ describe Chef::REST do
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])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.get_rest("monkey")
end
it "makes a :GET reqest for a streaming download with the composed url" do
- expect(rest).to receive(:streaming_request).with('monkey', {})
+ expect(rest).to receive(:streaming_request).with("monkey", {})
rest.get_rest("monkey", true)
end
@@ -129,7 +129,7 @@ describe Chef::REST do
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])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.delete_rest("monkey")
end
@@ -138,7 +138,7 @@ describe Chef::REST do
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])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.post_rest("monkey", "data")
end
@@ -147,7 +147,7 @@ describe Chef::REST do
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])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
rest.put_rest("monkey", "data")
end
end
@@ -162,11 +162,11 @@ describe Chef::REST do
Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
end
- it 'responds to raw_http_request as a public method' do
+ it "responds to raw_http_request as a public method" do
expect(rest.public_methods.map(&:to_s)).to include("raw_http_request")
end
- it 'calls the authn middleware' do
+ it "calls the authn middleware" do
data = "\"secure data\""
auth_headers = standard_write_headers.merge({"auth_done"=>"yep"})
@@ -177,18 +177,18 @@ describe Chef::REST do
expect(rest).to receive(:send_http_request).
with(:POST, monkey_uri, auth_headers, data).
and_return([1,2,3])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ 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
- it 'sets correct authn headers' do
+ it "sets correct authn headers" do
data = "\"secure data\""
method, uri, auth_headers, d = rest.authenticator.handle_request(:POST, monkey_uri, standard_write_headers, data)
expect(rest).to receive(:send_http_request).
with(:POST, monkey_uri, auth_headers, data).
and_return([1,2,3])
- expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true)
+ 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
@@ -287,12 +287,12 @@ describe Chef::REST do
let(:base_headers) do #FIXME: huh?
{
- 'Accept' => 'application/json',
- '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,
+ "Accept" => "application/json",
+ "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,
}
end
@@ -314,7 +314,7 @@ describe Chef::REST do
# XXX: must reset to default b/c knife changes the UA
Chef::REST::RESTRequest.user_agent = Chef::REST::RESTRequest::DEFAULT_UA
rest.request(:GET, url, {})
- expect(request_mock['User-Agent']).to match(/^Chef Client\/#{Chef::VERSION}/)
+ expect(request_mock["User-Agent"]).to match(/^Chef Client\/#{Chef::VERSION}/)
end
# CHEF-3140
@@ -340,8 +340,8 @@ describe Chef::REST do
context "when configured with custom http headers" do
let(:custom_headers) do
{
- 'X-Custom-ChefSecret' => 'sharpknives',
- 'X-Custom-RequestPriority' => 'extremely low',
+ "X-Custom-ChefSecret" => "sharpknives",
+ "X-Custom-RequestPriority" => "extremely low",
}
end
@@ -371,7 +371,7 @@ describe Chef::REST do
end
it "should set the cookie for this request if one exists for the given host:port" do
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers.merge('Cookie' => "cookie monster")).and_return(request_mock)
+ expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers.merge("Cookie" => "cookie monster")).and_return(request_mock)
rest.request(:GET, url, {})
end
end
@@ -383,7 +383,7 @@ describe Chef::REST do
it "should build a new HTTP POST request" do
request = Net::HTTP::Post.new(url.path)
- expected_headers = base_headers.merge("Content-Type" => 'application/json', 'Content-Length' => '13')
+ 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})
@@ -392,7 +392,7 @@ describe Chef::REST do
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')
+ 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(request.body).to eq('{"one":"two"}')
@@ -419,12 +419,12 @@ describe Chef::REST do
context "when JSON is returned" do
let(:body) { '{"ohai2u":"json_api"}' }
it "should inflate the body as to an object" do
- http_response.add_field('content-type', "application/json")
+ http_response.add_field("content-type", "application/json")
expect(rest.request(:GET, url, {})).to eq({"ohai2u"=>"json_api"})
end
it "should fail if the response is truncated" do
- http_response.add_field('content-type', "application/json")
+ http_response.add_field("content-type", "application/json")
http_response["Content-Length"] = (body.bytesize + 99).to_s
expect { rest.request(:GET, url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
@@ -486,7 +486,7 @@ describe Chef::REST do
allow(rest).to receive(:sleep)
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'))
+ 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
@@ -511,7 +511,7 @@ describe Chef::REST do
it "decompresses the JSON error message" do
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'))
+ 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
@@ -544,7 +544,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)
@@ -570,24 +570,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, {})
@@ -622,13 +622,13 @@ describe Chef::REST do
end
it "does not raise a divide by zero exception if the content's actual size is 0" do
- http_response['Content-Length'] = "5"
- allow(http_response).to receive(:read_body).and_yield('')
+ http_response["Content-Length"] = "5"
+ allow(http_response).to receive(:read_body).and_yield("")
expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
it "does not raise a divide by zero exception when the Content-Length is 0" do
- http_response['Content-Length'] = "0"
+ http_response["Content-Length"] = "0"
allow(http_response).to receive(:read_body).and_yield("ninja")
expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 6e9b133c50..a48137d28a 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/role'
+require "spec_helper"
+require "chef/role"
describe Chef::Role do
before(:each) do
@@ -108,12 +108,12 @@ describe Chef::Role do
describe "default_attributes" do
it "should let you set the default attributes hash explicitly" do
- expect(@role.default_attributes({ :one => 'two' })).to eq({ :one => 'two' })
+ expect(@role.default_attributes({ :one => "two" })).to eq({ :one => "two" })
end
it "should let you return the default attributes hash" do
- @role.default_attributes({ :one => 'two' })
- expect(@role.default_attributes).to eq({ :one => 'two' })
+ @role.default_attributes({ :one => "two" })
+ expect(@role.default_attributes).to eq({ :one => "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -123,12 +123,12 @@ describe Chef::Role do
describe "override_attributes" do
it "should let you set the override attributes hash explicitly" do
- expect(@role.override_attributes({ :one => 'two' })).to eq({ :one => 'two' })
+ expect(@role.override_attributes({ :one => "two" })).to eq({ :one => "two" })
end
it "should let you return the override attributes hash" do
- @role.override_attributes({ :one => 'two' })
- expect(@role.override_attributes).to eq({ :one => 'two' })
+ @role.override_attributes({ :one => "two" })
+ expect(@role.override_attributes).to eq({ :one => "two" })
end
it "should throw an ArgumentError if we aren't a kind of hash" do
@@ -138,18 +138,18 @@ describe Chef::Role do
describe "update_from!" do
before(:each) do
- @role.name('mars_volta')
- @role.description('Great band!')
- @role.run_list('one', 'two', 'role[a]')
- @role.default_attributes({ :el_groupo => 'nuevo' })
- @role.override_attributes({ :deloused => 'in the comatorium' })
+ @role.name("mars_volta")
+ @role.description("Great band!")
+ @role.run_list("one", "two", "role[a]")
+ @role.default_attributes({ :el_groupo => "nuevo" })
+ @role.override_attributes({ :deloused => "in the comatorium" })
@example = Chef::Role.new
- @example.name('newname')
- @example.description('Really Great band!')
- @example.run_list('alpha', 'bravo', 'role[alpha]')
- @example.default_attributes({ :el_groupo => 'nuevo dos' })
- @example.override_attributes({ :deloused => 'in the comatorium XOXO' })
+ @example.name("newname")
+ @example.description("Really Great band!")
+ @example.run_list("alpha", "bravo", "role[alpha]")
+ @example.default_attributes({ :el_groupo => "nuevo dos" })
+ @example.override_attributes({ :deloused => "in the comatorium XOXO" })
end
it "should update all fields except for name" do
@@ -164,11 +164,11 @@ describe Chef::Role do
describe "when serialized as JSON", :json => true do
before(:each) do
- @role.name('mars_volta')
- @role.description('Great band!')
- @role.run_list('one', 'two', 'role[a]')
- @role.default_attributes({ :el_groupo => 'nuevo' })
- @role.override_attributes({ :deloused => 'in the comatorium' })
+ @role.name("mars_volta")
+ @role.description("Great band!")
+ @role.run_list("one", "two", "role[a]")
+ @role.default_attributes({ :el_groupo => "nuevo" })
+ @role.override_attributes({ :deloused => "in the comatorium" })
@serialized_role = Chef::JSONCompat.to_json(@role)
end
@@ -200,14 +200,14 @@ describe Chef::Role do
describe "and it has per-environment run lists" do
before do
- @role.env_run_lists("_default" => ['one', 'two', 'role[a]'], "production" => ['role[monitoring]', 'role[auditing]', 'role[apache]'], "dev" => ["role[nginx]"])
+ @role.env_run_lists("_default" => ["one", "two", "role[a]"], "production" => ["role[monitoring]", "role[auditing]", "role[apache]"], "dev" => ["role[nginx]"])
@serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), :create_additions => false)
end
it "includes the per-environment run lists" do
#Activesupport messes with Chef json formatting
#This test should pass with and without activesupport
- expect(@serialized_role["env_run_lists"]["production"]).to eq(['role[monitoring]', 'role[auditing]', 'role[apache]'])
+ expect(@serialized_role["env_run_lists"]["production"]).to eq(["role[monitoring]", "role[auditing]", "role[apache]"])
expect(@serialized_role["env_run_lists"]["dev"]).to eq(["role[nginx]"])
end
@@ -224,11 +224,11 @@ describe Chef::Role do
describe "when created from JSON", :json => true do
before(:each) do
- @role.name('mars_volta')
- @role.description('Great band!')
- @role.run_list('one', 'two', 'role[a]')
- @role.default_attributes({ 'el_groupo' => 'nuevo' })
- @role.override_attributes({ 'deloused' => 'in the comatorium' })
+ @role.name("mars_volta")
+ @role.description("Great band!")
+ @role.run_list("one", "two", "role[a]")
+ @role.default_attributes({ "el_groupo" => "nuevo" })
+ @role.override_attributes({ "deloused" => "in the comatorium" })
@deserial = Chef::Role.from_hash(Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role)))
end
@@ -256,13 +256,13 @@ EOR
describe "when loading from disk" do
before do
- default_cache_path = windows? ? 'C:\chef' : '/var/chef'
+ default_cache_path = windows? ? 'C:\chef' : "/var/chef"
allow(Chef::Config).to receive(:cache_path).and_return(default_cache_path)
end
it "should return a Chef::Role object from JSON" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json"])
- file_path = File.join(Chef::Config[:role_path], 'memes/lolcat.json')
+ file_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
expect(File).to receive(:exists?).with(file_path).exactly(1).times.and_return(true)
expect(IO).to receive(:read).with(file_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@@ -271,7 +271,7 @@ EOR
it "should return a Chef::Role object from a Ruby DSL" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
- rb_path = File.join(Chef::Config[:role_path], 'memes/lolcat.rb')
+ rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
expect(File).to receive(:exists?).with(rb_path).exactly(2).times.and_return(true)
expect(File).to receive(:readable?).with(rb_path).exactly(1).times.and_return(true)
expect(IO).to receive(:read).with(rb_path).and_return(ROLE_DSL)
@@ -281,8 +281,8 @@ EOR
it "should prefer a Chef::Role Object from JSON over one from a Ruby DSL" do
expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json", "#{Chef::Config[:role_path]}/memes/lolcat.rb"])
- js_path = File.join(Chef::Config[:role_path], 'memes/lolcat.json')
- rb_path = File.join(Chef::Config[:role_path], 'memes/lolcat.rb')
+ js_path = File.join(Chef::Config[:role_path], "memes/lolcat.json")
+ rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb")
expect(File).to receive(:exists?).with(js_path).exactly(1).times.and_return(true)
expect(File).not_to receive(:exists?).with(rb_path)
expect(IO).to receive(:read).with(js_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
@@ -313,48 +313,48 @@ EOR
describe "when loading from disk and role_path is an array" do
before(:each) do
- Chef::Config[:role_path] = ['/path1', '/path/path2']
+ Chef::Config[:role_path] = ["/path1", "/path/path2"]
end
it "should return a Chef::Role object from JSON" do
- expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return(['/path1/lolcat.json'])
- expect(File).to receive(:exists?).with('/path1/lolcat.json').exactly(1).times.and_return(true)
- expect(IO).to receive(:read).with('/path1/lolcat.json').and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
+ expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.json"])
+ expect(File).to receive(:exists?).with("/path1/lolcat.json").exactly(1).times.and_return(true)
+ expect(IO).to receive(:read).with("/path1/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
end
it "should return a Chef::Role object from JSON when role is in the second path" 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(['/path/path2/lolcat.json'])
- expect(File).to receive(:exists?).with('/path/path2/lolcat.json').exactly(1).times.and_return(true)
- expect(IO).to receive(:read).with('/path/path2/lolcat.json').and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
+ 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(["/path/path2/lolcat.json"])
+ expect(File).to receive(:exists?).with("/path/path2/lolcat.json").exactly(1).times.and_return(true)
+ expect(IO).to receive(:read).with("/path/path2/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }')
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
end
it "should return a Chef::Role object from a Ruby DSL" do
- expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return(['/path1/lolcat.rb'])
- expect(File).to receive(:exists?).with('/path1/lolcat.rb').exactly(2).times.and_return(true)
- expect(File).to receive(:readable?).with('/path1/lolcat.rb').and_return(true)
- expect(IO).to receive(:read).with('/path1/lolcat.rb').exactly(1).times.and_return(ROLE_DSL)
+ expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.rb"])
+ expect(File).to receive(:exists?).with("/path1/lolcat.rb").exactly(2).times.and_return(true)
+ expect(File).to receive(:readable?).with("/path1/lolcat.rb").and_return(true)
+ expect(IO).to receive(:read).with("/path1/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
end
it "should return a Chef::Role object from a Ruby DSL when role is in the second path" 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(['/path/path2/lolcat.rb'])
- expect(File).to receive(:exists?).with('/path/path2/lolcat.rb').exactly(2).times.and_return(true)
- expect(File).to receive(:readable?).with('/path/path2/lolcat.rb').and_return(true)
- expect(IO).to receive(:read).with('/path/path2/lolcat.rb').exactly(1).times.and_return(ROLE_DSL)
+ 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(["/path/path2/lolcat.rb"])
+ expect(File).to receive(:exists?).with("/path/path2/lolcat.rb").exactly(2).times.and_return(true)
+ expect(File).to receive(:readable?).with("/path/path2/lolcat.rb").and_return(true)
+ expect(IO).to receive(:read).with("/path/path2/lolcat.rb").exactly(1).times.and_return(ROLE_DSL)
expect(@role).to be_a_kind_of(Chef::Role)
@role.class.from_disk("lolcat")
end
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(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)
end
diff --git a/spec/unit/run_context/child_run_context_spec.rb b/spec/unit/run_context/child_run_context_spec.rb
index 63586e459c..3654125a79 100644
--- a/spec/unit/run_context/child_run_context_spec.rb
+++ b/spec/unit/run_context/child_run_context_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/lib/library_load_order'
+require "spec_helper"
+require "support/lib/library_load_order"
describe Chef::RunContext::ChildRunContext do
context "with a run context with stuff in it" do
@@ -46,14 +46,14 @@ describe Chef::RunContext::ChildRunContext do
it "audits is not the same as the parent" do
expect(child.audits.object_id).not_to eq run_context.audits.object_id
- child.audits['hi'] = 'lo'
- expect(child.audits['hi']).to eq('lo')
- expect(run_context.audits['hi']).not_to eq('lo')
+ child.audits["hi"] = "lo"
+ expect(child.audits["hi"]).to eq("lo")
+ expect(run_context.audits["hi"]).not_to eq("lo")
end
it "resource_collection is not the same as the parent" do
expect(child.resource_collection.object_id).not_to eq run_context.resource_collection.object_id
- f = Chef::Resource::File.new('hi', child)
+ f = Chef::Resource::File.new("hi", child)
child.resource_collection.insert(f)
expect(child.resource_collection).to include f
expect(run_context.resource_collection).not_to include f
@@ -61,17 +61,17 @@ describe Chef::RunContext::ChildRunContext do
it "immediate_notification_collection is not the same as the parent" do
expect(child.immediate_notification_collection.object_id).not_to eq run_context.immediate_notification_collection.object_id
- src = Chef::Resource::File.new('hi', child)
- dest = Chef::Resource::File.new('argh', child)
+ src = Chef::Resource::File.new("hi", child)
+ dest = Chef::Resource::File.new("argh", child)
notification = Chef::Resource::Notification.new(dest, :create, src)
child.notifies_immediately(notification)
- expect(child.immediate_notification_collection['file[hi]']).to eq([notification])
- expect(run_context.immediate_notification_collection['file[hi]']).not_to eq([notification])
+ expect(child.immediate_notification_collection["file[hi]"]).to eq([notification])
+ expect(run_context.immediate_notification_collection["file[hi]"]).not_to eq([notification])
end
it "immediate_notifications is not the same as the parent" do
- src = Chef::Resource::File.new('hi', child)
- dest = Chef::Resource::File.new('argh', child)
+ src = Chef::Resource::File.new("hi", child)
+ dest = Chef::Resource::File.new("argh", child)
notification = Chef::Resource::Notification.new(dest, :create, src)
child.notifies_immediately(notification)
expect(child.immediate_notifications(src)).to eq([notification])
@@ -80,17 +80,17 @@ describe Chef::RunContext::ChildRunContext do
it "delayed_notification_collection is not the same as the parent" do
expect(child.delayed_notification_collection.object_id).not_to eq run_context.delayed_notification_collection.object_id
- src = Chef::Resource::File.new('hi', child)
- dest = Chef::Resource::File.new('argh', child)
+ src = Chef::Resource::File.new("hi", child)
+ dest = Chef::Resource::File.new("argh", child)
notification = Chef::Resource::Notification.new(dest, :create, src)
child.notifies_delayed(notification)
- expect(child.delayed_notification_collection['file[hi]']).to eq([notification])
- expect(run_context.delayed_notification_collection['file[hi]']).not_to eq([notification])
+ expect(child.delayed_notification_collection["file[hi]"]).to eq([notification])
+ expect(run_context.delayed_notification_collection["file[hi]"]).not_to eq([notification])
end
it "delayed_notifications is not the same as the parent" do
- src = Chef::Resource::File.new('hi', child)
- dest = Chef::Resource::File.new('argh', child)
+ src = Chef::Resource::File.new("hi", child)
+ dest = Chef::Resource::File.new("argh", child)
notification = Chef::Resource::Notification.new(dest, :create, src)
child.notifies_delayed(notification)
expect(child.delayed_notifications(src)).to eq([notification])
@@ -104,7 +104,7 @@ describe Chef::RunContext::ChildRunContext do
context "after load('include::default')" do
before do
- run_list = Chef::RunList.new('include::default').expand('_default')
+ run_list = Chef::RunList.new("include::default").expand("_default")
# TODO not sure why we had to do this to get everything to work ...
node.automatic_attrs[:recipes] = []
child.load(run_list)
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index 20ec1d2ef7..43d14addb8 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/lib/library_load_order'
+require "spec_helper"
+require "support/lib/library_load_order"
# These tests rely on fixture data in spec/data/run_context/cookbooks.
#
@@ -45,7 +45,7 @@ describe Chef::RunContext::CookbookCompiler do
let(:cookbook_collection) { Chef::CookbookCollection.new(cookbook_loader) }
# Lazy evaluation of `expansion` here is used to mutate the run list before expanding it
- let(:run_list_expansion) { node.run_list.expand('_default') }
+ let(:run_list_expansion) { node.run_list.expand("_default") }
let(:compiler) do
Chef::RunContext::CookbookCompiler.new(run_context, run_list_expansion, events)
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index efc2a6f63f..ca45ca415f 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'support/lib/library_load_order'
+require "spec_helper"
+require "support/lib/library_load_order"
describe Chef::RunContext do
let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) }
@@ -104,7 +104,7 @@ describe Chef::RunContext do
expect(node).to receive(:loaded_recipe).with(:test, "default")
expect(node).to receive(:loaded_recipe).with(:test, "one")
expect(node).to receive(:loaded_recipe).with(:test, "two")
- run_context.load(node.run_list.expand('_default'))
+ run_context.load(node.run_list.expand("_default"))
end
it "should load all the definitions in the cookbooks for this node" do
diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb
index a7df9e749b..1e509ac4d5 100644
--- a/spec/unit/run_list/run_list_expansion_spec.rb
+++ b/spec/unit/run_list/run_list_expansion_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::RunList::RunListExpansion do
before do
@run_list = Chef::RunList.new
- @run_list << 'recipe[lobster::mastercookbook@0.1.0]' << 'role[rage]' << 'recipe[fist@0.1]'
+ @run_list << "recipe[lobster::mastercookbook@0.1.0]" << "role[rage]" << "recipe[fist@0.1]"
@expansion = Chef::RunList::RunListExpansion.new("_default", @run_list.run_list_items)
end
@@ -43,7 +43,7 @@ describe Chef::RunList::RunListExpansion do
end
it "has not applied its roles" do
- expect(@expansion.applied_role?('rage')).to be_falsey
+ expect(@expansion.applied_role?("rage")).to be_falsey
end
end
@@ -51,7 +51,7 @@ describe Chef::RunList::RunListExpansion do
before do
@rage_role = Chef::Role.new.tap do |r|
r.name("rage")
- r.env_run_lists('_default' => [], "prod" => ["recipe[prod-only]"])
+ r.env_run_lists("_default" => [], "prod" => ["recipe[prod-only]"])
end
@expansion = Chef::RunList::RunListExpansion.new("prod", @run_list.run_list_items)
expect(@expansion).to receive(:fetch_role).and_return(@rage_role)
@@ -67,30 +67,30 @@ describe Chef::RunList::RunListExpansion do
describe "after applying a role" do
before do
allow(@expansion).to receive(:fetch_role).and_return(Chef::Role.new)
- @expansion.inflate_role('rage', "role[base]")
+ @expansion.inflate_role("rage", "role[base]")
end
it "tracks the applied role" do
- expect(@expansion.applied_role?('rage')).to be_truthy
+ expect(@expansion.applied_role?("rage")).to be_truthy
end
it "does not inflate the role again" do
- expect(@expansion.inflate_role('rage', "role[base]")).to be_falsey
+ expect(@expansion.inflate_role("rage", "role[base]")).to be_falsey
end
end
describe "after expanding a run list" do
before 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.name("rage")
+ @first_role.run_list("role[mollusk]")
+ @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.name("rage")
+ @second_role.run_list("recipe[crabrevenge]")
+ @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",'
@@ -109,24 +109,24 @@ describe Chef::RunList::RunListExpansion do
end
it "has the ordered list of recipes" do
- expect(@expansion.recipes).to eq(['lobster::mastercookbook', 'crabrevenge', 'fist'])
+ expect(@expansion.recipes).to eq(["lobster::mastercookbook", "crabrevenge", "fist"])
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
# this is the correct order, but 1.8 hash order is not stable
- expect(@expansion.roles).to match_array(['rage', 'mollusk'])
+ expect(@expansion.roles).to match_array(["rage", "mollusk"])
end
end
describe "after expanding a run list with a non existent role" do
before do
- allow(@expansion).to receive(:fetch_role) { @expansion.role_not_found('crabrevenge', "role[base]") }
+ allow(@expansion).to receive(:fetch_role) { @expansion.role_not_found("crabrevenge", "role[base]") }
@expansion.expand
end
@@ -136,7 +136,7 @@ describe Chef::RunList::RunListExpansion do
end
it "has a list of invalid role names" do
- expect(@expansion.errors).to include('crabrevenge')
+ expect(@expansion.errors).to include("crabrevenge")
end
end
diff --git a/spec/unit/run_list/run_list_item_spec.rb b/spec/unit/run_list/run_list_item_spec.rb
index 16832c1b7d..c69ca8f220 100644
--- a/spec/unit/run_list/run_list_item_spec.rb
+++ b/spec/unit/run_list/run_list_item_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::RunList::RunListItem do
@@ -26,12 +26,12 @@ describe Chef::RunList::RunListItem do
end
it "raises an exception when the hash doesn't have an :name key" do
- expect {Chef::RunList::RunListItem.new(:type => 'R') }.to raise_error(ArgumentError)
+ expect {Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError)
end
it "sets the name and type as given in the hash" do
- item = Chef::RunList::RunListItem.new(:type => 'fuuu', :name => 'uuuu')
- expect(item.to_s).to eq('fuuu[uuuu]')
+ item = Chef::RunList::RunListItem.new(:type => "fuuu", :name => "uuuu")
+ expect(item.to_s).to eq("fuuu[uuuu]")
end
end
@@ -41,33 +41,33 @@ describe Chef::RunList::RunListItem do
item = Chef::RunList::RunListItem.new("recipe[rage]")
expect(item).to be_a_recipe
expect(item).not_to be_a_role
- expect(item.to_s).to eq('recipe[rage]')
- expect(item.name).to eq('rage')
+ expect(item.to_s).to eq("recipe[rage]")
+ expect(item.name).to eq("rage")
end
it "parses a qualified recipe with a version" do
item = Chef::RunList::RunListItem.new("recipe[rage@0.1.0]")
expect(item).to be_a_recipe
expect(item).not_to be_a_role
- expect(item.to_s).to eq('recipe[rage@0.1.0]')
- expect(item.name).to eq('rage')
- expect(item.version).to eq('0.1.0')
+ expect(item.to_s).to eq("recipe[rage@0.1.0]")
+ expect(item.name).to eq("rage")
+ expect(item.version).to eq("0.1.0")
end
it "parses a qualified role" do
item = Chef::RunList::RunListItem.new("role[fist]")
expect(item).to be_a_role
expect(item).not_to be_a_recipe
- expect(item.to_s).to eq('role[fist]')
- expect(item.name).to eq('fist')
+ expect(item.to_s).to eq("role[fist]")
+ expect(item.name).to eq("fist")
end
it "parses an unqualified recipe" do
item = Chef::RunList::RunListItem.new("lobster")
expect(item).to be_a_recipe
expect(item).not_to be_a_role
- expect(item.to_s).to eq('recipe[lobster]')
- expect(item.name).to eq('lobster')
+ expect(item.to_s).to eq("recipe[lobster]")
+ expect(item.name).to eq("lobster")
end
it "raises an exception when the string has typo on the type part" do
@@ -85,33 +85,33 @@ describe Chef::RunList::RunListItem do
describe "comparing to other run list items" do
it "is equal to another run list item that has the same name and type" do
- item1 = Chef::RunList::RunListItem.new('recipe[lrf]')
- item2 = Chef::RunList::RunListItem.new('recipe[lrf]')
+ item1 = Chef::RunList::RunListItem.new("recipe[lrf]")
+ item2 = Chef::RunList::RunListItem.new("recipe[lrf]")
expect(item1).to eq(item2)
end
it "is not equal to another run list item with the same name and different type" do
- item1 = Chef::RunList::RunListItem.new('recipe[lrf]')
- item2 = Chef::RunList::RunListItem.new('role[lrf]')
+ item1 = Chef::RunList::RunListItem.new("recipe[lrf]")
+ item2 = Chef::RunList::RunListItem.new("role[lrf]")
expect(item1).not_to eq(item2)
end
it "is not equal to another run list item with the same type and different name" do
- item1 = Chef::RunList::RunListItem.new('recipe[lrf]')
- item2 = Chef::RunList::RunListItem.new('recipe[lobsterragefist]')
+ item1 = Chef::RunList::RunListItem.new("recipe[lrf]")
+ item2 = Chef::RunList::RunListItem.new("recipe[lobsterragefist]")
expect(item1).not_to eq(item2)
end
it "is not equal to another run list item with the same name and type but different version" do
- item1 = Chef::RunList::RunListItem.new('recipe[lrf,0.1.0]')
- item2 = Chef::RunList::RunListItem.new('recipe[lrf,0.2.0]')
+ item1 = Chef::RunList::RunListItem.new("recipe[lrf,0.1.0]")
+ item2 = Chef::RunList::RunListItem.new("recipe[lrf,0.2.0]")
expect(item1).not_to eq(item2)
end
end
describe "comparing to strings" do
it "is equal to a string if that string matches its to_s representation" do
- expect(Chef::RunList::RunListItem.new('recipe[lrf]')).to eq('recipe[lrf]')
+ expect(Chef::RunList::RunListItem.new("recipe[lrf]")).to eq("recipe[lrf]")
end
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 356b9d682c..e1927f8310 100644
--- a/spec/unit/run_list/versioned_recipe_list_spec.rb
+++ b/spec/unit/run_list/versioned_recipe_list_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
describe Chef::RunList::VersionedRecipeList do
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index 634b5c54cf..da5bcf83cb 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -18,10 +18,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/version_class'
-require 'chef/version_constraint'
+require "chef/version_class"
+require "chef/version_constraint"
describe Chef::RunList do
before(:each) do
@@ -30,21 +30,21 @@ describe Chef::RunList do
describe "<<" do
it "should add a recipe to the run list and recipe list with the fully qualified name" do
- @run_list << 'recipe[needy]'
- expect(@run_list).to include('recipe[needy]')
+ @run_list << "recipe[needy]"
+ expect(@run_list).to include("recipe[needy]")
expect(@run_list.recipes).to include("needy")
end
it "should add a role to the run list and role list with the fully qualified name" do
@run_list << "role[woot]"
- expect(@run_list).to include('role[woot]')
- expect(@run_list.roles).to include('woot')
+ expect(@run_list).to include("role[woot]")
+ expect(@run_list.roles).to include("woot")
end
it "should accept recipes that are unqualified" do
@run_list << "needy"
- expect(@run_list).to include('recipe[needy]')
- expect(@run_list.recipes.include?('needy')).to eq(true)
+ expect(@run_list).to include("recipe[needy]")
+ expect(@run_list.recipes.include?("needy")).to eq(true)
end
it "should not allow duplicates" do
@@ -59,7 +59,7 @@ describe Chef::RunList do
@run_list << "recipe[needy@0.1.0]"
expect(@run_list.run_list.length).to eq(2)
expect(@run_list.recipes.length).to eq(2)
- expect(@run_list.recipes.include?('needy')).to eq(true)
+ expect(@run_list.recipes.include?("needy")).to eq(true)
end
it "should not allow duplicate versions of a recipe" do
@@ -74,13 +74,13 @@ describe Chef::RunList do
# Testing only the basic functionality here
# since full behavior is tested above.
it "should add a recipe to the run_list" do
- @run_list.add 'recipe[needy]'
- expect(@run_list).to include('recipe[needy]')
+ @run_list.add "recipe[needy]"
+ expect(@run_list).to include("recipe[needy]")
end
it "should add a role to the run_list" do
- @run_list.add 'role[needy]'
- expect(@run_list).to include('role[needy]')
+ @run_list.add "role[needy]"
+ expect(@run_list).to include("role[needy]")
end
end
@@ -112,20 +112,20 @@ describe Chef::RunList do
describe "[]" do
it "should let you look up a member in the run list by position" do
- @run_list << 'recipe[loulou]'
- expect(@run_list[0]).to eq('recipe[loulou]')
+ @run_list << "recipe[loulou]"
+ expect(@run_list[0]).to eq("recipe[loulou]")
end
end
describe "[]=" do
it "should let you set a member of the run list by position" do
- @run_list[0] = 'recipe[loulou]'
- expect(@run_list[0]).to eq('recipe[loulou]')
+ @run_list[0] = "recipe[loulou]"
+ expect(@run_list[0]).to eq("recipe[loulou]")
end
it "should properly expand a member of the run list given by position" do
- @run_list[0] = 'loulou'
- expect(@run_list[0]).to eq('recipe[loulou]')
+ @run_list[0] = "loulou"
+ expect(@run_list[0]).to eq("recipe[loulou]")
end
end
@@ -199,7 +199,7 @@ describe Chef::RunList do
it "should load the role from the chef server" do
#@rest.should_receive(:get).with("roles/stubby")
expansion = @run_list.expand("_default", "server")
- expect(expansion.recipes).to eq(['one', 'two', 'kitty'])
+ expect(expansion.recipes).to eq(["one", "two", "kitty"])
end
it "should default to expanding from the server" do
@@ -270,7 +270,7 @@ describe Chef::RunList do
allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
allow(Chef::Role).to receive(:from_disk).with("dog").and_return(dog)
- expansion = @run_list.expand("_default", 'disk')
+ expansion = @run_list.expand("_default", "disk")
expect(expansion.recipes[2]).to eq("three")
expect(expansion.default_attrs[:seven]).to eq(:nine)
end
@@ -284,7 +284,7 @@ describe Chef::RunList do
allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role)
expect(Chef::Role).to receive(:from_disk).with("dog").once.and_return(dog)
- expansion = @run_list.expand("_default", 'disk')
+ expansion = @run_list.expand("_default", "disk")
expect(expansion.recipes[2]).to eq("three")
expect(expansion.recipes[3]).to eq("kitty")
expect(expansion.default_attrs[:seven]).to eq(:nine)
diff --git a/spec/unit/run_lock_spec.rb b/spec/unit/run_lock_spec.rb
index 51e6ba1b84..7b474919e9 100644
--- a/spec/unit/run_lock_spec.rb
+++ b/spec/unit/run_lock_spec.rb
@@ -15,13 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require File.expand_path('../../spec_helper', __FILE__)
-require 'chef/client'
+require File.expand_path("../../spec_helper", __FILE__)
+require "chef/client"
describe Chef::RunLock do
- default_cache_path = windows? ? 'C:\chef' : '/var/chef'
- default_pid_location = windows? ? 'C:\chef\cache\chef-client-running.pid' : '/var/chef/cache/chef-client-running.pid'
+ default_cache_path = windows? ? 'C:\chef' : "/var/chef"
+ default_pid_location = windows? ? 'C:\chef\cache\chef-client-running.pid' : "/var/chef/cache/chef-client-running.pid"
describe "when first created" do
it "locates the lockfile in the file cache path by default" do
diff --git a/spec/unit/run_status_spec.rb b/spec/unit/run_status_spec.rb
index d658cb5a5a..970635cc0d 100644
--- a/spec/unit/run_status_spec.rb
+++ b/spec/unit/run_status_spec.rb
@@ -17,7 +17,7 @@
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::RunStatus do
before do
@@ -82,7 +82,7 @@ describe Chef::RunStatus do
describe "with resources in the resource_collection" do
before do
- @all_resources = [Chef::Resource::Cat.new("whiskers"), Chef::Resource::ZenMaster.new('dtz')]
+ @all_resources = [Chef::Resource::Cat.new("whiskers"), Chef::Resource::ZenMaster.new("dtz")]
@run_context.resource_collection.all_resources.replace(@all_resources)
end
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index 46074728c2..44c40463ee 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class SnitchyProvider < Chef::Provider
def self.all_actions_called
diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb
index 8cf681e994..02928851b1 100644
--- a/spec/unit/scan_access_control_spec.rb
+++ b/spec/unit/scan_access_control_spec.rb
@@ -16,7 +16,7 @@
#
require File.expand_path("../../spec_helper", __FILE__)
-require 'chef/scan_access_control'
+require "chef/scan_access_control"
describe Chef::ScanAccessControl do
@@ -33,7 +33,7 @@ describe Chef::ScanAccessControl do
@new_resource.tap do |f|
f.owner("root")
f.group("root")
- f.mode('0755')
+ f.mode("0755")
end
@scanner.set_all!
end
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index d54e8b5391..84ac0c661f 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/search/query'
+require "spec_helper"
+require "chef/search/query"
describe Chef::Search::Query do
let(:rest) { double("Chef::ServerAPI") }
@@ -29,8 +29,8 @@ describe Chef::Search::Query do
let(:args) { { filter_key => filter_hash } }
let(:filter_hash) {
{
- 'env' => [ 'chef_environment' ],
- 'ruby_plat' => [ 'languages', 'ruby', 'platform' ],
+ "env" => [ "chef_environment" ],
+ "ruby_plat" => [ "languages", "ruby", "platform" ],
}
}
let(:response) {
@@ -251,12 +251,12 @@ describe Chef::Search::Query do
it "returns start" do
start = query.search(:node, "platform:rhel", args)[1]
- expect(start).to eq(response['start'])
+ expect(start).to eq(response["start"])
end
it "returns total" do
total = query.search(:node, "platform:rhel", args)[2]
- expect(total).to eq(response['total'])
+ expect(total).to eq(response["total"])
end
it "returns rows with the filter applied" do
diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb
index d6da2dcffc..d4a0b6df09 100644
--- a/spec/unit/shell/model_wrapper_spec.rb
+++ b/spec/unit/shell/model_wrapper_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Shell::ModelWrapper do
before do
@@ -81,14 +81,14 @@ describe Shell::ModelWrapper do
end
it "searches for objects using the given query string" do
- expect(@searcher).to receive(:search).with(:node, 'name:app*').and_yield(@node_1).and_yield(@node_2)
+ expect(@searcher).to receive(:search).with(:node, "name:app*").and_yield(@node_1).and_yield(@node_2)
expect(@wrapper.find("name:app*")).to include(@node_1, @node_2)
end
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(@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)
end
end
diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb
index 9521ae646b..eaff3cc807 100644
--- a/spec/unit/shell/shell_ext_spec.rb
+++ b/spec/unit/shell/shell_ext_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Shell::Extensions do
describe "extending object for top level methods" do
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index d1cedb3236..218c814d43 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
require "ostruct"
@@ -49,7 +49,7 @@ end
describe Shell::ClientSession do
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] }
+ Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
@chef_rest = double("Chef::ServerAPI")
@session = Shell::ClientSession.instance
@node = Chef::Node.build("foo")
@@ -80,7 +80,7 @@ end
describe Shell::StandAloneSession do
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] }
+ Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
@session = Shell::StandAloneSession.instance
@node = @session.node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@@ -131,7 +131,7 @@ end
describe Shell::SoloSession do
before do
- Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] }
+ Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
Chef::Config[:shell_solo] = true
@session = Shell::SoloSession.instance
@node = Chef::Node.new
diff --git a/spec/unit/shell_out_spec.rb b/spec/unit/shell_out_spec.rb
index 50b0b61cb7..35844f4961 100644
--- a/spec/unit/shell_out_spec.rb
+++ b/spec/unit/shell_out_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path("../../spec_helper", __FILE__)
describe "Chef::ShellOut deprecation notices" do
it "logs a warning when initializing a new Chef::ShellOut object" do
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index 379043a017..6add9991e8 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
require "ostruct"
ObjectTestHarness = Proc.new do
@@ -44,7 +44,7 @@ describe Shell do
Shell.irb_conf = {}
allow(Shell::ShellSession.instance).to receive(:reset!)
allow(ChefConfig).to receive(:windows?).and_return(false)
- allow(Chef::Util::PathHelper).to receive(:home).and_return('/home/foo')
+ allow(Chef::Util::PathHelper).to receive(:home).and_return("/home/foo")
end
describe "reporting its status" do
@@ -58,7 +58,7 @@ describe Shell do
describe "configuring IRB" do
it "configures irb history" do
Shell.configure_irb
- expect(Shell.irb_conf[:HISTORY_FILE]).to eq(Chef::Util::PathHelper.home('.chef', 'chef_shell_history'))
+ expect(Shell.irb_conf[:HISTORY_FILE]).to eq(Chef::Util::PathHelper.home(".chef", "chef_shell_history"))
expect(Shell.irb_conf[:SAVE_HISTORY]).to eq(1000)
end
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index 97cc32eb3e..0bf3c2d332 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -21,10 +21,10 @@
# Open Source Chef Server 11 and should be removed once support
# for OSC 11 ends. New development should occur in user_spec.rb.
-require 'spec_helper'
+require "spec_helper"
-require 'chef/user'
-require 'tempfile'
+require "chef/user"
+require "tempfile"
describe Chef::User do
before(:each) do
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index d2ba0cf4de..8bf27168d9 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
-require 'chef/user_v1'
-require 'tempfile'
+require "chef/user_v1"
+require "tempfile"
describe Chef::UserV1 do
before(:each) do
@@ -312,13 +312,13 @@ describe Chef::UserV1 do
end
describe "Versioned API Interactions" do
- let(:response_406) { OpenStruct.new(:code => '406') }
+ let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
before (:each) do
@user = Chef::UserV1.new
- allow(@user).to receive(:chef_root_rest_v0).and_return(double('chef rest root v0 object'))
- allow(@user).to receive(:chef_root_rest_v1).and_return(double('chef rest root v1 object'))
+ allow(@user).to receive(:chef_root_rest_v0).and_return(double("chef rest root v0 object"))
+ allow(@user).to receive(:chef_root_rest_v1).and_return(double("chef rest root v1 object"))
end
describe "update" do
@@ -374,7 +374,7 @@ describe Chef::UserV1 do
end
context "when the server returns a 400" do
- let(:response_400) { OpenStruct.new(:code => '400') }
+ let(:response_400) { OpenStruct.new(:code => "400") }
let(:exception_400) { Net::HTTPServerException.new("400 Bad Request", response_400) }
context "when the 400 was due to public / private key fields no longer being supported" do
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index f548e8241d..ab44c9fdc2 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -17,8 +17,8 @@
#
-require 'spec_helper'
-require 'tmpdir'
+require "spec_helper"
+require "tmpdir"
describe Chef::Util::Backup do
@@ -71,15 +71,15 @@ describe Chef::Util::Backup do
end
it "should not delete anything if this is the only backup" do
- expect(@backup).to receive(:sorted_backup_files).and_return(['a'])
+ expect(@backup).to receive(:sorted_backup_files).and_return(["a"])
expect(@backup).not_to receive(:delete_backup)
@backup.backup!
end
it "should keep only 1 backup copy" do
- expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b', 'c'])
- expect(@backup).to receive(:delete_backup).with('b')
- expect(@backup).to receive(:delete_backup).with('c')
+ expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c"])
+ expect(@backup).to receive(:delete_backup).with("b")
+ expect(@backup).to receive(:delete_backup).with("c")
@backup.backup!
end
end
@@ -90,15 +90,15 @@ describe Chef::Util::Backup do
end
it "should not delete anything if we only have one other backup" do
- expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b'])
+ expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b"])
expect(@backup).not_to receive(:delete_backup)
@backup.backup!
end
it "should keep only 2 backup copies" do
- expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b', 'c', 'd'])
- expect(@backup).to receive(:delete_backup).with('c')
- expect(@backup).to receive(:delete_backup).with('d')
+ expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c", "d"])
+ expect(@backup).to receive(:delete_backup).with("c")
+ expect(@backup).to receive(:delete_backup).with("d")
@backup.backup!
end
end
@@ -106,7 +106,7 @@ describe Chef::Util::Backup do
describe "backup_filename" do
it "should return a timestamped path" do
- expect(@backup).to receive(:path).and_return('/a/b/c.txt')
+ expect(@backup).to receive(:path).and_return("/a/b/c.txt")
expect(@backup.send(:backup_filename)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|)
end
it "should strip the drive letter off for windows" do
@@ -114,21 +114,21 @@ describe Chef::Util::Backup do
expect(@backup.send(:backup_filename)).to match(%r|^\\a\\b\\c.txt.chef-\d{14}.\d{6}$|)
end
it "should strip the drive letter off for windows (with forwardslashes)" do
- expect(@backup).to receive(:path).and_return('c:/a/b/c.txt')
+ expect(@backup).to receive(:path).and_return("c:/a/b/c.txt")
expect(@backup.send(:backup_filename)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|)
end
end
describe "backup_path" do
it "uses the file's directory when Chef::Config[:file_backup_path] is nil" do
- expect(@backup).to receive(:path).and_return('/a/b/c.txt')
+ expect(@backup).to receive(:path).and_return("/a/b/c.txt")
Chef::Config[:file_backup_path] = nil
expect(@backup.send(:backup_path)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|)
end
it "uses the configured Chef::Config[:file_backup_path]" do
- expect(@backup).to receive(:path).and_return('/a/b/c.txt')
- Chef::Config[:file_backup_path] = '/backupdir'
+ expect(@backup).to receive(:path).and_return("/a/b/c.txt")
+ Chef::Config[:file_backup_path] = "/backupdir"
expect(@backup.send(:backup_path)).to match(%r|^/backupdir[\\/]+a/b/c.txt.chef-\d{14}.\d{6}$|)
end
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index b0a57a32c0..f46bc31488 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -17,8 +17,8 @@
#
-require 'spec_helper'
-require 'tmpdir'
+require "spec_helper"
+require "tmpdir"
shared_context "using file paths with spaces" do
let!(:old_tempfile) { Tempfile.new("chef-util diff-spec") }
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index 9fbd3aaa51..f05780285f 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -16,25 +16,25 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/dsc/configuration_generator'
+require "chef"
+require "chef/util/dsc/configuration_generator"
describe Chef::Util::DSC::ConfigurationGenerator do
let(:conf_man) do
node = Chef::Node.new
- Chef::Util::DSC::ConfigurationGenerator.new(node, 'tmp')
+ Chef::Util::DSC::ConfigurationGenerator.new(node, "tmp")
end
describe '#validate_configuration_name!' do
- it 'should not raise an error if a name contains all upper case letters' do
+ it "should not raise an error if a name contains all upper case letters" do
conf_man.send(:validate_configuration_name!, "HELLO")
end
- it 'should not raise an error if the name contains all lower case letters' do
+ it "should not raise an error if the name contains all lower case letters" do
conf_man.send(:validate_configuration_name!, "hello")
end
- it 'should not raise an error if no special characters are used except _' do
+ it "should not raise an error if no special characters are used except _" do
conf_man.send(:validate_configuration_name!, "hello_world")
end
@@ -48,67 +48,67 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
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')
+ 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")
expect(merged).to include(:flag)
- expect(merged[:flag]).to eql('a')
+ expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
end
- it 'should raise an ArgumentError if you try to override outputpath' 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
+ 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')
+ it "should be case insensitive to switches that are allowed" do
+ 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')
+ 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")
expect(merged).to include(:flag)
- expect(merged[:flag]).to eql('a')
+ expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
end
- it 'should raise an ArgumentError if you try to override outputpath' 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
+ 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')
+ it "should be case insensitive to switches that are allowed" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => "a"}, "hello")
expect(merged).to include(:flag)
end
end
- context 'when there are no flags' do
- it 'should supply an output path if configuration_flags is an empty hash' do
- merged = conf_man.send(:get_merged_configuration_flags!, {}, 'hello')
+ context "when there are no flags" do
+ it "should supply an output path if configuration_flags is an empty hash" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {}, "hello")
expect(merged).to include(:outputpath)
expect(merged.length).to eql(1)
end
- it 'should supply an output path if configuration_flags is an empty hash' do
- merged = conf_man.send(:get_merged_configuration_flags!, nil, 'hello')
+ it "should supply an output path if configuration_flags is an empty hash" do
+ merged = conf_man.send(:get_merged_configuration_flags!, nil, "hello")
expect(merged).to include(:outputpath)
expect(merged.length).to eql(1)
end
@@ -130,7 +130,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
[a,b].join("++")
end
allow(file_like_object).to receive(:write)
- conf_man.send(:write_document_generation_script, 'file', 'hello', {})
+ conf_man.send(:write_document_generation_script, "file", "hello", {})
expect(file_like_object).to have_received(:write)
end
end
@@ -143,24 +143,24 @@ describe Chef::Util::DSC::ConfigurationGenerator do
[a,b].join("++")
end
- 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')
+ 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("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'f3']}
- expect(conf_man.send(:find_configuration_document, 'hello')).to be_nil
+ allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "f3"]}
+ expect(conf_man.send(:find_configuration_document, "hello")).to be_nil
end
end
describe "#configuration_code" do
it "should build dsc" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {})
found_configuration = false
- dsc.split(';').each do |command|
+ dsc.split(";").each do |command|
if command.downcase =~ /\s*configuration\s+'hello'\s*\{\s*node\s+'localhost'\s*\{\s*archive\s*\{\s*\}\s*\}\s*\}\s*/
found_configuration = true
end
@@ -169,22 +169,22 @@ 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
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 3d44e07885..2990e1f28e 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -16,24 +16,24 @@
# limitations under the License.
#
-require 'chef/util/dsc/lcm_output_parser'
+require "chef/util/dsc/lcm_output_parser"
describe Chef::Util::DSC::LocalConfigurationManager::Parser do
- context 'empty input parameter' do
- it 'raises an exception when there are no valid lines' 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)
end
- it 'raises an exception for a nil input' do
+ it "raises an exception for a nil input" do
expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil)}.to raise_error(Chef::Exceptions::LCMParser)
end
end
- context 'correctly formatted output from lcm' do
- it 'returns a single resource when only 1 logged with the correct name' do
+ context "correctly formatted output from lcm" do
+ it "returns a single resource when only 1 logged with the correct name" do
str = <<EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -42,10 +42,10 @@ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
expect(resources.length).to eq(1)
- expect(resources[0].name).to eq('[name]')
+ expect(resources[0].name).to eq("[name]")
end
- it 'identifies when a resource changes the state of the system' do
+ it "identifies when a resource changes the state of the system" do
str = <<EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -58,7 +58,7 @@ EOF
expect(resources[0].changes_state?).to be_truthy
end
- it 'preserves the log provided for how the system changed the state' do
+ it "preserves the log provided for how the system changed the state" do
str = <<EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -72,7 +72,7 @@ EOF
expect(resources[0].change_log).to match_array(["[name]","[message]","[name]"])
end
- it 'should return false for changes_state?' do
+ it "should return false for changes_state?" do
str = <<EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -84,7 +84,7 @@ EOF
expect(resources[0].changes_state?).to be_falsey
end
- it 'should return an empty array for change_log if changes_state? is false' do
+ it "should return an empty array for change_log if changes_state? is false" do
str = <<EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -97,8 +97,8 @@ EOF
end
end
- context 'Incorrectly formatted output from LCM' do
- it 'should allow missing a [End Resource] when its the last one and still find all the resource' do
+ context "Incorrectly formatted output from LCM" do
+ it "should allow missing a [End Resource] when its the last one and still find all the resource" do
str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -119,7 +119,7 @@ EOF
expect(resources[1].changes_state?).to be_truthy
end
- it 'should allow missing a [End Resource] when its the first one and still find all the resource' do
+ it "should allow missing a [End Resource] when its the first one and still find all the resource" do
str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -140,7 +140,7 @@ EOF
expect(resources[1].changes_state?).to be_truthy
end
- it 'should allow missing set and end resource and assume an unconverged resource in this case' do
+ it "should allow missing set and end resource and assume an unconverged resource in this case" do
str = <<-EOF
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
@@ -156,9 +156,9 @@ logtype: [machinename]: LCM: [ End Set ]
EOF
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
expect(resources[0].changes_state?).to be_truthy
- expect(resources[0].name).to eql('[name]')
+ expect(resources[0].name).to eql("[name]")
expect(resources[1].changes_state?).to be_truthy
- expect(resources[1].name).to eql('[name2]')
+ expect(resources[1].name).to eql("[name2]")
end
end
end
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 1cff9e445b..eb860b5c30 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/dsc/local_configuration_manager'
+require "chef"
+require "chef/util/dsc/local_configuration_manager"
describe Chef::Util::DSC::LocalConfigurationManager do
- let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, 'tmp') }
+ let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, "tmp") }
let(:normal_lcm_output) { <<-EOH
logtype: [machinename]: LCM: [ Start Set ]
@@ -50,12 +50,12 @@ EOH
double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success)
}
- describe 'test_configuration method invocation' do
- context 'when interacting with the LCM using a PowerShell cmdlet' do
+ describe "test_configuration method invocation" do
+ context "when interacting with the LCM using a PowerShell cmdlet" do
before(:each) do
allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
end
- context 'that returns successfully' do
+ context "that returns successfully" do
before(:each) do
allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
end
@@ -64,16 +64,16 @@ EOH
let(:lcm_standard_error) { nil }
let(:lcm_cmdlet_success) { true }
- it 'should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds' do
- test_configuration_result = lcm.test_configuration('config', {})
+ it "should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds" do
+ test_configuration_result = lcm.test_configuration("config", {})
expect(test_configuration_result.class).to be(Array)
expect(test_configuration_result.length).to be > 0
expect(Chef::Log).not_to receive(:warn)
end
end
- context 'that fails due to missing what-if switch in DSC resource cmdlet implementation' do
- let(:lcm_standard_output) { '' }
+ context "that fails due to missing what-if switch in DSC resource cmdlet implementation" do
+ let(:lcm_standard_output) { "" }
let(:lcm_standard_error) { no_whatif_lcm_output }
let(:lcm_cmdlet_success) { false }
@@ -81,58 +81,58 @@ EOH
expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy
end
- it 'should should return a (possibly empty) array of ResourceInfo instances' do
+ it "should should return a (possibly empty) array of ResourceInfo instances" do
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
- context 'that fails due to a DSC resource not being imported before StartDSCConfiguration -whatif is executed' do
- let(:lcm_standard_output) { '' }
+ context "that fails due to a DSC resource not being imported before StartDSCConfiguration -whatif is executed" do
+ let(:lcm_standard_output) { "" }
let(:lcm_standard_error) { dsc_resource_import_failure_output }
let(:lcm_cmdlet_success) { false }
- it 'should log a warning if the message is formatted as expected when a resource import failure occurs' do
+ it "should log a warning if the message is formatted as expected when a resource import failure occurs" do
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
+ 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
- context 'that fails due to an unknown PowerShell cmdlet error' do
- let(:lcm_standard_output) { 'some output' }
- let(:lcm_standard_error) { 'Abort, Retry, Fail?' }
+ context "that fails due to an unknown PowerShell cmdlet error" do
+ let(:lcm_standard_output) { "some output" }
+ let(:lcm_standard_error) { "Abort, Retry, Fail?" }
let(:lcm_cmdlet_success) { false }
- it 'should log a warning' do
+ 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
- it 'should identify a correctly formatted error message as a resource import failure' do
+ it "should identify a correctly formatted error message as a resource import failure" do
expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output)).to be(true)
end
- it 'should not identify an incorrectly formatted error message as a resource import failure' do
- expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub('module', 'gibberish'))).to be(false)
+ it "should not identify an incorrectly formatted error message as a resource import failure" do
+ expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("module", "gibberish"))).to be(false)
end
- it 'should not identify a message without a CimException reference as a resource import failure' do
- expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub('CimException', 'ArgumentException'))).to be(false)
+ it "should not identify a message without a CimException reference as a resource import failure" do
+ expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("CimException", "ArgumentException"))).to be(false)
end
end
end
diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb
index 181ac2bb6c..97652a3d1c 100644
--- a/spec/unit/util/dsc/resource_store.rb
+++ b/spec/unit/util/dsc/resource_store.rb
@@ -16,61 +16,61 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/dsc/resource_store'
+require "chef"
+require "chef/util/dsc/resource_store"
describe Chef::Util::DSC::ResourceStore do
let(:resource_store) { Chef::Util::DSC::ResourceStore.new }
let(:resource_a) { {
- 'ResourceType' => 'AFoo',
- 'Name' => 'Foo',
- 'Module' => {'Name' => 'ModuleA'},
+ "ResourceType" => "AFoo",
+ "Name" => "Foo",
+ "Module" => {"Name" => "ModuleA"},
}
}
let(:resource_b) { {
- 'ResourceType' => 'BFoo',
- 'Name' => 'Foo',
- 'Module' => {'Name' => 'ModuleB'},
+ "ResourceType" => "BFoo",
+ "Name" => "Foo",
+ "Module" => {"Name" => "ModuleB"},
}
}
- context 'when resources are not cached' do
+ context "when resources are not cached" do
context 'when calling #resources' do
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(resource_store.resources).to eql([])
end
end
context 'when calling #find' do
- it 'returns an empty list if it cannot find any matching resources' do
+ it "returns an empty list if it cannot find any matching resources" do
expect(resource_store).to receive(:query_resource).and_return([])
- expect(resource_store.find('foo')).to eql([])
+ expect(resource_store.find("foo")).to eql([])
end
- it 'returns the resource if it is found (comparisons are case insensitive)' do
+ it "returns the resource if it is found (comparisons are case insensitive)" do
expect(resource_store).to receive(:query_resource).and_return([resource_a])
- expect(resource_store.find('foo')).to eql([resource_a])
+ expect(resource_store.find("foo")).to eql([resource_a])
end
- it 'returns multiple resoures if they are found' do
+ it "returns multiple resoures if they are found" do
expect(resource_store).to receive(:query_resource).and_return([resource_a, resource_b])
- expect(resource_store.find('foo')).to include(resource_a, resource_b)
+ expect(resource_store.find("foo")).to include(resource_a, resource_b)
end
- it 'deduplicates resources by ResourceName' do
+ it "deduplicates resources by ResourceName" do
expect(resource_store).to receive(:query_resource).and_return([resource_a, resource_a])
- resource_store.find('foo')
+ resource_store.find("foo")
expect(resource_store.resources).to eq([resource_a])
end
end
end
- context 'when resources are cached' do
- it 'recalls resources from the cache if present' do
+ context "when resources are cached" do
+ it "recalls resources from the cache if present" do
expect(resource_store).not_to receive(:query_resource)
expect(resource_store).to receive(:resources).and_return([resource_a])
- resource_store.find('foo')
+ resource_store.find("foo")
end
end
end
diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb
index 968302df17..9db7e85931 100644
--- a/spec/unit/util/editor_spec.rb
+++ b/spec/unit/util/editor_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require 'chef/util/editor'
+require "spec_helper"
+require "chef/util/editor"
describe Chef::Util::Editor do
describe '#initialize' do
- it 'takes an Enumerable of lines' do
+ it "takes an Enumerable of lines" do
editor = described_class.new(File.open(__FILE__))
expect(editor.lines).to be == IO.readlines(__FILE__)
end
- it 'makes a copy of an Array' do
+ it "makes a copy of an Array" do
array = Array.new
editor = described_class.new(array)
expect(editor.lines).to_not be(array)
@@ -16,137 +16,137 @@ describe Chef::Util::Editor do
end
subject(:editor) { described_class.new(input_lines) }
- let(:input_lines) { ['one', 'two', 'two', 'three'] }
+ let(:input_lines) { ["one", "two", "two", "three"] }
describe '#append_line_after' do
- context 'when there is no match' do
- subject(:execute) { editor.append_line_after('missing', 'new') }
+ context "when there is no match" do
+ subject(:execute) { editor.append_line_after("missing", "new") }
- it('returns the number of added lines') { is_expected.to eq(0) }
- it 'does not add any lines' do
+ it("returns the number of added lines") { is_expected.to eq(0) }
+ it "does not add any lines" do
expect { execute }.to_not change { editor.lines }
end
end
- context 'when there is a match' do
- subject(:execute) { editor.append_line_after('two', 'new') }
+ context "when there is a match" do
+ subject(:execute) { editor.append_line_after("two", "new") }
- it('returns the number of added lines') { is_expected.to eq(2) }
- it 'adds a line after each match' do
+ it("returns the number of added lines") { is_expected.to eq(2) }
+ it "adds a line after each match" do
execute
- expect(editor.lines).to be == ['one', 'two', 'new', 'two', 'new', 'three']
+ expect(editor.lines).to be == ["one", "two", "new", "two", "new", "three"]
end
end
- it 'matches a Regexp' do
- expect(editor.append_line_after(/^ee/, 'new')).to be == 0
- expect(editor.append_line_after(/ee$/, 'new')).to be == 1
+ it "matches a Regexp" do
+ expect(editor.append_line_after(/^ee/, "new")).to be == 0
+ expect(editor.append_line_after(/ee$/, "new")).to be == 1
end
end
describe '#append_line_if_missing' do
- context 'when there is no match' do
- subject(:execute) { editor.append_line_if_missing('missing', 'new') }
+ context "when there is no match" do
+ subject(:execute) { editor.append_line_if_missing("missing", "new") }
- it('returns the number of added lines') { is_expected.to eq(1) }
- it 'adds a line to the end' do
+ it("returns the number of added lines") { is_expected.to eq(1) }
+ it "adds a line to the end" do
execute
- expect(editor.lines).to be == ['one', 'two', 'two', 'three', 'new']
+ expect(editor.lines).to be == ["one", "two", "two", "three", "new"]
end
end
- context 'when there is a match' do
- subject(:execute) { editor.append_line_if_missing('one', 'new') }
+ context "when there is a match" do
+ subject(:execute) { editor.append_line_if_missing("one", "new") }
- it('returns the number of added lines') { is_expected.to eq(0) }
- it 'does not add any lines' do
+ it("returns the number of added lines") { is_expected.to eq(0) }
+ it "does not add any lines" do
expect { execute }.to_not change { editor.lines }
end
end
- it 'matches a Regexp' do
- expect(editor.append_line_if_missing(/ee$/, 'new')).to be == 0
- expect(editor.append_line_if_missing(/^ee/, 'new')).to be == 1
+ it "matches a Regexp" do
+ expect(editor.append_line_if_missing(/ee$/, "new")).to be == 0
+ expect(editor.append_line_if_missing(/^ee/, "new")).to be == 1
end
end
describe '#remove_lines' do
- context 'when there is no match' do
- subject(:execute) { editor.remove_lines('missing') }
+ context "when there is no match" do
+ subject(:execute) { editor.remove_lines("missing") }
- it('returns the number of removed lines') { is_expected.to eq(0) }
- it 'does not remove any lines' do
+ it("returns the number of removed lines") { is_expected.to eq(0) }
+ it "does not remove any lines" do
expect { execute }.to_not change { editor.lines }
end
end
- context 'when there is a match' do
- subject(:execute) { editor.remove_lines('two') }
+ context "when there is a match" do
+ subject(:execute) { editor.remove_lines("two") }
- it('returns the number of removed lines') { is_expected.to eq(2) }
- it 'removes the matching lines' do
+ it("returns the number of removed lines") { is_expected.to eq(2) }
+ it "removes the matching lines" do
execute
- expect(editor.lines).to be == ['one', 'three']
+ expect(editor.lines).to be == ["one", "three"]
end
end
- it 'matches a Regexp' do
+ it "matches a Regexp" do
expect(editor.remove_lines(/^ee/)).to be == 0
expect(editor.remove_lines(/ee$/)).to be == 1
end
end
describe '#replace' do
- context 'when there is no match' do
- subject(:execute) { editor.replace('missing', 'new') }
+ context "when there is no match" do
+ subject(:execute) { editor.replace("missing", "new") }
- it('returns the number of changed lines') { is_expected.to eq(0) }
- it 'does not change any lines' do
+ it("returns the number of changed lines") { is_expected.to eq(0) }
+ it "does not change any lines" do
expect { execute }.to_not change { editor.lines }
end
end
- context 'when there is a match' do
- subject(:execute) { editor.replace('two', 'new') }
+ context "when there is a match" do
+ subject(:execute) { editor.replace("two", "new") }
- it('returns the number of changed lines') { is_expected.to eq(2) }
- it 'replaces the matching portions' do
+ it("returns the number of changed lines") { is_expected.to eq(2) }
+ it "replaces the matching portions" do
execute
- expect(editor.lines).to be == ['one', 'new', 'new', 'three']
+ expect(editor.lines).to be == ["one", "new", "new", "three"]
end
end
- it 'matches a Regexp' do
- expect(editor.replace(/^ee/, 'new')).to be == 0
- expect(editor.replace(/ee$/, 'new')).to be == 1
- expect(editor.lines).to be == ['one', 'two', 'two', 'thrnew']
+ it "matches a Regexp" do
+ expect(editor.replace(/^ee/, "new")).to be == 0
+ expect(editor.replace(/ee$/, "new")).to be == 1
+ expect(editor.lines).to be == ["one", "two", "two", "thrnew"]
end
end
describe '#replace_lines' do
- context 'when there is no match' do
- subject(:execute) { editor.replace_lines('missing', 'new') }
+ context "when there is no match" do
+ subject(:execute) { editor.replace_lines("missing", "new") }
- it('returns the number of changed lines') { is_expected.to eq(0) }
- it 'does not change any lines' do
+ it("returns the number of changed lines") { is_expected.to eq(0) }
+ it "does not change any lines" do
expect { execute }.to_not change { editor.lines }
end
end
- context 'when there is a match' do
- subject(:execute) { editor.replace_lines('two', 'new') }
+ context "when there is a match" do
+ subject(:execute) { editor.replace_lines("two", "new") }
- it('returns the number of replaced lines') { is_expected.to eq(2) }
- it 'replaces the matching line' do
+ it("returns the number of replaced lines") { is_expected.to eq(2) }
+ it "replaces the matching line" do
execute
- expect(editor.lines).to be == ['one', 'new', 'new', 'three']
+ expect(editor.lines).to be == ["one", "new", "new", "three"]
end
end
- it 'matches a Regexp' do
- expect(editor.replace_lines(/^ee/, 'new')).to be == 0
- expect(editor.replace_lines(/ee$/, 'new')).to be == 1
- expect(editor.lines).to be == ['one', 'two', 'two', 'new']
+ it "matches a Regexp" do
+ expect(editor.replace_lines(/^ee/, "new")).to be == 0
+ expect(editor.replace_lines(/ee$/, "new")).to be == 1
+ expect(editor.lines).to be == ["one", "two", "two", "new"]
end
end
end
diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb
index b99cf2f426..5f9b559a4c 100644
--- a/spec/unit/util/file_edit_spec.rb
+++ b/spec/unit/util/file_edit_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
describe Chef::Util::FileEdit do
@@ -93,7 +93,7 @@ twice
end
let(:target_file) do
- f = Tempfile.open('file_edit_spec')
+ f = Tempfile.open("file_edit_spec")
f.write(starting_content)
f.close
f
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index 5ddf9282c4..d2a7960db2 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -16,25 +16,25 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/powershell/cmdlet'
+require "chef"
+require "chef/util/powershell/cmdlet"
describe Chef::Util::Powershell::Cmdlet do
before (:all) do
@node = Chef::Node.new
- @cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, 'Some-Commandlet')
+ @cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Some-Commandlet")
end
describe '#validate_switch_name!' do
- it 'should not raise an error if a name contains all upper case letters' do
+ it "should not raise an error if a name contains all upper case letters" do
@cmdlet.send(:validate_switch_name!, "HELLO")
end
- it 'should not raise an error if the name contains all lower case letters' do
+ it "should not raise an error if the name contains all lower case letters" do
@cmdlet.send(:validate_switch_name!, "hello")
end
- it 'should not raise an error if no special characters are used except _' do
+ it "should not raise an error if no special characters are used except _" do
@cmdlet.send(:validate_switch_name!, "hello_world")
end
@@ -55,51 +55,51 @@ describe Chef::Util::Powershell::Cmdlet do
end
end
- it 'does not do anything to a string without special characters' do
- expect(@cmdlet.send(:escape_parameter_value, 'stuff')).to eql('stuff')
+ it "does not do anything to a string without special characters" do
+ expect(@cmdlet.send(:escape_parameter_value, "stuff")).to eql("stuff")
end
end
describe '#escape_string_parameter_value' do
it "surrounds a string with ''" do
- expect(@cmdlet.send(:escape_string_parameter_value, 'stuff')).to eql("'stuff'")
+ expect(@cmdlet.send(:escape_string_parameter_value, "stuff")).to eql("'stuff'")
end
end
describe '#command_switches_string' do
- it 'raises an ArgumentError if the key is not a symbol' 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
+ 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('')
+ it "ignores switches with a false value" do
+ 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'")
+ it "should correctly handle a value type of string" do
+ 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 ''")
+ 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 ''")
end
- it 'should not quote integers' do
+ it "should not quote integers" do
expect(@cmdlet.send(:command_switches_string, {foo: 1})).to eql("-foo 1")
end
- it 'should not quote floats' do
+ it "should not quote floats" do
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
+ it "has just the switch when the value is true" do
expect(@cmdlet.send(:command_switches_string, {foo: true})).to eql("-foo")
end
end
diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb
index 668ec525c6..2ec7ff6238 100644
--- a/spec/unit/util/powershell/ps_credential_spec.rb
+++ b/spec/unit/util/powershell/ps_credential_spec.rb
@@ -16,27 +16,27 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/powershell/ps_credential'
+require "chef"
+require "chef/util/powershell/ps_credential"
describe Chef::Util::Powershell::PSCredential do
- let (:username) { 'foo' }
- let (:password) { 'ThIsIsThEpAsSwOrD' }
+ let (:username) { "foo" }
+ let (:password) { "ThIsIsThEpAsSwOrD" }
- context 'when username and password are provided' do
+ context "when username and password are provided" do
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')
+ 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")
expect(ps_credential.to_psobject).to eq(
"New-Object System.Management.Automation.PSCredential("\
"'#{username}',('encrypted' | ConvertTo-SecureString))")
end
end
- context 'when to_text is called' do
- it 'should not contain the password' do
- allow(ps_credential).to receive(:encrypt).with(password).and_return('encrypted')
+ context "when to_text is called" do
+ it "should not contain the password" do
+ allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted")
expect(ps_credential.to_text).not_to match(/#{password}/)
end
end
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 0ed138c7bc..60f1ba8fae 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -17,7 +17,7 @@
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Util::Selinux do
class TestClass
@@ -40,7 +40,7 @@ describe Chef::Util::Selinux do
end
it "each part of ENV['PATH'] should be checked" do
- expected_paths = ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ]
+ expected_paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
expected_paths.each do |bin_path|
selinux_path = File.join(bin_path, "selinuxenabled")
diff --git a/spec/unit/util/threaded_job_queue_spec.rb b/spec/unit/util/threaded_job_queue_spec.rb
index 22626328be..e4eb58d8bd 100644
--- a/spec/unit/util/threaded_job_queue_spec.rb
+++ b/spec/unit/util/threaded_job_queue_spec.rb
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
+require "spec_helper"
class WorkerThreadError < StandardError
end
diff --git a/spec/unit/version/platform_spec.rb b/spec/unit/version/platform_spec.rb
index dd425b32a5..6c9720fe6d 100644
--- a/spec/unit/version/platform_spec.rb
+++ b/spec/unit/version/platform_spec.rb
@@ -14,13 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/version/platform'
+require "spec_helper"
+require "chef/version/platform"
describe Chef::Version::Platform do
it "is a subclass of Chef::Version" do
- v = Chef::Version::Platform.new('1.1')
+ v = Chef::Version::Platform.new("1.1")
expect(v).to be_an_instance_of(Chef::Version::Platform)
expect(v).to be_a_kind_of(Chef::Version)
end
diff --git a/spec/unit/version_class_spec.rb b/spec/unit/version_class_spec.rb
index f1f55c7b05..2e70b7e00c 100644
--- a/spec/unit/version_class_spec.rb
+++ b/spec/unit/version_class_spec.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/version_class'
+require "spec_helper"
+require "chef/version_class"
describe Chef::Version do
before do
diff --git a/spec/unit/version_constraint/platform_spec.rb b/spec/unit/version_constraint/platform_spec.rb
index f38eb49689..a4ddc4e0bd 100644
--- a/spec/unit/version_constraint/platform_spec.rb
+++ b/spec/unit/version_constraint/platform_spec.rb
@@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/version_constraint/platform'
+require "spec_helper"
+require "chef/version_constraint/platform"
describe Chef::VersionConstraint::Platform do
diff --git a/spec/unit/version_constraint_spec.rb b/spec/unit/version_constraint_spec.rb
index 0ae502f66d..e50fd2115c 100644
--- a/spec/unit/version_constraint_spec.rb
+++ b/spec/unit/version_constraint_spec.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'spec_helper'
-require 'chef/version_constraint'
+require "spec_helper"
+require "chef/version_constraint"
describe Chef::VersionConstraint do
describe "validation" do
@@ -88,7 +88,7 @@ describe Chef::VersionConstraint do
expect(@vc).to include Chef::Version.new("1.4")
end
it "Chef::CookbookVersion" do
- cv = Chef::CookbookVersion.new("alice", '/tmp/blah.txt')
+ cv = Chef::CookbookVersion.new("alice", "/tmp/blah.txt")
cv.version = "1.4"
expect(@vc).to include cv
end
@@ -149,31 +149,31 @@ describe Chef::VersionConstraint do
end
end
- describe 'to_s' do
- it 'shows a patch-level if one is given' do
- vc = Chef::VersionConstraint.new '~> 1.2.0'
+ describe "to_s" do
+ it "shows a patch-level if one is given" do
+ vc = Chef::VersionConstraint.new "~> 1.2.0"
- expect(vc.to_s).to eq('~> 1.2.0')
+ expect(vc.to_s).to eq("~> 1.2.0")
end
- it 'shows no patch-level if one is not given' do
- vc = Chef::VersionConstraint.new '~> 1.2'
+ it "shows no patch-level if one is not given" do
+ vc = Chef::VersionConstraint.new "~> 1.2"
- expect(vc.to_s).to eq('~> 1.2')
+ expect(vc.to_s).to eq("~> 1.2")
end
end
- describe 'inspect' do
- it 'shows a patch-level if one is given' do
- vc = Chef::VersionConstraint.new '~> 1.2.0'
+ describe "inspect" do
+ it "shows a patch-level if one is given" do
+ vc = Chef::VersionConstraint.new "~> 1.2.0"
- expect(vc.inspect).to eq('(~> 1.2.0)')
+ expect(vc.inspect).to eq("(~> 1.2.0)")
end
- it 'shows no patch-level if one is not given' do
- vc = Chef::VersionConstraint.new '~> 1.2'
+ it "shows no patch-level if one is not given" do
+ vc = Chef::VersionConstraint.new "~> 1.2"
- expect(vc.inspect).to eq('(~> 1.2)')
+ expect(vc.inspect).to eq("(~> 1.2)")
end
end
end
diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb
index 56def30638..fc0a21242b 100644
--- a/spec/unit/win32/registry_spec.rb
+++ b/spec/unit/win32/registry_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Win32::Registry do
include_context "Win32"
@@ -25,9 +25,9 @@ describe Chef::Win32::Registry do
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(:key_parent) { "Software" }
+ let(:key_to_delete) { "OpscodeNumbers" }
+ 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") }
@@ -49,10 +49,10 @@ describe Chef::Win32::Registry do
end
after(:each) do
- Win32::Registry.send(:remove_const, 'KEY_SET_VALUE') if defined?(Win32::Registry::KEY_SET_VALUE)
- Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE)
- Win32::Registry.send(:remove_const, 'KEY_READ') if defined?(Win32::Registry::KEY_READ)
- Win32::Registry.send(:remove_const, 'KEY_WRITE') if defined?(Win32::Registry::KEY_WRITE)
+ Win32::Registry.send(:remove_const, "KEY_SET_VALUE") if defined?(Win32::Registry::KEY_SET_VALUE)
+ Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE)
+ Win32::Registry.send(:remove_const, "KEY_READ") if defined?(Win32::Registry::KEY_READ)
+ Win32::Registry.send(:remove_const, "KEY_WRITE") if defined?(Win32::Registry::KEY_WRITE)
end
describe "get_values" do
diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb
index adc128c9d8..a614e6630d 100644
--- a/spec/unit/windows_service_spec.rb
+++ b/spec/unit/windows_service_spec.rb
@@ -15,13 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
if Chef::Platform.windows?
- require 'chef/application/windows_service'
+ require "chef/application/windows_service"
end
describe "Chef::Application::WindowsService", :windows_only do
- let(:shell_out_result) { double('shellout', stdout: nil, stderr: nil) }
+ let(:shell_out_result) { double("shellout", stdout: nil, stderr: nil) }
let(:config_options) do
{
log_location: STDOUT,
@@ -57,8 +57,8 @@ describe "Chef::Application::WindowsService", :windows_only do
subject.service_main
end
- context 'has a log location configured' do
- let(:tempfile) { Tempfile.new 'log_file' }
+ context "has a log location configured" do
+ let(:tempfile) { Tempfile.new "log_file" }
let(:config_options) do
{
log_location: tempfile.path,
@@ -79,7 +79,7 @@ describe "Chef::Application::WindowsService", :windows_only do
subject.service_main
end
- context 'configured to Event Logger' do
+ context "configured to Event Logger" do
let(:config_options) do
{
log_location: Chef::Log::WinEvt.new,
@@ -98,7 +98,7 @@ describe "Chef::Application::WindowsService", :windows_only do
end
end
- context 'configueres a watchdog timeout' do
+ context "configueres a watchdog timeout" do
let(:timeout) { 10 }
before do