summaryrefslogtreecommitdiff
path: root/chef-config
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-01-14 14:08:03 +0000
committerThom May <thom@chef.io>2016-01-14 14:08:03 +0000
commit51cfbdc4d16739caac4d946fadbe678444aafe34 (patch)
tree56dfd8f1cd9fd933de27268b32402e955a43ac2b /chef-config
parent05064423057d4cf46f4713b81b08829cf6d20af6 (diff)
downloadchef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go along with chef/chefstyle#5 . We should pick something and use it consistently, and my opinion is that double quotes are the appropriate thing.
Diffstat (limited to 'chef-config')
-rw-r--r--chef-config/Gemfile2
-rw-r--r--chef-config/Rakefile10
-rw-r--r--chef-config/chef-config.gemspec4
-rw-r--r--chef-config/lib/chef-config/config.rb86
-rw-r--r--chef-config/lib/chef-config/exceptions.rb4
-rw-r--r--chef-config/lib/chef-config/package_task.rb36
-rw-r--r--chef-config/lib/chef-config/path_helper.rb32
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb34
-rw-r--r--chef-config/spec/spec_helper.rb4
-rw-r--r--chef-config/spec/unit/config_spec.rb66
-rw-r--r--chef-config/spec/unit/path_helper_spec.rb22
-rw-r--r--chef-config/spec/unit/workstation_config_loader_spec.rb14
13 files changed, 158 insertions, 158 deletions
diff --git a/chef-config/Gemfile b/chef-config/Gemfile
index d39725ff87..96ab544690 100644
--- a/chef-config/Gemfile
+++ b/chef-config/Gemfile
@@ -1,4 +1,4 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
# Specify your gem's dependencies in chef-config.gemspec
gemspec
diff --git a/chef-config/Rakefile b/chef-config/Rakefile
index 36e7e2572d..ac088852cf 100644
--- a/chef-config/Rakefile
+++ b/chef-config/Rakefile
@@ -1,14 +1,14 @@
-require 'rspec/core/rake_task'
-require 'chef-config/package_task'
+require "rspec/core/rake_task"
+require "chef-config/package_task"
-ChefConfig::PackageTask.new(File.expand_path('..', __FILE__), 'ChefConfig') do |package|
- package.module_path = 'chef-config'
+ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "ChefConfig") do |package|
+ package.module_path = "chef-config"
end
task :default => :spec
desc "Run standard specs"
RSpec::Core::RakeTask.new(:spec) do |t|
- t.pattern = FileList['spec/**/*_spec.rb']
+ t.pattern = FileList["spec/**/*_spec.rb"]
end
diff --git a/chef-config/chef-config.gemspec b/chef-config/chef-config.gemspec
index 6619f04169..f67f3010ca 100644
--- a/chef-config/chef-config.gemspec
+++ b/chef-config/chef-config.gemspec
@@ -1,7 +1,7 @@
# coding: utf-8
-lib = File.expand_path('../lib', __FILE__)
+lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'chef-config/version'
+require "chef-config/version"
Gem::Specification.new do |spec|
spec.name = "chef-config"
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 1ad6266d14..81e9cf3f68 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -19,14 +19,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'mixlib/config'
-require 'pathname'
+require "mixlib/config"
+require "pathname"
-require 'chef-config/logger'
-require 'chef-config/windows'
-require 'chef-config/path_helper'
-require 'mixlib/shellout'
-require 'uri'
+require "chef-config/logger"
+require "chef-config/windows"
+require "chef-config/path_helper"
+require "mixlib/shellout"
+require "uri"
module ChefConfig
@@ -49,8 +49,8 @@ module ChefConfig
path = PathHelper.cleanpath(path)
if ChefConfig.windows?
# turns \etc\chef\client.rb and \var\chef\client.rb into C:/chef/client.rb
- if env['SYSTEMDRIVE'] && path[0] == '\\' && path.split('\\')[2] == 'chef'
- path = PathHelper.join(env['SYSTEMDRIVE'], path.split('\\', 3)[2])
+ if env["SYSTEMDRIVE"] && path[0] == '\\' && path.split('\\')[2] == "chef"
+ path = PathHelper.join(env["SYSTEMDRIVE"], path.split('\\', 3)[2])
end
end
path
@@ -107,10 +107,10 @@ module ChefConfig
default :chef_repo_path do
if self.configuration[:cookbook_path]
if self.configuration[:cookbook_path].kind_of?(String)
- File.expand_path('..', self.configuration[:cookbook_path])
+ File.expand_path("..", self.configuration[:cookbook_path])
else
self.configuration[:cookbook_path].map do |path|
- File.expand_path('..', path)
+ File.expand_path("..", path)
end
end
else
@@ -123,7 +123,7 @@ module ChefConfig
# This allows us to run config-free.
path = cwd
until File.directory?(PathHelper.join(path, "cookbooks"))
- new_path = File.expand_path('..', path)
+ new_path = File.expand_path("..", path)
if new_path == path
ChefConfig.logger.warn("No cookbooks directory found at or above current directory. Assuming #{Dir.pwd}.")
return Dir.pwd
@@ -145,66 +145,66 @@ module ChefConfig
# Location of acls on disk. String or array of strings.
# Defaults to <chef_repo_path>/acls.
# Only applies to Enterprise Chef commands.
- default(:acl_path) { derive_path_from_chef_repo_path('acls') }
+ default(:acl_path) { derive_path_from_chef_repo_path("acls") }
# Location of clients on disk. String or array of strings.
# Defaults to <chef_repo_path>/acls.
- default(:client_path) { derive_path_from_chef_repo_path('clients') }
+ default(:client_path) { derive_path_from_chef_repo_path("clients") }
# Location of cookbooks on disk. String or array of strings.
# Defaults to <chef_repo_path>/cookbooks. If chef_repo_path
# is not specified, this is set to [/var/chef/cookbooks, /var/chef/site-cookbooks]).
default(:cookbook_path) do
if self.configuration[:chef_repo_path]
- derive_path_from_chef_repo_path('cookbooks')
+ derive_path_from_chef_repo_path("cookbooks")
else
- Array(derive_path_from_chef_repo_path('cookbooks')).flatten +
- Array(derive_path_from_chef_repo_path('site-cookbooks')).flatten
+ Array(derive_path_from_chef_repo_path("cookbooks")).flatten +
+ Array(derive_path_from_chef_repo_path("site-cookbooks")).flatten
end
end
# Location of containers on disk. String or array of strings.
# Defaults to <chef_repo_path>/containers.
# Only applies to Enterprise Chef commands.
- default(:container_path) { derive_path_from_chef_repo_path('containers') }
+ default(:container_path) { derive_path_from_chef_repo_path("containers") }
# Location of data bags on disk. String or array of strings.
# Defaults to <chef_repo_path>/data_bags.
- default(:data_bag_path) { derive_path_from_chef_repo_path('data_bags') }
+ default(:data_bag_path) { derive_path_from_chef_repo_path("data_bags") }
# Location of environments on disk. String or array of strings.
# Defaults to <chef_repo_path>/environments.
- default(:environment_path) { derive_path_from_chef_repo_path('environments') }
+ default(:environment_path) { derive_path_from_chef_repo_path("environments") }
# Location of groups on disk. String or array of strings.
# Defaults to <chef_repo_path>/groups.
# Only applies to Enterprise Chef commands.
- default(:group_path) { derive_path_from_chef_repo_path('groups') }
+ default(:group_path) { derive_path_from_chef_repo_path("groups") }
# Location of nodes on disk. String or array of strings.
# Defaults to <chef_repo_path>/nodes.
- default(:node_path) { derive_path_from_chef_repo_path('nodes') }
+ default(:node_path) { derive_path_from_chef_repo_path("nodes") }
# Location of policies on disk. String or array of strings.
# Defaults to <chef_repo_path>/policies.
- default(:policy_path) { derive_path_from_chef_repo_path('policies') }
+ default(:policy_path) { derive_path_from_chef_repo_path("policies") }
# Location of policy_groups on disk. String or array of strings.
# Defaults to <chef_repo_path>/policy_groups.
- default(:policy_group_path) { derive_path_from_chef_repo_path('policy_groups') }
+ default(:policy_group_path) { derive_path_from_chef_repo_path("policy_groups") }
# Location of roles on disk. String or array of strings.
# Defaults to <chef_repo_path>/roles.
- default(:role_path) { derive_path_from_chef_repo_path('roles') }
+ default(:role_path) { derive_path_from_chef_repo_path("roles") }
# Location of users on disk. String or array of strings.
# Defaults to <chef_repo_path>/users.
# Does not apply to Enterprise Chef commands.
- default(:user_path) { derive_path_from_chef_repo_path('users') }
+ default(:user_path) { derive_path_from_chef_repo_path("users") }
# Location of policies on disk. String or array of strings.
# Defaults to <chef_repo_path>/policies.
- default(:policy_path) { derive_path_from_chef_repo_path('policies') }
+ default(:policy_path) { derive_path_from_chef_repo_path("policies") }
# Turn on "path sanity" by default. See also: http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity
default :enforce_path_sanity, true
@@ -222,7 +222,7 @@ module ChefConfig
# this is under the user's home directory.
default(:cache_path) do
if local_mode
- PathHelper.join(config_dir, 'local-mode-cache')
+ PathHelper.join(config_dir, "local-mode-cache")
else
primary_cache_root = platform_specific_path("/var")
primary_cache_path = platform_specific_path("/var/chef")
@@ -231,7 +231,7 @@ module ChefConfig
# Otherwise, we'll create .chef under the user's home directory and use that as
# the cache path.
unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root)
- secondary_cache_path = PathHelper.join(user_home, '.chef')
+ secondary_cache_path = PathHelper.join(user_home, ".chef")
ChefConfig.logger.info("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
secondary_cache_path
else
@@ -318,7 +318,7 @@ module ChefConfig
config_context :chef_zero do
config_strict_mode true
default(:enabled) { ChefConfig::Config.local_mode }
- default :host, 'localhost'
+ default :host, "localhost"
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
end
default :chef_server_url, "https://localhost:443"
@@ -327,7 +327,7 @@ module ChefConfig
# if the chef_server_url is a path to an organization, aka
# 'some_url.../organizations/*' then remove the '/organization/*' by default
if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/
- self.configuration[:chef_server_url].split('/')[0..-3].join('/')
+ self.configuration[:chef_server_url].split("/")[0..-3].join("/")
elsif self.configuration[:chef_server_url] # default to whatever chef_server_url is
self.configuration[:chef_server_url]
else
@@ -742,7 +742,7 @@ module ChefConfig
# pass = password
# @api private
def self.export_proxy(scheme, path, user, pass)
- path = "#{scheme}://#{path}" unless path.include?('://')
+ path = "#{scheme}://#{path}" unless path.include?("://")
# URI.split returns the following parts:
# [scheme, userinfo, host, port, registry, path, opaque, query, fragment]
parts = URI.split(URI.encode(path))
@@ -750,7 +750,7 @@ module ChefConfig
# returns a string for the port.
parts[3] = parts[3].to_i if parts[3]
if user && !user.empty?
- userinfo = URI.encode(URI.encode(user), '@:')
+ userinfo = URI.encode(URI.encode(user), "@:")
if pass
userinfo << ":#{URI.encode(URI.encode(pass), '@:')}"
end
@@ -764,8 +764,8 @@ module ChefConfig
# @api private
def self.export_no_proxy(value)
- ENV['no_proxy'] = value unless ENV['no_proxy']
- ENV['NO_PROXY'] = value unless ENV['NO_PROXY']
+ ENV["no_proxy"] = value unless ENV["no_proxy"]
+ ENV["NO_PROXY"] = value unless ENV["NO_PROXY"]
end
# Chef requires an English-language UTF-8 locale to function properly. We attempt
@@ -793,12 +793,12 @@ module ChefConfig
cmd.error!
locales = cmd.stdout.split
case
- when locales.include?('C.UTF-8')
- 'C.UTF-8'
- when locales.include?('en_US.UTF-8'), locales.include?('en_US.utf8')
- 'en_US.UTF-8'
- when locales.include?('en.UTF-8')
- 'en.UTF-8'
+ when locales.include?("C.UTF-8")
+ "C.UTF-8"
+ when locales.include?("en_US.UTF-8"), locales.include?("en_US.utf8")
+ "en_US.UTF-8"
+ when locales.include?("en.UTF-8")
+ "en.UTF-8"
else
# Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8
guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i }
@@ -808,7 +808,7 @@ module ChefConfig
guessed_locale.gsub(/UTF-?8$/i, "UTF-8")
else
ChefConfig.logger.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support."
- 'C'
+ "C"
end
end
rescue
@@ -817,7 +817,7 @@ module ChefConfig
else
ChefConfig.logger.debug "No usable locale -a command found, assuming you have en_US.UTF-8 installed."
end
- 'en_US.UTF-8'
+ "en_US.UTF-8"
end
default :internal_locale, guess_internal_locale
diff --git a/chef-config/lib/chef-config/exceptions.rb b/chef-config/lib/chef-config/exceptions.rb
index 1f80e505df..b4efe17329 100644
--- a/chef-config/lib/chef-config/exceptions.rb
+++ b/chef-config/lib/chef-config/exceptions.rb
@@ -15,8 +15,8 @@
# limitations under the License.
#
-require 'chef-config/windows'
-require 'chef-config/logger'
+require "chef-config/windows"
+require "chef-config/logger"
module ChefConfig
diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb
index 2e9b36d939..59620ad03a 100644
--- a/chef-config/lib/chef-config/package_task.rb
+++ b/chef-config/lib/chef-config/package_task.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'rake'
-require 'rubygems'
-require 'rubygems/package_task'
+require "rake"
+require "rubygems"
+require "rubygems/package_task"
module ChefConfig
class PackageTask < Rake::TaskLib
@@ -70,9 +70,9 @@ module ChefConfig
@module_name = module_name
@component_paths = []
@module_path = nil
- @version_file_path = 'VERSION'
- @package_dir = 'pkg'
- @git_remote = 'origin'
+ @version_file_path = "VERSION"
+ @package_dir = "pkg"
+ @git_remote = "origin"
@generate_version_class = false
end
@@ -93,7 +93,7 @@ module ChefConfig
end
def class_or_module
- generate_version_class ? 'class' : 'module'
+ generate_version_class ? "class" : "module"
end
def with_clean_env(&block)
@@ -105,46 +105,46 @@ module ChefConfig
end
def define
- raise 'Need to provide package root and module name' if root_path.nil? || module_name.nil?
+ raise "Need to provide package root and module name" if root_path.nil? || module_name.nil?
- desc 'Build Gems of component dependencies'
+ desc "Build Gems of component dependencies"
task :package_components do
component_full_paths.each do |component_path|
Dir.chdir(component_path) do
- sh 'rake package'
+ sh "rake package"
end
end
end
task :package => :package_components
- desc 'Build and install component dependencies'
+ desc "Build and install component dependencies"
task :install_components => :package_components do
component_full_paths.each do |component_path|
Dir.chdir(component_path) do
- sh 'rake install'
+ sh "rake install"
end
end
end
task :install => :install_components
- desc 'Clean up builds of component dependencies'
+ desc "Clean up builds of component dependencies"
task :clobber_component_packages do
component_full_paths.each do |component_path|
Dir.chdir(component_path) do
- sh 'rake clobber_package'
+ sh "rake clobber_package"
end
end
end
task :clobber_package => :clobber_component_packages
- desc 'Update the version number for component dependencies'
+ desc "Update the version number for component dependencies"
task :update_components_versions do
component_full_paths.each do |component_path|
Dir.chdir(component_path) do
- sh 'rake version'
+ sh "rake version"
end
end
end
@@ -209,11 +209,11 @@ end
sh %{gem uninstall #{module_path} -x -v #{version} }
end
- desc 'Build it, tag it and ship it'
+ desc "Build it, tag it and ship it"
task :ship => [:clobber_package, :gem] do
sh("git tag #{version}")
sh("git push #{git_remote} --tags")
- Dir[File.expand_path('*.gem', full_package_dir)].reverse.each do |built_gem|
+ Dir[File.expand_path("*.gem", full_package_dir)].reverse.each do |built_gem|
sh("gem push #{built_gem}")
end
end
diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb
index ce6c440571..05c1cb88b7 100644
--- a/chef-config/lib/chef-config/path_helper.rb
+++ b/chef-config/lib/chef-config/path_helper.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'chef-config/windows'
-require 'chef-config/logger'
-require 'chef-config/exceptions'
+require "chef-config/windows"
+require "chef-config/logger"
+require "chef-config/exceptions"
module ChefConfig
class PathHelper
@@ -32,7 +32,7 @@ module ChefConfig
loop do
slash = path.rindex(/[#{Regexp.escape(File::SEPARATOR)}#{Regexp.escape(path_separator)}]/, end_slash - 1)
if !slash
- return end_slash == path.size ? '.' : path_separator
+ return end_slash == path.size ? "." : path_separator
elsif slash == end_slash - 1
end_slash = slash
else
@@ -64,8 +64,8 @@ module ChefConfig
leading_slashes = /^[#{path_separator_regex}]+/
args.flatten.inject() do |joined_path, component|
- joined_path = joined_path.sub(trailing_slashes, '')
- component = component.sub(leading_slashes, '')
+ joined_path = joined_path.sub(trailing_slashes, "")
+ component = component.sub(leading_slashes, "")
joined_path += "#{path_separator}#{component}"
end
end
@@ -201,12 +201,12 @@ module ChefConfig
# HOMESHARE HOMEPATH
# USERPROFILE
- paths << ENV['HOME']
- paths << ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
- paths << ENV['HOMESHARE'] + ENV['HOMEPATH'] if ENV['HOMESHARE'] && ENV['HOMEPATH']
- paths << ENV['USERPROFILE']
+ paths << ENV["HOME"]
+ paths << ENV["HOMEDRIVE"] + ENV["HOMEPATH"] if ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
+ paths << ENV["HOMESHARE"] + ENV["HOMEPATH"] if ENV["HOMESHARE"] && ENV["HOMEPATH"]
+ paths << ENV["USERPROFILE"]
end
- paths << Dir.home if ENV['HOME']
+ paths << Dir.home if ENV["HOME"]
# Depending on what environment variables we're using, the slashes can go in any which way.
# Just change them all to / to keep things consistent.
@@ -231,10 +231,10 @@ module ChefConfig
# Determine if the given path is protected by OS X System Integrity Protection.
def self.is_sip_path?(path, node)
- if node['platform'] == 'mac_os_x' and Gem::Version.new(node['platform_version']) >= Gem::Version.new('10.11')
+ if node["platform"] == "mac_os_x" and Gem::Version.new(node["platform_version"]) >= Gem::Version.new("10.11")
# todo: parse rootless.conf for this?
sip_paths= [
- '/System', '/bin', '/sbin', '/usr'
+ "/System", "/bin", "/sbin", "/usr"
]
sip_paths.each do |sip_path|
ChefConfig.logger.info("This is a SIP path, checking if it in exceptions list.")
@@ -249,9 +249,9 @@ module ChefConfig
def self.writable_sip_path?(path)
# todo: parse rootless.conf for this?
sip_exceptions = [
- '/System/Library/Caches', '/System/Library/Extensions',
- '/System/Library/Speech', '/System/Library/User Template',
- '/usr/libexec/cups', '/usr/local', '/usr/share/man'
+ "/System/Library/Caches", "/System/Library/Extensions",
+ "/System/Library/Speech", "/System/Library/User Template",
+ "/usr/libexec/cups", "/usr/local", "/usr/share/man"
]
sip_exceptions.each do |exception_path|
return true if path.start_with?(exception_path)
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 2c5e2dec8a..dd2a5bb9ad 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
- VERSION = '12.6.0'
+ VERSION = "12.6.0"
end
#
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index 177cd776d4..ec291b80a7 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -16,11 +16,11 @@
# limitations under the License.
#
-require 'chef-config/config'
-require 'chef-config/exceptions'
-require 'chef-config/logger'
-require 'chef-config/path_helper'
-require 'chef-config/windows'
+require "chef-config/config"
+require "chef-config/exceptions"
+require "chef-config/logger"
+require "chef-config/path_helper"
+require "chef-config/windows"
module ChefConfig
class WorkstationConfigLoader
@@ -99,24 +99,24 @@ module ChefConfig
candidate_configs = []
# Look for $KNIFE_HOME/knife.rb (allow multiple knives config on same machine)
- if env['KNIFE_HOME']
- candidate_configs << File.join(env['KNIFE_HOME'], 'config.rb')
- candidate_configs << File.join(env['KNIFE_HOME'], 'knife.rb')
+ if env["KNIFE_HOME"]
+ candidate_configs << File.join(env["KNIFE_HOME"], "config.rb")
+ candidate_configs << File.join(env["KNIFE_HOME"], "knife.rb")
end
# Look for $PWD/knife.rb
if Dir.pwd
- candidate_configs << File.join(Dir.pwd, 'config.rb')
- candidate_configs << File.join(Dir.pwd, 'knife.rb')
+ candidate_configs << File.join(Dir.pwd, "config.rb")
+ candidate_configs << File.join(Dir.pwd, "knife.rb")
end
# Look for $UPWARD/.chef/knife.rb
if chef_config_dir
- candidate_configs << File.join(chef_config_dir, 'config.rb')
- candidate_configs << File.join(chef_config_dir, 'knife.rb')
+ candidate_configs << File.join(chef_config_dir, "config.rb")
+ candidate_configs << File.join(chef_config_dir, "knife.rb")
end
# Look for $HOME/.chef/knife.rb
- PathHelper.home('.chef') do |dot_chef_dir|
- candidate_configs << File.join(dot_chef_dir, 'config.rb')
- candidate_configs << File.join(dot_chef_dir, 'knife.rb')
+ PathHelper.home(".chef") do |dot_chef_dir|
+ candidate_configs << File.join(dot_chef_dir, "config.rb")
+ candidate_configs << File.join(dot_chef_dir, "knife.rb")
end
candidate_configs.find do | candidate_config |
@@ -126,9 +126,9 @@ module ChefConfig
def working_directory
a = if ChefConfig.windows?
- env['CD']
+ env["CD"]
else
- env['PWD']
+ env["PWD"]
end || Dir.pwd
a
diff --git a/chef-config/spec/spec_helper.rb b/chef-config/spec/spec_helper.rb
index df9461cde9..107becb9eb 100644
--- a/chef-config/spec/spec_helper.rb
+++ b/chef-config/spec/spec_helper.rb
@@ -1,4 +1,4 @@
-require 'chef-config/windows'
+require "chef-config/windows"
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
@@ -53,7 +53,7 @@ RSpec.configure do |config|
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
- config.default_formatter = 'doc'
+ config.default_formatter = "doc"
end
# Print the 10 slowest examples and example groups at the
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 8c20b0bef8..5983981ddd 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef-config/config'
+require "spec_helper"
+require "chef-config/config"
RSpec.describe ChefConfig::Config do
before(:each) do
@@ -28,7 +28,7 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.treat_deprecation_warnings_as_errors(true)
# Set environment variable so the setting persists in child processes
- ENV['CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS'] = "1"
+ ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"] = "1"
end
describe "config attribute writer: chef_server_url" do
@@ -123,7 +123,7 @@ RSpec.describe ChefConfig::Config do
if is_windows
it "should return a windows path on windows systems" do
path = "/etc/chef/cookbooks"
- allow(ChefConfig::Config).to receive(:env).and_return({ 'SYSTEMDRIVE' => 'C:' })
+ allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
# match on a regex that looks for the base path with an optional
# system drive at the beginning (c:)
# system drive is not hardcoded b/c it can change and b/c it is not present on linux systems
@@ -156,10 +156,10 @@ RSpec.describe ChefConfig::Config do
before do
if is_windows
- allow(ChefConfig::Config).to receive(:env).and_return({ 'SYSTEMDRIVE' => 'C:' })
+ allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
ChefConfig::Config[:user_home] = 'C:\Users\charlie'
else
- ChefConfig::Config[:user_home] = '/Users/charlie'
+ ChefConfig::Config[:user_home] = "/Users/charlie"
end
allow(ChefConfig::Config).to receive(:path_accessible?).and_return(false)
@@ -250,21 +250,21 @@ RSpec.describe ChefConfig::Config do
context "and config_dir is /a/b/c" do
before do
- ChefConfig::Config.config_dir to_platform('/a/b/c')
+ ChefConfig::Config.config_dir to_platform("/a/b/c")
end
it "cache_path is /a/b/c/local-mode-cache" do
- expect(ChefConfig::Config.cache_path).to eq(to_platform('/a/b/c/local-mode-cache'))
+ expect(ChefConfig::Config.cache_path).to eq(to_platform("/a/b/c/local-mode-cache"))
end
end
context "and config_dir is /a/b/c/" do
before do
- ChefConfig::Config.config_dir to_platform('/a/b/c/')
+ ChefConfig::Config.config_dir to_platform("/a/b/c/")
end
it "cache_path is /a/b/c/local-mode-cache" do
- expect(ChefConfig::Config.cache_path).to eq(to_platform('/a/b/c/local-mode-cache'))
+ expect(ChefConfig::Config.cache_path).to eq(to_platform("/a/b/c/local-mode-cache"))
end
end
end
@@ -326,7 +326,7 @@ RSpec.describe ChefConfig::Config do
it "does not set derived paths at FS root" do
ChefConfig::Config.local_mode = true
- expect(ChefConfig::Config.cache_path.downcase).to eq(to_platform(File.join(Dir.pwd, 'local-mode-cache')).downcase)
+ expect(ChefConfig::Config.cache_path.downcase).to eq(to_platform(File.join(Dir.pwd, "local-mode-cache")).downcase)
end
end
@@ -371,7 +371,7 @@ RSpec.describe ChefConfig::Config do
end
it "config_dir is /home/charlie/.chef/" do
- expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ''))
+ expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ""))
end
context "and chef is running in local mode" do
@@ -380,7 +380,7 @@ RSpec.describe ChefConfig::Config do
end
it "config_dir is /home/charlie/.chef/" do
- expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ''))
+ expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ""))
end
end
end
@@ -468,7 +468,7 @@ RSpec.describe ChefConfig::Config do
describe "ChefConfig::Config[:user_valid_regex]" do
context "on a platform that is not Windows" do
it "allows one letter usernames" do
- any_match = ChefConfig::Config[:user_valid_regex].any? { |regex| regex.match('a') }
+ any_match = ChefConfig::Config[:user_valid_regex].any? { |regex| regex.match("a") }
expect(any_match).to be_truthy
end
end
@@ -543,7 +543,7 @@ RSpec.describe ChefConfig::Config do
it "should fall back to C locale" do
expect(ChefConfig.logger).to receive(:warn).with("Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support.")
- expect(ChefConfig::Config.guess_internal_locale).to eq 'C'
+ expect(ChefConfig::Config.guess_internal_locale).to eq "C"
end
end
@@ -585,8 +585,8 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.http_proxy_pass = proxy_pass
end
it "exports ENV['http_proxy']" do
- expect(ENV).to receive(:[]=).with('http_proxy', "http://http_user:http_pass@localhost:7979")
- expect(ENV).to receive(:[]=).with('HTTP_PROXY', "http://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("http_proxy", "http://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://http_user:http_pass@localhost:7979")
ChefConfig::Config.export_proxies
end
end
@@ -598,8 +598,8 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.https_proxy_pass = proxy_pass
end
it "exports ENV['https_proxy']" do
- expect(ENV).to receive(:[]=).with('https_proxy', "https://http_user:http_pass@localhost:7979")
- expect(ENV).to receive(:[]=).with('HTTPS_PROXY', "https://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("https_proxy", "https://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("HTTPS_PROXY", "https://http_user:http_pass@localhost:7979")
ChefConfig::Config.export_proxies
end
end
@@ -611,16 +611,16 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.ftp_proxy_pass = proxy_pass
end
it "exports ENV['ftp_proxy']" do
- expect(ENV).to receive(:[]=).with('ftp_proxy', "ftp://http_user:http_pass@localhost:7979")
- expect(ENV).to receive(:[]=).with('FTP_PROXY', "ftp://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("ftp_proxy", "ftp://http_user:http_pass@localhost:7979")
+ expect(ENV).to receive(:[]=).with("FTP_PROXY", "ftp://http_user:http_pass@localhost:7979")
ChefConfig::Config.export_proxies
end
end
shared_examples "no user pass" do
it "does not populate the user or password" do
- expect(ENV).to receive(:[]=).with('http_proxy', "http://localhost:7979")
- expect(ENV).to receive(:[]=).with('HTTP_PROXY', "http://localhost:7979")
+ expect(ENV).to receive(:[]=).with("http_proxy", "http://localhost:7979")
+ expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://localhost:7979")
ChefConfig::Config.export_proxies
end
end
@@ -646,8 +646,8 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.http_proxy = "localhost:1111"
end
it "automatically adds the scheme to the proxy url" do
- expect(ENV).to receive(:[]=).with('http_proxy', "http://localhost:1111")
- expect(ENV).to receive(:[]=).with('HTTP_PROXY', "http://localhost:1111")
+ expect(ENV).to receive(:[]=).with("http_proxy", "http://localhost:1111")
+ expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://localhost:1111")
ChefConfig::Config.export_proxies
end
end
@@ -655,10 +655,10 @@ RSpec.describe ChefConfig::Config do
shared_examples "no export" do
it "does not export any proxy settings" do
ChefConfig::Config.export_proxies
- expect(ENV['http_proxy']).to eq(nil)
- expect(ENV['https_proxy']).to eq(nil)
- expect(ENV['ftp_proxy']).to eq(nil)
- expect(ENV['no_proxy']).to eq(nil)
+ expect(ENV["http_proxy"]).to eq(nil)
+ expect(ENV["https_proxy"]).to eq(nil)
+ expect(ENV["ftp_proxy"]).to eq(nil)
+ expect(ENV["no_proxy"]).to eq(nil)
end
end
@@ -683,8 +683,8 @@ RSpec.describe ChefConfig::Config do
ChefConfig::Config.no_proxy = "localhost"
end
it "exports ENV['no_proxy']" do
- expect(ENV).to receive(:[]=).with('no_proxy', "localhost")
- expect(ENV).to receive(:[]=).with('NO_PROXY', "localhost")
+ expect(ENV).to receive(:[]=).with("no_proxy", "localhost")
+ expect(ENV).to receive(:[]=).with("NO_PROXY", "localhost")
ChefConfig::Config.export_proxies
end
end
@@ -707,7 +707,7 @@ RSpec.describe ChefConfig::Config do
end
it "sets CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS environment variable" do
- expect(ENV['CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS']).to eq("1")
+ expect(ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"]).to eq("1")
end
it "treats deprecation warnings as errors in child processes when testing" do
@@ -725,7 +725,7 @@ RSpec.describe ChefConfig::Config do
context "outside of our test environment" do
before do
- ENV.delete('CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS')
+ ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
ChefConfig::Config.reset
end
diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb
index 3e2a0fd129..8b2fe62ce6 100644
--- a/chef-config/spec/unit/path_helper_spec.rb
+++ b/chef-config/spec/unit/path_helper_spec.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'chef-config/path_helper'
-require 'spec_helper'
+require "chef-config/path_helper"
+require "spec_helper"
RSpec.describe ChefConfig::PathHelper do
@@ -27,30 +27,30 @@ RSpec.describe ChefConfig::PathHelper do
describe "join" do
it "joins starting with '' resolve to absolute paths" do
- expect(path_helper.join('', 'a', 'b')).to eq("#{path_helper.path_separator}a#{path_helper.path_separator}b")
+ expect(path_helper.join("", "a", "b")).to eq("#{path_helper.path_separator}a#{path_helper.path_separator}b")
end
it "joins ending with '' add a / to the end" do
- expect(path_helper.join('a', 'b', '')).to eq("a#{path_helper.path_separator}b#{path_helper.path_separator}")
+ expect(path_helper.join("a", "b", "")).to eq("a#{path_helper.path_separator}b#{path_helper.path_separator}")
end
end
describe "dirname" do
it "dirname('abc') is '.'" do
- expect(path_helper.dirname('abc')).to eq('.')
+ expect(path_helper.dirname("abc")).to eq(".")
end
it "dirname('/') is '/'" do
expect(path_helper.dirname(path_helper.path_separator)).to eq(path_helper.path_separator)
end
it "dirname('a/b/c') is 'a/b'" do
- expect(path_helper.dirname(path_helper.join('a', 'b', 'c'))).to eq(path_helper.join('a', 'b'))
+ expect(path_helper.dirname(path_helper.join("a", "b", "c"))).to eq(path_helper.join("a", "b"))
end
it "dirname('a/b/c/') is 'a/b'" do
- expect(path_helper.dirname(path_helper.join('a', 'b', 'c', ''))).to eq(path_helper.join('a', 'b'))
+ expect(path_helper.dirname(path_helper.join("a", "b", "c", ""))).to eq(path_helper.join("a", "b"))
end
it "dirname('/a/b/c') is '/a/b'" do
- expect(path_helper.dirname(path_helper.join('', 'a', 'b', 'c'))).to eq(path_helper.join('', 'a', 'b'))
+ expect(path_helper.dirname(path_helper.join("", "a", "b", "c"))).to eq(path_helper.join("", "a", "b"))
end
end
end
@@ -113,11 +113,11 @@ RSpec.describe ChefConfig::PathHelper do
include_examples("common_functionality")
it "path_separator is /" do
- expect(path_helper.path_separator).to eq('/')
+ expect(path_helper.path_separator).to eq("/")
end
it "cleanpath removes extra slashes alone" do
- expect(path_helper.cleanpath('/a///b/c/d/')).to eq('/a/b/c/d')
+ expect(path_helper.cleanpath("/a///b/c/d/")).to eq("/a/b/c/d")
end
describe "platform-specific #join behavior" do
@@ -269,7 +269,7 @@ RSpec.describe ChefConfig::PathHelper do
describe "all_homes" do
before do
- stub_const('ENV', env)
+ stub_const("ENV", env)
allow(ChefConfig).to receive(:windows?).and_return(is_windows)
end
diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb
index 9f24a4f11b..77e573c776 100644
--- a/chef-config/spec/unit/workstation_config_loader_spec.rb
+++ b/chef-config/spec/unit/workstation_config_loader_spec.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
-require 'chef-config/exceptions'
-require 'chef-config/windows'
-require 'chef-config/workstation_config_loader'
+require "chef-config/exceptions"
+require "chef-config/windows"
+require "chef-config/workstation_config_loader"
RSpec.describe ChefConfig::WorkstationConfigLoader do
@@ -45,7 +45,7 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
end
it "tests a path's existence" do
- expect(config_loader.path_exists?('/nope/nope/nope/nope/frab/jab/nab')).to be(false)
+ expect(config_loader.path_exists?("/nope/nope/nope/nope/frab/jab/nab")).to be(false)
expect(config_loader.path_exists?(__FILE__)).to be(true)
end
@@ -68,7 +68,7 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
let(:home) { "/Users/example.user" }
before do
- allow(ChefConfig::PathHelper).to receive(:home).with('.chef').and_yield(File.join(home, '.chef'))
+ allow(ChefConfig::PathHelper).to receive(:home).with(".chef").and_yield(File.join(home, ".chef"))
allow(config_loader).to receive(:path_exists?).with("#{home}/.chef/knife.rb").and_return(true)
end