summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-18 12:27:13 -0700
committerGitHub <noreply@github.com>2016-08-18 12:27:13 -0700
commit6a5388d1a492437a6e798befc3b784a34fd27a53 (patch)
treea27f7ec85e919c52f86f521a8d2f187cb6ab71bd
parentf55d0053ce6646d2e925336f6766c3c8e018ad90 (diff)
parent0db588acb55bdbbbca5ab9c0e307f79e7de5dc31 (diff)
downloadchef-6a5388d1a492437a6e798befc3b784a34fd27a53.tar.gz
Merge pull request #5218 from chef/lcg/more-more-cops
fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgrade
-rw-r--r--chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb6
-rw-r--r--lib/chef/application/client.rb8
-rw-r--r--lib/chef/application/solo.rb4
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb4
-rw-r--r--lib/chef/cookbook/synchronizer.rb4
-rw-r--r--lib/chef/cookbook_version.rb4
-rw-r--r--lib/chef/http.rb37
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb4
-rw-r--r--lib/chef/knife.rb87
-rw-r--r--lib/chef/knife/client_delete.rb4
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb4
-rw-r--r--lib/chef/knife/status.rb4
-rw-r--r--lib/chef/mixin/command/unix.rb4
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb2
-rw-r--r--lib/chef/mixin/securable.rb4
-rw-r--r--lib/chef/monkey_patches/webrick-utils.rb4
-rw-r--r--lib/chef/node/attribute.rb4
-rw-r--r--lib/chef/property.rb4
-rw-r--r--lib/chef/provider/dsc_script.rb8
-rw-r--r--lib/chef/provider/osx_profile.rb16
-rw-r--r--lib/chef/provider/package/yum/yum_cache.rb2
-rw-r--r--lib/chef/provider/remote_file/ftp.rb4
-rw-r--r--lib/chef/provider/remote_file/sftp.rb4
-rw-r--r--lib/chef/provider/service/debian.rb4
-rw-r--r--lib/chef/provider/service/simple.rb5
-rw-r--r--lib/chef/resource.rb14
-rw-r--r--lib/chef/resource_builder.rb2
-rw-r--r--lib/chef/search/query.rb4
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb19
-rw-r--r--spec/functional/knife/ssh_spec.rb4
-rw-r--r--spec/functional/notifications_spec.rb4
-rw-r--r--spec/functional/provider/whyrun_safe_ruby_block_spec.rb4
-rw-r--r--spec/functional/rebooter_spec.rb10
-rw-r--r--spec/functional/resource/bash_spec.rb4
-rw-r--r--spec/functional/resource/dpkg_package_spec.rb4
-rw-r--r--spec/functional/resource/dsc_resource_spec.rb8
-rw-r--r--spec/functional/resource/dsc_script_spec.rb49
-rwxr-xr-xspec/functional/resource/env_spec.rb8
-rw-r--r--spec/functional/resource/execute_spec.rb8
-rw-r--r--spec/functional/resource/group_spec.rb14
-rw-r--r--spec/functional/resource/ohai_spec.rb12
-rw-r--r--spec/functional/resource/reboot_spec.rb4
-rw-r--r--spec/functional/resource/user/dscl_spec.rb4
-rw-r--r--spec/functional/resource/windows_service_spec.rb28
-rw-r--r--spec/functional/win32/crypto_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb16
-rw-r--r--spec/integration/client/client_spec.rb4
-rw-r--r--spec/integration/knife/upload_spec.rb2
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb12
-rw-r--r--spec/integration/recipes/noop_resource_spec.rb8
-rw-r--r--spec/integration/recipes/provider_choice.rb6
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb635
-rw-r--r--spec/integration/recipes/resource_action_spec.rb68
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb68
-rw-r--r--spec/integration/recipes/resource_load_spec.rb48
-rw-r--r--spec/integration/solo/solo_spec.rb4
-rw-r--r--spec/scripts/ssl-serve.rb2
-rw-r--r--spec/stress/win32/security_spec.rb8
-rw-r--r--spec/support/shared/context/client.rb5
-rw-r--r--spec/support/shared/functional/file_resource.rb8
-rw-r--r--spec/support/shared/functional/http.rb32
-rw-r--r--spec/support/shared/functional/win32_service.rb8
-rw-r--r--spec/support/shared/shared_examples.rb4
-rw-r--r--spec/support/shared/unit/api_versioning.rb4
-rw-r--r--spec/support/shared/unit/application_dot_d.rb15
-rw-r--r--spec/support/shared/unit/provider/file.rb4
-rw-r--r--spec/support/shared/unit/resource/static_provider_resolution.rb4
-rw-r--r--spec/support/shared/unit/script_resource.rb8
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb8
-rw-r--r--spec/unit/api_client_v1_spec.rb4
-rw-r--r--spec/unit/application_spec.rb2
-rw-r--r--spec/unit/audit/audit_event_proxy_spec.rb61
-rw-r--r--spec/unit/audit/audit_reporter_spec.rb55
-rw-r--r--spec/unit/audit/control_group_data_spec.rb33
-rw-r--r--spec/unit/chef_class_spec.rb2
-rw-r--r--spec/unit/chef_fs/data_handler/group_handler_spec.rb2
-rw-r--r--spec/unit/chef_fs/diff_spec.rb8
-rw-r--r--spec/unit/chef_fs/file_system/operation_failed_error_spec.rb8
-rw-r--r--spec/unit/chef_fs/file_system_spec.rb4
-rw-r--r--spec/unit/cookbook/metadata_spec.rb196
-rw-r--r--spec/unit/cookbook_loader_spec.rb48
-rw-r--r--spec/unit/cookbook_version_file_specificity_spec.rb16
-rw-r--r--spec/unit/data_bag_item_spec.rb36
-rw-r--r--spec/unit/data_bag_spec.rb4
-rw-r--r--spec/unit/data_collector/messages/helpers_spec.rb18
-rw-r--r--spec/unit/data_collector/messages_spec.rb4
-rw-r--r--spec/unit/data_collector_spec.rb36
-rw-r--r--spec/unit/dsl/audit_spec.rb6
-rw-r--r--spec/unit/dsl/data_query_spec.rb5
-rw-r--r--spec/unit/dsl/declare_resource_spec.rb20
-rw-r--r--spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb5
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb5
-rw-r--r--spec/unit/environment_spec.rb12
-rw-r--r--spec/unit/file_access_control_spec.rb2
-rw-r--r--spec/unit/file_content_management/tempfile_spec.rb4
-rw-r--r--spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb4
-rw-r--r--spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb4
-rw-r--r--spec/unit/http/validate_content_length_spec.rb16
-rw-r--r--spec/unit/knife/bootstrap/chef_vault_handler_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap_spec.rb14
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb16
-rw-r--r--spec/unit/knife/client_edit_spec.rb4
-rw-r--r--spec/unit/knife/configure_client_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb11
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb9
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb6
-rw-r--r--spec/unit/knife/core/ui_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb5
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb5
-rw-r--r--spec/unit/knife/key_create_spec.rb28
-rw-r--r--spec/unit/knife/key_delete_spec.rb4
-rw-r--r--spec/unit/knife/key_edit_spec.rb32
-rw-r--r--spec/unit/knife/key_list_spec.rb12
-rw-r--r--spec/unit/knife/key_show_spec.rb8
-rw-r--r--spec/unit/knife/status_spec.rb5
-rw-r--r--spec/unit/knife/user_create_spec.rb8
-rw-r--r--spec/unit/knife_spec.rb13
-rw-r--r--spec/unit/lwrp_spec.rb8
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb4
-rw-r--r--spec/unit/mixin/command_spec.rb31
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb4
-rw-r--r--spec/unit/mixin/params_validate_spec.rb105
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb4
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb4
-rw-r--r--spec/unit/mixin/shell_out_spec.rb2
-rw-r--r--spec/unit/mixin/xml_escape_spec.rb6
-rw-r--r--spec/unit/node_spec.rb4
-rw-r--r--spec/unit/platform/query_helpers_spec.rb6
-rw-r--r--spec/unit/property_spec.rb8
-rw-r--r--spec/unit/provider/cookbook_file_spec.rb8
-rw-r--r--spec/unit/provider/cron/unix_spec.rb8
-rw-r--r--spec/unit/provider/cron_spec.rb4
-rw-r--r--spec/unit/provider/deploy_spec.rb16
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb21
-rw-r--r--spec/unit/provider/dsc_script_spec.rb18
-rw-r--r--spec/unit/provider/env/windows_spec.rb16
-rw-r--r--spec/unit/provider/file/content_spec.rb12
-rw-r--r--spec/unit/provider/file_spec.rb8
-rw-r--r--spec/unit/provider/launchd_spec.rb3
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb96
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb8
-rw-r--r--spec/unit/provider/package/yum_spec.rb109
-rw-r--r--spec/unit/provider/package_spec.rb4
-rw-r--r--spec/unit/provider/powershell_script_spec.rb8
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb8
-rw-r--r--spec/unit/provider/remote_file/sftp_spec.rb8
-rw-r--r--spec/unit/provider/remote_file_spec.rb8
-rw-r--r--spec/unit/provider/script_spec.rb8
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb8
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb20
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb20
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb4
-rw-r--r--spec/unit/provider/service/windows_spec.rb20
-rw-r--r--spec/unit/provider/template/content_spec.rb16
-rw-r--r--spec/unit/provider/template_spec.rb16
-rw-r--r--spec/unit/provider/user/dscl_spec.rb100
-rw-r--r--spec/unit/provider/user/solaris_spec.rb4
-rw-r--r--spec/unit/provider/user_spec.rb4
-rw-r--r--spec/unit/recipe_spec.rb15
-rw-r--r--spec/unit/resource/dsc_resource_spec.rb16
-rw-r--r--spec/unit/resource/dsc_script_spec.rb8
-rw-r--r--spec/unit/resource/launchd_spec.rb5
-rw-r--r--spec/unit/resource/osx_profile_spec.rb5
-rw-r--r--spec/unit/resource/remote_file_spec.rb12
-rw-r--r--spec/unit/resource/service_spec.rb28
-rw-r--r--spec/unit/resource_collection_spec.rb8
-rw-r--r--spec/unit/resource_definition_spec.rb22
-rw-r--r--spec/unit/resource_reporter_spec.rb8
-rw-r--r--spec/unit/resource_resolver_spec.rb12
-rw-r--r--spec/unit/resource_spec.rb32
-rw-r--r--spec/unit/run_context/child_run_context_spec.rb8
-rw-r--r--spec/unit/run_context_spec.rb16
-rw-r--r--spec/unit/runner_spec.rb4
-rw-r--r--spec/unit/search/query_spec.rb29
-rw-r--r--spec/unit/user_v1_spec.rb16
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb24
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb21
-rw-r--r--spec/unit/util/dsc/resource_store.rb14
-rw-r--r--spec/unit/util/editor_spec.rb12
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb20
-rw-r--r--tasks/cbgb.rb4
-rw-r--r--tasks/maintainers.rb4
184 files changed, 1722 insertions, 1636 deletions
diff --git a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
index c4d9185d81..6dd678840a 100644
--- a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
+++ b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb
@@ -21,9 +21,9 @@ module ChefConfig
module FuzzyHostnameMatcher
def fuzzy_hostname_match_any?(hostname, matches)
- return matches.to_s.split(/\s*,\s*/).compact.any? {
- |m| fuzzy_hostname_match?(hostname, m)
- } if (hostname != nil) && (matches != nil)
+ return matches.to_s.split(/\s*,\s*/).compact.any? do |m|
+ fuzzy_hostname_match?(hostname, m)
+ end if (hostname != nil) && (matches != nil)
false
end
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 71bb300971..cbaa494b71 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -204,9 +204,9 @@ class Chef::Application::Client < Chef::Application
:description => "Replace current run list with specified items for a single run",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :runlist,
@@ -215,9 +215,9 @@ class Chef::Application::Client < Chef::Application
:description => "Permanently replace current run list with specified items",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :why_run,
:short => "-W",
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 8bf381a975..446a0f007d 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -168,9 +168,9 @@ class Chef::Application::Solo < Chef::Application
:description => "Replace current run list with specified items",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :client_fork,
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb
index b34aff4b98..3668f77dd5 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -93,7 +93,7 @@ class Chef
# name to recipe[name]. Then calls uniq on the result.
#
def normalize_run_list(run_list)
- run_list.map {|item|
+ run_list.map do |item|
case item.to_s
when /^recipe\[.*\]$/
item # explicit recipe
@@ -102,7 +102,7 @@ class Chef
else
"recipe[#{item}]"
end
- }.uniq
+ end.uniq
end
#
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index 01f6155bf3..bb44bc3d5c 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -152,11 +152,11 @@ class Chef
queue << lambda do |lock|
full_file_path = sync_file(file)
- lock.synchronize {
+ lock.synchronize do
# Save the full_path of the downloaded file to be restored in the manifest later
save_full_file_path(file, full_file_path)
mark_file_synced(file)
- }
+ end
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index bf9e755f3f..8de9cb26dd 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -316,13 +316,13 @@ class Chef
error_message << error_locations.join("\n")
existing_files = segment_filenames(segment)
# Strip the root_dir prefix off all files for readability
- pretty_existing_files = existing_files.map { |path|
+ pretty_existing_files = existing_files.map do |path|
if root_dir
path[root_dir.length + 1..-1]
else
path
end
- }
+ end
# Show the files that the cookbook does have. If the user made a typo,
# hopefully they'll see it here.
unless pretty_existing_files.empty?
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 0def3378be..924081bc6b 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -248,8 +248,16 @@ class Chef
end
end
+ # DEPRECATED: This is only kept around to provide access to cache control data in
+ # lib/chef/provider/remote_file/http.rb
+ # FIXME: Find a better API.
+ def last_response
+ @last_response
+ end
+
private
+ # @api private
def build_http_client(base_url)
if chef_zero_uri?(base_url)
# PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick
@@ -266,6 +274,7 @@ class Chef
end
end
+ # @api private
def create_url(path)
return path if path.is_a?(URI)
if path =~ /^(http|https|chefzero):\/\//i
@@ -280,6 +289,7 @@ class Chef
end
end
+ # @api private
def apply_request_middleware(method, url, headers, data)
middlewares.inject([method, url, headers, data]) do |req_data, middleware|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_request")
@@ -287,6 +297,7 @@ class Chef
end
end
+ # @api private
def apply_response_middleware(response, rest_request, return_value)
middlewares.reverse.inject([response, rest_request, return_value]) do |res_data, middleware|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_response")
@@ -294,6 +305,7 @@ class Chef
end
end
+ # @api private
def apply_stream_complete_middleware(response, rest_request, return_value)
middlewares.reverse.inject([response, rest_request, return_value]) do |res_data, middleware|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_stream_complete")
@@ -301,6 +313,7 @@ class Chef
end
end
+ # @api private
def log_failed_request(response, return_value)
return_value ||= {}
error_message = "HTTP Request Returned #{response.code} #{response.message}: "
@@ -308,12 +321,14 @@ class Chef
Chef::Log.info(error_message)
end
+ # @api private
def success_response?(response)
response.kind_of?(Net::HTTPSuccess) || response.kind_of?(Net::HTTPRedirection)
end
# Runs a synchronous HTTP request, with no middleware applied (use #request
# to have the middleware applied). The entire response will be loaded into memory.
+ # @api private
def send_http_request(method, url, headers, body, &response_handler)
headers = build_headers(method, url, headers, body)
@@ -349,6 +364,7 @@ class Chef
# Wraps an HTTP request with retry logic.
# === Arguments
# url:: URL of the request, used for error messages
+ # @api private
def retrying_http_errors(url)
http_attempts = 0
begin
@@ -398,18 +414,22 @@ class Chef
end
end
+ # @api private
def http_retry_delay
config[:http_retry_delay]
end
+ # @api private
def http_retry_count
config[:http_retry_count]
end
+ # @api private
def config
Chef::Config
end
+ # @api private
def follow_redirect
raise Chef::Exceptions::RedirectLimitExceeded if @redirects_followed >= redirect_limit
@redirects_followed += 1
@@ -420,11 +440,13 @@ class Chef
@redirects_followed = 0
end
+ # @api private
def chef_zero_uri?(uri)
uri = URI.parse(uri) unless uri.respond_to?(:scheme)
uri.scheme == "chefzero"
end
+ # @api private
def redirected_to(response)
return nil unless response.kind_of?(Net::HTTPRedirection)
# Net::HTTPNotModified is undesired subclass of Net::HTTPRedirection so test for this
@@ -432,6 +454,7 @@ class Chef
response["location"]
end
+ # @api private
def build_headers(method, url, headers = {}, json_body = false)
headers = @default_headers.merge(headers)
headers["Content-Length"] = json_body.bytesize.to_s if json_body
@@ -439,6 +462,7 @@ class Chef
headers
end
+ # @api private
def stream_to_tempfile(url, response, &progress_block)
content_length = response["Content-Length"]
tf = Tempfile.open("chef-rest")
@@ -462,18 +486,5 @@ class Chef
raise
end
- public
-
- ############################################################################
- # DEPRECATED
- ############################################################################
-
- # This is only kept around to provide access to cache control data in
- # lib/chef/provider/remote_file/http.rb
- # Find a better API.
- def last_response
- @last_response
- end
-
end
end
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index 1acac5e758..d2f1f45b1d 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -197,9 +197,9 @@ class Chef
private
def headers_extracted_from_options
- options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value|
+ options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map do |name, value|
[name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value]
- }
+ end
end
end
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 356bf47fd4..c8b344b5f1 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -233,61 +233,66 @@ class Chef
end
end
- private
-
OFFICIAL_PLUGINS = %w{ec2 rackspace windows openstack terremark bluebox}
- def self.path_from_caller(caller_line)
- caller_line.split(/:\d+/).first
- end
-
- # :nodoc:
- # Error out and print usage. probably because the arguments given by the
- # user could not be resolved to a subcommand.
- def self.subcommand_not_found!(args)
- ui.fatal("Cannot find subcommand for: '#{args.join(' ')}'")
+ class << self
+ private
- # Mention rehash when the subcommands cache(plugin_manifest.json) is used
- if subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::HashedCommandLoader) ||
- subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::CustomManifestLoader)
- ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
+ # @api private
+ def path_from_caller(caller_line)
+ caller_line.split(/:\d+/).first
end
- if category_commands = guess_category(args)
- list_commands(category_commands)
- elsif missing_plugin = ( OFFICIAL_PLUGINS.find { |plugin| plugin == args[0] } )
- ui.info("The #{missing_plugin} commands were moved to plugins in Chef 0.10")
- ui.info("You can install the plugin with `(sudo) gem install knife-#{missing_plugin}`")
- ui.info("Use `chef gem install knife-#{missing_plugin}` instead if using ChefDK")
- else
- list_commands
- end
+ # :nodoc:
+ # Error out and print usage. probably because the arguments given by the
+ # user could not be resolved to a subcommand.
+ # @api private
+ def subcommand_not_found!(args)
+ ui.fatal("Cannot find subcommand for: '#{args.join(' ')}'")
+
+ # Mention rehash when the subcommands cache(plugin_manifest.json) is used
+ if subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::HashedCommandLoader) ||
+ subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::CustomManifestLoader)
+ ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
+ end
- exit 10
- end
+ if category_commands = guess_category(args)
+ list_commands(category_commands)
+ elsif missing_plugin = ( OFFICIAL_PLUGINS.find { |plugin| plugin == args[0] } )
+ ui.info("The #{missing_plugin} commands were moved to plugins in Chef 0.10")
+ ui.info("You can install the plugin with `(sudo) gem install knife-#{missing_plugin}`")
+ ui.info("Use `chef gem install knife-#{missing_plugin}` instead if using ChefDK")
+ else
+ list_commands
+ end
- def self.list_commands(preferred_category = nil)
- category_desc = preferred_category ? preferred_category + " " : ""
- msg "Available #{category_desc}subcommands: (for details, knife SUB-COMMAND --help)\n\n"
- subcommand_loader.list_commands(preferred_category).sort.each do |category, commands|
- next if category =~ /deprecated/i
- msg "** #{category.upcase} COMMANDS **"
- commands.sort.each do |command|
- subcommand_loader.load_command(command)
- msg subcommands[command].banner if subcommands[command]
+ exit 10
+ end
+
+ # @api private
+ def list_commands(preferred_category = nil)
+ category_desc = preferred_category ? preferred_category + " " : ""
+ msg "Available #{category_desc}subcommands: (for details, knife SUB-COMMAND --help)\n\n"
+ subcommand_loader.list_commands(preferred_category).sort.each do |category, commands|
+ next if category =~ /deprecated/i
+ msg "** #{category.upcase} COMMANDS **"
+ commands.sort.each do |command|
+ subcommand_loader.load_command(command)
+ msg subcommands[command].banner if subcommands[command]
+ end
+ msg
end
- msg
end
- end
- def self.reset_config_path!
- @@chef_config_dir = nil
+ # @api private
+ def reset_config_path!
+ @@chef_config_dir = nil
+ end
+
end
reset_config_path!
- public
-
# Create a new instance of the current class configured for the given
# arguments and options
def initialize(argv = [])
diff --git a/lib/chef/knife/client_delete.rb b/lib/chef/knife/client_delete.rb
index e1b2365361..08cdf6c7dd 100644
--- a/lib/chef/knife/client_delete.rb
+++ b/lib/chef/knife/client_delete.rb
@@ -43,7 +43,7 @@ class Chef
exit 1
end
- delete_object(Chef::ApiClientV1, @client_name, "client") {
+ delete_object(Chef::ApiClientV1, @client_name, "client") do
object = Chef::ApiClientV1.load(@client_name)
if object.validator
unless config[:delete_validators]
@@ -52,7 +52,7 @@ class Chef
end
end
object.destroy
- }
+ end
end
end
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index bb129a652d..34c5c53d75 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -81,9 +81,9 @@ class Chef
files = []
if check_load_path
- files = $LOAD_PATH.map { |load_path|
+ files = $LOAD_PATH.map do |load_path|
Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
- }.flatten.select { |file| File.file? file.untaint }
+ end.flatten.select { |file| File.file? file.untaint }
end
gem_files = latest_gem_specs.map do |spec|
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 551d5addfc..0e3cd7e7d6 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -96,13 +96,13 @@ class Chef
all_nodes << node
end
- output(all_nodes.sort { |n1, n2|
+ output(all_nodes.sort do |n1, n2|
if config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse]
(n2["ohai_time"] || 0) <=> (n1["ohai_time"] || 0)
else
(n1["ohai_time"] || 0) <=> (n2["ohai_time"] || 0)
end
- })
+ end)
end
end
diff --git a/lib/chef/mixin/command/unix.rb b/lib/chef/mixin/command/unix.rb
index bfd507979f..aa541c3637 100644
--- a/lib/chef/mixin/command/unix.rb
+++ b/lib/chef/mixin/command/unix.rb
@@ -64,7 +64,7 @@ class Chef
$VERBOSE = nil
ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
- cid = fork {
+ cid = fork do
pw.last.close
STDIN.reopen pw.first
pw.first.close
@@ -111,7 +111,7 @@ class Chef
end
ps.last.close unless ps.last.closed?
exit!
- }
+ end
ensure
$VERBOSE = verbose
end
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index 381cbed637..6159c87948 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -63,7 +63,7 @@ class Chef
end
def unsafe?(s)
- ["'", '#', "`", '"'].any? do |x|
+ ["'", "#", "`", '"'].any? do |x|
s.include? x
end
end
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index a88d534b37..55b4e0a6d1 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -43,7 +43,7 @@ class Chef
:mode,
arg,
:callbacks => {
- "not in valid numeric range" => lambda { |m|
+ "not in valid numeric range" => lambda do |m|
if m.kind_of?(String)
m =~ /^0/ || m = "0#{m}"
end
@@ -54,7 +54,7 @@ class Chef
else
Integer(m) <= 07777 && Integer(m) >= 0
end
- },
+ end,
}
)
end
diff --git a/lib/chef/monkey_patches/webrick-utils.rb b/lib/chef/monkey_patches/webrick-utils.rb
index 7880adb202..ccca5825e2 100644
--- a/lib/chef/monkey_patches/webrick-utils.rb
+++ b/lib/chef/monkey_patches/webrick-utils.rb
@@ -31,7 +31,7 @@ module WEBrick
Socket::AI_PASSIVE) # flag
last_error = nil
sockets = []
- res.each {|ai|
+ res.each do |ai|
begin
logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
sock = TCPServer.new(ai[3], port)
@@ -42,7 +42,7 @@ module WEBrick
logger.warn("TCPServer Error: #{ex}") if logger
last_error = ex
end
- }
+ end
raise last_error if sockets.empty?
return sockets
end
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index e4035dd22f..95b3b09f7e 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -537,9 +537,9 @@ class Chef
end
def inspect
- "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map {|iv|
+ "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map do |iv|
"#{iv}=#{instance_variable_get(iv).inspect}"
- }.join(", ") << ">"
+ end.join(", ") << ">"
end
private
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 0589cb4c54..3cb235b612 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -235,9 +235,9 @@ class Chef
# @return [Hash<Symbol,Object>]
#
def validation_options
- @validation_options ||= options.reject { |k, v|
+ @validation_options ||= options.reject do |k, v|
[:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable].include?(k)
- }
+ end
end
#
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index 79769d9773..66783ceb0f 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -32,12 +32,12 @@ class Chef
@dsc_resource = dsc_resource
@resource_converged = false
@operations = {
- :set => Proc.new { |config_manager, document, shellout_flags|
+ :set => Proc.new do |config_manager, document, shellout_flags|
config_manager.set_configuration(document, shellout_flags)
- },
- :test => Proc.new { |config_manager, document, shellout_flags|
+ end,
+ :test => Proc.new do |config_manager, document, shellout_flags|
config_manager.test_configuration(document, shellout_flags)
- } }
+ end }
end
def action_run
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index f2e71a6621..f5535f5c37 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -66,33 +66,33 @@ class Chef
def define_resource_requirements
requirements.assert(:remove) do |a|
if @new_profile_identifier
- a.assertion {
+ a.assertion do
!@new_profile_identifier.nil? &&
!@new_profile_identifier.end_with?(".mobileconfig") &&
/^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
- }
+ end
a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier"
else
new_profile_name = @new_resource.profile_name
- a.assertion {
+ a.assertion do
!new_profile_name.end_with?(".mobileconfig") &&
/^\w+(?:\.\w+)+$/.match(new_profile_name)
- }
+ end
a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier "
end
end
requirements.assert(:install) do |a|
if @new_profile_hash.is_a?(Hash)
- a.assertion {
+ a.assertion do
@new_profile_hash.include?("PayloadIdentifier")
- }
+ end
a.failure_message RuntimeError, "The specified profile does not seem to be valid"
end
if @new_profile_hash.is_a?(String)
- a.assertion {
+ a.assertion do
@new_profile_hash.end_with?(".mobileconfig")
- }
+ end
a.failure_message RuntimeError, "#{new_profile_hash}' is not a valid profile"
end
end
diff --git a/lib/chef/provider/package/yum/yum_cache.rb b/lib/chef/provider/package/yum/yum_cache.rb
index fb25a91c8c..7462529113 100644
--- a/lib/chef/provider/package/yum/yum_cache.rb
+++ b/lib/chef/provider/package/yum/yum_cache.rb
@@ -197,7 +197,7 @@ class Chef
def shabang?(file)
::File.open(file, "r") do |f|
- f.read(2) == '#!'
+ f.read(2) == "#!"
end
rescue Errno::ENOENT
false
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index 5935e83301..b382c20c31 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -153,9 +153,9 @@ class Chef
def parse_path
path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
directories = path.split(%r{/}, -1)
- directories.each {|d|
+ directories.each do |d|
d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
+ end
unless filename = directories.pop
raise ArgumentError, "no filename: #{path.inspect}"
end
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index 530977e3c8..21c5c4ca04 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -68,9 +68,9 @@ class Chef
def validate_path!
path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
directories = path.split(%r{/}, -1)
- directories.each {|d|
+ directories.each do |d|
d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
+ end
unless filename = directories.pop
raise ArgumentError, "no filename: #{path.inspect}"
end
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 67b71953f7..9d11032055 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -106,13 +106,13 @@ class Chef
def service_currently_enabled?(priority)
enabled = false
- priority.each { |runlevel, arguments|
+ priority.each do |runlevel, arguments|
Chef::Log.debug("#{new_resource} runlevel #{runlevel}, action #{arguments[0]}, priority #{arguments[1]}")
# if we are in a update-rc.d default startup runlevel && we start in this runlevel
if %w{ 1 2 3 4 5 S }.include?(runlevel) && arguments[0] == :start
enabled = true
end
- }
+ end
enabled
end
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index 6369a3a9a0..d75e85989f 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -76,8 +76,9 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @new_resource.status_command || supports[:status] ||
- (!ps_cmd.nil? && !ps_cmd.empty?) }
+ a.assertion do
+ @new_resource.status_command || supports[:status] ||
+ (!ps_cmd.nil? && !ps_cmd.empty?) end
a.failure_message Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this node's 'command.ps' attribute"
end
requirements.assert(:all_actions) do |a|
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 479eb0a7e2..0de5c89475 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1276,15 +1276,15 @@ class Chef
# resolve_resource_reference on each in turn, causing them to
# resolve lazy/forward references.
def resolve_notification_references
- run_context.before_notifications(self).each { |n|
+ run_context.before_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
- run_context.immediate_notifications(self).each { |n|
+ end
+ run_context.immediate_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
- run_context.delayed_notifications(self).each {|n|
+ end
+ run_context.delayed_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
+ end
end
# Helper for #notifies
@@ -1575,8 +1575,6 @@ class Chef
end
end
- private
-
def self.remove_canonical_dsl
if @resource_name
remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
diff --git a/lib/chef/resource_builder.rb b/lib/chef/resource_builder.rb
index 1641fe60f2..57c57dd8c3 100644
--- a/lib/chef/resource_builder.rb
+++ b/lib/chef/resource_builder.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :resource
# FIXME (ruby-2.1 syntax): most of these are mandatory
- def initialize(type:nil, name:nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil)
+ def initialize(type: nil, name: nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil)
@type = type
@name = name
@created_at = created_at
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index ebf13bec36..024ec38a16 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -29,7 +29,7 @@ class Chef
attr_accessor :rest
attr_reader :config
- def initialize(url = nil, config:Chef::Config)
+ def initialize(url = nil, config: Chef::Config)
@config = config
@url = url
end
@@ -146,7 +146,7 @@ WARNDEP
qstr
end
- def call_rest_service(type, query:"*:*", rows:nil, start:0, sort:"X_CHEF_id_CHEF_X asc", filter_result:nil)
+ def call_rest_service(type, query: "*:*", rows: nil, start: 0, sort: "X_CHEF_id_CHEF_X asc", filter_result: nil)
query_string = create_query_string(type, query, rows, start, sort)
if filter_result
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 78aed7409f..019595ea8d 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -48,25 +48,28 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_o
it "writes run_start event with event_id 10000 and contains version" do
logger.run_start(version)
- expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10000 &&
- e.string_inserts[0].include?(version)}).to be_truthy
+ expect(event_log.read(flags, offset).any? do |e|
+ e.source == "Chef" && e.event_id == 10000 &&
+ e.string_inserts[0].include?(version) end).to be_truthy
end
it "writes run_started event with event_id 10001 and contains the run_id" do
logger.run_started(run_status)
- expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10001 &&
- e.string_inserts[0].include?(run_id)}).to be_truthy
+ expect(event_log.read(flags, offset).any? do |e|
+ e.source == "Chef" && e.event_id == 10001 &&
+ e.string_inserts[0].include?(run_id) end).to be_truthy
end
it "writes run_completed event with event_id 10002 and contains the run_id and elapsed time" do
logger.run_started(run_status)
logger.run_completed(node)
- expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10002 &&
- e.string_inserts[0].include?(run_id) &&
- e.string_inserts[1].include?(elapsed_time.to_s)
- }).to be_truthy
+ expect(event_log.read(flags, offset).any? do |e|
+ e.source == "Chef" && e.event_id == 10002 &&
+ e.string_inserts[0].include?(run_id) &&
+ e.string_inserts[1].include?(elapsed_time.to_s)
+ end).to be_truthy
end
it "writes run_failed event with event_id 10003 and contains the run_id, elapsed time, and exception info" do
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index a23220ed52..0f51b765af 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -276,9 +276,9 @@ describe Chef::Knife::Ssh do
Chef::Config[:client_key] = nil
Chef::Config[:chef_server_url] = "http://localhost:9000"
- @api.get("/search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0", 200) {
+ @api.get("/search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0", 200) do
%({"total":1, "start":0, "rows":[{"name":"i-xxxxxxxx", "json_class":"Chef::Node", "automatic":{"fqdn":"the.fqdn", "ec2":{"public_hostname":"the_public_hostname"}},"recipes":[]}]})
- }
+ end
end
end
diff --git a/spec/functional/notifications_spec.rb b/spec/functional/notifications_spec.rb
index 1b1ef83294..8d8b2d970c 100644
--- a/spec/functional/notifications_spec.rb
+++ b/spec/functional/notifications_spec.rb
@@ -13,11 +13,11 @@ describe "Notifications" do
# We always pretend we are on OSx because that has a specific provider (HomebrewProvider) so it
# tests the translation from Provider => HomebrewProvider
- let(:node) {
+ let(:node) do
n = Chef::Node.new
n.override[:os] = "darwin"
n
- }
+ end
let(:cookbook_collection) { double("Chef::CookbookCollection").as_null_object }
let(:events) { double("Chef::EventDispatch::Dispatcher").as_null_object }
let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
diff --git a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
index 892e1080db..1bb36f2cf6 100644
--- a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
@@ -21,10 +21,10 @@ require "spec_helper"
describe Chef::Resource::WhyrunSafeRubyBlock do
let(:node) { Chef::Node.new }
- let(:run_context) {
+ let(:run_context) do
events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, events)
- }
+ end
before do
$evil_global_evil_laugh = :wahwah
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 4b77c40e91..0006f3bcdb 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -50,15 +50,15 @@ describe Chef::Platform::Rebooter do
let(:rebooter) { Chef::Platform::Rebooter }
- describe '#reboot_if_needed!' do
+ describe "#reboot_if_needed!" do
- it 'should not call #shell_out! when reboot has not been requested' do
+ it "should not call #shell_out! when reboot has not been requested" do
expect(rebooter).to receive(:shell_out!).exactly(0).times
expect(rebooter).to receive(:reboot_if_needed!).once.and_call_original
rebooter.reboot_if_needed!(run_context.node)
end
- describe 'calling #shell_out! to reboot' do
+ describe "calling #shell_out! to reboot" do
before(:each) do
run_context.request_reboot(reboot_info)
@@ -77,7 +77,7 @@ describe Chef::Platform::Rebooter do
end
end
- describe 'when using #reboot_if_needed!' do
+ describe "when using #reboot_if_needed!" do
include_context "test a reboot method"
it "should produce the correct string on Windows" do
@@ -89,7 +89,7 @@ describe Chef::Platform::Rebooter do
end
end
- describe 'when using #reboot!' do
+ describe "when using #reboot!" do
include_context "test a reboot method"
it "should produce the correct string on Windows" do
diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb
index 87211ec264..a2e174d557 100644
--- a/spec/functional/resource/bash_spec.rb
+++ b/spec/functional/resource/bash_spec.rb
@@ -21,11 +21,11 @@ require "functional/resource/base"
describe Chef::Resource::Bash, :unix_only do
let(:code) { "echo hello" }
- let(:resource) {
+ let(:resource) do
resource = Chef::Resource::Bash.new("foo_resource", run_context)
resource.code(code)
resource
- }
+ end
describe "when setting the command attribute" do
let (:command) { "wizard racket" }
diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb
index d65256231b..1988fd0c7d 100644
--- a/spec/functional/resource/dpkg_package_spec.rb
+++ b/spec/functional/resource/dpkg_package_spec.rb
@@ -27,11 +27,11 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
let(:test1_1) { File.join(apt_data, "chef-integration-test_1.1-1_amd64.deb") }
let(:test2_0) { File.join(apt_data, "chef-integration-test2_1.0-1_amd64.deb") }
- let(:run_context) {
+ let(:run_context) do
node = TEST_NODE.dup
events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, events)
- }
+ end
let(:dpkg_package) { Chef::Resource::DpkgPackage.new(test1_0, run_context) }
diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb
index 1e5e9fb540..bb3cf2157d 100644
--- a/spec/functional/resource/dsc_resource_spec.rb
+++ b/spec/functional/resource/dsc_resource_spec.rb
@@ -21,17 +21,17 @@ require "spec_helper"
describe Chef::Resource::DscResource, :windows_powershell_dsc_only do
let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new }
- let(:node) {
+ let(:node) do
Chef::Node.new.tap do |n|
n.consume_external_attrs(OHAI_SYSTEM.data, {})
end
- }
+ end
let(:run_context) { Chef::RunContext.new(node, {}, event_dispatch) }
- let(:new_resource) {
+ let(:new_resource) do
Chef::Resource::DscResource.new("dsc_resource_test", run_context)
- }
+ end
context "when Powershell does not support Invoke-DscResource"
context "when Powershell supports Invoke-DscResource" do
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index 5ee97f04a3..e2b58f6432 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -74,7 +74,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:dsc_env_variable) { "chefenvtest" }
let(:dsc_env_value1) { "value1" }
let(:env_value2) { "value2" }
- let(:dsc_test_run_context) {
+ let(:dsc_test_run_context) do
node = Chef::Node.new
node.automatic["platform"] = "windows"
node.automatic["platform_version"] = "6.1"
@@ -82,11 +82,11 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
node.automatic[:languages][:powershell][:version] = "4.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
- }
+ end
let(:dsc_test_resource_name) { "DSCTest" }
- let(:dsc_test_resource_base) {
+ let(:dsc_test_resource_base) do
Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
- }
+ end
let(:test_registry_key) { 'HKEY_LOCAL_MACHINE\Software\Chef\Spec\Functional\Resource\dsc_script_spec' }
let(:test_registry_value) { "Registration" }
let(:test_registry_data1) { "LL927" }
@@ -94,7 +94,8 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
let(:reg_key_name_param_name) { "testregkeyname" }
let(:reg_key_value_param_name) { "testregvaluename" }
let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'" }
- let(:dsc_reg_code) { <<-EOH
+ let(:dsc_reg_code) do
+ <<-EOH
#{registry_embedded_parameters}
Registry "ChefRegKey"
{
@@ -104,14 +105,15 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
Ensure = 'Present'
}
EOH
- }
+ end
let(:dsc_code) { dsc_reg_code }
- let(:dsc_reg_script) { <<-EOH
+ let(:dsc_reg_script) do
+ <<-EOH
param($testregkeyname, $testregvaluename)
#{dsc_reg_code}
EOH
- }
+ end
let(:dsc_user_prefix) { "dsc" }
let(:dsc_user_suffix) { "chefx" }
@@ -128,7 +130,8 @@ EOH
let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\"" }
let(:config_flags) { nil }
- let(:config_params) { <<-EOH
+ let(:config_params) do
+ <<-EOH
[CmdletBinding()]
param
@@ -137,14 +140,15 @@ EOH
$#{dsc_user_suffix_param_name}
)
EOH
- }
+ end
let(:config_param_section) { "" }
let(:dsc_user_code) { "'#{dsc_user}'" }
let(:dsc_user_prefix_code) { dsc_user_prefix }
let(:dsc_user_suffix_code) { dsc_user_suffix }
let(:dsc_script_environment_attribute) { nil }
- let(:dsc_user_resources_code) { <<-EOH
+ let(:dsc_user_resources_code) do
+ <<-EOH
#{config_param_section}
node localhost
{
@@ -164,9 +168,9 @@ User dsctestusercreate
}
}
EOH
- }
+ end
- let(:dsc_user_config_data) {
+ let(:dsc_user_config_data) do
<<-EOH
@{
AllNodes = @(
@@ -178,13 +182,14 @@ EOH
}
EOH
- }
+ end
let(:dsc_environment_env_var_name) { "dsc_test_cwd" }
let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" }
let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
let(:exception_message_signature) { "LL927-LL928" }
- let(:dsc_environment_config) {<<-EOH
+ let(:dsc_environment_config) do
+ <<-EOH
if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}')))
{
throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}'
@@ -196,21 +201,21 @@ environment "whatsmydir"
Ensure = 'Present'
}
EOH
- }
+ end
- let(:dsc_config_name) {
+ let(:dsc_config_name) do
dsc_test_resource_base.name
- }
- let(:dsc_resource_from_code) {
+ end
+ let(:dsc_resource_from_code) do
dsc_test_resource_base.code(dsc_code)
dsc_test_resource_base
- }
+ end
let(:config_name_value) { dsc_test_resource_base.name }
- let(:dsc_resource_from_path) {
+ let(:dsc_resource_from_path) do
dsc_test_resource_base.command(create_config_script_from_code(dsc_code, config_name_value))
dsc_test_resource_base
- }
+ end
before(:each) do
test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context)
diff --git a/spec/functional/resource/env_spec.rb b/spec/functional/resource/env_spec.rb
index 83328a6738..4b0ff70c0b 100755
--- a/spec/functional/resource/env_spec.rb
+++ b/spec/functional/resource/env_spec.rb
@@ -27,17 +27,17 @@ describe Chef::Resource::Env, :windows_only do
let(:env_value2) { "value2" }
let(:env_value_expandable) { "%SystemRoot%" }
- let(:test_run_context) {
+ let(:test_run_context) do
node = Chef::Node.new
node.default["os"] = "windows"
node.default["platform"] = "windows"
node.default["platform_version"] = "6.1"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
- }
- let(:test_resource) {
+ end
+ let(:test_resource) do
Chef::Resource::Env.new("unknown", test_run_context)
- }
+ end
before(:each) do
resource_lower = Chef::Resource::Env.new(chef_env_test_lower_case, test_run_context)
diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb
index c5978da519..3c31537ebe 100644
--- a/spec/functional/resource/execute_spec.rb
+++ b/spec/functional/resource/execute_spec.rb
@@ -21,11 +21,11 @@ require "functional/resource/base"
require "timeout"
describe Chef::Resource::Execute do
- let(:resource) {
+ let(:resource) do
resource = Chef::Resource::Execute.new("foo_resource", run_context)
resource.command("echo hello")
resource
- }
+ end
describe "when guard is ruby block" do
it "guard can still run" do
@@ -41,10 +41,10 @@ describe Chef::Resource::Execute do
end
let(:guard) { "ruby -e 'exit 0'" }
- let!(:guard_resource) {
+ let!(:guard_resource) do
interpreter = Chef::GuardInterpreter::ResourceGuardInterpreter.new(resource, guard, nil)
interpreter.send(:get_interpreter_resource, resource)
- }
+ end
it "executes the guard and not the regular resource" do
expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:get_interpreter_resource).and_return(guard_resource)
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index a5de63b7c6..89f742a8f9 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -282,12 +282,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
let(:group_name) { "group#{SecureRandom.random_number(9999)}" }
let(:included_members) { nil }
let(:excluded_members) { nil }
- let(:group_resource) {
+ let(:group_resource) do
group = Chef::Resource::Group.new(group_name, run_context)
group.members(included_members)
group.excluded_members(excluded_members)
group
- }
+ end
it "append should be false by default" do
expect(group_resource.append).to eq(false)
@@ -305,10 +305,11 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
end
describe "when group name is length 256", :windows_only do
- let!(:group_name) { "theoldmanwalkingdownthestreetalwayshadagood\
+ let!(:group_name) do
+ "theoldmanwalkingdownthestreetalwayshadagood\
smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
-downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" }
+downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end
it "should create a group" do
group_resource.run_action(:create)
@@ -317,10 +318,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" }
end
describe "when group name length is more than 256", :windows_only do
- let!(:group_name) { "theoldmanwalkingdownthestreetalwayshadagood\
+ let!(:group_name) do
+ "theoldmanwalkingdownthestreetalwayshadagood\
smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
-downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
+downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end
it "should not create a group" do
expect { group_resource.run_action(:create) }.to raise_error(ArgumentError)
diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb
index 9ce989d8df..06bccfc398 100644
--- a/spec/functional/resource/ohai_spec.rb
+++ b/spec/functional/resource/ohai_spec.rb
@@ -19,18 +19,18 @@
require "spec_helper"
describe Chef::Resource::Ohai do
- let(:ohai) {
+ let(:ohai) do
OHAI_SYSTEM
- }
+ end
let(:node) { Chef::Node.new }
- let(:run_context) {
+ let(:run_context) do
node.default[:platform] = ohai[:platform]
node.default[:platform_version] = ohai[:platform_version]
events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, events)
- }
+ end
shared_examples_for "reloaded :uptime" do
it "should reload :uptime" do
@@ -51,11 +51,11 @@ describe Chef::Resource::Ohai do
end
describe "when reloading only uptime" do
- let(:ohai_resource) {
+ let(:ohai_resource) do
r = Chef::Resource::Ohai.new("reload all", run_context)
r.plugin("uptime")
r
- }
+ end
it_behaves_like "reloaded :uptime"
end
diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb
index 3cf7f58e55..c264b122a7 100644
--- a/spec/functional/resource/reboot_spec.rb
+++ b/spec/functional/resource/reboot_spec.rb
@@ -80,9 +80,9 @@ describe Chef::Resource::Reboot do
it "should have modified the run context correctly" do
# this doesn't actually test the flow of Chef::Client#do_run, unfortunately.
- expect {
+ expect do
resource.run_action(:reboot_now)
- }.to throw_symbol(:end_client_run_early)
+ end.to throw_symbol(:end_client_run_early)
test_reboot_action(resource)
end
diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb
index 5d904a980b..e2097710df 100644
--- a/spec/functional/resource/user/dscl_spec.rb
+++ b/spec/functional/resource/user/dscl_spec.rb
@@ -123,7 +123,7 @@ describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metada
end
describe "when password is being set via shadow hash" do
- let(:password) {
+ let(:password) do
if node[:platform_version].start_with?("10.7.")
# On Mac 10.7 we only need to set the password
"c9b3bd1a0cde797eef0eff16c580dab996ba3a21961cccc\
@@ -139,7 +139,7 @@ b1d4880833aa7a190afc13e2bf0936b8\
c5adbbac718b7eb99463a7b679571e0f\
1c9fef2ef08d0b9e9c2bcf644eed2ffc"
end
- }
+ end
let(:iterations) { 25000 }
let(:salt) { "9e2e7d5ee473b496fd24cf0bbfcaedfcb291ee21740e570d1e917e874f8788ca" }
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index b4af1e9e6a..f74e9bdac3 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -27,19 +27,19 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
let(:qualified_username) { "#{ENV['COMPUTERNAME']}\\#{username}" }
let(:password) { "1a2b3c4X!&narf" }
- let(:user_resource) {
+ let(:user_resource) do
r = Chef::Resource::User.new(username, run_context)
r.username(username)
r.password(password)
r.comment("temp spec user")
r
- }
+ end
- let(:global_service_file_path) {
+ let(:global_service_file_path) do
"#{ENV['WINDIR']}\\temp\\#{File.basename(test_service[:service_file_path])}"
- }
+ end
- let(:service_params) {
+ let(:service_params) do
id = "#{$$}_#{rand(1000)}"
@@ -51,19 +51,19 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
service_description: "Test service for running the windows_service functional spec.",
service_file_path: global_service_file_path,
} )
- }
+ end
- let(:manager) {
+ let(:manager) do
Chef::Application::WindowsServiceManager.new(service_params)
- }
+ end
- let(:service_resource) {
+ let(:service_resource) do
r = Chef::Resource::WindowsService.new(service_params[:service_name], run_context)
[:run_as_user, :run_as_password].each { |prop| r.send(prop, service_params[prop]) }
r
- }
+ end
- before {
+ before do
user_resource.run_action(:create)
# the service executable has to be outside the current user's home
@@ -81,13 +81,13 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
file.run_action(:create)
manager.run(%w{--action install})
- }
+ end
- after {
+ after do
user_resource.run_action(:remove)
manager.run(%w{--action uninstall})
File.delete(global_service_file_path)
- }
+ end
describe "logon as a service" do
it "successfully runs a service as another user" do
diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb
index 75a8bfbd24..145c9881b9 100644
--- a/spec/functional/win32/crypto_spec.rb
+++ b/spec/functional/win32/crypto_spec.rb
@@ -22,7 +22,7 @@ if Chef::Platform.windows?
end
describe "Chef::ReservedNames::Win32::Crypto", :windows_only do
- describe '#encrypt' do
+ describe "#encrypt" do
before(:all) do
new_node = Chef::Node.new
new_node.consume_external_attrs(OHAI_SYSTEM.data, {})
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index c4951f375c..40ae99bfa4 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -45,27 +45,27 @@ describe "Chef::Win32::Security", :windows_only do
end
describe "access_check" do
- let(:security_descriptor) {
+ let(:security_descriptor) do
Chef::ReservedNames::Win32::Security.get_file_security(
"C:\\Program Files")
- }
+ end
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS }
- let(:token) {
+ let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
token_rights).duplicate_token(:SecurityImpersonation)
- }
+ end
- let(:mapping) {
+ let(:mapping) do
mapping = Chef::ReservedNames::Win32::Security::GENERIC_MAPPING.new
mapping[:GenericRead] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ
mapping[:GenericWrite] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_WRITE
mapping[:GenericExecute] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_EXECUTE
mapping[:GenericAll] = Chef::ReservedNames::Win32::Security::FILE_ALL_ACCESS
mapping
- }
+ end
let(:desired_access) { Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ }
@@ -76,11 +76,11 @@ describe "Chef::Win32::Security", :windows_only do
end
describe "Chef::Win32::Security::Token" do
- let(:token) {
+ let(:token) do
Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
token_rights)
- }
+ end
context "with all rights" do
let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS }
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index a47bc6233c..4d406ea495 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -19,11 +19,11 @@ describe "chef-client" do
#
# just a normal file
# (expected_content should be uncompressed)
- @api.get("/recipes.tgz", 200) {
+ @api.get("/recipes.tgz", 200) do
File.open(recipes_filename, "rb") do |f|
f.read
end
- }
+ end
end
def stop_tiny_server
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 1db0ea8726..d372a83a35 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -1064,7 +1064,7 @@ EOM
when_the_repository "has a modified, extra and missing file for the cookbook" do
before do
- file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", '#modified')
+ file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "#modified")
file "cookbooks/x-1.0.0/y.rb", "hi"
end
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index 46fd83423d..65931d4764 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -38,9 +38,9 @@ describe "LWRPs with inline resources" do
it "this is totally a bug, but for backcompat purposes, it adds the resources to the main resource collection and does not get marked updated" do
r = nil
- expect_recipe {
+ expect_recipe do
r = lwrp_inline_resources_test "hi"
- }.to have_updated("ruby_block[run a]", :run)
+ end.to have_updated("ruby_block[run a]", :run)
expect(r.ran_a).to eq "ran a"
end
end
@@ -64,11 +64,11 @@ describe "LWRPs with inline resources" do
# https://github.com/chef/chef/issues/4334
it "does not warn spuriously" do
expect(Chef::Log).to_not receive(:warn).with(/is declared in both/)
- expect_recipe {
+ expect_recipe do
lwrp_shadowed_property_test "fnord" do
action :fiddle
end
- }
+ end
end
end
@@ -104,11 +104,11 @@ describe "LWRPs with inline resources" do
it "resources declared in b are executed immediately inline" do
r = nil
- expect_recipe {
+ expect_recipe do
r = lwrp_inline_resources_test2 "hi" do
action :b
end
- }.to have_updated("lwrp_inline_resources_test2[hi]", :b).
+ end.to have_updated("lwrp_inline_resources_test2[hi]", :b).
and have_updated("ruby_block[run a]", :run).
and have_updated("ruby_block[run b]", :run)
expect(r.ran_b).to eq "ran b: ran_a value was \"ran a\""
diff --git a/spec/integration/recipes/noop_resource_spec.rb b/spec/integration/recipes/noop_resource_spec.rb
index c8ff3e6b5e..e0cf47c371 100644
--- a/spec/integration/recipes/noop_resource_spec.rb
+++ b/spec/integration/recipes/noop_resource_spec.rb
@@ -4,20 +4,20 @@ describe "Resources with a no-op provider" do
include IntegrationSupport
context "with noop provider providing foo" do
- before(:context) {
+ before(:context) do
class NoOpFoo < Chef::Resource
resource_name "hi_there"
default_action :update
end
Chef::Provider::Noop.provides :hi_there
- }
+ end
it "does not blow up a run with a noop'd resource" do
- recipe = converge {
+ recipe = converge do
hi_there "blah" do
action :update
end
- }
+ end
expect(recipe.logged_warnings).to eq ""
end
end
diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb
index a9fc06038a..1895d93891 100644
--- a/spec/integration/recipes/provider_choice.rb
+++ b/spec/integration/recipes/provider_choice.rb
@@ -26,9 +26,9 @@ describe "Recipe DSL methods" do
end
it "provider_thingy 'blah' runs the provider and warns" do
- recipe = converge {
- provider_thingy "blah" do; end
- }
+ recipe = converge do
+ provider_thingy("blah") {}
+ end
expect(recipe.logged_warnings).to match /hello from Chef::Provider::ProviderThingy/
expect(recipe.logged_warnings).to match /you must use 'provides' to provide DSL/i
end
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index f96be7ea91..456319c306 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -12,7 +12,7 @@ describe "Recipe DSL methods" do
before { Namer.current_index += 1 }
context "with resource 'base_thingy' declared as BaseThingy" do
- before(:context) {
+ before(:context) do
class BaseThingy < Chef::Resource
resource_name "base_thingy"
@@ -43,7 +43,7 @@ describe "Recipe DSL methods" do
module RecipeDSLSpecNamespace; end
module RecipeDSLSpecNamespace::Bar; end
- }
+ end
before :each do
BaseThingy.created_resource = nil
@@ -51,26 +51,26 @@ describe "Recipe DSL methods" do
end
it "creates base_thingy when you call base_thingy in a recipe" do
- recipe = converge {
- base_thingy "blah" do; end
- }
+ recipe = converge do
+ base_thingy("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_name).to eq "blah"
expect(BaseThingy.created_resource).to eq BaseThingy
end
it "errors out when you call base_thingy do ... end in a recipe" do
- expect_converge {
- base_thingy do; end
- }.to raise_error(ArgumentError, "You must supply a name when declaring a base_thingy resource")
+ expect_converge do
+ base_thingy { ; }
+ end.to raise_error(ArgumentError, "You must supply a name when declaring a base_thingy resource")
end
it "emits a warning when you call base_thingy 'foo', 'bar' do ... end in a recipe" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe = converge {
+ recipe = converge do
base_thingy "foo", "bar" do
end
- }
+ end
expect(recipe.logged_warnings).to match(/Cannot create resource base_thingy with more than one argument. All arguments except the name \("foo"\) will be ignored. This will cause an error in Chef 13. Arguments: \["foo", "bar"\]/)
expect(BaseThingy.created_name).to eq "foo"
expect(BaseThingy.created_resource).to eq BaseThingy
@@ -82,7 +82,7 @@ describe "Recipe DSL methods" do
end
context "with a resource 'backcompat_thingy' declared in Chef::Resource and Chef::Provider" do
- before(:context) {
+ before(:context) do
class Chef::Resource::BackcompatThingy < Chef::Resource
default_action :create
@@ -97,30 +97,30 @@ describe "Recipe DSL methods" do
end
end
- }
+ end
it "backcompat_thingy creates a Chef::Resource::BackcompatThingy" do
- recipe = converge {
- backcompat_thingy "blah" do; end
- }
+ recipe = converge do
+ backcompat_thingy("blah") {}
+ end
expect(BaseThingy.created_resource).to eq Chef::Resource::BackcompatThingy
expect(BaseThingy.created_provider).to eq Chef::Provider::BackcompatThingy
end
context "and another resource 'backcompat_thingy' in BackcompatThingy with 'provides'" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::BackcompatThingy < BaseThingy
provides :backcompat_thingy
resource_name :backcompat_thingy
end
- }
+ end
it "backcompat_thingy creates a BackcompatThingy" do
- recipe = converge {
- backcompat_thingy "blah" do; end
- }
+ recipe = converge do
+ backcompat_thingy("blah") {}
+ end
expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'provides :backcompat_thingy'./)
expect(BaseThingy.created_resource).not_to be_nil
end
@@ -128,86 +128,86 @@ describe "Recipe DSL methods" do
end
context "with a resource named RecipeDSLSpecNamespace::Bar::BarThingy" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Bar::BarThingy < BaseThingy
end
- }
+ end
it "bar_thingy does not work" do
- expect_converge {
- bar_thingy "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ bar_thingy("blah") {}
+ end.to raise_error(NoMethodError)
end
end
context "with a resource named Chef::Resource::NoNameThingy with resource_name nil" do
- before(:context) {
+ before(:context) do
class Chef::Resource::NoNameThingy < BaseThingy
resource_name nil
end
- }
+ end
it "no_name_thingy does not work" do
- expect_converge {
- no_name_thingy "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ no_name_thingy("blah") {}
+ end.to raise_error(NoMethodError)
end
end
context "with a resource named AnotherNoNameThingy with resource_name :another_thingy_name" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy < BaseThingy
resource_name :another_thingy_name
end
- }
+ end
it "another_no_name_thingy does not work" do
- expect_converge {
- another_no_name_thingy "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ another_no_name_thingy("blah") {}
+ end.to raise_error(NoMethodError)
end
it "another_thingy_name works" do
- recipe = converge {
- another_thingy_name "blah" do; end
- }
+ recipe = converge do
+ another_thingy_name("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq(AnotherNoNameThingy)
end
end
context "with a resource named AnotherNoNameThingy2 with resource_name :another_thingy_name2; resource_name :another_thingy_name3" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy2 < BaseThingy
resource_name :another_thingy_name2
resource_name :another_thingy_name3
end
- }
+ end
it "another_no_name_thingy does not work" do
- expect_converge {
- another_no_name_thingy2 "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ another_no_name_thingy2("blah") {}
+ end.to raise_error(NoMethodError)
end
it "another_thingy_name2 does not work" do
- expect_converge {
- another_thingy_name2 "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ another_thingy_name2("blah") {}
+ end.to raise_error(NoMethodError)
end
it "yet_another_thingy_name3 works" do
- recipe = converge {
- another_thingy_name3 "blah" do; end
- }
+ recipe = converge do
+ another_thingy_name3("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq(AnotherNoNameThingy2)
end
@@ -215,36 +215,36 @@ describe "Recipe DSL methods" do
context "provides overriding resource_name" do
context "with a resource named AnotherNoNameThingy3 with provides :another_no_name_thingy3, os: 'blarghle'" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy3 < BaseThingy
resource_name :another_no_name_thingy_3
provides :another_no_name_thingy3, os: "blarghle"
end
- }
+ end
it "and os = linux, another_no_name_thingy3 does not work" do
- expect_converge {
+ expect_converge do
# TODO this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_no_name_thingy3 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_no_name_thingy3("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_no_name_thingy3 works" do
- recipe = converge {
+ recipe = converge do
# TODO this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_no_name_thingy3 "blah" do; end
- }
+ another_no_name_thingy3("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy3)
end
end
context "with a resource named AnotherNoNameThingy4 with two provides" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy4 < BaseThingy
resource_name :another_no_name_thingy_4
@@ -252,183 +252,183 @@ describe "Recipe DSL methods" do
provides :another_no_name_thingy4, platform_family: "foo"
end
- }
+ end
it "and os = linux, another_no_name_thingy4 does not work" do
- expect_converge {
+ expect_converge do
# TODO this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_no_name_thingy4 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_no_name_thingy4("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_no_name_thingy4 works" do
- recipe = converge {
+ recipe = converge do
# TODO this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_no_name_thingy4 "blah" do; end
- }
+ another_no_name_thingy4("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy4)
end
it "and platform_family = foo, another_no_name_thingy4 works" do
- recipe = converge {
+ recipe = converge do
# TODO this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:platform_family] = "foo"
- another_no_name_thingy4 "blah" do; end
- }
+ another_no_name_thingy4("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy4)
end
end
context "with a resource named AnotherNoNameThingy5, a different resource_name, and a provides with the original resource_name" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy5 < BaseThingy
resource_name :another_thingy_name_for_another_no_name_thingy5
provides :another_no_name_thingy5, os: "blarghle"
end
- }
+ end
it "and os = linux, another_no_name_thingy5 does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_no_name_thingy5 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_no_name_thingy5("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_no_name_thingy5 works" do
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_no_name_thingy5 "blah" do; end
- }
+ another_no_name_thingy5("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy5)
end
it "the new resource name can be used in a recipe" do
- recipe = converge {
- another_thingy_name_for_another_no_name_thingy5 "blah" do; end
- }
+ recipe = converge do
+ another_thingy_name_for_another_no_name_thingy5("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy5)
end
end
context "with a resource named AnotherNoNameThingy6, a provides with the original resource name, and a different resource_name" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy6 < BaseThingy
provides :another_no_name_thingy6, os: "blarghle"
resource_name :another_thingy_name_for_another_no_name_thingy6
end
- }
+ end
it "and os = linux, another_no_name_thingy6 does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_no_name_thingy6 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_no_name_thingy6("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_no_name_thingy6 works" do
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_no_name_thingy6 "blah" do; end
- }
+ another_no_name_thingy6("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy6)
end
it "the new resource name can be used in a recipe" do
- recipe = converge {
- another_thingy_name_for_another_no_name_thingy6 "blah" do; end
- }
+ recipe = converge do
+ another_thingy_name_for_another_no_name_thingy6("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy6)
end
end
context "with a resource named AnotherNoNameThingy7, a new resource_name, and provides with that new resource name" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy7 < BaseThingy
resource_name :another_thingy_name_for_another_no_name_thingy7
provides :another_thingy_name_for_another_no_name_thingy7, os: "blarghle"
end
- }
+ end
it "and os = linux, another_thingy_name_for_another_no_name_thingy7 does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_thingy_name_for_another_no_name_thingy7 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_thingy_name_for_another_no_name_thingy7("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_thingy_name_for_another_no_name_thingy7 works" do
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_thingy_name_for_another_no_name_thingy7 "blah" do; end
- }
+ another_thingy_name_for_another_no_name_thingy7("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy7)
end
it "the old resource name does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_no_name_thingy_7 "blah" do; end
- }.to raise_error(NoMethodError)
+ another_no_name_thingy_7("blah") {}
+ end.to raise_error(NoMethodError)
end
end
# opposite order from the previous test (provides, then resource_name)
context "with a resource named AnotherNoNameThingy8, a provides with a new resource name, and resource_name with that new resource name" do
- before(:context) {
+ before(:context) do
class AnotherNoNameThingy8 < BaseThingy
provides :another_thingy_name_for_another_no_name_thingy8, os: "blarghle"
resource_name :another_thingy_name_for_another_no_name_thingy8
end
- }
+ end
it "and os = linux, another_thingy_name_for_another_no_name_thingy8 does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_thingy_name_for_another_no_name_thingy8 "blah" do; end
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ another_thingy_name_for_another_no_name_thingy8("blah") {}
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
it "and os = blarghle, another_thingy_name_for_another_no_name_thingy8 works" do
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
- another_thingy_name_for_another_no_name_thingy8 "blah" do; end
- }
+ another_thingy_name_for_another_no_name_thingy8("blah") {}
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy8)
end
it "the old resource name does not work" do
- expect_converge {
+ expect_converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
- another_thingy_name8 "blah" do; end
- }.to raise_error(NoMethodError)
+ another_thingy_name8("blah") {}
+ end.to raise_error(NoMethodError)
end
end
end
@@ -436,64 +436,64 @@ describe "Recipe DSL methods" do
context "provides" do
context "when MySupplier provides :hemlock" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::MySupplier < BaseThingy
resource_name :hemlock
end
- }
+ end
it "my_supplier does not work in a recipe" do
- expect_converge {
- my_supplier "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ my_supplier("blah") {}
+ end.to raise_error(NoMethodError)
end
it "hemlock works in a recipe" do
- expect_recipe {
- hemlock "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ hemlock("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::MySupplier
end
end
context "when Thingy3 has resource_name :thingy3" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
resource_name :thingy3
end
- }
+ end
it "thingy3 works in a recipe" do
- expect_recipe {
- thingy3 "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ thingy3("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3
end
context "and Thingy4 has resource_name :thingy3" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
- }
+ end
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
- recipe = converge {
- thingy3 "blah" do; end
- }
+ recipe = converge do
+ thingy3("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3
end
it "thingy4 does not work in a recipe" do
- expect_converge {
- thingy4 "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ thingy4("blah") {}
+ end.to raise_error(NoMethodError)
end
it "resource_matching_short_name returns Thingy4" do
@@ -503,7 +503,7 @@ describe "Recipe DSL methods" do
end
context "when Thingy5 has resource_name :thingy5 and provides :thingy5reverse, :thingy5_2 and :thingy5_2reverse" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy5 < BaseThingy
resource_name :thingy5
@@ -512,36 +512,36 @@ describe "Recipe DSL methods" do
provides :thingy5_2reverse
end
- }
+ end
it "thingy5 works in a recipe" do
- expect_recipe {
- thingy5 "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ thingy5("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5
end
context "and Thingy6 provides :thingy5" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy6 < BaseThingy
resource_name :thingy6
provides :thingy5
end
- }
+ end
it "thingy6 works in a recipe and yields Thingy6" do
- recipe = converge {
- thingy6 "blah" do; end
- }
+ recipe = converge do
+ thingy6("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy6
end
it "thingy5 works in a recipe and yields Foo::Thingy5 (the alphabetical one)" do
- recipe = converge {
- thingy5 "blah" do; end
- }
+ recipe = converge do
+ thingy5("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5
end
@@ -550,24 +550,24 @@ describe "Recipe DSL methods" do
end
context "and AThingy5 provides :thingy5reverse" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::AThingy5 < BaseThingy
resource_name :thingy5reverse
end
- }
+ end
it "thingy5reverse works in a recipe and yields AThingy5 (the alphabetical one)" do
- recipe = converge {
- thingy5reverse "blah" do; end
- }
+ recipe = converge do
+ thingy5reverse("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::AThingy5
end
end
context "and ZRecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
- before(:context) {
+ before(:context) do
module ZRecipeDSLSpecNamespace
class Thingy5 < BaseThingy
@@ -575,18 +575,18 @@ describe "Recipe DSL methods" do
end
end
- }
+ end
it "thingy5_2 works in a recipe and yields the RecipeDSLSpaceNamespace one (the alphabetical one)" do
- recipe = converge {
- thingy5_2 "blah" do; end
- }
+ recipe = converge do
+ thingy5_2("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5
end
end
context "and ARecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
- before(:context) {
+ before(:context) do
module ARecipeDSLSpecNamespace
class Thingy5 < BaseThingy
@@ -594,53 +594,53 @@ describe "Recipe DSL methods" do
end
end
- }
+ end
it "thingy5_2reverse works in a recipe and yields the ARecipeDSLSpaceNamespace one (the alphabetical one)" do
- recipe = converge {
- thingy5_2reverse "blah" do; end
- }
+ recipe = converge do
+ thingy5_2reverse("blah") {}
+ end
expect(BaseThingy.created_resource).to eq ARecipeDSLSpecNamespace::Thingy5
end
end
end
context "when Thingy3 has resource_name :thingy3" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
resource_name :thingy3
end
- }
+ end
it "thingy3 works in a recipe" do
- expect_recipe {
- thingy3 "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ thingy3("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3
end
context "and Thingy4 has resource_name :thingy3" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
- }
+ end
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
- recipe = converge {
- thingy3 "blah" do; end
- }
+ recipe = converge do
+ thingy3("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3
end
it "thingy4 does not work in a recipe" do
- expect_converge {
- thingy4 "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ thingy4("blah") {}
+ end.to raise_error(NoMethodError)
end
it "resource_matching_short_name returns Thingy4" do
@@ -649,25 +649,25 @@ describe "Recipe DSL methods" do
end
context "and Thingy4 has resource_name :thingy3" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
resource_name :thingy3
end
- }
+ end
it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do
- recipe = converge {
- thingy3 "blah" do; end
- }
+ recipe = converge do
+ thingy3("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3
end
it "thingy4 does not work in a recipe" do
- expect_converge {
- thingy4 "blah" do; end
- }.to raise_error(NoMethodError)
+ expect_converge do
+ thingy4("blah") {}
+ end.to raise_error(NoMethodError)
end
it "resource_matching_short_name returns Thingy4" do
@@ -679,35 +679,35 @@ describe "Recipe DSL methods" do
end
context "when Thingy7 provides :thingy8" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy7 < BaseThingy
resource_name :thingy7
provides :thingy8
end
- }
+ end
context "and Thingy8 has resource_name :thingy8" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy8 < BaseThingy
resource_name :thingy8
end
- }
+ end
it "thingy7 works in a recipe and yields Thingy7" do
- recipe = converge {
- thingy7 "blah" do; end
- }
+ recipe = converge do
+ thingy7("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy7
end
it "thingy8 works in a recipe and yields Thingy7 (alphabetical)" do
- recipe = converge {
- thingy8 "blah" do; end
- }
+ recipe = converge do
+ thingy8("blah") {}
+ end
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy7
end
@@ -718,7 +718,7 @@ describe "Recipe DSL methods" do
end
context "when Thingy12 provides :thingy12, :twizzle and :twizzle2" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy12 < BaseThingy
resource_name :thingy12
@@ -726,32 +726,32 @@ describe "Recipe DSL methods" do
provides :twizzle2
end
- }
+ end
it "thingy12 works in a recipe and yields Thingy12" do
- expect_recipe {
- thingy12 "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ thingy12("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12
end
it "twizzle works in a recipe and yields Thingy12" do
- expect_recipe {
- twizzle "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ twizzle("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12
end
it "twizzle2 works in a recipe and yields Thingy12" do
- expect_recipe {
- twizzle2 "blah" do; end
- }.to emit_no_warnings_or_errors
+ expect_recipe do
+ twizzle2("blah") {}
+ end.to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12
end
end
context "with platform-specific resources 'my_super_thingy_foo' and 'my_super_thingy_bar'" do
- before(:context) {
+ before(:context) do
class MySuperThingyFoo < BaseThingy
resource_name :my_super_thingy_foo
provides :my_super_thingy, platform: "foo"
@@ -761,14 +761,14 @@ describe "Recipe DSL methods" do
resource_name :my_super_thingy_bar
provides :my_super_thingy, platform: "bar"
end
- }
+ end
it "A run with platform 'foo' uses MySuperThingyFoo" do
r = Cheffish::ChefRun.new(chef_config)
r.client.run_context.node.automatic["platform"] = "foo"
- r.compile_recipe {
- my_super_thingy "blah" do; end
- }
+ r.compile_recipe do
+ my_super_thingy("blah") {}
+ end
r.converge
expect(r).to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq MySuperThingyFoo
@@ -777,9 +777,9 @@ describe "Recipe DSL methods" do
it "A run with platform 'bar' uses MySuperThingyBar" do
r = Cheffish::ChefRun.new(chef_config)
r.client.run_context.node.automatic["platform"] = "bar"
- r.compile_recipe {
- my_super_thingy "blah" do; end
- }
+ r.compile_recipe do
+ my_super_thingy("blah") {}
+ end
r.converge
expect(r).to emit_no_warnings_or_errors
expect(BaseThingy.created_resource).to eq MySuperThingyBar
@@ -788,20 +788,20 @@ describe "Recipe DSL methods" do
it "A run with platform 'x' reports that my_super_thingy is not supported" do
r = Cheffish::ChefRun.new(chef_config)
r.client.run_context.node.automatic["platform"] = "x"
- expect {
- r.compile_recipe {
- my_super_thingy "blah" do; end
- }
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ expect do
+ r.compile_recipe do
+ my_super_thingy("blah") {}
+ end
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
end
end
context "when Thingy10 provides :thingy10" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy10 < BaseThingy
resource_name :thingy10
end
- }
+ end
it "declaring a resource providing the same :thingy10 with override: true does not produce a warning" do
expect(Chef::Log).not_to receive(:warn)
@@ -812,11 +812,11 @@ describe "Recipe DSL methods" do
end
context "when Thingy11 provides :thingy11" do
- before(:context) {
+ before(:context) do
class RecipeDSLSpecNamespace::Thingy11 < BaseThingy
resource_name :thingy10
end
- }
+ end
it "declaring a resource providing the same :thingy11 with os: 'linux' does not produce a warning" do
expect(Chef::Log).not_to receive(:warn)
@@ -829,7 +829,7 @@ describe "Recipe DSL methods" do
context "with a resource named 'B' with resource name :two_classes_one_dsl" do
let(:two_classes_one_dsl) { :"two_classes_one_dsl#{Namer.current_index}" }
- let(:resource_class) {
+ let(:resource_class) do
result = Class.new(BaseThingy) do
def self.name
"B"
@@ -841,11 +841,11 @@ describe "Recipe DSL methods" do
end
result.resource_name two_classes_one_dsl
result
- }
+ end
before { resource_class } # pull on it so it gets defined before the recipe runs
context "and another resource named 'A' with resource_name :two_classes_one_dsl" do
- let(:resource_class_a) {
+ let(:resource_class_a) do
result = Class.new(BaseThingy) do
def self.name
"A"
@@ -857,14 +857,14 @@ describe "Recipe DSL methods" do
end
result.resource_name two_classes_one_dsl
result
- }
+ end
before { resource_class_a } # pull on it so it gets defined before the recipe runs
it "two_classes_one_dsl resolves to A (alphabetically earliest)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class_a
end
@@ -875,7 +875,7 @@ describe "Recipe DSL methods" do
end
context "and another resource named 'Z' with resource_name :two_classes_one_dsl" do
- let(:resource_class_z) {
+ let(:resource_class_z) do
result = Class.new(BaseThingy) do
def self.name
"Z"
@@ -887,14 +887,14 @@ describe "Recipe DSL methods" do
end
result.resource_name two_classes_one_dsl
result
- }
+ end
before { resource_class_z } # pull on it so it gets defined before the recipe runs
it "two_classes_one_dsl resolves to B (alphabetically earliest)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
end
@@ -910,9 +910,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to Z (respects the priority array)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class_z
end
@@ -928,9 +928,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (picks the next thing in the priority array)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
end
@@ -949,9 +949,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to Z (respects the most recent priority array)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class_z
end
@@ -967,9 +967,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (picks the first match from the other priority array)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
end
@@ -992,9 +992,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (picks the first match outside the priority array)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
end
@@ -1012,7 +1012,7 @@ describe "Recipe DSL methods" do
resource_class.send(:define_method, :provider) { nil }
end
- let(:provider_class) {
+ let(:provider_class) do
result = Class.new(BaseThingy::Provider) do
def self.name
"B"
@@ -1024,11 +1024,11 @@ describe "Recipe DSL methods" do
end
result.provides two_classes_one_dsl
result
- }
+ end
before { provider_class } # pull on it so it gets defined before the recipe runs
context "and another provider named 'A'" do
- let(:provider_class_a) {
+ let(:provider_class_a) do
result = Class.new(BaseThingy::Provider) do
def self.name
"A"
@@ -1039,15 +1039,15 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
result
- }
+ end
context "which provides :two_classes_one_dsl" do
before { provider_class_a.provides two_classes_one_dsl }
it "two_classes_one_dsl resolves to A (alphabetically earliest)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class_a
end
@@ -1057,9 +1057,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (since A declined)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1067,7 +1067,7 @@ describe "Recipe DSL methods" do
end
context "and another provider named 'Z'" do
- let(:provider_class_z) {
+ let(:provider_class_z) do
result = Class.new(BaseThingy::Provider) do
def self.name
"Z"
@@ -1078,7 +1078,7 @@ describe "Recipe DSL methods" do
def self.inspect; name.inspect; end
end
result
- }
+ end
before { provider_class_z } # pull on it so it gets defined before the recipe runs
context "which provides :two_classes_one_dsl" do
@@ -1086,9 +1086,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (alphabetically earliest)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1098,9 +1098,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to Z (respects the priority map)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class_z
end
@@ -1115,9 +1115,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (the next one in the priority map)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1129,9 +1129,9 @@ describe "Recipe DSL methods" do
it "two_classes_one_dsl resolves to B (the one in the next priority map)" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1141,7 +1141,7 @@ describe "Recipe DSL methods" do
end
context "and another resource Blarghle with provides :two_classes_one_dsl, os: 'blarghle'" do
- let(:resource_class_blarghle) {
+ let(:resource_class_blarghle) do
result = Class.new(BaseThingy) do
def self.name
"Blarghle"
@@ -1154,27 +1154,27 @@ describe "Recipe DSL methods" do
result.resource_name two_classes_one_dsl
result.provides two_classes_one_dsl, os: "blarghle"
result
- }
+ end
before { resource_class_blarghle } # pull on it so it gets defined before the recipe runs
it "on os = blarghle, two_classes_one_dsl resolves to Blarghle" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
instance_eval("#{two_classes_one_dsl} 'blah' do; end")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class_blarghle
end
it "on os = linux, two_classes_one_dsl resolves to B" do
two_classes_one_dsl = self.two_classes_one_dsl
- recipe = converge {
+ recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
instance_eval("#{two_classes_one_dsl} 'blah' do; end")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
end
@@ -1182,37 +1182,38 @@ describe "Recipe DSL methods" do
end
context "with a resource MyResource" do
- let(:resource_class) { Class.new(BaseThingy) do
- def self.called_provides
- @called_provides
- end
+ let(:resource_class) do
+ Class.new(BaseThingy) do
+ def self.called_provides
+ @called_provides
+ end
- def to_s
- "MyResource"
- end
- end }
+ def to_s
+ "MyResource"
+ end
+ end end
let(:my_resource) { :"my_resource#{Namer.current_index}" }
let(:blarghle_blarghle_little_star) { :"blarghle_blarghle_little_star#{Namer.current_index}" }
context "with resource_name :my_resource" do
- before {
+ before do
resource_class.resource_name my_resource
- }
+ end
context "with provides? returning true to my_resource" do
- before {
+ before do
my_resource = self.my_resource
resource_class.define_singleton_method(:provides?) do |node, resource_name|
@called_provides = true
resource_name == my_resource
end
- }
+ end
it "my_resource returns the resource and calls provides?, but does not emit a warning" do
dsl_name = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{dsl_name} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_resource).to eq resource_class
expect(resource_class.called_provides).to be_truthy
@@ -1230,18 +1231,18 @@ describe "Recipe DSL methods" do
it "my_resource does not return the resource" do
dsl_name = self.my_resource
- expect_converge {
+ expect_converge do
instance_eval("#{dsl_name} 'foo'")
- }.to raise_error(Chef::Exceptions::NoSuchResourceType)
+ end.to raise_error(Chef::Exceptions::NoSuchResourceType)
expect(resource_class.called_provides).to be_truthy
end
it "blarghle_blarghle_little_star 'foo' returns the resource and emits a warning" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
dsl_name = self.blarghle_blarghle_little_star
- recipe = converge {
+ recipe = converge do
instance_eval("#{dsl_name} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to include "WARN: #{resource_class}.provides? returned true when asked if it provides DSL #{dsl_name}, but provides :#{dsl_name} was never called!"
expect(BaseThingy.created_resource).to eq resource_class
expect(resource_class.called_provides).to be_truthy
@@ -1281,9 +1282,9 @@ describe "Recipe DSL methods" do
it "my_resource runs the provider and does not emit a warning" do
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1311,9 +1312,9 @@ describe "Recipe DSL methods" do
it "my_resource runs the first provider" do
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1328,9 +1329,9 @@ describe "Recipe DSL methods" do
# TODO no warning? ick
it "my_resource runs the provider anyway" do
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
end
@@ -1360,9 +1361,9 @@ describe "Recipe DSL methods" do
it "my_resource runs the other provider" do
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class2
end
@@ -1371,24 +1372,24 @@ describe "Recipe DSL methods" do
end
context "with provides? returning true" do
- before {
+ before do
my_resource = self.my_resource
provider_class.define_singleton_method(:provides?) do |node, resource|
@called_provides = true
resource.declared_type == my_resource
end
- }
+ end
context "that provides :my_resource" do
- before {
+ before do
provider_class.provides my_resource
- }
+ end
it "my_resource calls the provider (and calls provides?), but does not emit a warning" do
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to eq ""
expect(BaseThingy.created_provider).to eq provider_class
expect(provider_class.called_provides).to be_truthy
@@ -1399,9 +1400,9 @@ describe "Recipe DSL methods" do
it "my_resource calls the provider (and calls provides?), and emits a warning" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
my_resource = self.my_resource
- recipe = converge {
+ recipe = converge do
instance_eval("#{my_resource} 'foo'")
- }
+ end
expect(recipe.logged_warnings).to include("WARN: #{provider_class}.provides? returned true when asked if it provides DSL #{my_resource}, but provides :#{my_resource} was never called!")
expect(BaseThingy.created_provider).to eq provider_class
expect(provider_class.called_provides).to be_truthy
@@ -1410,24 +1411,24 @@ describe "Recipe DSL methods" do
end
context "with provides? returning false to my_resource" do
- before {
+ before do
my_resource = self.my_resource
provider_class.define_singleton_method(:provides?) do |node, resource|
@called_provides = true
false
end
- }
+ end
context "that provides :my_resource" do
- before {
+ before do
provider_class.provides my_resource
- }
+ end
it "my_resource fails to find a provider (and calls provides)" do
my_resource = self.my_resource
- expect_converge {
+ expect_converge do
instance_eval("#{my_resource} 'foo'")
- }.to raise_error(Chef::Exceptions::ProviderNotFound)
+ end.to raise_error(Chef::Exceptions::ProviderNotFound)
expect(provider_class.called_provides).to be_truthy
end
end
@@ -1435,9 +1436,9 @@ describe "Recipe DSL methods" do
context "that does not provide :my_resource" do
it "my_resource fails to find a provider (and calls provides)" do
my_resource = self.my_resource
- expect_converge {
+ expect_converge do
instance_eval("#{my_resource} 'foo'")
- }.to raise_error(Chef::Exceptions::ProviderNotFound)
+ end.to raise_error(Chef::Exceptions::ProviderNotFound)
expect(provider_class.called_provides).to be_truthy
end
end
@@ -1451,15 +1452,15 @@ describe "Recipe DSL methods" do
before { Namer.current_index += 1 }
context "with an LWRP that declares actions" do
- let(:resource_class) {
+ let(:resource_class) do
Class.new(Chef::Resource::LWRPBase) do
provides :"recipe_dsl_spec#{Namer.current_index}"
actions :create
end
- }
- let(:resource) {
+ end
+ let(:resource) do
resource_class.new("blah", run_context)
- }
+ end
it "The actions are part of actions along with :nothing" do
expect(resource_class.actions).to eq [ :nothing, :create ]
end
@@ -1468,15 +1469,15 @@ describe "Recipe DSL methods" do
end
context "and a subclass that declares more actions" do
- let(:subresource_class) {
+ let(:subresource_class) do
Class.new(Chef::Resource::LWRPBase) do
provides :"recipe_dsl_spec_sub#{Namer.current_index}"
actions :delete
end
- }
- let(:subresource) {
+ end
+ let(:subresource) do
subresource_class.new("subblah", run_context)
- }
+ end
it "The parent class actions are not part of actions" do
expect(subresource_class.actions).to eq [ :nothing, :delete ]
@@ -1510,9 +1511,9 @@ describe "Recipe DSL methods" do
it "looks up the provider in Chef::Provider converting the resource name from snake case to camel case" do
resource = nil
- recipe = converge {
- resource = lw_resource_with_hw_provider_test_case "blah" do; end
- }
+ recipe = converge do
+ resource = lw_resource_with_hw_provider_test_case("blah") {}
+ end
expect(resource.created_provider).to eq(Chef::Provider::LwResourceWithHwProviderTestCase)
end
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index f3d1321b9b..0f90ed62f8 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -62,14 +62,14 @@ module ResourceActionSpec
end
it "the action cannot access private methods" do
- expect {
+ expect do
converge(<<-EOM, __FILE__, __LINE__ + 1)
#{resource_dsl} "hi" do
foo "foo!"
action :access_private_method
end
EOM
- }.to raise_error(NameError)
+ end.to raise_error(NameError)
expect(ActionJackson.ran_action).to eq :access_private_method
end
@@ -197,11 +197,11 @@ module ResourceActionSpec
end
end
- before(:each) {
+ before(:each) do
ActionJackson.ran_action = :error
ActionJackson.succeeded = :error
ActionJackson.ruby_block_converged = :error
- }
+ end
it_behaves_like "ActionJackson" do
let(:resource_dsl) { :action_jackson }
@@ -213,11 +213,11 @@ module ResourceActionSpec
end
context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
- before(:context) {
+ before(:context) do
class ActionJackgrandson < ActionJackson
use_automatic_resource_name
end
- }
+ end
it_behaves_like "ActionJackson" do
let(:resource_dsl) { :action_jackgrandson }
@@ -263,38 +263,38 @@ module ResourceActionSpec
end
it "the default action remains the same even though new actions were specified first" do
- converge {
+ converge do
action_jackalope "hi" do
foo "foo!"
bar "bar!"
end
- }
+ end
expect(ActionJackson.ran_action).to eq :access_recipe_dsl
expect(ActionJackson.succeeded).to eq true
end
it "new actions run, and can access overridden, new, and overridden attributes" do
- converge {
+ converge do
action_jackalope "hi" do
foo "foo!"
bar "bar!"
blarghle "blarghle!"
action :access_jackalope
end
- }
+ end
expect(ActionJackalope.jackalope_ran).to eq :access_jackalope
expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope"
end
it "overridden actions run, call super, and can access overridden, new, and overridden attributes" do
- converge {
+ converge do
action_jackalope "hi" do
foo "foo!"
bar "bar!"
blarghle "blarghle!"
action :access_attribute
end
- }
+ end
expect(ActionJackson.ran_action).to eq :access_attribute
expect(ActionJackson.succeeded).to eq "foo!alope blarghle! bar!alope"
expect(ActionJackalope.jackalope_ran).to eq :access_attribute
@@ -302,14 +302,14 @@ module ResourceActionSpec
end
it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do
- converge {
+ converge do
action_jackalope "hi" do
foo "foo!"
bar "bar!"
blarghle "blarghle!"
action :access_attribute2
end
- }
+ end
expect(ActionJackson.ran_action).to eq :access_attribute2
expect(ActionJackson.succeeded).to eq("foo!alope blarghle! bar!alope").or(eq("foo!alope blarghle!"))
end
@@ -331,12 +331,12 @@ module ResourceActionSpec
end
it "the default action is :nothing" do
- converge {
+ converge do
no_action_jackson "hi" do
foo "foo!"
NoActionJackson.action_was = action
end
- }
+ end
expect(NoActionJackson.action_was).to eq [:nothing]
end
end
@@ -355,9 +355,9 @@ module ResourceActionSpec
end
it "Running the action works" do
- expect_recipe {
+ expect_recipe do
weird_action_jackson "hi"
- }.to be_up_to_date
+ end.to be_up_to_date
expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
end
end
@@ -400,41 +400,41 @@ module ResourceActionSpec
attr_reader :x_warning_line
it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do
- recipe = converge {
+ recipe = converge do
resource_action_spec_also_with_x "hi" do
x 1
action :set_x_to_x
end
- }
+ end
warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
expect(warnings.size).to eq 1
expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/)
end
it "Using the enclosing resource to set x to x outside the initializer emits no warning" do
- expect_recipe {
+ expect_recipe do
resource_action_spec_also_with_x "hi" do
x 1
action :set_x_to_x_in_non_initializer
end
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
end
it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe {
+ expect_recipe do
resource_action_spec_also_with_x "hi" do
x 1
action :set_x_to_10
end
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
end
it "Using the enclosing resource to set x to 10 emits no warning" do
- expect_recipe {
+ expect_recipe do
r = resource_action_spec_also_with_x "hi"
r.x 1
r.action :set_x_to_10
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
end
end
@@ -460,11 +460,11 @@ module ResourceActionSpec
end
it "Setting group to nil in an action does not emit a warning about it being defined in two places" do
- expect_recipe {
+ expect_recipe do
resource_action_spec_set_group_to_nil "hi" do
action :set_group_to_nil
end
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
end
end
@@ -480,9 +480,9 @@ module ResourceActionSpec
end
it "Raises an error when attempting to use a template in the action" do
- expect_converge {
+ expect_converge do
has_property_named_template "hi"
- }.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./)
+ end.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./)
end
end
@@ -524,9 +524,9 @@ module ResourceActionSpec
it "the methods are available to the action" do
r = nil
- expect_recipe {
+ expect_recipe do
r = declares_action_class_methods "hi"
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
expect(r.x).to eq(10)
end
@@ -553,9 +553,9 @@ module ResourceActionSpec
it "the methods are available to the action" do
r = nil
- expect_recipe {
+ expect_recipe do
r = declares_action_class_methods_too "hi"
- }.to emit_no_warnings_or_errors
+ end.to emit_no_warnings_or_errors
expect(r.x).to eq(15)
end
end
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index 4e5fd526fc..89d831ddec 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -19,7 +19,7 @@ describe "Resource::ActionClass#converge_if_changed" do
context "when the resource has identity, state and control properties" do
let(:resource_name) { :"converge_if_changed_dsl#{Namer.current_index}" }
- let(:resource_class) {
+ let(:resource_class) do
result = Class.new(Chef::Resource) do
def self.to_s; resource_name.to_s; end
@@ -36,7 +36,7 @@ describe "Resource::ActionClass#converge_if_changed" do
end
result.resource_name resource_name
result
- }
+ end
let(:converged_recipe) { converge(converge_recipe) }
let(:resource) { converged_recipe.resources.first }
@@ -70,13 +70,13 @@ describe "Resource::ActionClass#converge_if_changed" do
end
context "and state1 is set to a new value" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
end
EOM
- }
+ end
it "the resource updates state1" do
expect(resource.converged).to eq 1
@@ -90,14 +90,14 @@ describe "Resource::ActionClass#converge_if_changed" do
end
context "and state1 and state2 are set to new values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 1
@@ -112,7 +112,7 @@ EOM
end
context "and state1 and state2 are set to new sensitive values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
sensitive true
@@ -120,7 +120,7 @@ EOM
state2 'new_state2'
end
EOM
- }
+ end
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 1
@@ -135,14 +135,14 @@ EOM
end
context "and state1 is set to its current value but state2 is set to a new value" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'current_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource updates state2" do
expect(resource.converged).to eq 1
@@ -156,14 +156,14 @@ EOM
end
context "and state1 and state2 are set to their current values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'current_state1'
state2 'current_state2'
end
EOM
- }
+ end
it "the resource updates nothing" do
expect(resource.converged).to eq 0
@@ -175,14 +175,14 @@ EOM
end
context "and identity1 and control1 are set to new values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
identity1 'new_identity1'
control1 'new_control1'
end
EOM
- }
+ end
# Because the identity value is copied over to the new resource, by
# default they do not register as "changed"
@@ -205,14 +205,14 @@ EOM
end
context "and identity1 and control1 are set to new values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
identity1 'new_identity1'
control1 'new_control1'
end
EOM
- }
+ end
# Control values are not desired state and are therefore not considered
# a reason for converging.
@@ -252,14 +252,14 @@ EOM
end
context "and state1 and state2 are set" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource is created" do
expect(resource.converged).to eq 1
@@ -275,7 +275,7 @@ EOM
end
context "and state1 and state2 are set with sensitive property" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
sensitive true
@@ -283,7 +283,7 @@ EOM
state2 'new_state2'
end
EOM
- }
+ end
it "the resource is created" do
expect(resource.converged).to eq 1
@@ -334,13 +334,13 @@ EOM
context "and state1 is set to a new value" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
end
EOM
- }
+ end
it "the resource updates state1" do
expect(resource.converged).to eq 1
@@ -354,14 +354,14 @@ EOM
end
context "and state1 and state2 are set to new values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource updates state1 and state2" do
expect(resource.converged).to eq 2
@@ -377,14 +377,14 @@ EOM
end
context "and state1 is set to its current value but state2 is set to a new value" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'current_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource updates state2" do
expect(resource.converged).to eq 1
@@ -398,14 +398,14 @@ EOM
end
context "and state1 and state2 are set to their current values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'current_state1'
state2 'current_state2'
end
EOM
- }
+ end
it "the resource updates nothing" do
expect(resource.converged).to eq 0
@@ -425,9 +425,9 @@ EOM
end
context "and nothing is set" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
"#{resource_name} 'blah'"
- }
+ end
it "the resource is created" do
expect(resource.converged).to eq 2
@@ -443,14 +443,14 @@ EOM
end
context "and state1 and state2 are set to new values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
state1 'new_state1'
state2 'new_state2'
end
EOM
- }
+ end
it "the resource is created" do
expect(resource.converged).to eq 2
@@ -466,7 +466,7 @@ EOM
end
context "and state1 and state2 are set to new sensitive values" do
- let(:converge_recipe) {
+ let(:converge_recipe) do
<<-EOM
#{resource_name} 'blah' do
sensitive true
@@ -474,7 +474,7 @@ EOM
state2 'new_state2'
end
EOM
- }
+ end
it "the resource is created" do
expect(resource.converged).to eq 2
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 53ce1c91b3..954fbf53a4 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -18,7 +18,7 @@ describe "Resource.load_current_value" do
before { Namer.incrementing_value = 0 }
let(:resource_name) { :"load_current_value_dsl#{Namer.current_index}" }
- let(:resource_class) {
+ let(:resource_class) do
result = Class.new(Chef::Resource) do
def self.to_s; resource_name.to_s; end
@@ -37,7 +37,7 @@ describe "Resource.load_current_value" do
end
result.resource_name resource_name
result
- }
+ end
# Pull on resource_class to initialize it
before { resource_class }
@@ -56,11 +56,11 @@ describe "Resource.load_current_value" do
let(:resource) do
e = self
r = nil
- converge {
+ converge do
r = public_send(e.resource_name, "blah") do
x "desired"
end
- }
+ end
r
end
@@ -83,17 +83,17 @@ describe "Resource.load_current_value" do
end
context "and identity: :i and :d with desired_state: false" do
- before {
+ before do
resource_class.class_eval do
property :i, identity: true
property :d, desired_state: false
end
- }
+ end
- before {
+ before do
resource.i "desired_i"
resource.d "desired_d"
- }
+ end
it "i, name and d are passed to load_current_value, but not x" do
expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)"
@@ -101,17 +101,17 @@ describe "Resource.load_current_value" do
end
context "and name_property: :i and :d with desired_state: false" do
- before {
+ before do
resource_class.class_eval do
property :i, name_property: true
property :d, desired_state: false
end
- }
+ end
- before {
+ before do
resource.i "desired_i"
resource.d "desired_d"
- }
+ end
it "i, name and d are passed to load_current_value, but not x" do
expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)"
@@ -123,10 +123,10 @@ describe "Resource.load_current_value" do
let(:resource) do
e = self
r = nil
- converge {
+ converge do
r = public_send(e.resource_name, "blah") do
end
- }
+ end
r
end
@@ -135,16 +135,16 @@ describe "Resource.load_current_value" do
end
end
- let (:subresource_name) {
+ let (:subresource_name) do
:"load_current_value_subresource_dsl#{Namer.current_index}"
- }
- let (:subresource_class) {
+ end
+ let (:subresource_class) do
r = Class.new(resource_class) do
property :y, default: lazy { "default_y #{Namer.incrementing_value}" }
end
r.resource_name subresource_name
r
- }
+ end
# Pull on subresource_class to initialize it
before { subresource_class }
@@ -152,11 +152,11 @@ describe "Resource.load_current_value" do
let(:subresource) do
e = self
r = nil
- converge {
+ converge do
r = public_send(e.subresource_name, "blah") do
x "desired"
end
- }
+ end
r
end
@@ -170,14 +170,14 @@ describe "Resource.load_current_value" do
end
context "And a child resource class with load_current_value" do
- before {
+ before do
subresource_class.load_current_value do
y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
select { |name, p| p.is_set?(self) }.
map { |name, p| "#{name}=#{p.get(self)}" }.
join(", ") })"
end
- }
+ end
it "the overridden load_current_value is used" do
current_resource = subresource.current_value
@@ -187,7 +187,7 @@ describe "Resource.load_current_value" do
end
context "and a child resource class with load_current_value calling super()" do
- before {
+ before do
subresource_class.load_current_value do
super()
y "loaded_y #{Namer.incrementing_value} (#{self.class.properties.sort_by { |name, p| name }.
@@ -195,7 +195,7 @@ describe "Resource.load_current_value" do
map { |name, p| "#{name}=#{p.get(self)}" }.
join(", ") })"
end
- }
+ end
it "the original load_current_value is called as well as the child one" do
current_resource = subresource.current_value
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index f142798546..7daa87d2f0 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -125,7 +125,7 @@ file_cache_path "#{path_to('config/cache')}"
EOM
# We have a timeout protection here so that if due to some bug
# run_lock gets stuck we can discover it.
- expect {
+ expect do
Timeout.timeout(120) do
chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..")
@@ -143,7 +143,7 @@ EOM
Process.waitpid(s1)
Process.waitpid(s2)
end
- }.not_to raise_error
+ end.not_to raise_error
# Unfortunately file / directory helpers in integration tests
# are implemented using before(:each) so we need to do all below
diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb
index c05aa2c285..3f4e343926 100644
--- a/spec/scripts/ssl-serve.rb
+++ b/spec/scripts/ssl-serve.rb
@@ -42,6 +42,6 @@ webrick_opts = DEFAULT_OPTIONS.merge(server_opts)
pp :webrick_opts => webrick_opts
server = WEBrick::HTTPServer.new(webrick_opts)
-trap "INT" do server.shutdown end
+trap("INT") { server.shutdown }
server.start
diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb
index 58cf7b3357..3c03a657b2 100644
--- a/spec/stress/win32/security_spec.rb
+++ b/spec/stress/win32/security_spec.rb
@@ -49,21 +49,21 @@ describe "Chef::ReservedNames::Win32::Security", :windows_only do
end
it "should not leak when retrieving and reading the ACE from a file", :volatile do
- expect {
+ expect do
sids = Chef::ReservedNames::Win32::Security::SecurableObject.new(@monkeyfoo).security_descriptor.dacl.select { |ace| ace.sid }
GC.start
- }.not_to leak_memory(:warmup => 50, :iterations => 100)
+ end.not_to leak_memory(:warmup => 50, :iterations => 100)
end
it "should not leak when creating a new ACL and setting it on a file", :volatile do
securable_object = Security::SecurableObject.new(@monkeyfoo)
- expect {
+ expect do
securable_object.dacl = Chef::ReservedNames::Win32::Security::ACL.create([
Chef::ReservedNames::Win32::Security::ACE.access_allowed(Chef::ReservedNames::Win32::Security::SID.Everyone, Chef::ReservedNames::Win32::API::Security::GENERIC_READ),
Chef::ReservedNames::Win32::Security::ACE.access_denied(Chef::ReservedNames::Win32::Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL),
])
GC.start
- }.not_to leak_memory(:warmup => 50, :iterations => 100)
+ end.not_to leak_memory(:warmup => 50, :iterations => 100)
end
end
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index d8676ef168..b0530ab497 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -230,8 +230,9 @@ shared_context "audit phase failed with error" do
end
shared_context "audit phase completed with failed controls" do
- let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) }
+ let(:audit_runner) do
+ instance_double("Chef::Audit::Runner", :failed? => true,
+ :num_failed => 1, :num_total => 3) end
let(:audit_error) do
err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index ec515e2e91..eb7a378db9 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -400,9 +400,9 @@ shared_examples_for "a configured file resource" do
end
context "when the target file is a symlink", :not_supported_on_win2k3 do
- let(:symlink_target) {
+ let(:symlink_target) do
File.join(CHEF_SPEC_DATA, "file-test-target")
- }
+ end
describe "when configured not to manage symlink's target" do
before(:each) do
@@ -820,9 +820,9 @@ shared_examples_for "a configured file resource" do
end
describe "when path is specified with windows separator", :windows_only do
- let(:path) {
+ let(:path) do
File.join(test_file_dir, make_tmpname(file_base)).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)
- }
+ end
before do
@notified_resource = Chef::Resource.new("punk", resource.run_context)
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 7e9e3f34c5..76faaaed47 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -52,27 +52,27 @@ module ChefHTTPShared
# just a normal file
# (expected_content should be uncompressed)
- @api.get("/nyan_cat.png", 200) {
+ @api.get("/nyan_cat.png", 200) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
# this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
# (expected_content should be compressed)
- @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
+ @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
# this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
# (expected_content should be uncompressed)
- @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) {
+ @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# endpoints that set Content-Length correctly
@@ -83,11 +83,11 @@ module ChefHTTPShared
{
"Content-Length" => nyan_uncompressed_size.to_s,
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_content_length_compressed.png", 200, nil,
@@ -96,11 +96,11 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}
- ) {
+ ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# endpoints that simulate truncated downloads (bad content-length header)
@@ -111,11 +111,11 @@ module ChefHTTPShared
{
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
# (expected_content should be uncompressed)
@api.get("/nyan_cat_truncated_compressed.png", 200, nil,
@@ -124,11 +124,11 @@ module ChefHTTPShared
"Content-Type" => "application/gzip",
"Content-Encoding" => "gzip",
}
- ) {
+ ) do
File.open(nyan_compressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
@@ -140,11 +140,11 @@ module ChefHTTPShared
"Content-Length" => (nyan_uncompressed_size + 1).to_s,
"Transfer-Encoding" => "anything",
}
- ) {
+ ) do
File.open(nyan_uncompressed_filename, "rb") do |f|
f.read
end
- }
+ end
#
# 403 with a Content-Length
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index f9cc43d3f9..3199caa34f 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -37,7 +37,7 @@ shared_context "using Win32::Service" do
# Definition for the test-service
- let(:test_service) {
+ let(:test_service) do
{
:service_name => "spec-service",
:service_display_name => "Spec Test Service",
@@ -45,13 +45,13 @@ shared_context "using Win32::Service" do
:service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
:delayed_start => true,
}
- }
+ end
# Test service creates a file for us to verify that it is running.
# Since our test service is running as Local System we should look
# for the file it creates under SYSTEM temp directory
- let(:test_service_file) {
+ let(:test_service_file) do
"#{ENV['SystemDrive']}\\windows\\temp\\spec_service_file"
- }
+ end
end
diff --git a/spec/support/shared/shared_examples.rb b/spec/support/shared/shared_examples.rb
index 550fa2eb68..0c031bbafd 100644
--- a/spec/support/shared/shared_examples.rb
+++ b/spec/support/shared/shared_examples.rb
@@ -3,9 +3,9 @@
# Any object which defines a .to_json should import this test
shared_examples "to_json equivalent to Chef::JSONCompat.to_json" do
- let(:jsonable) {
+ let(:jsonable) do
raise "You must define the subject when including this test"
- }
+ end
it "should allow consumers to call #to_json or Chef::JSONCompat.to_json" do
expect(jsonable.to_json).to eq(Chef::JSONCompat.to_json(jsonable))
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index b61469a2d0..28141b73b1 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -43,13 +43,13 @@ shared_examples_for "user and client reregister" do
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
let(:max_version) { "5" }
- let(:return_hash_406) {
+ let(:return_hash_406) do
{
"min_version" => min_version,
"max_version" => max_version,
"request_version" => "30",
}
- }
+ end
context "when V0 is not supported by the server" do
context "when the exception is 406 and returns x-ops-server-api-version header" do
diff --git a/spec/support/shared/unit/application_dot_d.rb b/spec/support/shared/unit/application_dot_d.rb
index a8769d6d03..da4eb88edd 100644
--- a/spec/support/shared/unit/application_dot_d.rb
+++ b/spec/support/shared/unit/application_dot_d.rb
@@ -31,8 +31,9 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory with configuration" do
# We're not going to mock out globbing the directory. We want to
# make sure that we are correctly globbing.
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../../data/client.d_00")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../../data/client.d_00")) end
it "loads the configuration in order" do
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0")
@@ -45,8 +46,9 @@ shared_examples_for "an application that loads a dot d" do
end
context "when client_d_dir is set to a directory without configuration" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_01")) end
# client.d_01 has a nested folder with a rb file that if
# executed, would raise an exception. If it is executed,
@@ -60,8 +62,9 @@ shared_examples_for "an application that loads a dot d" do
context "when client_d_dir is set to a directory containing a directory named foo.rb" do
# foo.rb as a directory should be ignored
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_02")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_02")) end
it "does not raise an exception" do
expect { app.reconfigure }.not_to raise_error
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index cb539ffbc3..394fdaa02f 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -459,11 +459,11 @@ shared_examples_for Chef::Provider::File do
context "do_validate_content" do
before { setup_normal_file }
- let(:tempfile) {
+ let(:tempfile) do
t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true)
allow(content).to receive(:tempfile).and_return(t)
t
- }
+ end
context "with user-supplied verifications" do
it "calls #verify on each verification with tempfile path" do
diff --git a/spec/support/shared/unit/resource/static_provider_resolution.rb b/spec/support/shared/unit/resource/static_provider_resolution.rb
index 4ae5d4576f..e68b805d7d 100644
--- a/spec/support/shared/unit/resource/static_provider_resolution.rb
+++ b/spec/support/shared/unit/resource/static_provider_resolution.rb
@@ -33,13 +33,13 @@ def static_provider_resolution(opts = {})
platform_version = opts[:platform_version]
describe resource_class, "static provider initialization" do
- let(:node) {
+ let(:node) do
node = Chef::Node.new
node.automatic_attrs[:os] = os
node.automatic_attrs[:platform_family] = platform_family
node.automatic_attrs[:platform_version] = platform_version
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:resource) { resource_class.new("foo", run_context) }
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index 732b07d4ef..27864e1625 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -57,18 +57,18 @@ shared_examples_for "a script resource" do
end
describe "when executing guards" do
- let(:resource) {
+ let(:resource) do
resource = script_resource
resource.run_context = run_context
resource.code "echo hi"
resource
- }
- let(:node) {
+ end
+ let(:node) do
node = Chef::Node.new
node.automatic[:platform] = "debian"
node.automatic[:platform_version] = "6.0"
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index e3481dfeca..6c31ca22d1 100644
--- a/spec/support/shared/unit/user_and_client_shared.rb
+++ b/spec/support/shared/unit/user_and_client_shared.rb
@@ -55,13 +55,13 @@ shared_examples_for "user or client create" do
end
context "when chef_key is returned by the server" do
- let(:chef_key) {
+ let(:chef_key) do
{
"chef_key" => {
"public_key" => "some_public_key",
},
}
- }
+ end
it "puts the public key into the objectr returned by create" do
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))
@@ -70,14 +70,14 @@ shared_examples_for "user or client create" do
end
context "when private_key is returned in chef_key" do
- let(:chef_key) {
+ let(:chef_key) do
{
"chef_key" => {
"public_key" => "some_public_key",
"private_key" => "some_private_key",
},
}
- }
+ end
it "puts the private key into the object returned by create" do
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index 8c90d5ad38..9c643fa492 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -326,13 +326,13 @@ describe Chef::ApiClientV1 do
describe "Versioned API Interactions" do
let(:response_406) { OpenStruct.new(:code => "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
- let(:payload) {
+ let(:payload) do
{
:name => "some_name",
:validator => true,
:admin => true,
}
- }
+ end
before do
@client = Chef::ApiClientV1.new
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index 8ab6e13204..867cd3f9c2 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -361,7 +361,7 @@ describe Chef::Application do
end
end
- context 'when called with an Array-like argument (#size)' do
+ context "when called with an Array-like argument (#size)" 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)
diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb
index 2496aef3e7..820e670f1c 100644
--- a/spec/unit/audit/audit_event_proxy_spec.rb
+++ b/spec/unit/audit/audit_event_proxy_spec.rb
@@ -34,8 +34,9 @@ describe Chef::Audit::AuditEventProxy do
describe "#example_group_started" do
let(:description) { "poots" }
- let(:group) { double("ExampleGroup", :parent_groups => parents,
- :description => description) }
+ let(:group) do
+ double("ExampleGroup", :parent_groups => parents,
+ :description => description) end
let(:notification) { double("Notification", :group => group) }
context "when notified from a top-level example group" do
@@ -120,35 +121,36 @@ describe Chef::Audit::AuditEventProxy do
let(:examples) { [example] }
- let(:example) { double("Example", :metadata => metadata,
- :description => example_description,
- :full_description => full_description, :exception => nil) }
+ let(:example) do
+ double("Example", :metadata => metadata,
+ :description => example_description,
+ :full_description => full_description, :exception => nil) end
- let(:metadata) {
+ let(:metadata) do
{
:described_class => described_class,
:example_group => example_group,
:line_number => line,
}
- }
+ end
- let(:example_group) {
+ let(:example_group) do
{
:description => group_description,
:parent_example_group => parent_group,
}
- }
+ end
- let(:parent_group) {
+ let(:parent_group) do
{
:description => control_group_name,
:parent_example_group => nil,
}
- }
+ end
let(:line) { 27 }
- let(:control_data) {
+ let(:control_data) do
{
:name => example_description,
:desc => full_description,
@@ -157,7 +159,7 @@ describe Chef::Audit::AuditEventProxy do
:context => context,
:line_number => line,
}
- }
+ end
shared_examples "built control" do
@@ -218,12 +220,14 @@ describe Chef::Audit::AuditEventProxy do
let(:control_group_name) { "application ports" }
let(:group_description) { "#{resource_type} #{resource_name}" }
let(:example_description) { "should not be listening" }
- let(:full_description) { [control_group_name, group_description,
- example_description].join(" ") }
+ let(:full_description) do
+ [control_group_name, group_description,
+ example_description].join(" ") end
# Metadata fields
- let(:described_class) { double("Serverspec::Type::Port",
- :class => "Serverspec::Type::Port", :name => resource_name) }
+ let(:described_class) do
+ double("Serverspec::Type::Port",
+ :class => "Serverspec::Type::Port", :name => resource_name) end
# Control data fields
let(:resource_type) { "Port" }
@@ -246,8 +250,9 @@ describe Chef::Audit::AuditEventProxy do
let(:control_group_name) { "application ports" }
let(:group_description) { "port 111" }
let(:example_description) { "is not listening" }
- let(:full_description) { [control_group_name, group_description,
- example_description].join(" ") }
+ let(:full_description) do
+ [control_group_name, group_description,
+ example_description].join(" ") end
# Metadata fields
let(:described_class) { nil }
@@ -276,27 +281,29 @@ describe Chef::Audit::AuditEventProxy do
let(:outer_group_description) { "File \"tmp/audit\"" }
let(:group_description) { "#{resource_type} #{resource_name}" }
let(:example_description) { "is a file" }
- let(:full_description) { [control_group_name, outer_group_description,
- group_description, example_description].join(" ") }
+ let(:full_description) do
+ [control_group_name, outer_group_description,
+ group_description, example_description].join(" ") end
# Metadata parts
- let(:described_class) { double("Serverspec::Type::File",
- :class => "Serverspec::Type::File", :name => resource_name) }
+ let(:described_class) do
+ double("Serverspec::Type::File",
+ :class => "Serverspec::Type::File", :name => resource_name) end
# Example group parts
- let(:parent_group) {
+ let(:parent_group) do
{
:description => outer_group_description,
:parent_example_group => control_group,
}
- }
+ end
- let(:control_group) {
+ let(:control_group) do
{
:description => control_group_name,
:parent_example_group => nil,
}
- }
+ end
# Control data parts
let(:resource_type) { "File" }
diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb
index 1db56a550e..cf916266d8 100644
--- a/spec/unit/audit/audit_reporter_spec.rb
+++ b/spec/unit/audit/audit_reporter_spec.rb
@@ -28,8 +28,9 @@ describe Chef::Audit::AuditReporter do
let(:run_id) { 0 }
let(:start_time) { Time.new(2014, 12, 3, 9, 31, 05, "-08:00") }
let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") }
- let(:run_status) { instance_double(Chef::RunStatus, :node => node, :run_id => run_id,
- :start_time => start_time, :end_time => end_time) }
+ let(:run_status) do
+ instance_double(Chef::RunStatus, :node => node, :run_id => run_id,
+ :start_time => start_time, :end_time => end_time) end
describe "#audit_phase_start" do
@@ -85,9 +86,10 @@ describe Chef::Audit::AuditReporter do
context "when audit phase failed" do
- let(:audit_error) { double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
+ let(:audit_error) do
+ double("AuditError", :class => "Chef::Exceptions::AuditError",
+ :message => "Audit phase failed with error message: derpderpderp",
+ :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
before do
reporter.instance_variable_set(:@audit_phase_error, audit_error)
@@ -233,13 +235,15 @@ EOM
let(:audit_data) { Chef::Audit::AuditData.new(node.name, run_id) }
let(:run_data) { audit_data.to_hash }
- let(:audit_error) { double("AuditError", :class => "Chef::Exceptions::AuditError",
- :message => "Audit phase failed with error message: derpderpderp",
- :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) }
+ let(:audit_error) do
+ double("AuditError", :class => "Chef::Exceptions::AuditError",
+ :message => "Audit phase failed with error message: derpderpderp",
+ :backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
- let(:run_error) { double("RunError", :class => "Chef::Exceptions::RunError",
- :message => "This error shouldn't be reported.",
- :backtrace => ["fix it", "fix it", "fix it"]) }
+ let(:run_error) do
+ double("RunError", :class => "Chef::Exceptions::RunError",
+ :message => "This error shouldn't be reported.",
+ :backtrace => ["fix it", "fix it", "fix it"]) end
before do
allow(reporter).to receive(:auditing_enabled?).and_return(true)
@@ -276,23 +280,27 @@ EOM
shared_context "audit data" do
- let(:control_group_foo) { instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("foo metadata")) }
- let(:control_group_bar) { instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("bar metadata")) }
+ let(:control_group_foo) do
+ instance_double(Chef::Audit::ControlGroupData,
+ :metadata => double("foo metadata")) end
+ let(:control_group_bar) do
+ instance_double(Chef::Audit::ControlGroupData,
+ :metadata => double("bar metadata")) end
- let(:ordered_control_groups) {
+ let(:ordered_control_groups) do
{
"foo" => control_group_foo,
"bar" => control_group_bar,
}
- }
+ end
- let(:audit_data) { instance_double(Chef::Audit::AuditData,
- :add_control_group => true) }
+ let(:audit_data) do
+ instance_double(Chef::Audit::AuditData,
+ :add_control_group => true) end
- let(:run_context) { instance_double(Chef::RunContext,
- :audits => ordered_control_groups) }
+ let(:run_context) do
+ instance_double(Chef::RunContext,
+ :audits => ordered_control_groups) end
before do
allow(reporter).to receive(:ordered_control_groups).and_return(ordered_control_groups)
@@ -340,8 +348,9 @@ EOM
include_context "audit data"
let(:name) { "bat" }
- let(:control_group) { instance_double(Chef::Audit::ControlGroupData,
- :metadata => double("metadata")) }
+ let(:control_group) do
+ instance_double(Chef::Audit::ControlGroupData,
+ :metadata => double("metadata")) end
before do
allow(Chef::Audit::ControlGroupData).to receive(:new).
diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb
index a7c8850350..ea4ac260f9 100644
--- a/spec/unit/audit/control_group_data_spec.rb
+++ b/spec/unit/audit/control_group_data_spec.rb
@@ -122,9 +122,10 @@ describe Chef::Audit::ControlData do
let(:context) { nil }
let(:line_number) { 27 }
- let(:control_data) { described_class.new(name: name,
- resource_type: resource_type, resource_name: resource_name,
- context: context, line_number: line_number) }
+ let(:control_data) do
+ described_class.new(name: name,
+ resource_type: resource_type, resource_name: resource_name,
+ context: context, line_number: line_number) end
describe "#to_hash" do
@@ -171,7 +172,7 @@ describe Chef::Audit::ControlGroupData do
let(:context) { nil }
let(:line_number) { 0 }
- let(:control_data) {
+ let(:control_data) do
{
:name => name,
:resource_type => resource_type,
@@ -179,16 +180,17 @@ describe Chef::Audit::ControlGroupData do
:context => context,
:line_number => line_number,
}
- }
+ end
end
shared_context "control" do
include_context "control data"
- let(:control) { Chef::Audit::ControlData.new(name: name,
- resource_type: resource_type, resource_name: resource_name,
- context: context, line_number: line_number) }
+ let(:control) do
+ Chef::Audit::ControlData.new(name: name,
+ resource_type: resource_type, resource_name: resource_name,
+ context: context, line_number: line_number) end
before do
allow(Chef::Audit::ControlData).to receive(:new).
@@ -436,15 +438,18 @@ describe Chef::Audit::ControlGroupData do
let(:control_hash_2) { { :line_number => 13 } }
let(:control_hash_3) { { :line_number => 35 } }
- let(:control_1) { double("control 1",
+ let(:control_1) do
+ double("control 1",
:line_number => control_hash_1[:line_number],
- :to_hash => control_hash_1) }
- let(:control_2) { double("control 2",
+ :to_hash => control_hash_1) end
+ let(:control_2) do
+ double("control 2",
:line_number => control_hash_2[:line_number],
- :to_hash => control_hash_2) }
- let(:control_3) { double("control 3",
+ :to_hash => control_hash_2) end
+ let(:control_3) do
+ double("control 3",
:line_number => control_hash_3[:line_number],
- :to_hash => control_hash_3) }
+ :to_hash => control_hash_3) end
let(:control_list) { [control_1, control_2, control_3] }
let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] }
diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb
index 3c8411ef2a..21987c01ab 100644
--- a/spec/unit/chef_class_spec.rb
+++ b/spec/unit/chef_class_spec.rb
@@ -85,7 +85,7 @@ describe "Chef class" do
end
end
- context '#event_handler' do
+ context "#event_handler" do
it "adds a new handler" do
x = 1
Chef.event_handler do
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 849bc84f92..ac0252162f 100644
--- a/spec/unit/chef_fs/data_handler/group_handler_spec.rb
+++ b/spec/unit/chef_fs/data_handler/group_handler_spec.rb
@@ -29,7 +29,7 @@ class TestEntry < Mash
end
describe Chef::ChefFS::DataHandler::GroupDataHandler do
- describe '#normalize_for_post' do
+ describe "#normalize_for_post" do
let(:entry) do
TestEntry.new("workers.json", "hive")
end
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index c1c9050101..d946fcb9e7 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -32,7 +32,7 @@ describe "diff", :uses_diff => true do
include FileSystemSupport
context "with two filesystems with all types of difference" do
- let(:a) {
+ let(:a) do
memory_fs("a", {
:both_dirs => {
:sub_both_dirs => { :subsub => nil },
@@ -58,8 +58,8 @@ describe "diff", :uses_diff => true do
:dir_in_a_file_in_b => {},
:file_in_a_dir_in_b => nil,
}, /cannot_be_in_a/)
- }
- let(:b) {
+ end
+ let(:b) do
memory_fs("b", {
:both_dirs => {
:sub_both_dirs => { :subsub => nil },
@@ -85,7 +85,7 @@ describe "diff", :uses_diff => true do
:dir_in_a_file_in_b => nil,
:file_in_a_dir_in_b => {},
}, /cannot_be_in_b/)
- }
+ end
it "Chef::ChefFS::CommandLine.diff_print(/)" do
results = []
Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, nil) do |diff|
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 b0b5a547cd..7f3eb6efe2 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
@@ -30,17 +30,17 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do
allow(@response).to receive(:code).and_return("400")
allow(@response).to receive(:body).and_return(response_body)
exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
- expect {
+ expect do
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, exception), error_message
- }.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}")
+ end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}")
end
end
context "does not have a cause attribute" do
it "does not include error cause" do
- expect {
+ expect do
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self), error_message
- }.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, error_message)
+ end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, error_message)
end
end
end
diff --git a/spec/unit/chef_fs/file_system_spec.rb b/spec/unit/chef_fs/file_system_spec.rb
index 429e039dda..5c74729557 100644
--- a/spec/unit/chef_fs/file_system_spec.rb
+++ b/spec/unit/chef_fs/file_system_spec.rb
@@ -55,7 +55,7 @@ describe Chef::ChefFS::FileSystem do
end
context "with a populated filesystem" do
- let(:fs) {
+ let(:fs) do
memory_fs("", {
:a => {
:aa => {
@@ -69,7 +69,7 @@ describe Chef::ChefFS::FileSystem do
:x => "",
:y => {},
})
- }
+ end
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")
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index c6d7e41283..27666eb338 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -461,21 +461,21 @@ describe Chef::Cookbook::Metadata do
expect(metadata.grouping("/db/mysql/databases/tuning", group)).to eq(group)
end
it "should not accept anything but a string for display_name" do
- expect {
+ expect do
metadata.grouping("db/mysql/databases", :title => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.grouping("db/mysql/databases", :title => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the description" do
- expect {
+ expect do
metadata.grouping("db/mysql/databases", :description => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.grouping("db/mysql/databases", :description => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
@@ -498,63 +498,63 @@ describe Chef::Cookbook::Metadata do
end
it "should not accept anything but a string for display_name" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :display_name => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :display_name => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the description" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :description => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :description => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the source_url" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :source_url => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :source_url => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but a string for the issues_url" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :issues_url => "foo")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :issues_url => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but true or false for the privacy flag" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :privacy => true)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :privacy => false)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :privacy => "true")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not accept anything but an array of strings for choice" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :choice => %w{dedicated shared})
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :choice => [10, "shared"])
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
metadata.attribute("db/mysql/databases", :choice => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should set choice to empty array by default" do
@@ -563,15 +563,15 @@ describe Chef::Cookbook::Metadata do
end
it "should let calculated be true or false" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :calculated => true)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :calculated => false)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :calculated => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should set calculated to false by default" do
@@ -580,55 +580,55 @@ describe Chef::Cookbook::Metadata do
end
it "accepts String for the attribute type" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :type => "string")
- }.not_to raise_error
+ end.not_to raise_error
end
it "accepts Array for the attribute type" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :type => "array")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :type => Array.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "accepts symbol for the attribute type" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :type => "symbol")
- }.not_to raise_error
+ end.not_to raise_error
end
it "should let type be hash (backwards compatibility only)" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :type => "hash")
- }.not_to raise_error
+ end.not_to raise_error
end
it "should let required be required, recommended or optional" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :required => "required")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :required => "recommended")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :required => "optional")
- }.not_to raise_error
+ end.not_to raise_error
end
it "should convert required true to required" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :required => true)
- }.not_to raise_error
+ end.not_to raise_error
#attrib = metadata.attributes["db/mysql/databases"][:required].should == "required"
end
it "should convert required false to optional" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :required => false)
- }.not_to raise_error
+ end.not_to raise_error
#attrib = metadata.attributes["db/mysql/databases"][:required].should == "optional"
end
@@ -638,12 +638,12 @@ describe Chef::Cookbook::Metadata do
end
it "should make sure recipes is an array" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :recipes => [])
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :required => Hash.new)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should set recipes to an empty array by default" do
@@ -652,24 +652,24 @@ describe Chef::Cookbook::Metadata do
end
it "should allow the default value to be a string, array, hash, boolean or numeric" do
- expect {
+ expect do
metadata.attribute("db/mysql/databases", :default => [])
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :default => {})
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :default => "alice in chains")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :default => 1337)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :default => true)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
metadata.attribute("db/mysql/databases", :required => :not_gonna_do_it)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should limit the types allowed in the choice array" do
@@ -678,87 +678,87 @@ describe Chef::Cookbook::Metadata do
:choice => %w{test1 test2},
:default => "test1",
}
- expect {
+ expect do
metadata.attribute("test_cookbook/test", options)
- }.not_to raise_error
+ end.not_to raise_error
options = {
:type => "boolean",
:choice => [ true, false ],
:default => true,
}
- expect {
+ expect do
metadata.attribute("test_cookbook/test", options)
- }.not_to raise_error
+ end.not_to raise_error
options = {
:type => "numeric",
:choice => [ 1337, 420 ],
:default => 1337,
}
- expect {
+ expect do
metadata.attribute("test_cookbook/test", options)
- }.not_to raise_error
+ end.not_to raise_error
options = {
:type => "numeric",
:choice => [ true, "false" ],
:default => false,
}
- expect {
+ expect do
metadata.attribute("test_cookbook/test", options)
- }.to raise_error(Chef::Exceptions::ValidationFailed)
+ end.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should error if default used with calculated" do
- expect {
+ expect do
attrs = {
:calculated => true,
:default => [ "I thought you said calculated" ],
}
metadata.attribute("db/mysql/databases", attrs)
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
attrs = {
:calculated => true,
:default => "I thought you said calculated",
}
metadata.attribute("db/mysql/databases", attrs)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should allow a default that is a choice" do
- expect {
+ expect do
attrs = {
:choice => %w{a b c},
:default => "b",
}
metadata.attribute("db/mysql/databases", attrs)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
attrs = {
:choice => %w{a b c d e},
:default => %w{b d},
}
metadata.attribute("db/mysql/databases", attrs)
- }.not_to raise_error
+ end.not_to raise_error
end
it "should error if default is not a choice" do
- expect {
+ expect do
attrs = {
:choice => %w{a b c},
:default => "d",
}
metadata.attribute("db/mysql/databases", attrs)
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
attrs = {
:choice => %w{a b c d e},
:default => %w{b z},
}
metadata.attribute("db/mysql/databases", attrs)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index db10a4eb4f..eef5d2afd5 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -112,63 +112,63 @@ describe Chef::CookbookLoader do
end
it "should allow you to override an attribute file via cookbook_path" do
- expect(cookbook_loader[:openldap].attribute_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].attribute_filenames.detect do |f|
f =~ /cookbooks\/openldap\/attributes\/default.rb/
- }).not_to eql(nil)
- expect(cookbook_loader[:openldap].attribute_filenames.detect { |f|
+ end).not_to eql(nil)
+ expect(cookbook_loader[:openldap].attribute_filenames.detect do |f|
f =~ /kitchen\/openldap\/attributes\/default.rb/
- }).to eql(nil)
+ end).to eql(nil)
end
it "should load different attribute files from deeper paths" do
- expect(cookbook_loader[:openldap].attribute_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].attribute_filenames.detect do |f|
f =~ /kitchen\/openldap\/attributes\/robinson.rb/
- }).not_to eql(nil)
+ end).not_to eql(nil)
end
it "should allow you to override a definition file via cookbook_path" do
- expect(cookbook_loader[:openldap].definition_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].definition_filenames.detect do |f|
f =~ /cookbooks\/openldap\/definitions\/client.rb/
- }).not_to eql(nil)
- expect(cookbook_loader[:openldap].definition_filenames.detect { |f|
+ end).not_to eql(nil)
+ expect(cookbook_loader[:openldap].definition_filenames.detect do |f|
f =~ /kitchen\/openldap\/definitions\/client.rb/
- }).to eql(nil)
+ end).to eql(nil)
end
it "should load definition files from deeper paths" do
- expect(cookbook_loader[:openldap].definition_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].definition_filenames.detect do |f|
f =~ /kitchen\/openldap\/definitions\/drewbarrymore.rb/
- }).not_to eql(nil)
+ end).not_to eql(nil)
end
it "should allow you to override a recipe file via cookbook_path" do
- expect(cookbook_loader[:openldap].recipe_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].recipe_filenames.detect do |f|
f =~ /cookbooks\/openldap\/recipes\/gigantor.rb/
- }).not_to eql(nil)
- expect(cookbook_loader[:openldap].recipe_filenames.detect { |f|
+ end).not_to eql(nil)
+ expect(cookbook_loader[:openldap].recipe_filenames.detect do |f|
f =~ /kitchen\/openldap\/recipes\/gigantor.rb/
- }).to eql(nil)
+ end).to eql(nil)
end
it "should load recipe files from deeper paths" do
- expect(cookbook_loader[:openldap].recipe_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].recipe_filenames.detect do |f|
f =~ /kitchen\/openldap\/recipes\/woot.rb/
- }).not_to eql(nil)
+ end).not_to eql(nil)
end
it "should allow you to have an 'ignore' file, which skips loading files in later cookbooks" do
- expect(cookbook_loader[:openldap].recipe_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].recipe_filenames.detect do |f|
f =~ /kitchen\/openldap\/recipes\/ignoreme.rb/
- }).to eql(nil)
+ end).to eql(nil)
end
it "should find files that start with a ." do
- expect(cookbook_loader[:openldap].file_filenames.detect { |f|
+ expect(cookbook_loader[:openldap].file_filenames.detect do |f|
f =~ /\.dotfile$/
- }).to match(/\.dotfile$/)
- expect(cookbook_loader[:openldap].file_filenames.detect { |f|
+ end).to match(/\.dotfile$/)
+ expect(cookbook_loader[:openldap].file_filenames.detect do |f|
f =~ /\.ssh\/id_rsa$/
- }).to match(/\.ssh\/id_rsa$/)
+ end).to match(/\.ssh\/id_rsa$/)
end
it "should load the metadata for the cookbook" do
diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb
index df9e6571d8..3b5450cb2d 100644
--- a/spec/unit/cookbook_version_file_specificity_spec.rb
+++ b/spec/unit/cookbook_version_file_specificity_spec.rb
@@ -304,24 +304,24 @@ describe Chef::CookbookVersion, "file specificity" do
it "should raise a FileNotFound exception without match" do
node = Chef::Node.new
- expect {
+ expect do
@cookbook.preferred_manifest_record(node, :files, "doesn't_exist.rb")
- }.to raise_error(Chef::Exceptions::FileNotFound)
+ end.to raise_error(Chef::Exceptions::FileNotFound)
end
it "should raise a FileNotFound exception consistently without match" do
node = Chef::Node.new
- expect {
+ expect do
@cookbook.preferred_manifest_record(node, :files, "doesn't_exist.rb")
- }.to raise_error(Chef::Exceptions::FileNotFound)
+ end.to raise_error(Chef::Exceptions::FileNotFound)
- expect {
+ expect do
@cookbook.preferred_manifest_record(node, :files, "doesn't_exist.rb")
- }.to raise_error(Chef::Exceptions::FileNotFound)
+ end.to raise_error(Chef::Exceptions::FileNotFound)
- expect {
+ expect do
@cookbook.preferred_manifest_record(node, :files, "doesn't_exist.rb")
- }.to raise_error(Chef::Exceptions::FileNotFound)
+ end.to raise_error(Chef::Exceptions::FileNotFound)
end
describe "when fetching the contents of a directory by file specificity" do
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 2711fcae03..e83f0ca0ec 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -91,12 +91,12 @@ describe Chef::DataBagItem do
end
describe "object_name" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag("dreams")
data_bag_item.raw_data = { "id" => "the_beatdown" }
data_bag_item
- }
+ end
it "should return an object name based on the bag name and the raw_data id" do
expect(data_bag_item.object_name).to eq("data_bag_item_dreams_the_beatdown")
@@ -110,12 +110,12 @@ describe Chef::DataBagItem do
end
describe "class method name" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag("dreams")
data_bag_item.raw_data = { "id" => "the_beatdown", "name" => "Bruce" }
data_bag_item
- }
+ end
it "should return the object name" do
expect(data_bag_item.name).to eq(data_bag_item.object_name)
@@ -128,11 +128,11 @@ describe Chef::DataBagItem do
end
describe "when used like a Hash" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.raw_data = { "id" => "journey", "trials" => "been through" }
data_bag_item
- }
+ end
it "responds to keys" do
expect(data_bag_item.keys).to include("id")
@@ -158,9 +158,9 @@ describe Chef::DataBagItem do
describe "from_hash" do
context "when hash contains raw_data" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
Chef::DataBagItem.from_hash({ "raw_data" => { "id" => "whoa", "name" => "Bruce", "i_know" => "kung_fu" } })
- }
+ end
it "should have the id key set" do
expect(data_bag_item["id"]).to eq("whoa")
@@ -172,9 +172,9 @@ describe Chef::DataBagItem do
end
context "when hash does not contain raw_data" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
Chef::DataBagItem.from_hash({ "id" => "whoa", "name" => "Bruce", "i_know" => "kung_fu" })
- }
+ end
it "should have the id key set" do
expect(data_bag_item["id"]).to eq("whoa")
@@ -187,12 +187,12 @@ describe Chef::DataBagItem do
end
describe "to_hash" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag("still_lost")
data_bag_item.raw_data = { "id" => "whoa", "name" => "Bruce", "i_know" => "kung_fu" }
data_bag_item
- }
+ end
let!(:original_data_bag_keys) { data_bag_item.keys }
@@ -223,12 +223,12 @@ describe Chef::DataBagItem do
end
describe "when deserializing from JSON" do
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag("mars_volta")
data_bag_item.raw_data = { "id" => "octahedron", "name" => "Bruce", "snooze" => { "finally" => :world_will } }
data_bag_item
- }
+ end
let(:deserial) { Chef::DataBagItem.from_hash(Chef::JSONCompat.parse(Chef::JSONCompat.to_json(data_bag_item))) }
@@ -275,13 +275,13 @@ describe Chef::DataBagItem do
describe "save" do
let(:server) { instance_double(Chef::ServerAPI) }
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item["id"] = "heart of darkness"
data_bag_item.raw_data = { "id" => "heart_of_darkness", "author" => "Conrad" }
data_bag_item.data_bag("books")
data_bag_item
- }
+ end
before do
expect(Chef::ServerAPI).to receive(:new).and_return(server)
@@ -320,12 +320,12 @@ describe Chef::DataBagItem do
describe "destroy" do
let(:server) { instance_double(Chef::ServerAPI) }
- let(:data_bag_item) {
+ let(:data_bag_item) do
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag("a_baggy_bag")
data_bag_item.raw_data = { "id" => "some_id" }
data_bag_item
- }
+ end
it "should set default parameters" do
expect(Chef::ServerAPI).to receive(:new).and_return(server)
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 84aa724927..cadd60936e 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -241,9 +241,9 @@ describe Chef::DataBag do
it "should raise an error if the configured data_bag_path is invalid" do
file_dir_stub(@paths.first, false)
- expect {
+ expect do
Chef::DataBag.load("foo")
- }.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid"
+ end.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid"
end
end
diff --git a/spec/unit/data_collector/messages/helpers_spec.rb b/spec/unit/data_collector/messages/helpers_spec.rb
index 26f7dbacfa..b0d9f4d09d 100644
--- a/spec/unit/data_collector/messages/helpers_spec.rb
+++ b/spec/unit/data_collector/messages/helpers_spec.rb
@@ -25,7 +25,7 @@ class TestMessage
end
describe Chef::DataCollector::Messages::Helpers do
- describe '#organization' do
+ describe "#organization" do
context "when the run is a solo run" do
it "returns the data collector organization" do
allow(TestMessage).to receive(:solo_run?).and_return(true)
@@ -43,7 +43,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#data_collector_organization' do
+ describe "#data_collector_organization" do
context "when the org is specified in the config" do
it "returns the org from the config" do
Chef::Config[:data_collector][:organization] = "org1"
@@ -58,7 +58,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#chef_server_organization' do
+ describe "#chef_server_organization" do
context "when the URL is properly formatted" do
it "returns the org from the parsed URL" do
Chef::Config[:chef_server_url] = "http://mycompany.com/organizations/myorg"
@@ -74,7 +74,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#collector_source' do
+ describe "#collector_source" do
context "when the run is a solo run" do
it "returns chef_solo" do
allow(TestMessage).to receive(:solo_run?).and_return(true)
@@ -90,7 +90,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#solo_run?' do
+ describe "#solo_run?" do
context "when :solo is set in Chef::Config" do
it "returns true" do
Chef::Config[:solo] = true
@@ -116,7 +116,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#node_uuid' do
+ describe "#node_uuid" do
context "when the node UUID can be read" do
it "returns the read-in node UUID" do
allow(TestMessage).to receive(:read_node_uuid).and_return("read_uuid")
@@ -133,7 +133,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#generate_node_uuid' do
+ describe "#generate_node_uuid" do
it "generates a new UUID, stores it, and returns it" do
expect(SecureRandom).to receive(:uuid).and_return("generated_uuid")
expect(TestMessage).to receive(:update_metadata).with("node_uuid", "generated_uuid")
@@ -141,7 +141,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#read_node_uuid' do
+ describe "#read_node_uuid" do
it "reads the node UUID from metadata" do
expect(TestMessage).to receive(:metadata).and_return({ "node_uuid" => "read_uuid" })
expect(TestMessage.read_node_uuid).to eq("read_uuid")
@@ -170,7 +170,7 @@ describe Chef::DataCollector::Messages::Helpers do
end
end
- describe '#update_metadata' do
+ describe "#update_metadata" do
it "updates the file" do
allow(TestMessage).to receive(:metadata_filename).and_return("fake_metadata_file.json")
allow(TestMessage).to receive(:metadata).and_return({ "key" => "current_value" })
diff --git a/spec/unit/data_collector/messages_spec.rb b/spec/unit/data_collector/messages_spec.rb
index b0c7e692d2..394f18dce0 100644
--- a/spec/unit/data_collector/messages_spec.rb
+++ b/spec/unit/data_collector/messages_spec.rb
@@ -22,7 +22,7 @@ require "ffi_yajl"
require "chef/data_collector/messages/helpers"
describe Chef::DataCollector::Messages do
- describe '#run_start_message' do
+ describe "#run_start_message" do
let(:run_status) { Chef::RunStatus.new(Chef::Node.new, Chef::EventDispatch::Dispatcher.new) }
let(:required_fields) do
%w{
@@ -61,7 +61,7 @@ describe Chef::DataCollector::Messages do
end
end
- describe '#run_end_message' do
+ describe "#run_end_message" do
let(:node) { Chef::Node.new }
let(:run_status) { Chef::RunStatus.new(node, Chef::EventDispatch::Dispatcher.new) }
let(:report1) { double("report1", report_data: { "status" => "updated" }) }
diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb
index 764510d0ad..37df758ff2 100644
--- a/spec/unit/data_collector_spec.rb
+++ b/spec/unit/data_collector_spec.rb
@@ -160,7 +160,7 @@ describe Chef::DataCollector::Reporter do
Chef::Config[:data_collector][:server_url] = "http://my-data-collector-server.mycompany.com"
end
- describe '#run_started' do
+ describe "#run_started" do
before do
allow(reporter).to receive(:update_run_status)
allow(reporter).to receive(:send_to_data_collector)
@@ -182,7 +182,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#run_completed' do
+ describe "#run_completed" do
it "sends the run completion" do
node = Chef::Node.new
@@ -191,35 +191,35 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#run_failed' do
+ describe "#run_failed" do
it "updates the exception and sends the run completion" do
expect(reporter).to receive(:send_run_completion).with(status: "failure")
reporter.run_failed("test_exception")
end
end
- describe '#converge_start' do
+ describe "#converge_start" do
it "stashes the run_context for later use" do
reporter.converge_start("test_context")
expect(reporter.run_context).to eq("test_context")
end
end
- describe '#converge_complete' do
+ describe "#converge_complete" do
it "detects and processes any unprocessed resources" do
expect(reporter).to receive(:detect_unprocessed_resources)
reporter.converge_complete
end
end
- describe '#converge_failed' do
+ describe "#converge_failed" do
it "detects and processes any unprocessed resources" do
expect(reporter).to receive(:detect_unprocessed_resources)
reporter.converge_failed("exception")
end
end
- describe '#resource_current_state_loaded' do
+ describe "#resource_current_state_loaded" do
let(:new_resource) { double("new_resource") }
let(:action) { double("action") }
let(:current_resource) { double("current_resource") }
@@ -245,7 +245,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#resource_up_to_date' do
+ describe "#resource_up_to_date" do
let(:new_resource) { double("new_resource") }
let(:action) { double("action") }
let(:resource_report) { double("resource_report") }
@@ -273,7 +273,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#resource_skipped' do
+ describe "#resource_skipped" do
let(:new_resource) { double("new_resource") }
let(:action) { double("action") }
let(:conditional) { double("conditional") }
@@ -311,7 +311,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#resource_updated' do
+ describe "#resource_updated" do
let(:resource_report) { double("resource_report") }
before do
@@ -325,7 +325,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#resource_failed' do
+ describe "#resource_failed" do
let(:new_resource) { double("new_resource") }
let(:action) { double("action") }
let(:exception) { double("exception") }
@@ -368,7 +368,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#resource_completed' do
+ describe "#resource_completed" do
let(:new_resource) { double("new_resource") }
let(:resource_report) { double("resource_report") }
@@ -418,14 +418,14 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#run_list_expanded' do
+ describe "#run_list_expanded" do
it "sets the expanded run list" do
reporter.run_list_expanded("test_run_list")
expect(reporter.expanded_run_list).to eq("test_run_list")
end
end
- describe '#run_list_expand_failed' do
+ describe "#run_list_expand_failed" do
let(:node) { double("node") }
let(:error_mapper) { double("error_mapper") }
let(:exception) { double("exception") }
@@ -441,7 +441,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#cookbook_resolution_failed' do
+ describe "#cookbook_resolution_failed" do
let(:error_mapper) { double("error_mapper") }
let(:exception) { double("exception") }
let(:expanded_run_list) { double("expanded_run_list") }
@@ -458,7 +458,7 @@ describe Chef::DataCollector::Reporter do
end
- describe '#cookbook_sync_failed' do
+ describe "#cookbook_sync_failed" do
let(:cookbooks) { double("cookbooks") }
let(:error_mapper) { double("error_mapper") }
let(:exception) { double("exception") }
@@ -474,7 +474,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#disable_reporter_on_error' do
+ describe "#disable_reporter_on_error" do
context "when no exception is raise by the block" do
it "does not disable the reporter" do
expect(reporter).not_to receive(:disable_data_collector_reporter)
@@ -521,7 +521,7 @@ describe Chef::DataCollector::Reporter do
end
end
- describe '#validate_data_collector_server_url!' do
+ describe "#validate_data_collector_server_url!" do
context "when server_url is empty" do
it "raises an exception" do
Chef::Config[:data_collector][:server_url] = ""
diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb
index a8227f6c99..42e543fdb2 100644
--- a/spec/unit/dsl/audit_spec.rb
+++ b/spec/unit/dsl/audit_spec.rb
@@ -21,14 +21,14 @@ describe Chef::DSL::Audit do
end
it "raises an error when no audit name is given" do
- expect { auditor.control_group do end }.to raise_error(Chef::Exceptions::AuditNameMissing)
+ expect { auditor.control_group {} }.to raise_error(Chef::Exceptions::AuditNameMissing)
end
context "audits already populated" do
let(:audits) { { "unique" => {} } }
it "raises an error if the audit name is a duplicate" do
- expect { auditor.control_group "unique" do end }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
+ expect { auditor.control_group("unique") {} }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
end
end
@@ -36,7 +36,7 @@ describe Chef::DSL::Audit do
let(:auditor) { BadAuditDSLTester.new }
it "fails because it relies on the recipe DSL existing" do
- expect { auditor.control_group "unique" do end }.to raise_error(NoMethodError, /undefined method `cookbook_name'/)
+ expect { auditor.control_group("unique") {} }.to raise_error(NoMethodError, /undefined method `cookbook_name'/)
end
end
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 55c6e5f578..f93f07bc52 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -60,14 +60,15 @@ describe Chef::DSL::DataQuery do
let(:item_name) { "item_name" }
- let(:raw_data) {{
+ let(:raw_data) do
+ {
"id" => item_name,
"greeting" => "hello",
"nested" => {
"a1" => [1, 2, 3],
"a2" => { "b1" => true },
},
- }}
+ } end
let(:item) do
item = Chef::DataBagItem.new
diff --git a/spec/unit/dsl/declare_resource_spec.rb b/spec/unit/dsl/declare_resource_spec.rb
index 692e57d2e1..57a7fd7f18 100644
--- a/spec/unit/dsl/declare_resource_spec.rb
+++ b/spec/unit/dsl/declare_resource_spec.rb
@@ -50,17 +50,17 @@ describe Chef::ResourceCollection do
describe "#edit_resource!" do
it "raises if nothing is found" do
- expect {
+ expect do
recipe.edit_resource!(:zen_master, "monkey") do
something true
end
- }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ end.to raise_error(Chef::Exceptions::ResourceNotFound)
end
it "raises if nothing is found and no block is given" do
- expect {
+ expect do
recipe.edit_resource!(:zen_master, "monkey")
- }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ end.to raise_error(Chef::Exceptions::ResourceNotFound)
end
it "edits the resource if it finds one" do
@@ -131,20 +131,20 @@ describe Chef::ResourceCollection do
describe "#find_resource!" do
it "raises if nothing is found" do
- expect {
+ expect do
recipe.find_resource!(:zen_master, "monkey")
- }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ end.to raise_error(Chef::Exceptions::ResourceNotFound)
end
it "raises if given a block" do
resource = recipe.declare_resource(:zen_master, "monkey") do
something false
end
- expect {
+ expect do
recipe.find_resource!(:zen_master, "monkey") do
something false
end
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "returns the resource if it finds one" do
@@ -221,9 +221,9 @@ describe Chef::ResourceCollection do
describe "#delete_resource!" do
it "raises if nothing is found" do
- expect {
+ expect do
recipe.delete_resource!(:zen_master, "monkey")
- }.to raise_error(Chef::Exceptions::ResourceNotFound)
+ end.to raise_error(Chef::Exceptions::ResourceNotFound)
end
it "deletes and returns the resource if it finds one" 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 c2cb275f9d..7e885f8818 100644
--- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
+++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb
@@ -39,14 +39,15 @@ describe Chef::EncryptedDataBagItem::CheckEncrypted do
let(:default_secret) { "abc123SECRET" }
let(:item_name) { "item_name" }
- let(:raw_data) {{
+ let(:raw_data) do
+ {
"id" => item_name,
"greeting" => "hello",
"nested" => {
"a1" => [1, 2, 3],
"a2" => { "b1" => true },
},
- }}
+ } end
let(:version) { 1 }
let(:encoded_data) do
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb
index e17f7a2331..a8fb144bf7 100644
--- a/spec/unit/encrypted_data_bag_item_spec.rb
+++ b/spec/unit/encrypted_data_bag_item_spec.rb
@@ -320,11 +320,12 @@ end
describe Chef::EncryptedDataBagItem do
subject { described_class }
let(:encrypted_data_bag_item) { subject.new(encoded_data, secret) }
- let(:plaintext_data) {{
+ let(:plaintext_data) do
+ {
"id" => "item_name",
"greeting" => "hello",
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
- }}
+ } end
let(:secret) { "abc123SECRET" }
let(:encoded_data) { subject.encrypt_data_bag_item(plaintext_data, secret) }
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 5557b5dc11..63c96ad93e 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -296,9 +296,9 @@ describe Chef::Environment do
end
it "should raise and exception" do
- expect {
+ expect do
Chef::Environment.validate_cookbook_version("= 1.2.3.4")
- }.to raise_error Chef::Exceptions::IllegalVersionConstraint,
+ end.to raise_error Chef::Exceptions::IllegalVersionConstraint,
"Environment cookbook version constraints not allowed in chef-solo"
end
end
@@ -450,9 +450,9 @@ describe Chef::Environment 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 {
+ expect do
Chef::Environment.load("foo")
- }.to raise_error Chef::Exceptions::InvalidEnvironmentPath, "Environment path '/var/chef/environments' is invalid"
+ end.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
@@ -460,9 +460,9 @@ describe Chef::Environment do
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
- expect {
+ expect do
Chef::Environment.load("foo")
- }.to raise_error Chef::Exceptions::EnvironmentNotFound, "Environment 'foo' could not be loaded from disk"
+ end.to raise_error Chef::Exceptions::EnvironmentNotFound, "Environment 'foo' could not be loaded from disk"
end
end
end
diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb
index 4118133692..ee806b5c3a 100644
--- a/spec/unit/file_access_control_spec.rb
+++ b/spec/unit/file_access_control_spec.rb
@@ -43,7 +43,7 @@ describe Chef::FileAccessControl do
end
describe "class methods" do
- it 'responds to #writable?' do
+ it "responds to #writable?" do
expect(Chef::FileAccessControl).to respond_to(:writable?)
end
end
diff --git a/spec/unit/file_content_management/tempfile_spec.rb b/spec/unit/file_content_management/tempfile_spec.rb
index a833e21fac..4b27fc8cc9 100644
--- a/spec/unit/file_content_management/tempfile_spec.rb
+++ b/spec/unit/file_content_management/tempfile_spec.rb
@@ -19,11 +19,11 @@
require "spec_helper"
describe Chef::FileContentManagement::Tempfile do
- let(:resource) {
+ let(:resource) do
r = Chef::Resource::File.new("new_file")
r.path "/foo/bar/new_file"
r
- }
+ end
subject { described_class.new(resource) }
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 97fa92ca52..0e5104a0db 100644
--- a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
+++ b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb
@@ -32,13 +32,13 @@ describe Chef::Formatters::APIErrorFormatting do
let(:min_version) { "2" }
let(:max_version) { "5" }
let(:request_version) { "30" }
- let(:return_hash) {
+ let(:return_hash) do
{
"min_version" => min_version,
"max_version" => max_version,
"request_version" => request_version,
}
- }
+ end
before do
# mock out the header
diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
index e76e69d2cd..746b343e9c 100644
--- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
@@ -105,9 +105,9 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
parent_resource
end
- let(:shell_out) {
+ let(:shell_out) do
instance_double(Mixlib::ShellOut, :live_stream => true, :run_command => true, :error! => nil)
- }
+ end
before do
# TODO for some reason Windows is failing on executing a ruby script
diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb
index 85f8d92f78..5067d36d38 100644
--- a/spec/unit/http/validate_content_length_spec.rb
+++ b/spec/unit/http/validate_content_length_spec.rb
@@ -37,25 +37,25 @@ describe Chef::HTTP::ValidateContentLength do
let(:content_length_value) { 23 }
let(:streaming_length) { 23 }
let(:response_body) { "Thanks for checking in." }
- let(:response_headers) {
+ let(:response_headers) do
{
"content-length" => content_length_value,
}
- }
+ end
- let(:response) {
+ let(:response) do
m = double("HttpResponse", :body => response_body)
allow(m).to receive(:[]) do |key|
response_headers[key]
end
m
- }
+ end
- let(:middleware) {
+ let(:middleware) do
client = TestClient.new(url)
client.middlewares[0]
- }
+ end
def run_content_length_validation
stream_handler = middleware.stream_response_handler(response)
@@ -169,12 +169,12 @@ describe Chef::HTTP::ValidateContentLength do
end
describe "when Transfer-Encoding & Content-Length is set" do
- let(:response_headers) {
+ let(:response_headers) do
{
"content-length" => content_length_value,
"transfer-encoding" => "chunked",
}
- }
+ end
%w{direct streaming}.each do |req_type|
describe "when running #{req_type} request" do
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
index 734b27216d..d822fe8f98 100644
--- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
+++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
@@ -29,10 +29,10 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
let(:client) { Chef::ApiClient.new }
- let(:chef_vault_handler) {
+ let(:chef_vault_handler) do
chef_vault_handler = Chef::Knife::Bootstrap::ChefVaultHandler.new(knife_config: knife_config, ui: ui)
chef_vault_handler
- }
+ end
context "when there's no vault option" do
it "should report its not doing anything" do
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 491d0ca754..97ba0fc48e 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -33,12 +33,12 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
let(:rest) { double("Chef::ServerAPI") }
- let(:client_builder) {
+ let(:client_builder) do
client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(knife_config: knife_config, chef_config: chef_config, ui: ui)
allow(client_builder).to receive(:rest).and_return(rest)
allow(client_builder).to receive(:node_name).and_return(node_name)
client_builder
- }
+ end
context "#sanity_check!" do
let(:response_404) { OpenStruct.new(:code => "404") }
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 5f1ba9f781..9f944b82d9 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -236,11 +236,11 @@ describe Chef::Knife::Bootstrap do
end
context "with bootstrap_attribute options" do
- let(:jsonfile) {
+ let(:jsonfile) do
file = Tempfile.new (["node", ".json"])
File.open(file.path, "w") { |f| f.puts '{"foo":{"bar":"baz"}}' }
file
- }
+ end
it "should have foo => {bar => baz} in the first_boot from cli" do
knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
@@ -478,8 +478,9 @@ describe Chef::Knife::Bootstrap do
end
context "when client_d_dir is set" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_00")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_00")) end
it "creates /etc/chef/client.d" do
expect(rendered_template).to match("mkdir -p /etc/chef/client\.d")
@@ -497,8 +498,9 @@ describe Chef::Knife::Bootstrap do
end
context "a nested directory structure" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_01")) end
it "creates a file foo/bar.rb" do
expect(rendered_template).to match("cat > /etc/chef/client.d/foo/bar.rb <<'EOP'")
expect(rendered_template).to match("1 / 0")
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index a9b18c9086..994f4d33a4 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::ClientBulkDelete do
let(:stderr_io) { StringIO.new }
let(:stderr) { stderr_io.string }
- let(:knife) {
+ let(:knife) do
k = Chef::Knife::ClientBulkDelete.new
k.name_args = name_args
k.config = option_args
@@ -33,7 +33,7 @@ describe Chef::Knife::ClientBulkDelete do
allow(k.ui).to receive(:confirm).and_return(knife_confirm)
allow(k.ui).to receive(:confirm_without_exit).and_return(knife_confirm)
k
- }
+ end
let(:name_args) { [ "." ] }
let(:option_args) { {} }
@@ -41,7 +41,7 @@ describe Chef::Knife::ClientBulkDelete do
let(:knife_confirm) { true }
let(:nonvalidator_client_names) { %w{tim dan stephen} }
- let(:nonvalidator_clients) {
+ let(:nonvalidator_clients) do
clients = Hash.new
nonvalidator_client_names.each do |client_name|
@@ -52,10 +52,10 @@ describe Chef::Knife::ClientBulkDelete do
end
clients
- }
+ end
let(:validator_client_names) { %w{myorg-validator} }
- let(:validator_clients) {
+ let(:validator_clients) do
clients = Hash.new
validator_client_names.each do |validator_client_name|
@@ -67,12 +67,12 @@ describe Chef::Knife::ClientBulkDelete do
end
clients
- }
+ end
let(:client_names) { nonvalidator_client_names + validator_client_names }
- let(:clients) {
+ let(:clients) do
nonvalidator_clients.merge(validator_clients)
- }
+ end
before(:each) do
allow(Chef::ApiClientV1).to receive(:list).and_return(clients)
diff --git a/spec/unit/knife/client_edit_spec.rb b/spec/unit/knife/client_edit_spec.rb
index 584a94014c..e7c9030883 100644
--- a/spec/unit/knife/client_edit_spec.rb
+++ b/spec/unit/knife/client_edit_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::ClientEdit do
end
describe "run" do
- let(:data) {
+ let(:data) do
{
"name" => "adam",
"validator" => false,
@@ -35,7 +35,7 @@ describe Chef::Knife::ClientEdit do
"chef_type" => "client",
"create_key" => true,
}
- }
+ end
it "should edit the client" do
allow(Chef::ApiClientV1).to receive(:load).with("adam").and_return(data)
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index 192da862d7..3ecb89f827 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -33,9 +33,9 @@ describe Chef::Knife::ConfigureClient 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 {
+ expect do
@knife.run
- }.to raise_error SystemExit
+ end.to raise_error SystemExit
end
describe "when specifing a directory" do
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index 0e3fccfa7e..4b405d0842 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -128,9 +128,9 @@ describe Chef::Knife::CookbookMetadata do
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 {
+ expect do
@knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb")
- }.to raise_error(SystemExit)
+ end.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
expect(@stderr.string).to match /#{description} blah/im
@@ -166,9 +166,9 @@ describe Chef::Knife::CookbookMetadata do
and_return(@json_data)
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception)
- expect {
+ expect do
@knife.validate_metadata_json(@cookbook_dir, "foobar")
- }.to raise_error(SystemExit)
+ end.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
expect(@stderr.string).to match /#{description} blah/im
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index 1549245ea3..d93af10761 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -24,16 +24,17 @@ describe Chef::Knife::CookbookSiteInstall do
let(:stderr) { StringIO.new }
let(:downloader) { Hash.new }
let(:archive) { double(Mixlib::Archive, extract: true) }
- let(:repo) { double(:sanity_check => true, :reset_to_default_state => true,
- :prepare_to_import => true, :finalize_updates_to => true,
- :merge_updates_from => true) }
- let(:install_path) {
+ let(:repo) do
+ double(:sanity_check => true, :reset_to_default_state => true,
+ :prepare_to_import => true, :finalize_updates_to => true,
+ :merge_updates_from => true) end
+ let(:install_path) do
if Chef::Platform.windows?
"C:/tmp/chef"
else
"/var/tmp/chef"
end
- }
+ end
before(:each) do
require "chef/knife/core/cookbook_scm_repo"
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 081f9deae5..53bd81f4f7 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
allow(ChefConfig).to receive(:windows?) { false }
end
- let(:plugin_manifest) {
+ let(:plugin_manifest) do
{
"_autogenerated_command_paths" => {
"plugins_paths" => {
@@ -39,11 +39,12 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
},
},
}
- }
+ end
- let(:loader) { Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
+ let(:loader) do
+ Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
File.join(CHEF_SPEC_DATA, "knife-site-subcommands"),
- plugin_manifest)}
+ plugin_manifest) end
describe "#list_commands" do
before do
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index 19af419632..ce169a77dd 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Knife::NodeEditor do
subject { described_class.new(node, ui, config) }
- describe '#view' do
+ describe "#view" do
it "returns a Hash with only the name, chef_environment, normal, " +
"policy_name, policy_group, and run_list properties" do
expected = node_data.select do |key,|
@@ -61,7 +61,7 @@ describe Chef::Knife::NodeEditor do
end
end
- describe '#apply_updates' do
+ describe "#apply_updates" do
context "when the node name is changed" do
before(:each) do
allow(ui).to receive(:warn)
@@ -143,7 +143,7 @@ describe Chef::Knife::NodeEditor do
end
end
- describe '#updated?' do
+ describe "#updated?" do
context "before the node has been edited" do
it "returns false" do
expect(subject.updated?).to be false
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 0b9547fc1f..9f525f22f0 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -500,9 +500,9 @@ EOM
shared_examples_for "confirm with negative answer" do
it "confirm should exit 3" do
- expect {
+ expect do
run_confirm
- }.to raise_error(SystemExit) { |e| expect(e.status).to eq(3) }
+ end.to raise_error(SystemExit) { |e| expect(e.status).to eq(3) }
end
it "confirm_without_exit should return false" do
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index bf6bd82a68..3bea392ae2 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -72,11 +72,12 @@ describe Chef::Knife::DataBagFromFile do
let(:loader) { double("Knife::Core::ObjectLoader") }
let(:data_bags_path) { "data_bags" }
- let(:plain_data) { {
+ let(:plain_data) do
+ {
"id" => "item_name",
"greeting" => "hello",
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
- } }
+ } end
let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) }
let(:rest) { double("Chef::ServerAPI") }
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 0672b8bb33..ece7f5bf78 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -45,8 +45,9 @@ describe Chef::Knife::DataBagShow do
let(:bag_name) { "sudoing_admins" }
let(:item_name) { "ME" }
- let(:data_bag_contents) { { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
- "qux" => "http://localhost:4000/data/bag_o_data/qux" } }
+ let(:data_bag_contents) do
+ { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
+ "qux" => "http://localhost:4000/data/bag_o_data/qux" } end
let(:enc_hash) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(data_bag_contents, secret) }
let(:data_bag) { Chef::DataBagItem.from_hash(data_bag_contents) }
let(:data_bag_with_encoded_hash) { Chef::DataBagItem.from_hash(enc_hash) }
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 146b6a904b..5b00c6ea31 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -73,7 +73,7 @@ describe "key create commands that inherit knife" do
end
describe Chef::Knife::KeyCreate do
- let(:public_key) {
+ let(:public_key) do
"-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
@@ -83,15 +83,15 @@ IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
- }
+ end
let(:config) { Hash.new }
let(:actor) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key create run command" do
- let(:key_create_object) {
+ let(:key_create_object) do
described_class.new(actor, actor_field_name, ui, config)
- }
+ end
context "when public_key and key_name weren't passed" do
it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do
@@ -100,11 +100,11 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when the command is run" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
}
- }
+ end
before do
allow(File).to receive(:read).and_return(public_key)
@@ -120,14 +120,14 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
context "when a valid hash is passed" do
let(:key_name) { "charmander-key" }
let(:valid_expiration_date) { "2020-12-24T21:00:00Z" }
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"expiration_date" => valid_expiration_date,
"key_name" => key_name,
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
key_create_object.config[:expiration_Date] = valid_expiration_date,
@@ -141,12 +141,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
end
@@ -158,13 +158,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end # when public_key is passed
context "when public_key isn't passed and key_name is" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => "charmander-key",
"create_key" => true,
}
- }
+ end
before do
key_create_object.config[:key_name] = "charmander-key"
end
@@ -176,13 +176,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when the server returns a private key" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"private_key" => "super_private",
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index 3da5a9762a..0176f3c71e 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -80,9 +80,9 @@ describe Chef::Knife::KeyDelete do
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key delete run command" do
- let(:key_delete_object) {
+ let(:key_delete_object) do
described_class.new(keyname, actor, actor_field_name, ui)
- }
+ end
before do
allow_any_instance_of(Chef::Key).to receive(:destroy)
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 9195e97135..244d8bdcc7 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -75,7 +75,7 @@ describe "key edit commands that inherit knife" do
end
describe Chef::Knife::KeyEdit do
- let(:public_key) {
+ let(:public_key) do
"-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
@@ -85,23 +85,23 @@ IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
- }
+ end
let(:config) { Hash.new }
let(:actor) { "charmander" }
let(:keyname) { "charmander-key" }
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key edit run command" do
- let(:key_edit_object) {
+ let(:key_edit_object) do
described_class.new(keyname, actor, actor_field_name, ui, config)
- }
+ end
context "when the command is run" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
}
- }
+ end
let(:new_keyname) { "charizard-key" }
before do
@@ -126,12 +126,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when key_name is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => new_keyname,
}
- }
+ end
before do
key_edit_object.config[:key_name] = new_keyname
allow_any_instance_of(Chef::Key).to receive(:update)
@@ -155,14 +155,14 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key, key_name, and expiration_date are passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"name" => new_keyname,
"expiration_date" => "infinity",
}
- }
+ end
before do
key_edit_object.config[:public_key] = "this-public-key"
key_edit_object.config[:key_name] = new_keyname
@@ -177,12 +177,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when create_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"create_key" => true,
}
- }
+ end
before do
key_edit_object.config[:create_key] = true
@@ -196,12 +196,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
}
- }
+ end
before do
allow(key_edit_object).to receive(:update_key_from_hash).and_return(Chef::Key.from_hash(expected_hash))
key_edit_object.config[:public_key] = "public_key_path"
@@ -214,13 +214,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end # when public_key is passed
context "when the server returns a private key" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"private_key" => "super_private",
}
- }
+ end
before do
allow(key_edit_object).to receive(:update_key_from_hash).and_return(Chef::Key.from_hash(expected_hash))
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 2d4f0a07bb..82fd1e4a09 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -78,9 +78,9 @@ describe Chef::Knife::KeyList do
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key list run command" do
- let(:key_list_object) {
+ let(:key_list_object) do
described_class.new(actor, list_method, ui, config)
- }
+ end
before do
allow(Chef::Key).to receive(list_method).and_return(http_response)
@@ -191,26 +191,26 @@ describe Chef::Knife::KeyList do
context "when list_method is :list_by_user" do
it_should_behave_like "key list run command" do
let(:list_method) { :list_by_user }
- let(:http_response) {
+ let(:http_response) do
[
{ "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
{ "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
{ "uri" => "https://api.opscode.piab/users/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
- }
+ end
end
end
context "when list_method is :list_by_client" do
it_should_behave_like "key list run command" do
let(:list_method) { :list_by_client }
- let(:http_response) {
+ let(:http_response) do
[
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
- }
+ end
end
end
end
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index c161efbe0d..139d4f91a2 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -78,19 +78,19 @@ describe Chef::Knife::KeyShow do
let(:actor) { "charmander" }
let(:keyname) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => "charmander-key",
"public_key" => "some-public-key",
"expiration_date" => "infinity",
}
- }
+ end
shared_examples_for "key show run command" do
- let(:key_show_object) {
+ let(:key_show_object) do
described_class.new(keyname, actor, load_method, ui)
- }
+ end
before do
allow(key_show_object).to receive(:display_output)
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 473598fd85..c87ea3ad17 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -34,10 +34,11 @@ describe Chef::Knife::Status do
end
describe "run" do
- let(:opts) {{ filter_result:
+ let(:opts) do
+ { filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
- platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }}
+ platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } end
it "should default to searching for everything" do
expect(@query).to receive(:search).with(:node, "*:*", opts)
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index e708d2d1ad..07d72fd05a 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -24,13 +24,13 @@ Chef::Knife::UserCreate.load_deps
describe Chef::Knife::UserCreate do
let(:knife) { Chef::Knife::UserCreate.new }
- let(:stderr) {
+ let(:stderr) do
StringIO.new
- }
+ end
- let(:stdout) {
+ let(:stdout) do
StringIO.new
- }
+ end
before(:each) do
allow(knife.ui).to receive(:stdout).and_return(stdout)
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index ec1e59d863..f0ec45d59a 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -159,12 +159,13 @@ describe Chef::Knife do
describe "the headers include X-Remote-Request-Id" do
- let(:headers) {{ "Accept" => "application/json",
- "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
- "X-Chef-Version" => Chef::VERSION,
- "Host" => "api.opscode.piab",
- "X-REMOTE-REQUEST-ID" => request_id,
- }}
+ let(:headers) do
+ { "Accept" => "application/json",
+ "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
+ "X-Chef-Version" => Chef::VERSION,
+ "Host" => "api.opscode.piab",
+ "X-REMOTE-REQUEST-ID" => request_id,
+ } end
let(:request_id) { "1234" }
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index ab7a6302ee..0689d99647 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -232,9 +232,9 @@ describe "LWRP" do
end
it "allows to user to user the resource_name" do
- expect {
+ expect do
klass.resource_name(:foo)
- }.to_not raise_error
+ end.to_not raise_error
end
it "returns the set value for the resource" do
@@ -741,7 +741,7 @@ describe "LWRP" do
end
end
- let(:recipe) {
+ let(:recipe) do
cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
cookbook_loader.load_cookbooks
@@ -750,7 +750,7 @@ describe "LWRP" do
events = Chef::EventDispatch::Dispatcher.new
run_context = Chef::RunContext.new(node, cookbook_collection, events)
Chef::Recipe.new("hjk", "test", run_context)
- }
+ end
it "lets you extend the recipe DSL" do
expect(Chef::Recipe).to receive(:include).with(MyAwesomeDSLExensionClass)
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index 13b729538c..191dee643b 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -50,12 +50,12 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when x-ops-server-api-version header exists" do
let(:min_server_version) { 2 }
let(:max_server_version) { 4 }
- let(:return_hash) {
+ let(:return_hash) do
{
"min_version" => min_server_version,
"max_version" => max_server_version,
}
- }
+ end
before(:each) do
allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash))
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb
index 0c2f6da188..e9f0dacad6 100644
--- a/spec/unit/mixin/command_spec.rb
+++ b/spec/unit/mixin/command_spec.rb
@@ -49,22 +49,24 @@ describe Chef::Mixin::Command, :volatile do
end
it "should end when the child process reads from STDIN and a block is given" do
- expect {Timeout.timeout(10) do
- popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
- (1..5).each { |i| stdin.puts "#{i}" }
+ expect do
+ Timeout.timeout(10) do
+ popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
+ (1..5).each { |i| stdin.puts "#{i}" }
+ end
end
- end
- }.not_to raise_error
+ end.not_to raise_error
end
describe "when a process detaches but doesn't close STDOUT and STDERR [CHEF-584]" do
it "returns immediately after the first child process exits" do
- expect {Timeout.timeout(10) do
- evil_forker = "exit if fork; 10.times { sleep 1}"
- popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr|
- end
- end}.not_to raise_error
+ expect do
+ Timeout.timeout(10) do
+ evil_forker = "exit if fork; 10.times { sleep 1}"
+ popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr|
+ end
+ end end.not_to raise_error
end
end
@@ -92,10 +94,11 @@ describe Chef::Mixin::Command, :volatile do
# btm
# Serdar - During Solaris tests, we've seen that processes
# are taking a long time to exit. Bumping timeout now to 10.
- expect {Timeout.timeout(10) do
- evil_forker = "exit if fork; 10.times { sleep 1}"
- run_command(:command => "ruby -e '#{evil_forker}'")
- end}.not_to raise_error
+ expect do
+ Timeout.timeout(10) do
+ evil_forker = "exit if fork; 10.times { sleep 1}"
+ run_command(:command => "ruby -e '#{evil_forker}'")
+ end end.not_to raise_error
end
end
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb
index de72f6b935..c9a6e6e909 100644
--- a/spec/unit/mixin/homebrew_user_spec.rb
+++ b/spec/unit/mixin/homebrew_user_spec.rb
@@ -51,11 +51,11 @@ describe Chef::Mixin::HomebrewUser do
let(:user) { nil }
let(:brew_owner) { 2001 }
let(:default_brew_path) { "/usr/local/bin/brew" }
- let(:stat_double) {
+ let(:stat_double) do
d = double()
expect(d).to receive(:uid).and_return(brew_owner)
d
- }
+ end
context "debug statement prints owner name" do
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index dcee123982..0cafb925c8 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -56,7 +56,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should allow you to check what kind_of? thing an argument is with kind_of" do
- expect {
+ expect do
@vo.validate(
{ :one => "string" },
{
@@ -65,9 +65,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :one => "string" },
{
@@ -76,11 +76,11 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should allow you to specify an argument is required with required" do
- expect {
+ expect do
@vo.validate(
{ :one => "string" },
{
@@ -89,9 +89,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :two => "string" },
{
@@ -100,9 +100,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
@vo.validate(
{ :two => "string" },
{
@@ -111,11 +111,11 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
end
it "should allow you to specify whether an object has a method with respond_to" do
- expect {
+ expect do
@vo.validate(
{ :one => @vo },
{
@@ -124,9 +124,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :one => @vo },
{
@@ -135,11 +135,11 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should allow you to specify whether an object has all the given methods with respond_to and an array" do
- expect {
+ expect do
@vo.validate(
{ :one => @vo },
{
@@ -148,9 +148,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :one => @vo },
{
@@ -159,7 +159,7 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should let you set a default value with default => value" do
@@ -173,7 +173,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should let you check regular expressions" do
- expect {
+ expect do
@vo.validate(
{ :one => "is good" },
{
@@ -182,9 +182,9 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :one => "is good" },
{
@@ -193,44 +193,44 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should let you specify your own callbacks" do
- expect {
+ expect do
@vo.validate(
{ :one => "is good" },
{
:one => {
:callbacks => {
- "should be equal to is good" => lambda { |a|
+ "should be equal to is good" => lambda do |a|
a == "is good"
- },
+ end,
},
},
}
)
- }.not_to raise_error
+ end.not_to raise_error
- expect {
+ expect do
@vo.validate(
{ :one => "is bad" },
{
:one => {
:callbacks => {
- "should be equal to 'is good'" => lambda { |a|
+ "should be equal to 'is good'" => lambda do |a|
a == "is good"
- },
+ end,
},
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should let you combine checks" do
args = { :one => "is good", :two => "is bad" }
- expect {
+ expect do
@vo.validate(
args,
{
@@ -239,9 +239,9 @@ describe Chef::Mixin::ParamsValidate do
:respond_to => [ :to_s, :upcase ],
:regex => /^is good/,
:callbacks => {
- "should be your friend" => lambda { |a|
+ "should be your friend" => lambda do |a|
a == "is good"
- },
+ end,
},
:required => true,
},
@@ -252,9 +252,9 @@ describe Chef::Mixin::ParamsValidate do
:three => { :default => "neato mosquito" },
}
)
- }.not_to raise_error
+ end.not_to raise_error
expect(args[:three]).to eq("neato mosquito")
- expect {
+ expect do
@vo.validate(
args,
{
@@ -263,9 +263,9 @@ describe Chef::Mixin::ParamsValidate do
:respond_to => [ :to_s, :upcase ],
:regex => /^is good/,
:callbacks => {
- "should be your friend" => lambda { |a|
+ "should be your friend" => lambda do |a|
a == "is good"
- },
+ end,
},
:required => true,
},
@@ -276,11 +276,12 @@ describe Chef::Mixin::ParamsValidate do
:three => { :default => "neato mosquito" },
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should raise an ArgumentError if the validation map has an unknown check" do
- expect { @vo.validate(
+ expect do
+ @vo.validate(
{ :one => "two" },
{
:one => {
@@ -288,17 +289,17 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept keys that are strings in the options" do
- expect {
+ expect do
@vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } })
- }.not_to raise_error
+ end.not_to raise_error
end
it "should allow an array to kind_of" do
- expect {
+ expect do
@vo.validate(
{ :one => "string" },
{
@@ -307,8 +308,8 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
@vo.validate(
{ :one => ["string"] },
{
@@ -317,8 +318,8 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
@vo.validate(
{ :one => Hash.new },
{
@@ -327,7 +328,7 @@ describe Chef::Mixin::ParamsValidate do
},
}
)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "asserts that a value returns false from a predicate method" do
@@ -354,15 +355,15 @@ describe Chef::Mixin::ParamsValidate do
end
it "should raise an ArgumentError when argument is nil and required is true" do
- expect {
+ expect do
@vo.set_or_return(:test, nil, { :required => true })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should not raise an error when argument is nil and required is false" do
- expect {
+ expect do
@vo.set_or_return(:test, nil, { :required => false })
- }.not_to raise_error
+ end.not_to raise_error
end
it "should set and return @name, then return @name for foo when argument is nil" do
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index eae5b033f1..8e5f3588ce 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -22,9 +22,9 @@ describe Chef::Mixin::PowershellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } }
subject(:object) { shell_out_class.new }
let(:architecture) { "something" }
- let(:flags) {
+ let(:flags) do
"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None"
- }
+ end
describe "#powershell_out" do
it "runs a command and returns the shell_out object" do
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index 7f2ecb94e2..6f52abccfb 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -27,12 +27,12 @@ end
describe Chef::Mixin::PowershellTypeCoercions do
let (:test_class) { Chef::PSTypeTester.new }
- describe '#translate_type' do
+ describe "#translate_type" do
it "single quotes a string" do
expect(test_class.translate_type("foo")).to eq("'foo'")
end
- ["'", '"', '#', "`"].each do |c|
+ ["'", '"', "#", "`"].each do |c|
it "base64 encodes a string that contains #{c}" do
expect(test_class.translate_type("#{c}")).to match(Base64.strict_encode64(c))
end
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 191ea920c0..bf74ff410e 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -25,7 +25,7 @@ require "spec_helper"
describe Chef::Mixin::ShellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } }
subject(:shell_out_obj) { shell_out_class.new }
- describe '#run_command_compatible_options' do
+ describe "#run_command_compatible_options" do
subject { shell_out_obj.run_command_compatible_options(command_args) }
let(:command_args) { [ cmd, options ] }
let(:cmd) { "echo '#{rand(1000)}'" }
diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb
index 903c91164e..495ad0662c 100644
--- a/spec/unit/mixin/xml_escape_spec.rb
+++ b/spec/unit/mixin/xml_escape_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Mixin::XMLEscape do
end
it "does not modify ASCII strings" do
- expect(@escaper.xml_escape('foobarbaz!@#$%^*()')).to eq('foobarbaz!@#$%^*()')
+ expect(@escaper.xml_escape("foobarbaz!@\#$%^*()")).to eq("foobarbaz!@\#$%^*()")
end
it "converts invalid bytes to asterisks" do
@@ -45,10 +45,10 @@ describe Chef::Mixin::XMLEscape do
end
it "converts UTF-8 correctly" do
- expect(@escaper.xml_escape("\xC2\xA9")).to eq('&#169;')
+ expect(@escaper.xml_escape("\xC2\xA9")).to eq("&#169;")
end
it "converts win 1252 characters correctly" do
- expect(@escaper.xml_escape("#{0x80.chr}")).to eq('&#8364;')
+ expect(@escaper.xml_escape("#{0x80.chr}")).to eq("&#8364;")
end
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 72731c927f..2c8fc4408b 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1359,10 +1359,10 @@ describe Chef::Node do
end
include_examples "to_json equivalent to Chef::JSONCompat.to_json" do
- let(:jsonable) {
+ let(:jsonable) do
node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
node
- }
+ end
end
end
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index 49da6a95f0..aa2b3c1f11 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -151,7 +151,7 @@ describe "Chef::Platform#supports_msi?" do
end
end
-describe 'Chef::Platform#supports_dsc?' do
+describe "Chef::Platform#supports_dsc?" do
it "returns false if powershell is not present" do
node = Chef::Node.new
expect(Chef::Platform.supports_dsc?(node)).to be_falsey
@@ -174,7 +174,7 @@ describe 'Chef::Platform#supports_dsc?' do
end
end
-describe 'Chef::Platform#supports_dsc_invoke_resource?' do
+describe "Chef::Platform#supports_dsc_invoke_resource?" 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
@@ -195,7 +195,7 @@ describe 'Chef::Platform#supports_dsc_invoke_resource?' do
end
end
-describe 'Chef::Platform#dsc_refresh_mode_disabled?' do
+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") }
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index f5eb361426..50ff3434f6 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -1103,18 +1103,18 @@ describe "Chef::Resource.property" do
context "property_type" do
it "property_types validate their defaults" do
- expect {
+ expect do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
property_type(is: [:a, :b], default: :c)
end
- }.to raise_error(Chef::Exceptions::DeprecatedFeatureError, /Default value :c is invalid for property <property type>./)
- expect {
+ end.to raise_error(Chef::Exceptions::DeprecatedFeatureError, /Default value :c is invalid for property <property type>./)
+ expect do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
property_type(is: [:a, :b], default: :b)
end
- }.not_to raise_error
+ end.not_to raise_error
end
context "With property_type ABType (is: [:a, :b]) and CDType (is: [:c, :d])" do
diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb
index b375784d00..f49cc7d3da 100644
--- a/spec/unit/provider/cookbook_file_spec.rb
+++ b/spec/unit/provider/cookbook_file_spec.rb
@@ -26,12 +26,12 @@ 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(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
# Subject
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index 83e0f431bf..5e1fcb35ab 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -91,9 +91,9 @@ describe Chef::Provider::Cron::Unix do
let (:exitstatus) { 2 }
it "should raise an exception if another error occurs" do
- expect {
+ expect do
provider.send(:read_crontab)
- }.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
+ end.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
end
it "logs the crontab output to debug" do
@@ -130,9 +130,9 @@ describe Chef::Provider::Cron::Unix do
context "when writing the crontab fails" do
let(:exitstatus) { 1 }
it "should raise an exception if the command returns non-zero" do
- expect {
+ expect do
provider.send(:write_crontab, "Foo")
- }.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
+ end.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
end
end
end
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb
index 9e849743e7..64916ef454 100644
--- a/spec/unit/provider/cron_spec.rb
+++ b/spec/unit/provider/cron_spec.rb
@@ -199,9 +199,9 @@ CRONTAB
# Chef Name: foo[bar] (baz)
21 */4 * * * some_prog 1234567
CRONTAB
- expect {
+ expect do
@provider.load_current_resource
- }.not_to raise_error
+ end.not_to raise_error
end
end
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index 62d9123e7b..e69714280c 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -167,9 +167,9 @@ describe Chef::Provider::Deploy do
allow(@provider).to receive(:deploy) { raise "Unexpected error" }
allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).not_to receive(:rollback)
- expect {
+ expect do
@provider.run_action(:deploy)
- }.to raise_exception(RuntimeError, "Unexpected error")
+ end.to raise_exception(RuntimeError, "Unexpected error")
end
it "rollbacks to previous release if error happens on deploy" do
@@ -178,9 +178,9 @@ describe Chef::Provider::Deploy do
allow(@provider).to receive(:deploy) { raise "Unexpected error" }
allow(@provider).to receive(:previous_release_path).and_return("previous_release")
expect(@provider).to receive(:rollback)
- expect {
+ expect do
@provider.run_action(:deploy)
- }.to raise_exception(RuntimeError, "Unexpected error")
+ end.to raise_exception(RuntimeError, "Unexpected error")
end
describe "on systems without broken Dir.glob results" do
@@ -232,17 +232,17 @@ describe Chef::Provider::Deploy do
#FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342")
#@provider.run_action(:rollback)
#@provider.release_path.should eql(NIL) -- no check needed since assertions will fail
- expect {
+ expect do
@provider.run_action(:rollback)
- }.to raise_exception(RuntimeError, "There is no release to rollback to!")
+ end.to raise_exception(RuntimeError, "There is no release to rollback to!")
end
it "an exception is raised when there are no releases" do
all_releases = []
allow(Dir).to receive(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases)
- expect {
+ expect do
@provider.run_action(:rollback)
- }.to raise_exception(RuntimeError, "There is no release to rollback to!")
+ end.to raise_exception(RuntimeError, "There is no release to rollback to!")
end
end
end
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 2a00c2ed7f..34eb9727f8 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -28,11 +28,11 @@ describe Chef::Provider::DscResource do
end
context "when Powershell does not support Invoke-DscResource" do
- let (:node) {
+ let (:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "4.0"
node
- }
+ end
it "raises a ProviderNotFound exception" do
expect(provider).not_to receive(:meta_configuration)
expect { provider.run_action(:run) }.to raise_error(
@@ -44,11 +44,11 @@ describe Chef::Provider::DscResource do
context "when RefreshMode is not set to Disabled" do
context "and the WMF 5 is a preview release" do
- let (:node) {
+ let (:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
- }
+ end
it "raises an exception" do
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
expect { provider.run_action(:run) }.to raise_error(
@@ -56,11 +56,11 @@ describe Chef::Provider::DscResource do
end
end
context "and the WMF is 5 RTM or newer" do
- let (:node) {
+ let (:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
node
- }
+ end
it "does not raises an exception" do
expect(provider).to receive(:test_resource)
expect(provider).to receive(:set_resource)
@@ -72,11 +72,11 @@ describe Chef::Provider::DscResource do
end
context "when the LCM supports Invoke-DscResource" do
- let (:node) {
+ let (:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
- }
+ end
let (:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
let (:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
let (:store) { double("ResourceStore", find: resource_records) }
@@ -153,10 +153,11 @@ describe Chef::Provider::DscResource do
end
context "multiple resource are found" do
- let (:resource_records) { [
+ let (:resource_records) do
+ [
{ "Module" => { "Name" => "ModuleName1" } },
{ "Module" => { "Name" => "ModuleName2" } },
- ] }
+ ] end
it "raises MultipleDscResourcesFound" do
expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::MultipleDscResourcesFound)
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index 3877a37e61..5f091b8813 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -23,11 +23,11 @@ require "spec_helper"
describe Chef::Provider::DscScript do
context "when DSC is available" do
- let (:node) {
+ let (:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "4.0"
node
- }
+ end
let (:events) { Chef::EventDispatch::Dispatcher.new }
let (:run_context) { Chef::RunContext.new(node, {}, events) }
let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
@@ -35,7 +35,7 @@ describe Chef::Provider::DscScript do
Chef::Provider::DscScript.new(resource, run_context)
end
- describe '#load_current_resource' do
+ describe "#load_current_resource" 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
@@ -75,7 +75,7 @@ describe Chef::Provider::DscScript do
end
end
- describe '#generate_configuration_document' do
+ 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
@@ -123,7 +123,7 @@ describe Chef::Provider::DscScript do
end
end
- describe '#generate_description' do
+ 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])
@@ -156,16 +156,16 @@ describe Chef::Provider::DscScript do
it "raises an exception for powershell version '#{version}'" do
node.automatic[:languages][:powershell][:version] = version
- expect {
+ expect do
provider.run_action(:run)
- }.to raise_error(Chef::Exceptions::ProviderNotFound)
+ end.to raise_error(Chef::Exceptions::ProviderNotFound)
end
end
it "raises an exception if Powershell is not present" do
- expect {
+ expect do
provider.run_action(:run)
- }.to raise_error(Chef::Exceptions::ProviderNotFound)
+ end.to raise_error(Chef::Exceptions::ProviderNotFound)
end
end
diff --git a/spec/unit/provider/env/windows_spec.rb b/spec/unit/provider/env/windows_spec.rb
index abe2344443..5ddc1d6f91 100644
--- a/spec/unit/provider/env/windows_spec.rb
+++ b/spec/unit/provider/env/windows_spec.rb
@@ -24,16 +24,16 @@ describe Chef::Provider::Env::Windows, :windows_only do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
context "when environment variable is not PATH" do
- let(:new_resource) {
+ let(:new_resource) do
new_resource = Chef::Resource::Env.new("CHEF_WINDOWS_ENV_TEST")
new_resource.value("foo")
new_resource
- }
- let(:provider) {
+ end
+ let(:provider) do
provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object)
provider
- }
+ end
describe "action_create" do
before do
@@ -76,16 +76,16 @@ describe Chef::Provider::Env::Windows, :windows_only do
describe "for PATH" do
let(:system_root) { "%SystemRoot%" }
let(:system_root_value) { 'D:\Windows' }
- let(:new_resource) {
+ let(:new_resource) do
new_resource = Chef::Resource::Env.new("PATH")
new_resource.value(system_root)
new_resource
- }
- let(:provider) {
+ end
+ let(:provider) do
provider = Chef::Provider::Env::Windows.new(new_resource, run_context)
allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object)
provider
- }
+ end
before do
stub_const("ENV", { "PATH" => "" })
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index a31c75baf4..f840d92dbb 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -28,12 +28,12 @@ describe Chef::Provider::File::Content do
double("Chef::Provider::File::Resource (current)")
end
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
let(:new_resource) do
double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path)
@@ -77,9 +77,9 @@ describe Chef::Provider::File::Content do
end
context "when creating a tempfiles in destdir fails" do
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path("/nonexisting/path")
- }
+ end
it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do
Chef::Config[:file_staging_uses_destdir] = :auto
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index 11bef8a44d..d8d4ed2286 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -35,12 +35,12 @@ describe Chef::Provider::File 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(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
# Subject
diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb
index 4286405ef5..2893044833 100644
--- a/spec/unit/provider/launchd_spec.rb
+++ b/spec/unit/provider/launchd_spec.rb
@@ -51,7 +51,8 @@ describe Chef::Provider::Launchd do
</plist>
XML
- let(:test_hash) do {
+ let(:test_hash) do
+ {
"Label" => "call.mom.weekly",
"Program" => "/Library/scripts/call_mom.sh",
"StartCalendarInterval" => {
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 51ace83470..264c8b9b36 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
let(:options) { nil }
- let(:new_resource) {
+ let(:new_resource) do
new_resource = Chef::Resource::Mount.new(mountpoint)
new_resource.device device
new_resource.device_type device_type
@@ -50,13 +50,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
new_resource.options options
new_resource.supports :remount => false
new_resource
- }
+ end
- let(:provider) {
+ let(:provider) do
Chef::Provider::Mount::Solaris.new(new_resource, run_context)
- }
+ end
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
@@ -74,21 +74,21 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
# ufs
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
- }
+ end
- let(:vfstab_file) {
+ let(:vfstab_file) do
t = Tempfile.new("rspec-vfstab")
t.write(vfstab_file_contents)
t.close
t
- }
+ end
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
before do
stub_const("Chef::Provider::Mount::Solaris::VFSTAB", vfstab_file.path )
@@ -214,7 +214,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
describe "#load_current_resource" do
context "when loading a normal UFS filesystem with noauto, don't mount at boot" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
@@ -232,7 +232,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
# ufs
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 no -
EOF
- }
+ end
before do
provider.load_current_resource
@@ -244,16 +244,16 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the device is an smbfs mount" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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) {
+ end
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
//WORKGROUP;username:password@host/share - /mountpoint smbfs - no fileperms=0777,dirperms=0777
EOF
- }
+ end
let(:fsck_device) { "-" }
@@ -263,17 +263,17 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the device is an NFS mount" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
cartman:/share2 - /cartman nfs - yes rw,soft
EOF
- }
+ end
let(:fsck_device) { "-" }
@@ -334,17 +334,17 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
let(:target) { "/dev/mapper/target" }
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
#{target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
- }
+ end
before do
expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true)
@@ -371,17 +371,17 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
let(:absolute_target) { File.expand_path(target, File.dirname(device)) }
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
#{absolute_target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
- }
+ end
before do
expect(File).to receive(:symlink?).with(device).at_least(:once).and_return(true)
@@ -404,12 +404,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the matching mount point is last in the mounts list" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
it "should set mounted true" do
provider.load_current_resource()
expect(provider.current_resource.mounted).to be_truthy
@@ -417,12 +417,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the matching mount point is not last in the mounts list" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
it "should set mounted false" do
provider.load_current_resource()
expect(provider.current_resource.mounted).to be_falsey
@@ -430,11 +430,11 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the matching mount point is not in the mounts list (mountpoint wrong)" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
it "should set mounted false" do
provider.load_current_resource()
expect(provider.current_resource.mounted).to be_falsey
@@ -442,11 +442,11 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the matching mount point is not in the mounts list (raw device wrong)" do
- let(:mount_output) {
+ let(:mount_output) do
<<-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
- }
+ end
it "should set mounted false" do
provider.load_current_resource()
expect(provider.current_resource.mounted).to be_falsey
@@ -454,12 +454,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mount point is last in fstab" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-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
- }
+ end
it "should set enabled to true" do
provider.load_current_resource
@@ -468,12 +468,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mount point is not last in fstab and is a substring of another mount" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-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
- }
+ end
it "should set enabled to true" do
provider.load_current_resource
@@ -482,12 +482,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mount point is not last in fstab" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-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
- }
+ end
it "should set enabled to false" do
provider.load_current_resource
@@ -496,11 +496,11 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mount point is not in fstab, but the mountpoint is a substring of one that is" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foob ufs 2 yes -
EOF
- }
+ end
it "should set enabled to false" do
provider.load_current_resource
@@ -509,11 +509,11 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mount point is not in fstab, but the device is a substring of one that is" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
/dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
- }
+ end
it "should set enabled to false" do
provider.load_current_resource
@@ -522,11 +522,11 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
end
context "when the mountpoint line is commented out" do
- let(:vfstab_file_contents) {
+ let(:vfstab_file_contents) do
<<-EOF.gsub /^\s*/, ""
#/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes -
EOF
- }
+ end
it "should set enabled to false" do
provider.load_current_resource
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index 8344c3d0ec..704ef1aef2 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -462,18 +462,18 @@ describe "behavior when Chocolatey is not installed" do
Chef::Provider::Package::Chocolatey.new(new_resource, run_context)
end
- before {
+ before do
# the shellout sometimes returns "", but test nil to be safe.
allow(provider).to receive(:choco_install_path).and_return(nil)
provider.instance_variable_set("@choco_install_path", nil)
# we don't care what this returns, but we have to let it be called.
allow(provider).to receive(:shell_out!).and_return(double(:stdout => ""))
- }
+ end
- let(:error_regex) {
+ let(:error_regex) do
/Could not locate.*install.*cookbook.*PowerShell.*GetEnvironmentVariable/m
- }
+ end
context "#choco_exe" do
it "triggers a MissingLibrary exception when Chocolatey is not installed" do
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 4bc28f130a..e9aec933e2 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -312,7 +312,8 @@ describe Chef::Provider::Package::Yum do
end
context "when the package name isn't found" do
- let(:yum_cache) { double(
+ let(:yum_cache) do
+ double(
"Chef::Provider::Yum::YumCache",
:reload_installed => true,
:reset => true,
@@ -322,7 +323,7 @@ describe Chef::Provider::Package::Yum do
:version_available? => true,
:disable_extra_repo_control => true
)
- }
+ end
before do
allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(yum_cache)
@@ -1063,21 +1064,21 @@ describe Chef::Provider::Package::Yum::RPMVersion do
end
it "should raise an error unless passed 1 or 3 args" do
- expect {
+ expect do
Chef::Provider::Package::Yum::RPMVersion.new()
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMVersion.new("1:1.6.5-9.36.el5")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMVersion.new("1:1.6.5-9.36.el5", "extra")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMVersion.new("1", "1.6.5", "9.36.el5")
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMVersion.new("1", "1.6.5", "9.36.el5", "extra")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
# thanks version_class_spec.rb!
@@ -1260,30 +1261,30 @@ describe Chef::Provider::Package::Yum::RPMPackage do
end
it "should raise an error unless passed 4 or 6 args" do
- expect {
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new()
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64", [])
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64", [])
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64", [], "extra")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
describe "<=>" do
@@ -1397,27 +1398,27 @@ describe Chef::Provider::Package::Yum::RPMDependency do
end
it "should raise an error unless passed 3 or 5 args" do
- expect {
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new()
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==, "extra")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1", "1.6.5", "9.36.el5", :==)
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1", "1.6.5", "9.36.el5", :==, "extra")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
describe "parse" do
@@ -1485,12 +1486,12 @@ describe Chef::Provider::Package::Yum::RPMDependency do
it "should raise an error unless a RPMDependency is passed" do
@rpmprovide = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :>=)
- expect {
+ expect do
@rpmprovide.satisfy?("hi")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
@rpmprovide.satisfy?(@rpmrequire)
- }.not_to raise_error
+ end.not_to raise_error
end
it "should validate dependency satisfaction logic for standard examples" do
@@ -1712,12 +1713,12 @@ describe Chef::Provider::Package::Yum::RPMDb do
it "should raise an error unless a RPMDependency is passed" do
@rpmprovide = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :>=)
- expect {
+ expect do
@rpmdb.whatprovides("hi")
- }.to raise_error(ArgumentError)
- expect {
+ end.to raise_error(ArgumentError)
+ expect do
@rpmdb.whatprovides(@rpmrequire)
- }.not_to raise_error
+ end.not_to raise_error
end
it "should return an Array of packages statisfying a RPMDependency" do
@@ -1748,13 +1749,13 @@ describe Chef::Provider::Package::Yum::YumCache do
end
end
- let(:yum_exe) {
+ let(:yum_exe) do
StringIO.new("#!/usr/bin/python\n\naldsjfa\ldsajflkdsjf\lajsdfj")
- }
+ end
- let(:bin_exe) {
+ let(:bin_exe) do
StringIO.new(SecureRandom.random_bytes)
- }
+ end
before(:each) do
@stdin = double("STDIN", :nil_object => true)
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index 2ef58db9f3..40b7516b5c 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -396,13 +396,13 @@ describe Chef::Provider::Package do
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_resource) {
+ let(:response_file_resource) do
response_file_resource = Chef::Resource::CookbookFile.new(response_file_destination, run_context)
response_file_resource.cookbook_name = "java"
response_file_resource.backup(false)
response_file_resource.source("java.response")
response_file_resource
- }
+ end
before do
expect(provider).to receive(:preseed_resource).with("java", "6").and_return(response_file_resource)
diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb
index 96869ff31c..4fd3f3534d 100644
--- a/spec/unit/provider/powershell_script_spec.rb
+++ b/spec/unit/provider/powershell_script_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Provider::PowershellScript, "action_run" do
let(:powershell_version) { nil }
- let(:node) {
+ let(:node) do
node = Chef::Node.new
node.default["kernel"] = Hash.new
node.default["kernel"][:machine] = :x86_64.to_s
@@ -28,14 +28,14 @@ describe Chef::Provider::PowershellScript, "action_run" do
node.default[:languages] = { :powershell => { :version => powershell_version } }
end
node
- }
+ end
- let(:provider) {
+ let(:provider) do
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)
Chef::Provider::PowershellScript.new(new_resource, run_context)
- }
+ end
context "when setting interpreter flags" do
context "on nano" do
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index 9963c401d2..b2fbb7300c 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -19,12 +19,12 @@
require "spec_helper"
describe Chef::Provider::RemoteFile::FTP do
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
let(:new_resource) do
r = Chef::Resource::RemoteFile.new("remote file ftp backend test (new resource)")
diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb
index 673ea015c0..7be507dc89 100644
--- a/spec/unit/provider/remote_file/sftp_spec.rb
+++ b/spec/unit/provider/remote_file/sftp_spec.rb
@@ -20,12 +20,12 @@ require "spec_helper"
describe Chef::Provider::RemoteFile::SFTP do
#built out dependencies
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
let(:new_resource) do
r = Chef::Resource::RemoteFile.new("remote file sftp backend test (new resource)")
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index 6107f93c41..6ceb1d450d 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -37,12 +37,12 @@ describe Chef::Provider::RemoteFile 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(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
subject(:provider) do
provider = described_class.new(resource, run_context)
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 4e8d8bdf59..7e34a8f083 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -25,12 +25,12 @@ describe Chef::Provider::Script, "action_run" do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
- let(:new_resource) {
+ let(:new_resource) do
new_resource = Chef::Resource::Script.new("run some perl code")
new_resource.code "$| = 1; print 'i like beans'"
new_resource.interpreter "perl"
new_resource
- }
+ end
let(:provider) { Chef::Provider::Script.new(new_resource, run_context) }
@@ -87,9 +87,9 @@ describe Chef::Provider::Script, "action_run" do
end
describe "when running the script" do
- let (:default_opts) {
+ let (:default_opts) do
{ timeout: 3600, returns: 0, log_level: :info, log_tag: "script[run some perl code]" }
- }
+ end
before do
allow(STDOUT).to receive(:tty?).and_return(false)
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 2192671370..799ed991a3 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -39,9 +39,9 @@ describe Chef::Provider::Service::Debian do
expect(File).to receive(:exists?).with("/usr/sbin/update-rc.d") .and_return(false)
@provider.define_resource_requirements
- expect {
+ expect do
@provider.process_resource_requirements
- }.to raise_error(Chef::Exceptions::Service)
+ end.to raise_error(Chef::Exceptions::Service)
end
context "when update-rc.d shows init linked to rc*.d/" do
@@ -108,9 +108,9 @@ describe Chef::Provider::Service::Debian do
it "raises an error" do
@provider.define_resource_requirements
- expect {
+ expect do
@provider.process_resource_requirements
- }.to raise_error(Chef::Exceptions::Service)
+ end.to raise_error(Chef::Exceptions::Service)
end
end
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 68d4d63991..10eb3c1a14 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -257,10 +257,11 @@ PS_SAMPLE
end
context "when the enable variable partial matches (left) some other service and we are disabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{thing_#{new_resource.service_name}_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] }
+ ] end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -268,10 +269,11 @@ PS_SAMPLE
end
context "when the enable variable partial matches (right) some other service and we are disabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{#{new_resource.service_name}_thing_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] }
+ ] end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -279,10 +281,11 @@ PS_SAMPLE
end
context "when the enable variable partial matches (left) some other disabled service and we are enabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{thing_#{new_resource.service_name}_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] }
+ ] end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -290,10 +293,11 @@ PS_SAMPLE
end
context "when the enable variable partial matches (right) some other disabled service and we are enabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{#{new_resource.service_name}_thing_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] }
+ ] end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index b11015a63a..872a3bc400 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -174,10 +174,11 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the enable variable partial matches (left) some other service and we are disabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{thing_#{provider.builtin_service_enable_variable_name}="YES"},
%Q{#{provider.builtin_service_enable_variable_name}="NO"},
- ] }
+ ] end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -185,10 +186,11 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the enable variable partial matches (right) some other service and we are disabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{#{provider.builtin_service_enable_variable_name}_thing="YES"},
%Q{#{provider.builtin_service_enable_variable_name}},
- ] }
+ ] end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -196,10 +198,11 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the enable variable partial matches (left) some other disabled service and we are enabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{thing_#{provider.builtin_service_enable_variable_name}="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] }
+ ] end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -207,10 +210,11 @@ describe Chef::Provider::Service::Openbsd do
end
context "when the enable variable partial matches (right) some other disabled service and we are enabled" do
- let(:lines) { [
+ let(:lines) do
+ [
%Q{#{provider.builtin_service_enable_variable_name}_thing="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] }
+ ] end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index e0a94127b7..8574cbf772 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
describe Chef::Provider::Service::Systemd do
- let(:node) {
+ let(:node) do
node = Chef::Node.new
node.default["etc"] = Hash.new
node.default["etc"]["passwd"] = {
@@ -30,7 +30,7 @@ describe Chef::Provider::Service::Systemd do
},
}
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index f944d8f6c6..d4c451511d 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -151,15 +151,15 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
let(:old_run_as_user) { new_resource.run_as_user }
let(:old_run_as_password) { new_resource.run_as_password }
- before {
+ before do
new_resource.run_as_user(".\\wallace")
new_resource.run_as_password("Wensleydale")
- }
+ end
- after {
+ after do
new_resource.run_as_user(old_run_as_user)
new_resource.run_as_password(old_run_as_password)
- }
+ end
it "calls #grant_service_logon if the :run_as_user and :run_as_password attributes are present" do
expect(Win32::Service).to receive(:start)
@@ -409,17 +409,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
shared_context "testing private methods" do
- let(:private_methods) {
+ let(:private_methods) do
described_class.private_instance_methods
- }
+ end
- before {
+ before do
described_class.send(:public, *private_methods)
- }
+ end
- after {
+ after do
described_class.send(:private, *private_methods)
- }
+ end
end
describe "grant_service_logon" do
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index 0f936c8f11..8f30d8f868 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -20,13 +20,13 @@ require "spec_helper"
describe Chef::Provider::Template::Content do
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(Dir.mktmpdir)
- }
+ end
- let(:resource_path) {
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "openldap_stuff.conf")))
- }
+ end
let(:new_resource) do
double("Chef::Resource::Template (new)",
@@ -46,10 +46,10 @@ describe Chef::Provider::Template::Content do
:helper_modules => [])
end
- let(:rendered_file_locations) {
+ let(:rendered_file_locations) do
[Dir.tmpdir + "/openldap_stuff.conf",
enclosing_directory + "/openldap_stuff.conf"]
- }
+ end
let(:run_context) do
cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
@@ -101,9 +101,9 @@ describe Chef::Provider::Template::Content do
end
context "when creating a tempfile in destdir fails" do
- let(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path("/nonexisting/path")
- }
+ end
it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do
Chef::Config[:file_staging_uses_destdir] = :auto
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index 488039ad18..306fd6ea71 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -27,12 +27,12 @@ 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(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
# Subject
@@ -61,12 +61,12 @@ 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(:enclosing_directory) {
+ let(:enclosing_directory) do
canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates")))
- }
- let(:resource_path) {
+ end
+ let(:resource_path) do
canonicalize_path(File.expand_path(File.join(enclosing_directory, "seattle.txt")))
- }
+ end
# Subject
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index bf8b3169d7..a309033161 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -24,52 +24,52 @@ describe Chef::Provider::User::Dscl do
before do
allow(ChefConfig).to receive(:windows?) { false }
end
- let(:shellcmdresult) {
+ let(:shellcmdresult) do
Struct.new(:stdout, :stderr, :exitstatus)
- }
- let(:node) {
+ end
+ let(:node) do
node = Chef::Node.new
allow(node).to receive(:[]).with(:platform_version).and_return(mac_version)
allow(node).to receive(:[]).with(:platform).and_return("mac_os_x")
node
- }
+ end
- let(:events) {
+ let(:events) do
Chef::EventDispatch::Dispatcher.new
- }
+ end
- let(:run_context) {
+ let(:run_context) do
Chef::RunContext.new(node, {}, events)
- }
+ end
- let(:new_resource) {
+ let(:new_resource) do
r = Chef::Resource::User.new("toor")
r.password(password)
r.salt(salt)
r.iterations(iterations)
r
- }
+ end
- let(:provider) {
+ let(:provider) do
Chef::Provider::User::Dscl.new(new_resource, run_context)
- }
+ end
- let(:mac_version) {
+ let(:mac_version) do
"10.9.1"
- }
+ end
let(:password) { nil }
let(:salt) { nil }
let(:iterations) { nil }
- let(:salted_sha512_password) {
+ let(:salted_sha512_password) do
"0f543f021c63255e64e121a3585601b8ecfedf6d2\
705ddac69e682a33db5dbcdb9b56a2520bc8fff63a\
2ba6b7984c0737ff0b7949455071581f7affcd536d\
402b6cdb097"
- }
+ end
- let(:salted_sha512_pbkdf2_password) {
+ let(:salted_sha512_pbkdf2_password) do
"c734b6e4787c3727bb35e29fdd92b97c\
1de12df509577a045728255ec7c6c5f5\
c18efa05ed02b682ffa7ebc05119900e\
@@ -78,24 +78,24 @@ b1d4880833aa7a190afc13e2bf0936b8\
9464a8c234f3919082400b4f939bb77b\
c5adbbac718b7eb99463a7b679571e0f\
1c9fef2ef08d0b9e9c2bcf644eed2ffc"
- }
+ end
- let(:salted_sha512_pbkdf2_salt) {
+ let(:salted_sha512_pbkdf2_salt) do
"2d942d8364a9ccf2b8e5cb7ed1ff58f78\
e29dbfee7f9db58859144d061fd0058"
- }
+ end
- let(:salted_sha512_pbkdf2_iterations) {
+ let(:salted_sha512_pbkdf2_iterations) do
25000
- }
+ end
- let(:vagrant_sha_512) {
+ let(:vagrant_sha_512) do
"6f75d7190441facc34291ebbea1fc756b242d4f\
e9bcff141bccb84f1979e27e539539aa31f9f7dcc92c0cea959\
ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
- }
+ end
- let(:vagrant_sha_512_pbkdf2) {
+ let(:vagrant_sha_512_pbkdf2) do
"12601a90db17cbf\
8ba4808e6382fb0d3b9d8a6c1a190477bf680ab21afb\
6065467136e55cc208a6f74156e3daf20fb13369ef4b\
@@ -103,15 +103,15 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
47cca84341a7f93a27147343f89fb843fb46c0017d2\
64afa4976baacf941b915bd1ec1ca24c30b3e759e02\
403e02f59fe7ff5938a7636c"
- }
+ end
- let(:vagrant_sha_512_pbkdf2_salt) {
+ let(:vagrant_sha_512_pbkdf2_salt) do
"ee954be472fdc60ddf89484781433993625f006af6ec810c08f49a7e413946a1"
- }
+ end
- let(:vagrant_sha_512_pbkdf2_iterations) {
+ let(:vagrant_sha_512_pbkdf2_iterations) do
34482
- }
+ end
describe "when shelling out to dscl" do
it "should run dscl with the supplied cmd /Path args" do
@@ -214,9 +214,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
describe "when modifying the home directory" do
- let(:current_resource) {
+ let(:current_resource) do
new_resource.dup
- }
+ end
before do
new_resource.supports({ :manage_home => true })
@@ -307,9 +307,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
describe "when on Mac 10.6" do
- let(:mac_version) {
+ let(:mac_version) do
"10.6.5"
- }
+ end
it "should raise an error" do
expect { run_requirements }.to raise_error(Chef::Exceptions::User)
@@ -317,9 +317,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
describe "when on Mac 10.7" do
- let(:mac_version) {
+ let(:mac_version) do
"10.7.5"
- }
+ end
describe "when password is SALTED-SHA512" do
let(:password) { salted_sha512_password }
@@ -340,9 +340,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
[ "10.9", "10.10"].each do |version|
describe "when on Mac #{version}" do
- let(:mac_version) {
+ let(:mac_version) do
"#{version}.2"
- }
+ end
describe "when password is SALTED-SHA512" do
let(:password) { salted_sha512_password }
@@ -413,9 +413,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
let(:password) { "something" } # Load password during load_current_resource
describe "on 10.7" do
- let(:mac_version) {
+ let(:mac_version) do
"10.7.5"
- }
+ end
let(:user_plist_file) { "10.7" }
@@ -478,9 +478,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
describe "on 10.8" do
- let(:mac_version) {
+ let(:mac_version) do
"10.8.3"
- }
+ end
let(:user_plist_file) { "10.8" }
@@ -504,9 +504,9 @@ e68d1f9821b26689312366")
describe "on 10.7 upgraded to 10.8" do
# In this scenario user password is still in 10.7 format
- let(:mac_version) {
+ let(:mac_version) do
"10.8.3"
- }
+ end
let(:user_plist_file) { "10.7-8" }
@@ -542,9 +542,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
end
describe "on 10.9" do
- let(:mac_version) {
+ let(:mac_version) do
"10.9.1"
- }
+ end
let(:user_plist_file) { "10.9" }
@@ -646,9 +646,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
describe "prepare_password_shadow_info" do
describe "when on Mac 10.7" do
- let(:mac_version) {
+ let(:mac_version) do
"10.7.1"
- }
+ end
describe "when the password is plain text" do
let(:password) { "vagrant" }
@@ -676,9 +676,9 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
["10.8", "10.9", "10.10"].each do |version|
describe "when on Mac #{version}" do
- let(:mac_version) {
+ let(:mac_version) do
"#{version}.1"
- }
+ end
describe "when the password is plain text" do
let(:password) { "vagrant" }
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index 07a39a1f0c..af16a6bd80 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -25,9 +25,9 @@ require "spec_helper"
describe Chef::Provider::User::Solaris do
- let(:shellcmdresult) {
+ let(:shellcmdresult) do
Struct.new(:stdout, :stderr, :exitstatus)
- }
+ end
subject(:provider) do
p = described_class.new(@new_resource, @run_context)
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb
index 1cdbe462f7..1a8ad6ad1b 100644
--- a/spec/unit/provider/user_spec.rb
+++ b/spec/unit/provider/user_spec.rb
@@ -190,7 +190,7 @@ describe Chef::Provider::User do
end
describe "compare_user" do
- let(:mapping) {
+ let(:mapping) do
{
"username" => %w{adam Adam},
"comment" => ["Adam Jacob", "adam jacob"],
@@ -200,7 +200,7 @@ describe Chef::Provider::User do
"shell" => ["/usr/bin/zsh", "/bin/bash"],
"password" => %w{abcd 12345},
}
- }
+ end
%w{uid gid comment home shell password}.each do |attribute|
it "should return true if #{attribute} doesn't match" do
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 3c30f96b20..f42b7563f5 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -75,15 +75,15 @@ describe Chef::Recipe do
end
it "should require a name argument" do
- expect {
+ expect do
recipe.cat
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should allow regular errors (not NameErrors) to pass unchanged" do
- expect {
+ expect do
recipe.cat("felix") { raise ArgumentError, "You Suck" }
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should add our zen_master to the collection" do
@@ -288,9 +288,10 @@ describe Chef::Recipe do
end
it "validating resources via build_resource" do
- expect {recipe.build_resource(:remote_file, "klopp") do
- source Chef::DelayedEvaluator.new { "http://chef.io" }
- end}.to_not raise_error
+ expect do
+ recipe.build_resource(:remote_file, "klopp") do
+ source Chef::DelayedEvaluator.new { "http://chef.io" }
+ end end.to_not raise_error
end
end
diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb
index 00e667c9de..b610c262cc 100644
--- a/spec/unit/resource/dsc_resource_spec.rb
+++ b/spec/unit/resource/dsc_resource_spec.rb
@@ -24,16 +24,16 @@ describe Chef::Resource::DscResource do
let(:dsc_test_timeout) { 101 }
context "when Powershell supports Dsc" do
- let(:dsc_test_run_context) {
+ let(:dsc_test_run_context) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
- }
+ end
- let(:dsc_test_resource) {
+ let(:dsc_test_resource) do
Chef::Resource::DscResource.new(dsc_test_resource_name, dsc_test_run_context)
- }
+ end
it "has a default action of `:run`" do
expect(dsc_test_resource.action).to eq([:run])
@@ -71,16 +71,16 @@ describe Chef::Resource::DscResource do
end
it "raises a TypeError if property_name is not a symbol" do
- expect {
+ expect do
dsc_test_resource.property("Foo", dsc_test_property_value)
- }.to raise_error(TypeError)
+ end.to raise_error(TypeError)
end
context "when using DelayedEvaluators" do
it "allows setting a dsc property with a property name of type Symbol" do
- dsc_test_resource.property(dsc_test_property_name, Chef::DelayedEvaluator.new {
+ dsc_test_resource.property(dsc_test_property_name, Chef::DelayedEvaluator.new do
dsc_test_property_value
- })
+ end)
expect(dsc_test_resource.property(dsc_test_property_name)).to eq(dsc_test_property_value)
expect(dsc_test_resource.properties[dsc_test_property_name]).to eq(dsc_test_property_value)
end
diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb
index 4892049884..f0c81e43b5 100644
--- a/spec/unit/resource/dsc_script_spec.rb
+++ b/spec/unit/resource/dsc_script_spec.rb
@@ -22,15 +22,15 @@ describe Chef::Resource::DscScript do
let(:dsc_test_resource_name) { "DSCTest" }
context "when Powershell supports Dsc" do
- let(:dsc_test_run_context) {
+ let(:dsc_test_run_context) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "4.0"
empty_events = Chef::EventDispatch::Dispatcher.new
Chef::RunContext.new(node, {}, empty_events)
- }
- let(:dsc_test_resource) {
+ end
+ let(:dsc_test_resource) do
Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
- }
+ end
let(:configuration_code) { 'echo "This is supposed to create a configuration document."' }
let(:configuration_path) { "c:/myconfigs/formatc.ps1" }
let(:configuration_name) { "formatme" }
diff --git a/spec/unit/resource/launchd_spec.rb b/spec/unit/resource/launchd_spec.rb
index 95febc47cf..98d21a8234 100644
--- a/spec/unit/resource/launchd_spec.rb
+++ b/spec/unit/resource/launchd_spec.rb
@@ -4,10 +4,11 @@ require "spec_helper"
describe Chef::Resource::Launchd do
@launchd = Chef::Resource::Launchd.new("io.chef.chef-client")
- let(:resource) { Chef::Resource::Launchd.new(
+ let(:resource) do
+ Chef::Resource::Launchd.new(
"io.chef.chef-client",
run_context
- )}
+ ) end
it "should create a new Chef::Resource::Launchd" do
expect(resource).to be_a_kind_of(Chef::Resource)
diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb
index 7bd504d414..513e570e7c 100644
--- a/spec/unit/resource/osx_profile_spec.rb
+++ b/spec/unit/resource/osx_profile_spec.rb
@@ -19,10 +19,11 @@
require "spec_helper"
describe Chef::Resource::OsxProfile do
- let(:resource) { Chef::Resource::OsxProfile.new(
+ let(:resource) do
+ Chef::Resource::OsxProfile.new(
"Test Profile Resource",
run_context)
- }
+ end
it "should create a new Chef::Resource::OsxProfile" do
expect(resource).to be_a_kind_of(Chef::Resource)
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 718129aba3..5fac457ebf 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -86,15 +86,15 @@ describe Chef::Resource::RemoteFile do
end
it "should only accept a single argument if a delayed evalutor is used" do
- expect {
+ expect do
@resource.source("http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" })
- }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "should only accept a single array item if a delayed evalutor is used" do
- expect {
+ expect do
@resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" }])
- }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "does not accept a non-URI as the source" do
@@ -102,10 +102,10 @@ describe Chef::Resource::RemoteFile do
end
it "does not accept a non-URI as the source when read from a delayed evaluator" do
- expect {
+ expect do
@resource.source(Chef::DelayedEvaluator.new { "not-a-uri" })
@resource.source
- }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "should raise an exception when source is an empty array" do
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index e06f5bca5e..7aadc55532 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -53,9 +53,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service pattern" do
- expect {
+ expect do
@resource.pattern /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service start command" do
@@ -64,9 +64,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service start command" do
- expect {
+ expect do
@resource.start_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service stop command" do
@@ -75,9 +75,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service stop command" do
- expect {
+ expect do
@resource.stop_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service status command" do
@@ -86,9 +86,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service status command" do
- expect {
+ expect do
@resource.status_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service restart command" do
@@ -97,9 +97,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service restart command" do
- expect {
+ expect do
@resource.restart_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service reload command" do
@@ -108,9 +108,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service reload command" do
- expect {
+ expect do
@resource.reload_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should accept a string for the service init command" do
@@ -119,9 +119,9 @@ describe Chef::Resource::Service do
end
it "should not accept a regexp for the service init command" do
- expect {
+ expect do
@resource.init_command /.*/
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
%w{enabled running}.each do |attrib|
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 3fec2d9477..5feb34833a 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -98,11 +98,11 @@ describe Chef::ResourceCollection do
it "should allow you to iterate over every resource in the collection" do
load_up_resources
results = Array.new
- expect {
+ expect do
rc.each do |r|
results << r.name
end
- }.not_to raise_error
+ end.not_to raise_error
results.each_index do |i|
case i
when 0
@@ -120,11 +120,11 @@ describe Chef::ResourceCollection do
it "should allow you to iterate over every resource by index" do
load_up_resources
results = Array.new
- expect {
+ expect do
rc.each_index do |i|
results << rc[i].name
end
- }.not_to raise_error
+ end.not_to raise_error
results.each_index do |i|
case i
when 0
diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb
index 45dfaffca7..cc19cc7a01 100644
--- a/spec/unit/resource_definition_spec.rb
+++ b/spec/unit/resource_definition_spec.rb
@@ -53,26 +53,26 @@ describe Chef::ResourceDefinition do
end
it "should accept a new definition with a symbol for a name" do
- expect {
+ expect do
defn.define :smoke do
end
- }.not_to raise_error
- expect {
+ end.not_to raise_error
+ expect do
defn.define "george washington" do
end
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
expect(defn.name).to eql(:smoke)
end
it "should accept a new definition with a hash" do
- expect {
+ expect do
defn.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do
end
- }.not_to raise_error
+ end.not_to raise_error
end
it "should expose the prototype hash params in the params hash" do
- defn.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do; end
+ defn.define(:smoke, :cigar => "cuban", :cigarette => "marlboro") {}
expect(defn.params[:cigar]).to eql("cuban")
expect(defn.params[:cigarette]).to eql("marlboro")
end
@@ -91,16 +91,16 @@ describe Chef::ResourceDefinition do
end
it "should raise an exception if prototype_params is not a hash" do
- expect {
+ expect do
defn.define :monkey, Array.new do
end
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should raise an exception if define is called without a block" do
- expect {
+ expect do
defn.define :monkey
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should load a description from a file" do
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 0df3a165bd..51075a7d44 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -664,9 +664,9 @@ describe Chef::ResourceReporter do
it "fails the run and prints an message about the error" do
expect(Chef::Log).to receive(:error).with(/500/)
- expect {
+ expect do
@resource_reporter.run_started(@run_status)
- }.to raise_error(Net::HTTPServerException)
+ end.to raise_error(Net::HTTPServerException)
end
end
@@ -749,9 +749,9 @@ describe Chef::ResourceReporter do
it "should raise if an unkwown error happens" do
allow(@rest_client).to receive(:raw_request).and_raise(Exception.new)
- expect {
+ expect do
@resource_reporter.post_reporting_data
- }.to raise_error(Exception)
+ end.to raise_error(Exception)
end
end
end
diff --git a/spec/unit/resource_resolver_spec.rb b/spec/unit/resource_resolver_spec.rb
index f3a20ab0e3..d707ade009 100644
--- a/spec/unit/resource_resolver_spec.rb
+++ b/spec/unit/resource_resolver_spec.rb
@@ -20,11 +20,11 @@ require "spec_helper"
require "chef/resource_resolver"
describe Chef::ResourceResolver do
- it '#resolve' do
+ it "#resolve" do
expect(described_class.resolve(:execute)).to eq(Chef::Resource::Execute)
end
- it '#list' do
+ it "#list" do
expect(described_class.list(:package)).to_not be_empty
end
@@ -33,19 +33,19 @@ describe Chef::ResourceResolver do
described_class.new(Chef::Node.new, "execute")
end
- it '#resolve' do
+ it "#resolve" do
expect(resolver.resolve).to eq Chef::Resource::Execute
end
- it '#list' do
+ it "#list" do
expect(resolver.list).to eq [ Chef::Resource::Execute ]
end
- it '#provided_by? returns true when resource class is in the list' do
+ it "#provided_by? returns true when resource class is in the list" do
expect(resolver.provided_by?(Chef::Resource::Execute)).to be_truthy
end
- it '#provided_by? returns false when resource class is not in the list' do
+ it "#provided_by? returns false when resource class is not in the list" do
expect(resolver.provided_by?(Chef::Resource::File)).to be_falsey
end
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index e88931fa54..e35203c78a 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -95,7 +95,7 @@ describe Chef::Resource do
end
describe "when an identity attribute has been declared" do
- let(:file_resource) {
+ let(:file_resource) do
file_resource_class = Class.new(Chef::Resource) do
identity_attr :path
attr_accessor :path
@@ -104,7 +104,7 @@ describe Chef::Resource do
file_resource = file_resource_class.new("identity-attr-test")
file_resource.path = "/tmp/foo.txt"
file_resource
- }
+ end
it "gives the value of its identity attribute" do
expect(file_resource.identity).to eq("/tmp/foo.txt")
@@ -140,7 +140,7 @@ describe Chef::Resource do
end
describe "when a set of state attributes has been declared" do
- let(:file_resource) {
+ let(:file_resource) do
file_resource_class = Class.new(Chef::Resource) do
state_attrs :checksum, :owner, :group, :mode
@@ -157,7 +157,7 @@ describe Chef::Resource do
file_resource.group = "wheel"
file_resource.mode = "0644"
file_resource
- }
+ end
it "describes its state" do
resource_state = file_resource.state
@@ -170,14 +170,14 @@ describe Chef::Resource do
end
describe "load_from" do
- let(:prior_resource) {
+ let(:prior_resource) do
prior_resource = Chef::Resource.new("funk")
prior_resource.supports(:funky => true)
prior_resource.source_line
prior_resource.allowed_actions << :funkytown
prior_resource.action(:funkytown)
prior_resource
- }
+ end
before(:each) do
resource.allowed_actions << :funkytown
run_context.resource_collection << prior_resource
@@ -236,9 +236,9 @@ describe Chef::Resource do
it "should raise an exception if told to act in other than :delay or :immediate(ly)" do
run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee")
- expect {
+ expect do
resource.notifies :reload, run_context.resource_collection.find(:zen_master => "coffee"), :someday
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should allow multiple notified resources appear in the actions hash" do
@@ -503,12 +503,12 @@ describe Chef::Resource do
end
describe "retries" do
- let(:retriable_resource) {
+ let(:retriable_resource) do
retriable_resource = Chef::Resource::Cat.new("precious", run_context)
retriable_resource.provider = Chef::Provider::SnakeOil
retriable_resource.action = :purr
retriable_resource
- }
+ end
before do
node.automatic_attrs[:platform] = "fubuntu"
@@ -563,11 +563,11 @@ describe Chef::Resource do
end
it "warns when setting provider_base" do
- expect {
+ expect do
class OverrideProviderBaseTest2 < Chef::Resource
provider_base Chef::Provider::Package
end
- }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
+ end.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
end
end
@@ -607,11 +607,11 @@ describe Chef::Resource do
end
describe "when invoking its action" do
- let(:resource) {
+ let(:resource) do
resource = Chef::Resource.new("provided", run_context)
resource.provider = Chef::Provider::SnakeOil
resource
- }
+ end
before do
node.automatic_attrs[:platform] = "fubuntu"
node.automatic_attrs[:platform_version] = "10.04"
@@ -797,11 +797,11 @@ describe Chef::Resource do
end
describe "when resource action is :nothing" do
- let(:resource1) {
+ let(:resource1) do
resource1 = Chef::Resource::Cat.new("sugar", run_context)
resource1.action = :nothing
resource1
- }
+ end
before do
node.automatic_attrs[:platform] = "fubuntu"
node.automatic_attrs[:platform_version] = "10.04"
diff --git a/spec/unit/run_context/child_run_context_spec.rb b/spec/unit/run_context/child_run_context_spec.rb
index 13a035c871..47a6c84f7a 100644
--- a/spec/unit/run_context/child_run_context_spec.rb
+++ b/spec/unit/run_context/child_run_context_spec.rb
@@ -24,16 +24,16 @@ require "support/lib/library_load_order"
describe Chef::RunContext::ChildRunContext do
context "with a run context with stuff in it" do
let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) }
- let(:cookbook_collection) {
+ let(:cookbook_collection) do
cl = Chef::CookbookLoader.new(chef_repo_path)
cl.load_cookbooks
Chef::CookbookCollection.new(cl)
- }
- let(:node) {
+ end
+ let(:node) do
node = Chef::Node.new
node.run_list << "test" << "test::one" << "test::two"
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index 234cd3c9e1..f1c3072b8e 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -23,16 +23,16 @@ 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")) }
- let(:cookbook_collection) {
+ let(:cookbook_collection) do
cl = Chef::CookbookLoader.new(chef_repo_path)
cl.load_cookbooks
Chef::CookbookCollection.new(cl)
- }
- let(:node) {
+ end
+ let(:node) do
node = Chef::Node.new
node.run_list << "test" << "test::one" << "test::two"
node
- }
+ end
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
@@ -151,13 +151,13 @@ describe Chef::RunContext do
describe "querying the contents of cookbooks" do
let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) }
- let(:node) {
+ let(:node) do
node = Chef::Node.new
node.normal[:platform] = "ubuntu"
node.normal[:platform_version] = "13.04"
node.name("testing")
node
- }
+ end
it "queries whether a given cookbook has a specific template" do
expect(run_context).to have_template_in_cookbook("openldap", "test.erb")
@@ -212,11 +212,11 @@ describe Chef::RunContext do
shared_context "notifying resource is a subclass of Chef::Resource" do
let(:declared_type) { :alpaca }
- let(:notifying_resource) {
+ let(:notifying_resource) do
r = Class.new(Chef::Resource).new("guinea pig")
r.declared_type = declared_type
r
- }
+ end
it "should be keyed off the resource declared key" do
run_context.send(setter, notification)
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index f15f3951e0..c1e10a78f4 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -392,12 +392,12 @@ Multiple failures occurred:
it "should resolve resource references in notifications when resources are defined lazily" do
first_resource.action = :nothing
- lazy_resources = lambda {
+ lazy_resources = lambda do
last_resource = Chef::Resource::Cat.new("peanut", run_context)
run_context.resource_collection << last_resource
last_resource.notifies(:purr, first_resource.to_s, :delayed)
last_resource.action = :purr
- }
+ end
second_resource = Chef::Resource::RubyBlock.new("myblock", run_context)
run_context.resource_collection << second_resource
second_resource.block { lazy_resources.call }
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index 7f815f1757..51667784fb 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -27,13 +27,13 @@ describe Chef::Search::Query do
let(:query_string) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0" }
let(:server_url) { "https://api.opscode.com/organizations/opscode/nodes" }
let(:args) { { filter_key => filter_hash } }
- let(:filter_hash) {
+ let(:filter_hash) do
{
"env" => [ "chef_environment" ],
"ruby_plat" => %w{languages ruby platform},
}
- }
- let(:response) {
+ end
+ let(:response) do
{
"rows" => [
{ "url" => "#{server_url}/my-name-is-node",
@@ -64,15 +64,15 @@ describe Chef::Search::Query do
"start" => 0,
"total" => 4,
}
- }
- let(:response_rows) {
+ end
+ let(:response_rows) do
[
{ "env" => "elysium", "ruby_plat" => "nudibranch" },
{ "env" => "hades", "ruby_plat" => "i386-mingw32" },
{ "env" => "elysium", "ruby_plat" => "centos" },
{ "env" => "moon", "ruby_plat" => "solaris2" },
]
- }
+ end
end
before(:each) do
@@ -86,7 +86,8 @@ describe Chef::Search::Query do
let(:query_string_with_rows) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=4" }
let(:query_string_continue_with_rows) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=4&rows=4" }
- let(:response) { {
+ let(:response) do
+ {
"rows" => [
{ "name" => "my-name-is-node",
"chef_environment" => "elysium",
@@ -147,28 +148,28 @@ describe Chef::Search::Query do
],
"start" => 0,
"total" => 4,
- } }
+ } end
- let(:big_response) {
+ let(:big_response) do
r = response.dup
r["total"] = 8
r
- }
+ end
- let(:big_response_empty) {
+ let(:big_response_empty) do
{
"start" => 0,
"total" => 8,
"rows" => [],
}
- }
+ end
- let(:big_response_end) {
+ let(:big_response_end) do
r = response.dup
r["start"] = 4
r["total"] = 8
r
- }
+ end
it "accepts a type as the first argument" do
expect { query.search("node") }.not_to raise_error
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index 51dc3c9118..16f0d0158b 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -332,7 +332,7 @@ describe Chef::UserV1 do
@user.password "some_password"
end
- let(:payload) {
+ let(:payload) do
{
:username => "some_username",
:display_name => "some_display_name",
@@ -342,7 +342,7 @@ describe Chef::UserV1 do
:email => "some_email",
:password => "some_password",
}
- }
+ end
context "when server API V1 is valid on the Chef Server receiving the request" do
context "when the user submits valid data" do
@@ -354,7 +354,7 @@ describe Chef::UserV1 do
end
context "when server API V1 is not valid on the Chef Server receiving the request" do
- let(:payload) {
+ let(:payload) do
{
:username => "some_username",
:display_name => "some_display_name",
@@ -365,7 +365,7 @@ describe Chef::UserV1 do
:password => "some_password",
:public_key => "some_public_key",
}
- }
+ end
before do
@user.public_key "some_public_key"
@@ -442,7 +442,7 @@ describe Chef::UserV1 do
end # update
describe "create" do
- let(:payload) {
+ let(:payload) do
{
:username => "some_username",
:display_name => "some_display_name",
@@ -451,7 +451,7 @@ describe Chef::UserV1 do
:email => "some_email",
:password => "some_password",
}
- }
+ end
before do
@user.username "some_username"
@user.display_name "some_display_name"
@@ -506,11 +506,11 @@ describe Chef::UserV1 do
# DEPRECATION
# This can be removed after API V0 support is gone
describe "reregister" do
- let(:payload) {
+ let(:payload) do
{
"username" => "some_username",
}
- }
+ end
before do
@user.username "some_username"
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index 12f62deb5a..cfa7a4e264 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
Chef::Util::DSC::ConfigurationGenerator.new(node, "tmp")
end
- describe '#validate_configuration_name!' do
+ describe "#validate_configuration_name!" do
it "should not raise an error if a name contains all upper case letters" do
conf_man.send(:validate_configuration_name!, "HELLO")
end
@@ -40,9 +40,9 @@ describe Chef::Util::DSC::ConfigurationGenerator do
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
it "raises an Argument error if it configuration name contains #{sym}" do
- expect {
+ expect do
conf_man.send(:validate_configuration_name!, "Hello#{sym}")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
end
@@ -57,15 +57,15 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
it "should raise an ArgumentError if you try to override outputpath" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { "outputpath" => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { "OutputPath" => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
@@ -83,15 +83,15 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
it "should raise an ArgumentError if you try to override outputpath" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
@@ -121,7 +121,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
#
end
- describe '#write_document_generation_script' do
+ describe "#write_document_generation_script" do
let(:file_like_object) { double("file like object") }
it "should write the input to a file" do
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 15cf38394e..45fe8df40d 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -23,15 +23,17 @@ describe Chef::Util::DSC::LocalConfigurationManager do
let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, "tmp") }
- let(:normal_lcm_output) { <<-EOH
+ let(:normal_lcm_output) do
+ <<-EOH
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOH
- }
+ end
- let(:no_whatif_lcm_output) { <<-EOH
+ let(:no_whatif_lcm_output) do
+ <<-EOH
Start-DscConfiguration : A parameter cannot be found\r\n that matches parameter name 'whatif'.
At line:1 char:123
+ run-somecommand -whatif
@@ -39,16 +41,17 @@ At line:1 char:123
+ CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand
EOH
- }
+ end
- let(:dsc_resource_import_failure_output) { <<-EOH
+ let(:dsc_resource_import_failure_output) do
+ <<-EOH
PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : .
EOH
- }
+ end
- let(:lcm_status) {
+ let(:lcm_status) do
double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success)
- }
+ end
describe "test_configuration method invocation" do
context "when interacting with the LCM using a PowerShell cmdlet" do
@@ -77,7 +80,7 @@ EOH
let(:lcm_standard_error) { no_whatif_lcm_output }
let(:lcm_cmdlet_success) { false }
- it 'returns true when passed to #whatif_not_supported?' do
+ it "returns true when passed to #whatif_not_supported?" do
expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy
end
diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb
index 84b39190b2..a864a2c1da 100644
--- a/spec/unit/util/dsc/resource_store.rb
+++ b/spec/unit/util/dsc/resource_store.rb
@@ -21,28 +21,30 @@ require "chef/util/dsc/resource_store"
describe Chef::Util::DSC::ResourceStore do
let(:resource_store) { Chef::Util::DSC::ResourceStore.new }
- let(:resource_a) { {
+ let(:resource_a) do
+ {
"ResourceType" => "AFoo",
"Name" => "Foo",
"Module" => { "Name" => "ModuleA" },
}
- }
+ end
- let(:resource_b) { {
+ let(:resource_b) do
+ {
"ResourceType" => "BFoo",
"Name" => "Foo",
"Module" => { "Name" => "ModuleB" },
}
- }
+ end
context "when resources are not cached" do
- context 'when calling #resources' do
+ context "when calling #resources" do
it "returns an empty array" do
expect(resource_store.resources).to eql([])
end
end
- context 'when calling #find' do
+ context "when calling #find" 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([])
diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb
index 7a0ec91533..e53bc9662a 100644
--- a/spec/unit/util/editor_spec.rb
+++ b/spec/unit/util/editor_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
require "chef/util/editor"
describe Chef::Util::Editor do
- describe '#initialize' do
+ describe "#initialize" do
it "takes an Enumerable of lines" do
editor = described_class.new(File.open(__FILE__))
expect(editor.lines).to be == IO.readlines(__FILE__)
@@ -18,7 +18,7 @@ describe Chef::Util::Editor do
subject(:editor) { described_class.new(input_lines) }
let(:input_lines) { %w{one two two three} }
- describe '#append_line_after' do
+ describe "#append_line_after" do
context "when there is no match" do
subject(:execute) { editor.append_line_after("missing", "new") }
@@ -44,7 +44,7 @@ describe Chef::Util::Editor do
end
end
- describe '#append_line_if_missing' do
+ describe "#append_line_if_missing" do
context "when there is no match" do
subject(:execute) { editor.append_line_if_missing("missing", "new") }
@@ -70,7 +70,7 @@ describe Chef::Util::Editor do
end
end
- describe '#remove_lines' do
+ describe "#remove_lines" do
context "when there is no match" do
subject(:execute) { editor.remove_lines("missing") }
@@ -96,7 +96,7 @@ describe Chef::Util::Editor do
end
end
- describe '#replace' do
+ describe "#replace" do
context "when there is no match" do
subject(:execute) { editor.replace("missing", "new") }
@@ -123,7 +123,7 @@ describe Chef::Util::Editor do
end
end
- describe '#replace_lines' do
+ describe "#replace_lines" do
context "when there is no match" do
subject(:execute) { editor.replace_lines("missing", "new") }
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index 5c0e66aee2..800e4cc9c0 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Util::Powershell::Cmdlet do
@cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Some-Commandlet")
end
- describe '#validate_switch_name!' do
+ describe "#validate_switch_name!" do
it "should not raise an error if a name contains all upper case letters" do
@cmdlet.send(:validate_switch_name!, "HELLO")
end
@@ -40,14 +40,14 @@ describe Chef::Util::Powershell::Cmdlet do
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
it "raises an Argument error if it configuration name contains #{sym}" do
- expect {
+ expect do
@cmdlet.send(:validate_switch_name!, "Hello#{sym}")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
end
- describe '#escape_parameter_value' do
+ describe "#escape_parameter_value" do
# Is this list really complete?
%w{` " # '}.each do |c|
it "escapse #{c}" do
@@ -60,23 +60,23 @@ describe Chef::Util::Powershell::Cmdlet do
end
end
- describe '#escape_string_parameter_value' do
+ describe "#escape_string_parameter_value" do
it "surrounds a string with ''" do
expect(@cmdlet.send(:escape_string_parameter_value, "stuff")).to eql("'stuff'")
end
end
- describe '#command_switches_string' do
+ describe "#command_switches_string" do
it "raises an ArgumentError if the key is not a symbol" do
- expect {
+ expect do
@cmdlet.send(:command_switches_string, { "foo" => "bar" })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "does not allow invalid switch names" do
- expect {
+ expect do
@cmdlet.send(:command_switches_string, { :foo! => "bar" })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "ignores switches with a false value" do
diff --git a/tasks/cbgb.rb b/tasks/cbgb.rb
index 9aa6700137..70ca1036e8 100644
--- a/tasks/cbgb.rb
+++ b/tasks/cbgb.rb
@@ -44,9 +44,9 @@ begin
out << cbgb(cbgb["corporations"], cbgb["Org"]["Corporate-Contributors"]["governers"]) + "\n\n"
out << "### " + cbgb["Org"]["Lieutenants"]["title"] + "\n\n"
out << cbgb(cbgb["people"], cbgb["Org"]["Lieutenants"]["governers"]) + "\n\n"
- File.open(CBGB_TARGET, "w") { |fn|
+ File.open(CBGB_TARGET, "w") do |fn|
fn.write out
- }
+ end
end
end
diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb
index 91742854bb..e13d4724b0 100644
--- a/tasks/maintainers.rb
+++ b/tasks/maintainers.rb
@@ -46,9 +46,9 @@ begin
out << format_person(source["Org"]["Lead"]["person"]) + "\n\n"
out << format_components(source["Org"]["Components"])
- File.open(TARGET, "w") { |fn|
+ File.open(TARGET, "w") do |fn|
fn.write out
- }
+ end
end
desc "Synchronize GitHub teams"