diff options
77 files changed, 671 insertions, 682 deletions
diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index eb257ff4b5..de830c09d3 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -182,7 +182,7 @@ module ChefConfig IO.write(version_file_path, new_version) end - def update_version_rb + def update_version_rb # rubocop:disable Lint/NestedMethodDefinition puts "Updating #{version_rb_path} to include version #{version} ..." contents = <<-VERSION_RB # Copyright:: Copyright 2010-2016, Chef Software, Inc. @@ -223,7 +223,7 @@ end IO.write(version_rb_path, contents) end - def update_gemfile_lock + def update_gemfile_lock # rubocop:disable Lint/NestedMethodDefinition if File.exist?(gemfile_lock_path) puts "Updating #{gemfile_lock_path} to include version #{version} ..." contents = IO.read(gemfile_lock_path) diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb index c824bc90df..2d887f4780 100644 --- a/lib/chef/chef_fs/command_line.rb +++ b/lib/chef/chef_fs/command_line.rb @@ -242,48 +242,50 @@ class Chef return [ [ :error, old_entry, new_entry, nil, nil, e ] ] end - private + class << self + private - def self.sort_keys(json_object) - if json_object.is_a?(Array) - json_object.map { |o| sort_keys(o) } - elsif json_object.is_a?(Hash) - new_hash = {} - json_object.keys.sort.each { |key| new_hash[key] = sort_keys(json_object[key]) } - new_hash - else - json_object + def sort_keys(json_object) + if json_object.is_a?(Array) + json_object.map { |o| sort_keys(o) } + elsif json_object.is_a?(Hash) + new_hash = {} + json_object.keys.sort.each { |key| new_hash[key] = sort_keys(json_object[key]) } + new_hash + else + json_object + end end - end - def self.canonicalize_json(json_text) - parsed_json = Chef::JSONCompat.parse(json_text) - sorted_json = sort_keys(parsed_json) - Chef::JSONCompat.to_json_pretty(sorted_json) - end - - def self.diff_text(old_path, new_path, old_value, new_value) - # Copy to tempfiles before diffing - # TODO don't copy things that are already in files! Or find an in-memory diff algorithm - begin - new_tempfile = Tempfile.new("new") - new_tempfile.write(new_value) - new_tempfile.close + def canonicalize_json(json_text) + parsed_json = Chef::JSONCompat.parse(json_text) + sorted_json = sort_keys(parsed_json) + Chef::JSONCompat.to_json_pretty(sorted_json) + end + def diff_text(old_path, new_path, old_value, new_value) + # Copy to tempfiles before diffing + # TODO don't copy things that are already in files! Or find an in-memory diff algorithm begin - old_tempfile = Tempfile.new("old") - old_tempfile.write(old_value) - old_tempfile.close + new_tempfile = Tempfile.new("new") + new_tempfile.write(new_value) + new_tempfile.close - result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) - result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") - result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") - result + begin + old_tempfile = Tempfile.new("old") + old_tempfile.write(old_value) + old_tempfile.close + + result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) + result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") + result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") + result + ensure + old_tempfile.close! + end ensure - old_tempfile.close! + new_tempfile.close! end - ensure - new_tempfile.close! end end end diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb index a308a0fe2c..9c12bd4b96 100644 --- a/lib/chef/chef_fs/file_pattern.rb +++ b/lib/chef/chef_fs/file_pattern.rb @@ -160,7 +160,7 @@ class Chef pattern end - private + private def regexp calculate diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index 69dce54f00..1a8da2fd6b 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -68,7 +68,7 @@ class Chef list_from(exact_child, &block) end - # Otherwise, go through all children and find any matches + # Otherwise, go through all children and find any matches elsif entry.dir? results = Parallelizer.parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) } results.flatten(1).each(&block) @@ -257,172 +257,174 @@ class Chef [ are_same, a_value, b_value ] end - private - - # Copy two entries (could be files or dirs) - def self.copy_entries(src_entry, dest_entry, new_dest_parent, recurse_depth, options, ui, format_path) - # A NOTE about this algorithm: - # There are cases where this algorithm does too many network requests. - # knife upload with a specific filename will first check if the file - # exists (a "dir" in the parent) before deciding whether to POST or - # PUT it. If we just tried PUT (or POST) and then tried the other if - # the conflict failed, we wouldn't need to check existence. - # On the other hand, we may already have DONE the request, in which - # case we shouldn't waste time trying PUT if we know the file doesn't - # exist. - # Will need to decide how that works with checksums, though. - error = false - begin - dest_path = format_path.call(dest_entry) if ui - src_path = format_path.call(src_entry) if ui - if !src_entry.exists? - if options[:purge] - # If we would not have uploaded it, we will not purge it. - if src_entry.parent.can_have_child?(dest_entry.name, dest_entry.dir?) - if options[:dry_run] - ui.output "Would delete #{dest_path}" if ui - else - begin - dest_entry.delete(true) - ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui - rescue Chef::ChefFS::FileSystem::NotFoundError - ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui + class << self + private + + # Copy two entries (could be files or dirs) + def copy_entries(src_entry, dest_entry, new_dest_parent, recurse_depth, options, ui, format_path) + # A NOTE about this algorithm: + # There are cases where this algorithm does too many network requests. + # knife upload with a specific filename will first check if the file + # exists (a "dir" in the parent) before deciding whether to POST or + # PUT it. If we just tried PUT (or POST) and then tried the other if + # the conflict failed, we wouldn't need to check existence. + # On the other hand, we may already have DONE the request, in which + # case we shouldn't waste time trying PUT if we know the file doesn't + # exist. + # Will need to decide how that works with checksums, though. + error = false + begin + dest_path = format_path.call(dest_entry) if ui + src_path = format_path.call(src_entry) if ui + if !src_entry.exists? + if options[:purge] + # If we would not have uploaded it, we will not purge it. + if src_entry.parent.can_have_child?(dest_entry.name, dest_entry.dir?) + if options[:dry_run] + ui.output "Would delete #{dest_path}" if ui + else + begin + dest_entry.delete(true) + ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui + rescue Chef::ChefFS::FileSystem::NotFoundError + ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui + end end - end - else - ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui - end - end - - elsif !dest_entry.exists? - if new_dest_parent.can_have_child?(src_entry.name, src_entry.dir?) - # If the entry can do a copy directly from filesystem, do that. - if new_dest_parent.respond_to?(:create_child_from) - if options[:dry_run] - ui.output "Would create #{dest_path}" if ui else - new_dest_parent.create_child_from(src_entry) - ui.output "Created #{dest_path}" if ui + ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui end - return end - if src_entry.dir? - if options[:dry_run] - ui.output "Would create #{dest_path}" if ui - new_dest_dir = new_dest_parent.child(src_entry.name) - else - new_dest_dir = new_dest_parent.create_child(src_entry.name, nil) - ui.output "Created #{dest_path}" if ui - end - # Directory creation is recursive. - if recurse_depth != 0 - parallel_do(src_entry.children) do |src_child| - new_dest_child = new_dest_dir.child(src_child.name) - child_error = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path) - error ||= child_error + elsif !dest_entry.exists? + if new_dest_parent.can_have_child?(src_entry.name, src_entry.dir?) + # If the entry can do a copy directly from filesystem, do that. + if new_dest_parent.respond_to?(:create_child_from) + if options[:dry_run] + ui.output "Would create #{dest_path}" if ui + else + new_dest_parent.create_child_from(src_entry) + ui.output "Created #{dest_path}" if ui end + return end - else - if options[:dry_run] - ui.output "Would create #{dest_path}" if ui - else - child = new_dest_parent.create_child(src_entry.name, src_entry.read) - ui.output "Created #{format_path.call(child)}" if ui - end - end - end - - else - # Both exist. - # If the entry can do a copy directly, do that. - if dest_entry.respond_to?(:copy_from) - if options[:force] || compare(src_entry, dest_entry)[0] == false - if options[:dry_run] - ui.output "Would update #{dest_path}" if ui + if src_entry.dir? + if options[:dry_run] + ui.output "Would create #{dest_path}" if ui + new_dest_dir = new_dest_parent.child(src_entry.name) + else + new_dest_dir = new_dest_parent.create_child(src_entry.name, nil) + ui.output "Created #{dest_path}" if ui + end + # Directory creation is recursive. + if recurse_depth != 0 + parallel_do(src_entry.children) do |src_child| + new_dest_child = new_dest_dir.child(src_child.name) + child_error = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path) + error ||= child_error + end + end else - dest_entry.copy_from(src_entry, options) - ui.output "Updated #{dest_path}" if ui + if options[:dry_run] + ui.output "Would create #{dest_path}" if ui + else + child = new_dest_parent.create_child(src_entry.name, src_entry.read) + ui.output "Created #{format_path.call(child)}" if ui + end end end - return - end - # If they are different types, log an error. - if src_entry.dir? - if dest_entry.dir? - # If both are directories, recurse into their children - if recurse_depth != 0 - parallel_do(child_pairs(src_entry, dest_entry)) do |src_child, dest_child| - child_error = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path) - error ||= child_error + else + # Both exist. + + # If the entry can do a copy directly, do that. + if dest_entry.respond_to?(:copy_from) + if options[:force] || compare(src_entry, dest_entry)[0] == false + if options[:dry_run] + ui.output "Would update #{dest_path}" if ui + else + dest_entry.copy_from(src_entry, options) + ui.output "Updated #{dest_path}" if ui end end - else - # If they are different types. - ui.error("File #{src_path} is a directory while file #{dest_path} is a regular file\n") if ui return end - else - if dest_entry.dir? - ui.error("File #{src_path} is a regular file while file #{dest_path} is a directory\n") if ui - return - else - # Both are files! Copy them unless we're sure they are the same.' - if options[:diff] == false - should_copy = false - elsif options[:force] - should_copy = true - src_value = nil + # If they are different types, log an error. + if src_entry.dir? + if dest_entry.dir? + # If both are directories, recurse into their children + if recurse_depth != 0 + parallel_do(child_pairs(src_entry, dest_entry)) do |src_child, dest_child| + child_error = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path) + error ||= child_error + end + end else - are_same, src_value, _dest_value = compare(src_entry, dest_entry) - should_copy = !are_same + # If they are different types. + ui.error("File #{src_path} is a directory while file #{dest_path} is a regular file\n") if ui + return end - if should_copy - if options[:dry_run] - ui.output "Would update #{dest_path}" if ui + else + if dest_entry.dir? + ui.error("File #{src_path} is a regular file while file #{dest_path} is a directory\n") if ui + return + else + + # Both are files! Copy them unless we're sure they are the same.' + if options[:diff] == false + should_copy = false + elsif options[:force] + should_copy = true + src_value = nil else - src_value = src_entry.read if src_value.nil? - dest_entry.write(src_value) - ui.output "Updated #{dest_path}" if ui + are_same, src_value, _dest_value = compare(src_entry, dest_entry) + should_copy = !are_same + end + if should_copy + if options[:dry_run] + ui.output "Would update #{dest_path}" if ui + else + src_value = src_entry.read if src_value.nil? + dest_entry.write(src_value) + ui.output "Updated #{dest_path}" if ui + end end end end end + rescue RubyFileError => e + ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui + rescue DefaultEnvironmentCannotBeModifiedError => e + ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui + rescue OperationFailedError => e + ui.error "#{format_path.call(e.entry)} failed to #{e.operation}: #{e.message}" if ui + error = true + rescue OperationNotAllowedError => e + ui.error "#{format_path.call(e.entry)} #{e.reason}." if ui + error = true end - rescue RubyFileError => e - ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui - rescue DefaultEnvironmentCannotBeModifiedError => e - ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui - rescue OperationFailedError => e - ui.error "#{format_path.call(e.entry)} failed to #{e.operation}: #{e.message}" if ui - error = true - rescue OperationNotAllowedError => e - ui.error "#{format_path.call(e.entry)} #{e.reason}." if ui - error = true + error end - error - end - def self.get_or_create_parent(entry, options, ui, format_path) - parent = entry.parent - if parent && !parent.exists? - parent_path = format_path.call(parent) if ui - parent_parent = get_or_create_parent(parent, options, ui, format_path) - if options[:dry_run] - ui.output "Would create #{parent_path}" if ui - else - parent = parent_parent.create_child(parent.name, nil) - ui.output "Created #{parent_path}" if ui + def get_or_create_parent(entry, options, ui, format_path) + parent = entry.parent + if parent && !parent.exists? + parent_path = format_path.call(parent) if ui + parent_parent = get_or_create_parent(parent, options, ui, format_path) + if options[:dry_run] + ui.output "Would create #{parent_path}" if ui + else + parent = parent_parent.create_child(parent.name, nil) + ui.output "Created #{parent_path}" if ui + end end + return parent end - return parent - end - def self.parallel_do(enum, options = {}, &block) - Chef::ChefFS::Parallelizer.parallel_do(enum, options, &block) + def parallel_do(enum, options = {}, &block) + Chef::ChefFS::Parallelizer.parallel_do(enum, options, &block) + end end end end diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb index 9d02bbab78..ab578bdb7f 100644 --- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb @@ -184,9 +184,7 @@ class Chef sleep(0.01) end - until @unconsumed_output.empty? - yield @unconsumed_output.pop - end + yield @unconsumed_output.pop until @unconsumed_output.empty? # If no one is working on our tasks and we're allowed to # work on them in the main thread, process an input to @@ -227,9 +225,7 @@ class Chef def stop @unconsumed_input.clear - while @in_process.size > 0 - sleep(0.05) - end + sleep(0.05) while @in_process.size > 0 @unconsumed_output.clear end diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index d9b027f322..cf72426740 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -168,7 +168,7 @@ class Chef when /\.json$/ apply_json_metadata(metadata_file) else - raise RuntimeError, "Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}" + raise "Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}" end end diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index 603f80748c..ab83da9e55 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -722,7 +722,7 @@ class Chef end end - private + private # Helper to match a gem style version (ohai_version/chef_version) against a set of # Gem::Dependency version constraints. If none are present, it always matches. if diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb index 9fb8d0d4bc..c0e85ff984 100644 --- a/lib/chef/cookbook_site_streaming_uploader.rb +++ b/lib/chef/cookbook_site_streaming_uploader.rb @@ -31,7 +31,7 @@ class Chef # inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html class CookbookSiteStreamingUploader - DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION } + DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION } # rubocop:disable Style/ConstantName class << self @@ -149,11 +149,11 @@ class Chef alias :to_s :body # BUGBUG this makes the response compatible with what respsonse_steps expects to test headers (response.headers[] -> response[]) - def headers + def headers # rubocop:disable Lint/NestedMethodDefinition self end - def status + def status # rubocop:disable Lint/NestedMethodDefinition code.to_i end end diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb index 95c27799ec..bb75234563 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -55,7 +55,7 @@ class Chef checksum_files.merge!(cb.checksums) end - checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil ; memo } + checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil; memo } new_sandbox = rest.post("sandboxes", { :checksums => checksums }) Chef::Log.info("Uploading files") diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 1e903608b5..bf9e755f3f 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -599,12 +599,12 @@ class Chef end end - def <=>(o) - raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != o.name + def <=>(other) + raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != other.name # FIXME: can we change the interface to the Metadata class such # that metadata.version returns a Chef::Version instance instead # of a string? - Chef::Version.new(self.version) <=> Chef::Version.new(o.version) + Chef::Version.new(self.version) <=> Chef::Version.new(other.version) end private @@ -623,7 +623,7 @@ class Chef # For each filename, produce a mapping of base filename (i.e. recipe name # or attribute file) to on disk location def filenames_by_name(filenames) - filenames.select { |filename| filename =~ /\.rb$/ }.inject({}) { |memo, filename| memo[File.basename(filename, ".rb")] = filename ; memo } + filenames.select { |filename| filename =~ /\.rb$/ }.inject({}) { |memo, filename| memo[File.basename(filename, ".rb")] = filename; memo } end def file_vendor diff --git a/lib/chef/dsl/powershell.rb b/lib/chef/dsl/powershell.rb index 1a900af6f6..7dc7a9a0f6 100644 --- a/lib/chef/dsl/powershell.rb +++ b/lib/chef/dsl/powershell.rb @@ -21,7 +21,7 @@ require "chef/util/powershell/ps_credential" class Chef module DSL module Powershell - def ps_credential(username = "placeholder", password) + def ps_credential(username = "placeholder", password) # rubocop:disable Style/OptionalArguments Chef::Util::Powershell::PSCredential.new(username, password) end end diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index 43759568a7..a4d5ff60e2 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -184,7 +184,7 @@ class Chef # A different version of a cookbook was added to a # VersionedRecipeList than the one already there. - class CookbookVersionConflict < ArgumentError ; end + class CookbookVersionConflict < ArgumentError; end # does not follow X.Y.Z format. ArgumentError? class InvalidPlatformVersion < ArgumentError; end diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index cefc9da1eb..8e9bb1e3e4 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -85,7 +85,7 @@ class Chef File.join(create_cache_path(File.join(file_path_array), true), file_name) ) else - raise RuntimeError, "Cannot move #{file} to #{path}!" + raise "Cannot move #{file} to #{path}!" end end diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index d43f1993b2..7dbbf1d948 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -32,9 +32,9 @@ class Chef def pretty_elapsed_time time = elapsed_time - if time < 60 then + if time < 60 message = Time.at(time).utc.strftime("%S seconds") - elsif time < 3600 then + elsif time < 3600 message = Time.at(time).utc.strftime("%M minutes %S seconds") else message = Time.at(time).utc.strftime("%H hours %M minutes %S seconds") diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb index d5dbff3758..053b2c938e 100644 --- a/lib/chef/http/auth_credentials.rb +++ b/lib/chef/http/auth_credentials.rb @@ -49,7 +49,7 @@ class Chef sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params) signed = sign_obj.sign(key).merge({ :host => host }) - signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo } + signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1]; memo } end end diff --git a/lib/chef/key.rb b/lib/chef/key.rb index 1c25c5daad..38822e8b26 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -201,72 +201,71 @@ class Chef chef_rest.delete("#{api_base}/#{@actor}/keys/#{@name}") end - # Class methods - def self.from_hash(key_hash) - if key_hash.has_key?("user") - key = Chef::Key.new(key_hash["user"], "user") - elsif key_hash.has_key?("client") - key = Chef::Key.new(key_hash["client"], "client") - else - raise Chef::Exceptions::MissingKeyAttribute, "The hash passed to from_hash does not contain the key 'user' or 'client'. Please pass a hash that defines one of those keys." + class << self + def from_hash(key_hash) + if key_hash.has_key?("user") + key = Chef::Key.new(key_hash["user"], "user") + elsif key_hash.has_key?("client") + key = Chef::Key.new(key_hash["client"], "client") + else + raise Chef::Exceptions::MissingKeyAttribute, "The hash passed to from_hash does not contain the key 'user' or 'client'. Please pass a hash that defines one of those keys." + end + key.name key_hash["name"] if key_hash.key?("name") + key.public_key key_hash["public_key"] if key_hash.key?("public_key") + key.private_key key_hash["private_key"] if key_hash.key?("private_key") + key.create_key key_hash["create_key"] if key_hash.key?("create_key") + key.expiration_date key_hash["expiration_date"] if key_hash.key?("expiration_date") + key end - key.name key_hash["name"] if key_hash.key?("name") - key.public_key key_hash["public_key"] if key_hash.key?("public_key") - key.private_key key_hash["private_key"] if key_hash.key?("private_key") - key.create_key key_hash["create_key"] if key_hash.key?("create_key") - key.expiration_date key_hash["expiration_date"] if key_hash.key?("expiration_date") - key - end - - def self.from_json(json) - Chef::Key.from_hash(Chef::JSONCompat.from_json(json)) - end - def self.json_create(json) - Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.") - Chef::Key.from_json(json) - end + def from_json(json) + Chef::Key.from_hash(Chef::JSONCompat.from_json(json)) + end - def self.list_by_user(actor, inflate = false) - keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys") - self.list(keys, actor, :load_by_user, inflate) - end + def json_create(json) + Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.") + Chef::Key.from_json(json) + end - def self.list_by_client(actor, inflate = false) - keys = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys") - self.list(keys, actor, :load_by_client, inflate) - end + def list_by_user(actor, inflate = false) + keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys") + self.list(keys, actor, :load_by_user, inflate) + end - def self.load_by_user(actor, key_name) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys/#{key_name}") - Chef::Key.from_hash(response.merge({ "user" => actor })) - end + def list_by_client(actor, inflate = false) + keys = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys") + self.list(keys, actor, :load_by_client, inflate) + end - def self.load_by_client(actor, key_name) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys/#{key_name}") - Chef::Key.from_hash(response.merge({ "client" => actor })) - end + def load_by_user(actor, key_name) + response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys/#{key_name}") + Chef::Key.from_hash(response.merge({ "user" => actor })) + end - def self.generate_fingerprint(public_key) - openssl_key_object = OpenSSL::PKey::RSA.new(public_key) - data_string = OpenSSL::ASN1::Sequence([ - OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.n), - OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e), - ]) - OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":") - end + def load_by_client(actor, key_name) + response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys/#{key_name}") + Chef::Key.from_hash(response.merge({ "client" => actor })) + end - private + def generate_fingerprint(public_key) + openssl_key_object = OpenSSL::PKey::RSA.new(public_key) + data_string = OpenSSL::ASN1::Sequence([ + OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.n), + OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e), + ]) + OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":") + end - def self.list(keys, actor, load_method_symbol, inflate) - if inflate - keys.inject({}) do |key_map, result| - name = result["name"] - key_map[name] = Chef::Key.send(load_method_symbol, actor, name) - key_map + def list(keys, actor, load_method_symbol, inflate) + if inflate + keys.inject({}) do |key_map, result| + name = result["name"] + key_map[name] = Chef::Key.send(load_method_symbol, actor, name) + key_map + end + else + keys end - else - keys end end end diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/lib/chef/knife/cookbook_bulk_delete.rb index bd1c8a22cc..cdd1584e36 100644 --- a/lib/chef/knife/cookbook_bulk_delete.rb +++ b/lib/chef/knife/cookbook_bulk_delete.rb @@ -42,7 +42,7 @@ class Chef all_cookbooks = Chef::CookbookVersion.list cookbooks_names = all_cookbooks.keys.grep(regex) - cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name];hash } + cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name]; hash } ui.msg "All versions of the following cookbooks will be deleted:" ui.msg "" ui.msg ui.list(cookbooks_to_delete.keys.sort, :columns_down) diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb index a20e62ffc2..d0c930de0a 100644 --- a/lib/chef/knife/cookbook_show.rb +++ b/lib/chef/knife/cookbook_show.rb @@ -63,7 +63,7 @@ class Chef node[:platform_version] = config[:platform_version] if config.has_key?(:platform_version) class << node - def attribute?(name) + def attribute?(name) # rubocop:disable Lint/NestedMethodDefinition has_key?(name) end end diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index f5eff26903..bb129a652d 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -110,7 +110,7 @@ class Chef end def check_spec_for_glob(spec, glob) - dirs = if spec.require_paths.size > 1 then + dirs = if spec.require_paths.size > 1 "{#{spec.require_paths.join(',')}}" else spec.require_paths.first diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 2bbcbfc79e..6f266b2719 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -164,9 +164,7 @@ class Chef end def configure_session - list = config[:manual] ? - @name_args[0].split(" ") : - search_nodes + list = config[:manual] ? @name_args[0].split(" ") : search_nodes if list.length == 0 if @action_nodes.length == 0 ui.fatal("No nodes returned from search") @@ -548,24 +546,24 @@ class Chef configure_session exit_status = - case @name_args[1] - when "interactive" - interactive - when "screen" - screen - when "tmux" - tmux - when "macterm" - macterm - when "cssh" - cssh - when "csshx" - Chef::Log.warn("knife ssh csshx will be deprecated in a future release") - Chef::Log.warn("please use knife ssh cssh instead") - cssh - else - ssh_command(@name_args[1..-1].join(" ")) - end + case @name_args[1] + when "interactive" + interactive + when "screen" + screen + when "tmux" + tmux + when "macterm" + macterm + when "cssh" + cssh + when "csshx" + Chef::Log.warn("knife ssh csshx will be deprecated in a future release") + Chef::Log.warn("please use knife ssh cssh instead") + cssh + else + ssh_command(@name_args[1..-1].join(" ")) + end session.close if exit_status != 0 diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb index 11e1b5559d..49252af484 100644 --- a/lib/chef/mixin/windows_architecture_helper.rb +++ b/lib/chef/mixin/windows_architecture_helper.rb @@ -74,16 +74,15 @@ class Chef def node_supports_windows_architecture?(node, desired_architecture) assert_valid_windows_architecture!(desired_architecture) - return (node_windows_architecture(node) == :x86_64 || - desired_architecture == :i386) ? true : false + return ( node_windows_architecture(node) == :x86_64 ) || ( desired_architecture == :i386 ) end def valid_windows_architecture?(architecture) - return (architecture == :x86_64) || (architecture == :i386) + return ( architecture == :x86_64 ) || ( architecture == :i386 ) end def assert_valid_windows_architecture!(architecture) - if ! valid_windows_architecture?(architecture) + if !valid_windows_architecture?(architecture) raise Chef::Exceptions::Win32ArchitectureIncorrect, "The specified architecture was not valid. It must be one of :i386 or :x86_64" end diff --git a/lib/chef/monologger.rb b/lib/chef/monologger.rb index 8bcdae1293..82816e887f 100644 --- a/lib/chef/monologger.rb +++ b/lib/chef/monologger.rb @@ -61,7 +61,7 @@ class MonoLogger < Logger @dev.close rescue nil end - private + private def open_logfile(filename) if FileTest.exist?(filename) diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 54faab6d3e..212b1ced14 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -642,8 +642,8 @@ class Chef end end - def <=>(other_node) - self.name <=> other_node.name + def <=>(other) + self.name <=> other.name end private diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index f5fe89251d..e4035dd22f 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -542,7 +542,7 @@ class Chef }.join(", ") << ">" end - private + private # Helper method for merge_all/merge_defaults/merge_overrides. # diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb index 40474242f0..bc565d92ef 100644 --- a/lib/chef/platform/provider_mapping.rb +++ b/lib/chef/platform/provider_mapping.rb @@ -197,8 +197,11 @@ class Chef def resource_matching_provider(platform, version, resource_type) if resource_type.kind_of?(Chef::Resource) - class_name = resource_type.class.name ? resource_type.class.name.split("::").last : - convert_to_class_name(resource_type.resource_name.to_s) + class_name = if resource_type.class.name + resource_type.class.name.split("::").last + else + convert_to_class_name(resource_type.resource_name.to_s) + end if Chef::Provider.const_defined?(class_name, false) Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.") diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index c7487cf42f..7baaeec0c5 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -187,8 +187,7 @@ class Chef end crontab << line end - description = cron_found ? "remove #{@new_resource.name} from crontab" : - "save unmodified crontab" + description = cron_found ? "remove #{@new_resource.name} from crontab" : "save unmodified crontab" converge_by(description) do write_crontab crontab Chef::Log.info("#{@new_resource} deleted crontab entry") diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index cac0fb6eb0..82b85fb1e4 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -194,12 +194,12 @@ class Chef end def action_reconfig - if @current_resource.version == nil then + if @current_resource.version == nil Chef::Log.debug("#{@new_resource} is NOT installed - nothing to do") return end - unless @new_resource.response_file then + unless @new_resource.response_file Chef::Log.debug("#{@new_resource} no response_file provided - nothing to do") return end diff --git a/lib/chef/provider/package/windows/registry_uninstall_entry.rb b/lib/chef/provider/package/windows/registry_uninstall_entry.rb index 3fa00b6081..a693558883 100644 --- a/lib/chef/provider/package/windows/registry_uninstall_entry.rb +++ b/lib/chef/provider/package/windows/registry_uninstall_entry.rb @@ -79,8 +79,6 @@ class Chef attr_reader :uninstall_string attr_reader :data - private - UNINSTALL_SUBKEY = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'.freeze end end diff --git a/lib/chef/provider/package/yum/rpm_utils.rb b/lib/chef/provider/package/yum/rpm_utils.rb index a748c664a9..032597d047 100644 --- a/lib/chef/provider/package/yum/rpm_utils.rb +++ b/lib/chef/provider/package/yum/rpm_utils.rb @@ -243,16 +243,16 @@ class Chef self.new(*args) end - def <=>(y) - compare_versions(y) + def <=>(other) + compare_versions(other) end - def compare(y) - compare_versions(y, false) + def compare(other) + compare_versions(other, false) end - def partial_compare(y) - compare_versions(y, true) + def partial_compare(other) + compare_versions(other, true) end # RPM::Version rpm_version_to_s equivalent @@ -352,8 +352,8 @@ class Chef alias :name :n alias :arch :a - def <=>(y) - compare(y) + def <=>(other) + compare(other) end def compare(y) diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index fe4768b2e8..6369a3a9a0 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -108,7 +108,7 @@ class Chef shell_out_with_systems_locale!(@new_resource.reload_command) end - protected + protected def determine_current_status! if @new_resource.status_command diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index 1e5398eba8..868b3e1ac1 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -40,7 +40,7 @@ class Chef @current_resource.service_name(@new_resource.service_name) [@init_command, @status_command].each do |cmd| - unless ::File.executable? cmd then + unless ::File.executable? cmd raise Chef::Exceptions::Service, "#{cmd} not executable!" end end diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index 3ac5ff51da..99ffc24653 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -80,8 +80,11 @@ class Chef shared_resource_requirements requirements.assert(:all_actions) do |a| if !@command_success - whyrun_msg = @new_resource.status_command ? "Provided status command #{@new_resource.status_command} failed." : - "Could not determine upstart state for service" + whyrun_msg = if @new_resource.status_command + "Provided status command #{@new_resource.status_command} failed." + else + "Could not determine upstart state for service" + end end a.assertion { @command_success } # no failure here, just document the assumptions made. diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb index 67342a86ea..1e8b925071 100644 --- a/lib/chef/provider/template_finder.rb +++ b/lib/chef/provider/template_finder.rb @@ -40,7 +40,7 @@ class Chef cookbook.preferred_filename_on_disk_location(@node, :templates, template_name) end - protected + protected def template_source_name(name, options) if options[:source] diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb index 3f168b8da3..befb6ac3fd 100644 --- a/lib/chef/provider/user/aix.rb +++ b/lib/chef/provider/user/aix.rb @@ -66,7 +66,7 @@ class Chef shell_out!("chuser account_locked=false #{new_resource.username}") end - private + private def add_password if @current_resource.password != @new_resource.password && @new_resource.password diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index 1f0cbb6054..83ee8346a9 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -70,7 +70,7 @@ class Chef shell_out!("passwd", "-u", new_resource.username) end - private + private def manage_password if @current_resource.password != @new_resource.password && @new_resource.password diff --git a/lib/chef/provider/windows_script.rb b/lib/chef/provider/windows_script.rb index 2de127addf..3b0202790c 100644 --- a/lib/chef/provider/windows_script.rb +++ b/lib/chef/provider/windows_script.rb @@ -33,8 +33,11 @@ class Chef super( new_resource, run_context ) @script_extension = script_extension - target_architecture = new_resource.architecture.nil? ? - node_windows_architecture(run_context.node) : new_resource.architecture + target_architecture = if new_resource.architecture.nil? + node_windows_architecture(run_context.node) + else + new_resource.architecture + end @is_wow64 = wow64_architecture_override_required?(run_context.node, target_architecture) diff --git a/lib/chef/resource_collection/stepable_iterator.rb b/lib/chef/resource_collection/stepable_iterator.rb index d1165764ca..958ffa28cb 100644 --- a/lib/chef/resource_collection/stepable_iterator.rb +++ b/lib/chef/resource_collection/stepable_iterator.rb @@ -100,9 +100,7 @@ class Chef end def iterate - while @position < size && !paused? - step - end + step while @position < size && !paused? collection end diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb index 4135483441..8422870e2a 100644 --- a/lib/chef/resource_reporter.rb +++ b/lib/chef/resource_reporter.rb @@ -26,11 +26,11 @@ require "chef/event_dispatch/base" class Chef class ResourceReporter < EventDispatch::Base - class ResourceReport < Struct.new(:new_resource, - :current_resource, - :action, - :exception, - :elapsed_time) + ResourceReport = Struct.new(:new_resource, + :current_resource, + :action, + :exception, + :elapsed_time) do def self.new_with_current_state(new_resource, action, current_resource) report = new diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb index 4dea938423..3ac5fab07b 100644 --- a/lib/chef/run_list.rb +++ b/lib/chef/run_list.rb @@ -47,13 +47,13 @@ class Chef end def role_names - @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.role? ; memo } + @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.role?; memo } end alias :roles :role_names def recipe_names - @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.recipe? ; memo } + @run_list_items.inject([]) { |memo, run_list_item| memo << run_list_item.name if run_list_item.recipe?; memo } end alias :recipes :recipe_names diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb index 40d7e10d2e..0c10309521 100644 --- a/lib/chef/shell/ext.rb +++ b/lib/chef/shell/ext.rb @@ -39,13 +39,13 @@ module Shell # irb breaks if you prematurely define IRB::JobMangager # so these methods need to be defined at the latest possible time. unless jobs.respond_to?(:select_session_by_context) - def jobs.select_session_by_context(&block) + def jobs.select_session_by_context(&block) # rubocop:disable Lint/NestedMethodDefinition @jobs.select { |job| block.call(job[1].context.main) } end end unless jobs.respond_to?(:session_select) - def jobs.select_shell_session(target_context) + def jobs.select_shell_session(target_context) # rubocop:disable Lint/NestedMethodDefinition session = if target_context.kind_of?(Class) select_session_by_context { |main| main.kind_of?(target_context) } else diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb index 0a8cba5be3..a458286157 100644 --- a/lib/chef/shell/shell_session.rb +++ b/lib/chef/shell/shell_session.rb @@ -126,7 +126,7 @@ module Shell end def shorten_node_inspect - def @node.inspect + def @node.inspect # rubocop:disable Lint/NestedMethodDefinition "<Chef::Node:0x#{self.object_id.to_s(16)} @name=\"#{self.name}\">" end end diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb index 739a463ad5..8b492d483a 100644 --- a/lib/chef/util/dsc/configuration_generator.rb +++ b/lib/chef/util/dsc/configuration_generator.rb @@ -48,7 +48,7 @@ class Chef::Util::DSC configuration_document_location = find_configuration_document(configuration_name) if ! configuration_document_location - raise RuntimeError, "No DSC configuration for '#{configuration_name}' was generated from supplied DSC script" + raise "No DSC configuration for '#{configuration_name}' was generated from supplied DSC script" end configuration_document = get_configuration_document(configuration_document_location) diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb index 6ab380c071..e300266b1e 100644 --- a/lib/chef/util/powershell/cmdlet.rb +++ b/lib/chef/util/powershell/cmdlet.rb @@ -62,8 +62,11 @@ class Chef json_depth = @output_format_options[:depth] end - json_command = @json_format ? " | convertto-json -compress -depth #{json_depth} "\ - "> #{streams[:json].path}" : "" + json_command = if @json_format + " | convertto-json -compress -depth #{json_depth} > #{streams[:json].path}" + else + "" + end redirections = "4> '#{streams[:verbose].path}'" command_string = "powershell.exe -executionpolicy bypass -noprofile -noninteractive "\ "-command \"trap [Exception] {write-error -exception "\ diff --git a/lib/chef/util/selinux.rb b/lib/chef/util/selinux.rb index 1aac7eeeca..edca589034 100644 --- a/lib/chef/util/selinux.rb +++ b/lib/chef/util/selinux.rb @@ -78,7 +78,7 @@ class Chef when 0 return true else - raise RuntimeError, "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}" + raise "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}" end else # We assume selinux is not enabled if selinux utils are not diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb index f018833717..f26368902d 100644 --- a/lib/chef/version_class.rb +++ b/lib/chef/version_class.rb @@ -32,11 +32,11 @@ class Chef "#{@major}.#{@minor}.#{@patch}" end - def <=>(v) + def <=>(other) [:major, :minor, :patch].each do |method| version = self.send(method) begin - ans = (version <=> v.send(method)) + ans = (version <=> other.send(method)) rescue NoMethodError # if the other thing isn't a version object, return nil return nil end diff --git a/lib/chef/version_constraint.rb b/lib/chef/version_constraint.rb index d4fa5df775..f10325f946 100644 --- a/lib/chef/version_constraint.rb +++ b/lib/chef/version_constraint.rb @@ -57,8 +57,8 @@ class Chef "#{@op} #{@raw_version}" end - def eql?(o) - o.class == self.class && @op == o.op && @version == o.version + def eql?(other) + other.class == self.class && @op == other.op && @version == other.version end alias_method :==, :eql? diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb index dc83f9cb2b..12ccdb5ee9 100644 --- a/lib/chef/win32/api/error.rb +++ b/lib/chef/win32/api/error.rb @@ -194,12 +194,12 @@ class Chef ERROR_INVALID_EXE_SIGNATURE = 191 ERROR_EXE_MARKED_INVALID = 192 ERROR_BAD_EXE_FORMAT = 193 - ERROR_ITERATED_DATA_EXCEEDS_64k = 194 + ERROR_ITERATED_DATA_EXCEEDS_64k = 194 # rubocop:disable Style/ConstantName ERROR_INVALID_MINALLOCSIZE = 195 ERROR_DYNLINK_FROM_INVALID_RING = 196 ERROR_IOPL_NOT_ENABLED = 197 ERROR_INVALID_SEGDPL = 198 - ERROR_AUTODATASEG_EXCEEDS_64k = 199 + ERROR_AUTODATASEG_EXCEEDS_64k = 199 # rubocop:disable Style/ConstantName ERROR_RING2SEG_MUST_BE_MOVABLE = 200 ERROR_RELOC_CHAIN_XEEDS_SEGLIM = 201 ERROR_INFLOOP_IN_RELOC_CHAIN = 202 diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb index bec00f638a..abf0dd83ec 100644 --- a/lib/chef/win32/api/net.rb +++ b/lib/chef/win32/api/net.rb @@ -45,7 +45,7 @@ class Chef USE_FORCE = 1 USE_LOTS_OF_FORCE = 2 #every windows API should support this flag - NERR_Success = 0 + NERR_Success = 0 # rubocop:disable Style/ConstantName ERROR_MORE_DATA = 234 ffi_lib "netapi32" diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb index 4254b8ead3..eae0ae4abf 100644 --- a/lib/chef/win32/eventlog.rb +++ b/lib/chef/win32/eventlog.rb @@ -26,6 +26,6 @@ if Chef::Platform.windows? && (not Chef::Platform.windows_server_2003?) end require "win32/eventlog" - Chef::Win32EventLogLoaded = true + Chef::Win32EventLogLoaded = true # rubocop:disable Style/ConstantName end end diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb index 0454b17d49..09db2af89d 100644 --- a/lib/chef/win32/net.rb +++ b/lib/chef/win32/net.rb @@ -207,7 +207,7 @@ class Chef def self.members_to_lgrmi3(members) buf = FFI::MemoryPointer.new(LOCALGROUP_MEMBERS_INFO_3, members.size) - members.size.times.collect do |i| + Array.new(members.size) do |i| member_info = LOCALGROUP_MEMBERS_INFO_3.new( buf + i * LOCALGROUP_MEMBERS_INFO_3.size) member_info[:lgrmi3_domainandname] = FFI::MemoryPointer.from_string(wstring(members[i])) diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb index 9951b931c9..f6b88c60ce 100644 --- a/lib/chef/win32/security/sid.rb +++ b/lib/chef/win32/security/sid.rb @@ -279,7 +279,7 @@ class Chef status = NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle) if status == NERR_Success || status == ERROR_MORE_DATA - entriesread.read_long.times.collect do |i| + Array.new(entriesread.read_long) do |i| user_info = USER_INFO_3.new(bufptr.read_pointer + i * USER_INFO_3.size) # Check if the account is the Administrator account # RID for the Administrator account is always 500 and it's privilage is set to USER_PRIV_ADMIN diff --git a/omnibus/omnibus.rb b/omnibus/omnibus.rb index 4eeee4abcb..5d91bb786a 100644 --- a/omnibus/omnibus.rb +++ b/omnibus/omnibus.rb @@ -26,8 +26,10 @@ # Windows architecture defaults - set to x86 unless otherwise specified. # ------------------------------ -windows_arch %w{x86 x64}.include?((ENV["OMNIBUS_WINDOWS_ARCH"] || "").downcase) ? - ENV["OMNIBUS_WINDOWS_ARCH"].downcase.to_sym : :x86 +env_omnibus_windows_arch = (ENV["OMNIBUS_WINDOWS_ARCH"] || "").downcase +env_omnibus_windows_arch = :x86 unless %w{x86 x64}.include?(env_omnibus_windows_arch) + +windows_arch env_omnibus_windows_arch # Disable git caching # ------------------------------ diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb index 7c54af347c..9e2131388f 100644 --- a/spec/functional/file_content_management/deploy_strategies_spec.rb +++ b/spec/functional/file_content_management/deploy_strategies_spec.rb @@ -209,7 +209,7 @@ describe Chef::FileContentManagement::Deploy::MvUnix, :unix_only do end # On Unix we won't have loaded the file, avoid undefined constant errors: -class Chef::FileContentManagement::Deploy::MvWindows ; end +class Chef::FileContentManagement::Deploy::MvWindows; end describe Chef::FileContentManagement::Deploy::MvWindows, :windows_only do diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb index 838d15671c..74d006a8b8 100644 --- a/spec/functional/knife/exec_spec.rb +++ b/spec/functional/knife/exec_spec.rb @@ -21,7 +21,7 @@ require "tiny_server" describe Chef::Knife::Exec do before(:all) do - @server = TinyServer::Manager.new#(:debug => true) + @server = TinyServer::Manager.new #(:debug => true) @server.start end diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb index 72eaea3c12..572609d8ff 100644 --- a/spec/functional/resource/deploy_revision_spec.rb +++ b/spec/functional/resource/deploy_revision_spec.rb @@ -840,7 +840,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true, :requires_git => tr end def run_action(action) - raise RuntimeError, "network error" + raise "network error" end end diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb index 8e4940d475..1e5e9fb540 100644 --- a/spec/functional/resource/dsc_resource_spec.rb +++ b/spec/functional/resource/dsc_resource_spec.rb @@ -77,7 +77,7 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do new_resource.run_action(:run) expect(new_resource).to be_updated reresource = - Chef::Resource::DscResource.new("dsc_resource_retest", run_context) + Chef::Resource::DscResource.new("dsc_resource_retest", run_context) reresource.resource :File reresource.property :Contents, test_text reresource.property :DestinationPath, tmp_file_name diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index 19d45d3e7d..998e77f6b4 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -48,9 +48,7 @@ describe Chef::RunLock do WAIT_ON_LOCK_TIME = 1.0 def wait_on_lock Timeout.timeout(WAIT_ON_LOCK_TIME) do - until File.exist?(lockfile) - sleep 0.1 - end + sleep 0.1 until File.exist?(lockfile) end rescue Timeout::Error raise "Lockfile never created, abandoning test" @@ -393,9 +391,7 @@ describe Chef::RunLock do # Send it the kill signal over and over until it dies Timeout.timeout(CLIENT_PROCESS_TIMEOUT) do Process.kill(:KILL, pid) - until Process.waitpid2(pid, Process::WNOHANG) - sleep(0.05) - end + sleep(0.05) until Process.waitpid2(pid, Process::WNOHANG) end example.log_event("#{name}.stop finished (stopped pid #{pid})") # Process not found is perfectly fine when we're trying to kill a process :) diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index 8f6f4b7f46..f3d1321b9b 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -139,26 +139,6 @@ module ResourceActionSpec attr_accessor :ruby_block_converged end - public - - def foo_public - "foo_public!" - end - - protected - - def foo_protected - "foo_protected!" - end - - private - - def foo_private - "foo_private!" - end - - public - action :access_recipe_dsl do ActionJackson.ran_action = :access_recipe_dsl ruby_block "hi there" do @@ -199,6 +179,22 @@ module ResourceActionSpec ActionJackson.ran_action = :access_class_method ActionJackson.succeeded = ActionJackson.ruby_block_converged end + + def foo_public + "foo_public!" + end + + protected + + def foo_protected + "foo_protected!" + end + + private + + def foo_private + "foo_private!" + end end before(:each) { diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 9ba56a15e3..4b727a18ca 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -169,7 +169,7 @@ def selinux_enabled? when 0 return true else - raise RuntimeError, "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}" + raise "Unknown exit code from command #{selinuxenabled_path}: #{cmd.exitstatus}" end else # We assume selinux is not enabled if selinux utils are not diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index 506b96736c..95f4f4bd49 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -81,7 +81,7 @@ shared_context "use Windows permissions", :windows_only do SID ||= Chef::ReservedNames::Win32::Security::SID ACE ||= Chef::ReservedNames::Win32::Security::ACE ACL ||= Chef::ReservedNames::Win32::Security::ACL - SecurableObject ||= Chef::ReservedNames::Win32::Security::SecurableObject + SecurableObject ||= Chef::ReservedNames::Win32::Security::SecurableObject # rubocop:disable Style/ConstantName end def get_security_descriptor(path) @@ -138,9 +138,9 @@ shared_context "use Windows permissions", :windows_only do RSpec::Matchers.define :have_expected_properties do |mask, type, flags| match do |ace| - ace.mask == mask - ace.type == type - ace.flags == flags + ace.mask == mask && + ace.type == type && + ace.flags == flags end end @@ -439,7 +439,7 @@ shared_examples_for "a securable resource without existing target" do context "with a mode attribute" do if windows? - Security ||= Chef::ReservedNames::Win32::API::Security + Security ||= Chef::ReservedNames::Win32::API::Security # rubocop:disable Style/ConstantName end it "respects mode in string form as an octal number" do diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb index 0f9072bdef..f9cc43d3f9 100644 --- a/spec/support/shared/functional/win32_service.rb +++ b/spec/support/shared/functional/win32_service.rb @@ -23,9 +23,7 @@ shared_context "using Win32::Service" do # We can only uninstall when the service is stopped. if test_service_state != "stopped" ::Win32::Service.send("stop", "spec-service") - while test_service_state != "stopped" - sleep 1 - end + sleep 1 while test_service_state != "stopped" end ::Win32::Service.delete("spec-service") diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb index 9bc48dbd93..4dfa3fa155 100644 --- a/spec/support/shared/integration/app_server_support.rb +++ b/spec/support/shared/integration/app_server_support.rb @@ -33,9 +33,7 @@ module AppServerSupport end end Timeout.timeout(30) do - until server && server.status == :Running - sleep(0.01) - end + sleep(0.01) until server && server.status == :Running end [server, thread] end diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index 01df9ab1a7..1a374e1b84 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -111,8 +111,6 @@ module KnifeSupport end end - private - class KnifeResult include ::RSpec::Matchers diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 9de8077677..84637f7283 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -35,9 +35,9 @@ describe Chef::ChefFS::Parallelizer do context "With :ordered => false (unordered output)" do it "An empty input produces an empty output" do - parallelize([], :ordered => false) do + expect(parallelize([], :ordered => false) do sleep 10 - end.to_a == [] + end.to_a).to eql([]) expect(elapsed_time).to be < 0.1 end @@ -107,9 +107,9 @@ describe Chef::ChefFS::Parallelizer do context "With :ordered => true (ordered output)" do it "An empty input produces an empty output" do - parallelize([]) do + expect(parallelize([]) do sleep 10 - end.to_a == [] + end.to_a).to eql([]) expect(elapsed_time).to be < 0.1 end @@ -211,9 +211,7 @@ describe Chef::ChefFS::Parallelizer do occupying_job_finished[0] = true end.wait end - until started - sleep(0.01) - end + sleep(0.01) until started end after :each do diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index e31ce7d151..ae3d626113 100644 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -22,7 +22,7 @@ describe Chef::Daemon do before do if windows? mock_struct = #Struct::Passwd.new(nil, nil, 111, 111) - mock_struct = OpenStruct.new(:uid => 2342, :gid => 2342) + mock_struct = OpenStruct.new(:uid => 2342, :gid => 2342) allow(Etc).to receive(:getpwnam).and_return mock_struct allow(Etc).to receive(:getgrnam).and_return mock_struct # mock unimplemented methods diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb index 131d6b8df9..764510d0ad 100644 --- a/spec/unit/data_collector_spec.rb +++ b/spec/unit/data_collector_spec.rb @@ -488,7 +488,7 @@ describe Chef::DataCollector::Reporter do context "when an unexpected exception is raised by the block" do it "re-raises the exception" do - expect { reporter.send(:disable_reporter_on_error) { raise RuntimeError, "bummer" } }.to raise_error(RuntimeError) + expect { reporter.send(:disable_reporter_on_error) { raise "bummer" } }.to raise_error(RuntimeError) end end diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb index 4357a91148..4118133692 100644 --- a/spec/unit/file_access_control_spec.rb +++ b/spec/unit/file_access_control_spec.rb @@ -67,7 +67,7 @@ describe Chef::FileAccessControl do it "raises a Chef::Exceptions::UserIDNotFound error when Etc can't find the user's name" do expect(Etc).to receive(:getpwnam).with("toor").and_raise(ArgumentError) - expect { @fac.target_uid ; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::UserIDNotFound, "cannot determine user id for 'toor', does the user exist on this system?") + expect { @fac.target_uid; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::UserIDNotFound, "cannot determine user id for 'toor', does the user exist on this system?") end it "does not attempt to resolve the uid if the user is not specified" do @@ -84,7 +84,7 @@ describe Chef::FileAccessControl do it "raises an ArgumentError if the resource's owner is set to something wack" do @resource.instance_variable_set(:@owner, :diaf) - expect { @fac.target_uid ; @provider_requirements.run(:create) }.to raise_error(ArgumentError) + expect { @fac.target_uid; @provider_requirements.run(:create) }.to raise_error(ArgumentError) end it "uses the resource's uid for the target uid when the resource's owner is specified by an integer" do diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index 5ac48539e4..823eff8b04 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -199,8 +199,8 @@ describe Chef::Knife::CookbookSiteShare do response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(500) - expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered - expect(@knife.ui).to receive(:error).with(/Unknown error/)#.ordered + expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/) #.ordered + expect(@knife.ui).to receive(:error).with(/Unknown error/) #.ordered expect { @knife.run }.to raise_error(SystemExit) end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 6574a91f13..ab7a6302ee 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -28,13 +28,13 @@ describe "LWRP" do include Chef::Mixin::ConvertToClassName before do - @original_VERBOSE = $VERBOSE + @original_verbose = $VERBOSE $VERBOSE = nil Chef::Resource::LWRPBase.class_eval { @loaded_lwrps = {} } end after do - $VERBOSE = @original_VERBOSE + $VERBOSE = @original_verbose end def get_lwrp(name) diff --git a/spec/unit/mixin/deprecation_spec.rb b/spec/unit/mixin/deprecation_spec.rb index 8f22b09295..8707c6476e 100644 --- a/spec/unit/mixin/deprecation_spec.rb +++ b/spec/unit/mixin/deprecation_spec.rb @@ -36,7 +36,7 @@ describe Chef::Mixin do end it "warns when accessing the deprecated constant" do - Chef::Mixin::DeprecatedClass + Chef::Mixin::DeprecatedClass # rubocop:disable Lint/Void expect(@log_io.string).to include("This is a test deprecation") end end diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 42585d9e3e..0b956d9bb9 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -82,7 +82,7 @@ describe Chef::Provider::Mount::Mount do it "should raise an error if the mount device does not exist" do allow(::File).to receive(:exists?).with("/dev/sdz1").and_return false - expect { @provider.load_current_resource();@provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should not call mountable? with load_current_resource - CHEF-1565" do @@ -99,25 +99,25 @@ describe Chef::Provider::Mount::Mount do @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) expect(::File).to receive(:exists?).with("").and_return(false) - expect { @provider.load_current_resource();@provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end it "should raise an error if the mount point does not exist" do allow(::File).to receive(:exists?).with("/tmp/foo").and_return false - expect { @provider.load_current_resource();@provider.mountable? }.to raise_error(Chef::Exceptions::Mount) + expect { @provider.load_current_resource(); @provider.mountable? }.to raise_error(Chef::Exceptions::Mount) end %w{tmpfs fuse cgroup}.each do |fstype| it "does not expect the device to exist for #{fstype}" do @new_resource.fstype(fstype) @new_resource.device("whatever") - expect { @provider.load_current_resource();@provider.mountable? }.not_to raise_error + expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error end end it "does not expect the device to exist if it's none" do @new_resource.device("none") - expect { @provider.load_current_resource();@provider.mountable? }.not_to raise_error + expect { @provider.load_current_resource(); @provider.mountable? }.not_to raise_error end it "should set mounted true if the mount point is found in the mounts list" do diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index b593da4ff1..4ae8d960a2 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -74,8 +74,8 @@ describe Chef::Provider::Package::Freebsd::Port do it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do pkg_enabled = OpenStruct.new(:stdout => "yes\n") - [1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version| - @node.automatic_attrs[:os_version] = __freebsd_version + [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| + @node.automatic_attrs[:os_version] = freebsd_version expect(@new_resource).to receive(:shell_out!).with("make -V WITH_PKGNG", env: nil).and_return(pkg_enabled) expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") @@ -83,8 +83,8 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do - __freebsd_version = 1000017 - @node.automatic_attrs[:os_version] = __freebsd_version + freebsd_version = 1000017 + @node.automatic_attrs[:os_version] = freebsd_version expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index ed109bf20f..b1ebde2b7d 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -63,7 +63,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do begin @gem_env.with_gem_sources("http://gems.example.org") do sources_in_block = Gem.sources - raise RuntimeError, "sources should be reset even in case of an error" + raise "sources should be reset even in case of an error" end rescue RuntimeError end @@ -77,7 +77,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do begin @gem_env.with_gem_sources(nil) do sources_in_block = Gem.sources - raise RuntimeError, "sources should be reset even in case of an error" + raise "sources should be reset even in case of an error" end rescue RuntimeError end diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index ab726134e9..4bc28f130a 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -1229,9 +1229,9 @@ describe Chef::Provider::Package::Yum::RPMPackage do it "should always have at least one provide, itself" do expect(@rpm.provides.size).to eq(1) - @rpm.provides[0].name == "testing" - @rpm.provides[0].version.evr == "1:1.6.5-9.36.el5" - @rpm.provides[0].flag == :== + expect(@rpm.provides[0].name).to eql("testing") + expect(@rpm.provides[0].version.evr).to eql("1:1.6.5-9.36.el5") + expect(@rpm.provides[0].flag).to eql(:==) end end @@ -1253,9 +1253,9 @@ describe Chef::Provider::Package::Yum::RPMPackage do it "should always have at least one provide, itself" do expect(@rpm.provides.size).to eq(1) - @rpm.provides[0].name == "testing" - @rpm.provides[0].version.evr == "1:1.6.5-9.36.el5" - @rpm.provides[0].flag == :== + expect(@rpm.provides[0].name).to eql("testing") + expect(@rpm.provides[0].version.evr).to eql("1:1.6.5-9.36.el5") + expect(@rpm.provides[0].flag).to eql(:==) end end diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index 5d4396ea4d..f1567ed86e 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -517,347 +517,347 @@ describe Chef::ProviderResolver do end PROVIDERS = - { - bash: [ Chef::Resource::Bash, Chef::Provider::Script ], - breakpoint: [ Chef::Resource::Breakpoint, Chef::Provider::Breakpoint ], - chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ], - cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ], - csh: [ Chef::Resource::Csh, Chef::Provider::Script ], - deploy: [ Chef::Resource::Deploy, Chef::Provider::Deploy::Timestamped ], - deploy_revision: [ Chef::Resource::DeployRevision, Chef::Provider::Deploy::Revision ], - directory: [ Chef::Resource::Directory, Chef::Provider::Directory ], - easy_install_package: [ Chef::Resource::EasyInstallPackage, Chef::Provider::Package::EasyInstall ], - erl_call: [ Chef::Resource::ErlCall, Chef::Provider::ErlCall ], - execute: [ Chef::Resource::Execute, Chef::Provider::Execute ], - file: [ Chef::Resource::File, Chef::Provider::File ], - gem_package: [ Chef::Resource::GemPackage, Chef::Provider::Package::Rubygems ], - git: [ Chef::Resource::Git, Chef::Provider::Git ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], - homebrew_package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], - http_request: [ Chef::Resource::HttpRequest, Chef::Provider::HttpRequest ], - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - link: [ Chef::Resource::Link, Chef::Provider::Link ], - log: [ Chef::Resource::Log, Chef::Provider::Log::ChefLog ], - macports_package: [ Chef::Resource::MacportsPackage, Chef::Provider::Package::Macports ], - mdadm: [ Chef::Resource::Mdadm, Chef::Provider::Mdadm ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Mount ], - perl: [ Chef::Resource::Perl, Chef::Provider::Script ], - portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], - python: [ Chef::Resource::Python, Chef::Provider::Script ], - remote_directory: [ Chef::Resource::RemoteDirectory, Chef::Provider::RemoteDirectory ], - route: [ Chef::Resource::Route, Chef::Provider::Route ], - ruby: [ Chef::Resource::Ruby, Chef::Provider::Script ], - ruby_block: [ Chef::Resource::RubyBlock, Chef::Provider::RubyBlock ], - script: [ Chef::Resource::Script, Chef::Provider::Script ], - subversion: [ Chef::Resource::Subversion, Chef::Provider::Subversion ], - template: [ Chef::Resource::Template, Chef::Provider::Template ], - timestamped_deploy: [ Chef::Resource::TimestampedDeploy, Chef::Provider::Deploy::Timestamped ], - user: [ Chef::Resource::User, Chef::Provider::User::Useradd ], - whyrun_safe_ruby_block: [ Chef::Resource::WhyrunSafeRubyBlock, Chef::Provider::WhyrunSafeRubyBlock ], - - # We want to check that these are unsupported: - apt_package: nil, - bff_package: nil, - dpkg_package: nil, - dsc_script: nil, - ips_package: nil, - pacman_package: nil, - paludis_package: nil, - rpm_package: nil, - smartos_package: nil, - solaris_package: nil, - yum_package: nil, - windows_package: nil, - windows_service: nil, - - "linux" => { - apt_package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], - dpkg_package: [ Chef::Resource::DpkgPackage, Chef::Provider::Package::Dpkg ], - pacman_package: [ Chef::Resource::PacmanPackage, Chef::Provider::Package::Pacman ], - paludis_package: [ Chef::Resource::PaludisPackage, Chef::Provider::Package::Paludis ], - rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ], - yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], - - "debian" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ], - package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], - # service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ], + { + bash: [ Chef::Resource::Bash, Chef::Provider::Script ], + breakpoint: [ Chef::Resource::Breakpoint, Chef::Provider::Breakpoint ], + chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ], + cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ], + csh: [ Chef::Resource::Csh, Chef::Provider::Script ], + deploy: [ Chef::Resource::Deploy, Chef::Provider::Deploy::Timestamped ], + deploy_revision: [ Chef::Resource::DeployRevision, Chef::Provider::Deploy::Revision ], + directory: [ Chef::Resource::Directory, Chef::Provider::Directory ], + easy_install_package: [ Chef::Resource::EasyInstallPackage, Chef::Provider::Package::EasyInstall ], + erl_call: [ Chef::Resource::ErlCall, Chef::Provider::ErlCall ], + execute: [ Chef::Resource::Execute, Chef::Provider::Execute ], + file: [ Chef::Resource::File, Chef::Provider::File ], + gem_package: [ Chef::Resource::GemPackage, Chef::Provider::Package::Rubygems ], + git: [ Chef::Resource::Git, Chef::Provider::Git ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], + homebrew_package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], + http_request: [ Chef::Resource::HttpRequest, Chef::Provider::HttpRequest ], + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + link: [ Chef::Resource::Link, Chef::Provider::Link ], + log: [ Chef::Resource::Log, Chef::Provider::Log::ChefLog ], + macports_package: [ Chef::Resource::MacportsPackage, Chef::Provider::Package::Macports ], + mdadm: [ Chef::Resource::Mdadm, Chef::Provider::Mdadm ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Mount ], + perl: [ Chef::Resource::Perl, Chef::Provider::Script ], + portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], + python: [ Chef::Resource::Python, Chef::Provider::Script ], + remote_directory: [ Chef::Resource::RemoteDirectory, Chef::Provider::RemoteDirectory ], + route: [ Chef::Resource::Route, Chef::Provider::Route ], + ruby: [ Chef::Resource::Ruby, Chef::Provider::Script ], + ruby_block: [ Chef::Resource::RubyBlock, Chef::Provider::RubyBlock ], + script: [ Chef::Resource::Script, Chef::Provider::Script ], + subversion: [ Chef::Resource::Subversion, Chef::Provider::Subversion ], + template: [ Chef::Resource::Template, Chef::Provider::Template ], + timestamped_deploy: [ Chef::Resource::TimestampedDeploy, Chef::Provider::Deploy::Timestamped ], + user: [ Chef::Resource::User, Chef::Provider::User::Useradd ], + whyrun_safe_ruby_block: [ Chef::Resource::WhyrunSafeRubyBlock, Chef::Provider::WhyrunSafeRubyBlock ], + + # We want to check that these are unsupported: + apt_package: nil, + bff_package: nil, + dpkg_package: nil, + dsc_script: nil, + ips_package: nil, + pacman_package: nil, + paludis_package: nil, + rpm_package: nil, + smartos_package: nil, + solaris_package: nil, + yum_package: nil, + windows_package: nil, + windows_service: nil, + + "linux" => { + apt_package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], + dpkg_package: [ Chef::Resource::DpkgPackage, Chef::Provider::Package::Dpkg ], + pacman_package: [ Chef::Resource::PacmanPackage, Chef::Provider::Package::Pacman ], + paludis_package: [ Chef::Resource::PaludisPackage, Chef::Provider::Package::Paludis ], + rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ], + yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], "debian" => { - "7.0" => { - }, - "6.0" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - # service: [ Chef::Resource::InsservService, Chef::Provider::Service::Insserv ], - }, - "5.0" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - }, - }, - "gcel" => { - "3.1.4" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - }, - }, - "linaro" => { - "3.1.4" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - }, - }, - "linuxmint" => { - "3.1.4" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - # service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ], - }, - }, - "raspbian" => { - "3.1.4" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ], + package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ], + # service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ], + + "debian" => { + "7.0" => { + }, + "6.0" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + # service: [ Chef::Resource::InsservService, Chef::Provider::Service::Insserv ], + }, + "5.0" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + }, + }, + "gcel" => { + "3.1.4" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + }, + }, + "linaro" => { + "3.1.4" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + }, + }, + "linuxmint" => { + "3.1.4" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + # service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ], + }, + }, + "raspbian" => { + "3.1.4" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + }, + }, + "ubuntu" => { + "11.10" => { + }, + "10.04" => { + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], + }, }, }, - "ubuntu" => { - "11.10" => { - }, - "10.04" => { - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ], - }, - }, - }, - - "arch" => { - # TODO should be Chef::Resource::PacmanPackage - package: [ Chef::Resource::Package, Chef::Provider::Package::Pacman ], "arch" => { - "3.1.4" => { + # TODO should be Chef::Resource::PacmanPackage + package: [ Chef::Resource::Package, Chef::Provider::Package::Pacman ], + + "arch" => { + "3.1.4" => { + }, }, }, - }, - - "freebsd" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Pw ], - user: [ Chef::Resource::User, Chef::Provider::User::Pw ], "freebsd" => { - "3.1.4" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Pw ], + user: [ Chef::Resource::User, Chef::Provider::User::Pw ], + + "freebsd" => { + "3.1.4" => { + }, }, }, - }, - "suse" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], "suse" => { - "12.0" => { - }, - %w{11.1 11.2 11.3} => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ], + "suse" => { + "12.0" => { + }, + %w{11.1 11.2 11.3} => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ], + }, + }, + "opensuse" => { + # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + package: [ Chef::Resource::ZypperPackage, Chef::Provider::Package::Zypper ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + "12.3" => { + }, + "12.2" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ], + }, }, }, - "opensuse" => { - # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], - package: [ Chef::Resource::ZypperPackage, Chef::Provider::Package::Zypper ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], - "12.3" => { - }, - "12.2" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ], - }, - }, - }, - - "gentoo" => { - # TODO should be Chef::Resource::PortagePackage - package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ], - portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], - # service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ], "gentoo" => { - "3.1.4" => { - }, - }, - }, - - "rhel" => { - # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ], - package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ], + # TODO should be Chef::Resource::PortagePackage + package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ], + portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ], + # service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ], - %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => { - "3.1.4" => { - # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + "gentoo" => { + "3.1.4" => { + }, }, }, - %w{redhat centos scientific oracle} => { - "7.0" => { - }, - "6.0" => { - # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], - }, - }, - "fedora" => { - "15.0" => { - }, - "14.0" => { - # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + + "rhel" => { + # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ], + package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ], + + %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => { + "3.1.4" => { + # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + }, + }, + %w{redhat centos scientific oracle} => { + "7.0" => { + }, + "6.0" => { + # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + }, + }, + "fedora" => { + "15.0" => { + }, + "14.0" => { + # service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ], + }, }, }, - }, - }, + }, - "darwin" => { - %w{mac_os_x mac_os_x_server} => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Dscl ], - package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], - osx_profile: [ Chef::Resource::OsxProfile, Chef::Provider::OsxProfile], - user: [ Chef::Resource::User, Chef::Provider::User::Dscl ], + "darwin" => { + %w{mac_os_x mac_os_x_server} => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Dscl ], + package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ], + osx_profile: [ Chef::Resource::OsxProfile, Chef::Provider::OsxProfile], + user: [ Chef::Resource::User, Chef::Provider::User::Dscl ], - "mac_os_x" => { - "10.9.2" => { + "mac_os_x" => { + "10.9.2" => { + }, }, }, }, - }, - - "windows" => { - batch: [ Chef::Resource::Batch, Chef::Provider::Batch ], - dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], - env: [ Chef::Resource::Env, Chef::Provider::Env::Windows ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ], - package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], - powershell_script: [ Chef::Resource::PowershellScript, Chef::Provider::PowershellScript ], - service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], - user: [ Chef::Resource::User, Chef::Provider::User::Windows ], - windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], - windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], "windows" => { - %w{mswin mingw32 windows} => { - "10.9.2" => { + batch: [ Chef::Resource::Batch, Chef::Provider::Batch ], + dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ], + env: [ Chef::Resource::Env, Chef::Provider::Env::Windows ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ], + package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], + powershell_script: [ Chef::Resource::PowershellScript, Chef::Provider::PowershellScript ], + service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], + user: [ Chef::Resource::User, Chef::Provider::User::Windows ], + windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ], + windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], + + "windows" => { + %w{mswin mingw32 windows} => { + "10.9.2" => { + }, }, }, }, - }, - - "aix" => { - bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Aix ], - cron: [ Chef::Resource::Cron, Chef::Provider::Cron::Aix ], - group: [ Chef::Resource::Group, Chef::Provider::Group::Aix ], - ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Aix ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Aix ], - # TODO should be Chef::Resource::BffPackage - package: [ Chef::Resource::Package, Chef::Provider::Package::Aix ], - rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ], - user: [ Chef::Resource::User, Chef::Provider::User::Aix ], - # service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ], "aix" => { + bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Aix ], + cron: [ Chef::Resource::Cron, Chef::Provider::Cron::Aix ], + group: [ Chef::Resource::Group, Chef::Provider::Group::Aix ], + ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Aix ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Aix ], + # TODO should be Chef::Resource::BffPackage + package: [ Chef::Resource::Package, Chef::Provider::Package::Aix ], + rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ], + user: [ Chef::Resource::User, Chef::Provider::User::Aix ], + # service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ], + "aix" => { - "5.6" => { + "aix" => { + "5.6" => { + }, }, }, }, - }, - "hpux" => { "hpux" => { "hpux" => { - "3.1.4" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + "hpux" => { + "3.1.4" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + }, }, }, }, - }, - "netbsd" => { "netbsd" => { "netbsd" => { - "3.1.4" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Groupmod ], + "netbsd" => { + "3.1.4" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Groupmod ], + }, }, }, }, - }, - - "openbsd" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], - package: [ Chef::Resource::OpenbsdPackage, Chef::Provider::Package::Openbsd ], "openbsd" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + package: [ Chef::Resource::OpenbsdPackage, Chef::Provider::Package::Openbsd ], + "openbsd" => { - "3.1.4" => { + "openbsd" => { + "3.1.4" => { + }, }, }, }, - }, - - "solaris2" => { - group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], - ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], - package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], - mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Solaris ], - solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], - "smartos" => { - smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], - package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], + "solaris2" => { + group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ], + ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], + package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], + mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Solaris ], + solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ], "smartos" => { - "3.1.4" => { - }, - }, - }, + smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], + package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ], - "solaris2" => { - "nexentacore" => { - "3.1.4" => { + "smartos" => { + "3.1.4" => { + }, }, }, - "omnios" => { - "3.1.4" => { - user: [ Chef::Resource::User, Chef::Provider::User::Solaris ], + + "solaris2" => { + "nexentacore" => { + "3.1.4" => { + }, }, - }, - "openindiana" => { - "3.1.4" => { + "omnios" => { + "3.1.4" => { + user: [ Chef::Resource::User, Chef::Provider::User::Solaris ], + }, }, - }, - "opensolaris" => { - "3.1.4" => { + "openindiana" => { + "3.1.4" => { + }, }, - }, - "solaris2" => { - user: [ Chef::Resource::User, Chef::Provider::User::Solaris ], - "5.11" => { - package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], + "opensolaris" => { + "3.1.4" => { + }, }, - "5.9" => { + "solaris2" => { + user: [ Chef::Resource::User, Chef::Provider::User::Solaris ], + "5.11" => { + package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ], + }, + "5.9" => { + }, }, }, - }, - }, + }, - "solaris" => { "solaris" => { "solaris" => { - "3.1.4" => { + "solaris" => { + "3.1.4" => { + }, }, }, }, - }, - "exherbo" => { "exherbo" => { "exherbo" => { - "3.1.4" => { - # TODO should be Chef::Resource::PaludisPackage - package: [ Chef::Resource::Package, Chef::Provider::Package::Paludis ], + "exherbo" => { + "3.1.4" => { + # TODO should be Chef::Resource::PaludisPackage + package: [ Chef::Resource::Package, Chef::Provider::Package::Paludis ], + }, }, }, }, - }, - } + } def self.create_provider_tests(providers, test, expected, filter) expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) }) diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 0842114c47..4edc3dbc78 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -52,10 +52,10 @@ describe Chef::Resource::FreebsdPackage do end end - describe "if __Freebsd_version is greater than or equal to 1000017" do + describe "if freebsd_version is greater than or equal to 1000017" do it "should be Freebsd::Pkgng" do - [1000017, 1000018, 1000500, 1001001, 1100000].each do |__freebsd_version| - @node.automatic_attrs[:os_version] = __freebsd_version + [1000017, 1000018, 1000500, 1001001, 1100000].each do |freebsd_version| + @node.automatic_attrs[:os_version] = freebsd_version @resource.after_created expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng) end @@ -71,13 +71,13 @@ describe Chef::Resource::FreebsdPackage do end end - describe "if __Freebsd_version is less than 1000017 and pkgng not enabled" do + describe "if freebsd_version is less than 1000017 and pkgng not enabled" do it "should be Freebsd::Pkg" do pkg_enabled = OpenStruct.new(:stdout => "\n") allow(@resource).to receive(:shell_out!).with("make -V WITH_PKGNG", :env => nil).and_return(pkg_enabled) - [1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version| - @node.automatic_attrs[:os_version] = __freebsd_version + [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| + @node.automatic_attrs[:os_version] = freebsd_version @resource.after_created expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkg) end diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb index e1af112dbf..3a39bc79cc 100644 --- a/spec/unit/run_list/run_list_expansion_spec.rb +++ b/spec/unit/run_list/run_list_expansion_spec.rb @@ -104,8 +104,8 @@ describe Chef::RunList::RunListExpansion do end it "produces json tree upon tracing expansion" do - jsonRunList = @expansion.to_json - expect(jsonRunList).to eq(@json) + json_run_list = @expansion.to_json + expect(json_run_list).to eq(@json) end it "has the ordered list of recipes" do |