diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-12 09:32:14 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-12 09:32:14 -0800 |
commit | 03eadde04eb219bfa8abe52d312261a5142e7266 (patch) | |
tree | b0864a3e70741f5a15f0337824f25b69fc319c07 | |
parent | 1e324f073455db7596f37da6bf21b2f6521529ce (diff) | |
download | chef-03eadde04eb219bfa8abe52d312261a5142e7266.tar.gz |
pull rubocop 0.37.2 into chefstyle
this is from the same ruleset that we had, but the new code catches more
conditions.
32 files changed, 207 insertions, 207 deletions
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index 4a39ba5ba1..2a3e35bea7 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -38,7 +38,7 @@ class Chef::Application::Knife < Chef::Application :short => "-V", :long => "--verbose", :description => "More verbose output. Use twice for max verbosity", - :proc => Proc.new { verbosity_level += 1 }, + :proc => Proc.new { verbosity_level += 1 }, :default => 0 option :color, @@ -63,7 +63,7 @@ class Chef::Application::Knife < Chef::Application :long => "--disable-editing", :description => "Do not open EDITOR, just accept the data as is", :boolean => true, - :default => false + :default => false option :help, :short => "-h", diff --git a/lib/chef/cookbook/cookbook_collection.rb b/lib/chef/cookbook/cookbook_collection.rb index 81e7bb92b4..853657fb38 100644 --- a/lib/chef/cookbook/cookbook_collection.rb +++ b/lib/chef/cookbook/cookbook_collection.rb @@ -36,7 +36,7 @@ class Chef def initialize(cookbook_versions = {}) super() do |hash, key| raise Chef::Exceptions::CookbookNotFound, "Cookbook #{key} not found. " << - "If you're loading #{key} from another cookbook, make sure you configure the dependency in your metadata" + "If you're loading #{key} from another cookbook, make sure you configure the dependency in your metadata" end cookbook_versions.each { |cookbook_name, cookbook_version| self[cookbook_name] = cookbook_version } end diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb index 8162a9aa54..bbdcf7a721 100644 --- a/lib/chef/encrypted_data_bag_item/assertions.rb +++ b/lib/chef/encrypted_data_bag_item/assertions.rb @@ -30,7 +30,7 @@ class Chef::EncryptedDataBagItem unless format_version.kind_of?(Integer) and format_version >= Chef::Config[:data_bag_decrypt_minimum_version] raise UnacceptableEncryptedDataBagItemFormat, "The encrypted data bag item has format version `#{format_version}', " + - "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'" + "but the config setting 'data_bag_decrypt_minimum_version' requires version `#{Chef::Config[:data_bag_decrypt_minimum_version]}'" end end diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index b286dad4e2..9cdb8a8522 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -36,7 +36,7 @@ class Chef attr_accessor :chef_server_rest - COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/.freeze + COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/ def initialize(chef_server_rest: nil) @name = "" @@ -123,7 +123,7 @@ class Chef result = { "name" => @name, "description" => @description, - "cookbook_versions" => @cookbook_versions, + "cookbook_versions" => @cookbook_versions, "json_class" => self.class.name, "chef_type" => "environment", "default_attributes" => @default_attributes, diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 0060fb08c7..9cd55f18dd 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -383,7 +383,7 @@ class Chef end def build_headers(method, url, headers = {}, json_body = false) - headers = @default_headers.merge(headers) + headers = @default_headers.merge(headers) headers["Content-Length"] = json_body.bytesize.to_s if json_body headers.merge!(Chef::Config[:custom_http_headers]) if Chef::Config[:custom_http_headers] headers diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index 6cd7dda251..20c46aaa8d 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -60,7 +60,7 @@ class Chef HOST_LOWER = "host".freeze - URI_SCHEME_DEFAULT_PORT = { "http" => 80, "https" => 443 }.freeze + URI_SCHEME_DEFAULT_PORT = { "http" => 80, "https" => 443 }.freeze def self.user_agent=(ua) @user_agent = ua diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb index ecacb36833..22c7ce907d 100644 --- a/lib/chef/knife/client_create.rb +++ b/lib/chef/knife/client_create.rb @@ -39,7 +39,7 @@ class Chef :boolean => true option :validator, - :long => "--validator", + :long => "--validator", :description => "Create the client as a validator.", :boolean => true diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index 9a79cd076a..01374b9b36 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -53,7 +53,7 @@ class Chef :default => "master" option :use_current_branch, - :short => "-b", + :short => "-b", :long => "--use-current-branch", :description => "Use the current branch", :boolean => true, @@ -172,7 +172,7 @@ class Chef def preferred_metadata md = Chef::Cookbook::Metadata.new - rb = File.join(@install_path, @cookbook_name, "metadata.rb") + rb = File.join(@install_path, @cookbook_name, "metadata.rb") if File.exist?(rb) md.from_file(rb) return md diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index e16e21ae64..a2d7bd4bc1 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -151,7 +151,7 @@ class Chef ui.info "Uploaded #{upload_ok} cookbook#{upload_ok > 1 ? "s" : ""}." elsif upload_failures > 0 && upload_ok > 0 ui.warn "Uploaded #{upload_ok} cookbook#{upload_ok > 1 ? "s" : ""} ok but #{upload_failures} " + - "cookbook#{upload_failures > 1 ? "s" : ""} upload failed." + "cookbook#{upload_failures > 1 ? "s" : ""} upload failed." elsif upload_failures > 0 && upload_ok == 0 ui.error "Failed to upload #{upload_failures} cookbook#{upload_failures > 1 ? "s" : ""}." exit 1 diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index a863e0cdb7..62e23cdcc1 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -188,7 +188,7 @@ validation_client_name "#{@chef_config[:validation_client_name]}" if @chef_config[:trusted_certs_dir] Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + - IO.read(File.expand_path(cert)) + "\nEOP\n" + IO.read(File.expand_path(cert)) + "\nEOP\n" end end content diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index 6802be29ef..78726feee7 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -22,8 +22,8 @@ class Chef class Knife class SubcommandLoader class GemGlobLoader < Chef::Knife::SubcommandLoader - MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+}.freeze - MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/}.freeze + MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+} + MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/} def subcommand_files @subcommand_files ||= (gem_and_builtin_subcommands.values + site_subcommands).flatten.uniq diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb index 5a9589aad8..b1782a893b 100644 --- a/lib/chef/knife/user_create.rb +++ b/lib/chef/knife/user_create.rb @@ -38,7 +38,7 @@ class Chef option :user_key, :long => "--user-key FILENAME", - :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." + :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." option :prevent_keygen, :short => "-k", diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index c423ccaa42..f749d34c51 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -105,7 +105,7 @@ class Chef def node return @node if @node raise "Could not find a value for node. If you are explicitly setting variables in a template, " + - "include a node variable if you plan to use it." + "include a node variable if you plan to use it." end # diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb index afb0d09c2d..f9a41b9fd0 100644 --- a/lib/chef/mixin/xml_escape.rb +++ b/lib/chef/mixin/xml_escape.rb @@ -64,14 +64,14 @@ class Chef CP1252 = { 128 => 8364, # euro sign 130 => 8218, # single low-9 quotation mark - 131 => 402, # latin small letter f with hook + 131 => 402, # latin small letter f with hook 132 => 8222, # double low-9 quotation mark 133 => 8230, # horizontal ellipsis 134 => 8224, # dagger 135 => 8225, # double dagger - 136 => 710, # modifier letter circumflex accent + 136 => 710, # modifier letter circumflex accent 137 => 8240, # per mille sign - 138 => 352, # latin capital letter s with caron + 138 => 352, # latin capital letter s with caron 139 => 8249, # single left-pointing angle quotation mark 140 => 338, # latin capital ligature oe 142 => 381, # latin capital letter z with caron @@ -82,9 +82,9 @@ class Chef 149 => 8226, # bullet 150 => 8211, # en dash 151 => 8212, # em dash - 152 => 732, # small tilde + 152 => 732, # small tilde 153 => 8482, # trade mark sign - 154 => 353, # latin small letter s with caron + 154 => 353, # latin small letter s with caron 155 => 8250, # single right-pointing angle quotation mark 156 => 339, # latin small ligature oe 158 => 382, # latin small letter z with caron diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 9a6e62bc5d..1c0145348a 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -257,7 +257,7 @@ class Chef named_run_list or raise ConfigurationError, "Policy '#{retrieved_policy_name}' revision '#{revision_id}' does not have named_run_list '#{named_run_list_name}'" + - "(available named_run_lists: [#{available_named_run_lists.join(', ')}])" + "(available named_run_lists: [#{available_named_run_lists.join(', ')}])" else policy["run_list"] end diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 600da540e5..854b5c01d9 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -53,9 +53,9 @@ class Chef a.assertion { !(@new_resource.revision =~ /^origin\//) } a.failure_message Chef::Exceptions::InvalidRemoteGitReference, "Deploying remote branches is not supported. " + - "Specify the remote branch as a local branch for " + - "the git repository you're deploying from " + - "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')." + "Specify the remote branch as a local branch for " + + "the git repository you're deploying from " + + "(ie: '#{@new_resource.revision.gsub('origin/', '')}' rather than '#{@new_resource.revision}')." end requirements.assert(:all_actions) do |a| @@ -65,8 +65,8 @@ class Chef a.assertion { target_revision != nil } a.failure_message Chef::Exceptions::UnresolvableGitReference, "Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. " + - "Verify your (case-sensitive) repository URL and revision.\n" + - "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}" + "Verify your (case-sensitive) repository URL and revision.\n" + + "`git ls-remote '#{@new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}" end end diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 858b430abe..1ab06a36f8 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -240,7 +240,7 @@ class Chef @r = args[2] else raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " + - "version, release'" + "version, release'" end end attr_reader :e, :v, :r @@ -349,7 +349,7 @@ class Chef @provides = args[5] else raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " + - "or 'name, epoch, version, release, arch, provides'" + "or 'name, epoch, version, release, arch, provides'" end # We always have one, ourselves! @@ -433,7 +433,7 @@ class Chef @flag = args[4] || :== else raise ArgumentError, "Expecting either 'name, epoch-version-release, flag' or " + - "'name, epoch, version, release, flag'" + "'name, epoch, version, release, flag'" end end attr_reader :name, :version, :flag @@ -1224,7 +1224,7 @@ class Chef else # we bail like yum when the package is older raise Chef::Exceptions::Package, "Installed package #{n}-#{current_version_array[idx]} is newer " + - "than candidate package #{n}-#{v}" + "than candidate package #{n}-#{v}" end end end @@ -1257,7 +1257,7 @@ class Chef yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}") else raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " + - "and release? (version-release, e.g. 1.84-10.fc6)" + "and release? (version-release, e.g. 1.84-10.fc6)" end end diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index 85bd674d8d..795a5950fb 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -98,7 +98,7 @@ class Chef a.assertion { @shadow_lib_ok } a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!" a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." + - "Note that user update converge may report false-positive on the basis of mismatched password. " + "Note that user update converge may report false-positive on the basis of mismatched password. " end requirements.assert(:modify, :lock, :unlock) do |a| a.assertion { @user_exists } diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 1570af2812..0b9d86f242 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -171,8 +171,8 @@ class Chef elsif module_name.nil? raise Exceptions::ValidationFailed, "#helpers requires either a module name or inline module code as a block.\n" + - "e.g.: helpers do; helper_code; end;\n" + - "OR: helpers(MyHelpersModule)" + "e.g.: helpers do; helper_code; end;\n" + + "OR: helpers(MyHelpersModule)" else raise Exceptions::ValidationFailed, "Argument to #helpers must be a module. You gave #{module_name.inspect} (#{module_name.class})" diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb index 2a653356dc..be24dc6ad8 100644 --- a/lib/chef/resource_collection/resource_set.rb +++ b/lib/chef/resource_collection/resource_set.rb @@ -124,7 +124,7 @@ class Chef else raise Chef::Exceptions::InvalidResourceSpecification, "The object `#{query_object.inspect}' is not valid for resource collection lookup. " + - "Use a String like `resource_type[resource_name]' or a Chef::Resource object" + "Use a String like `resource_type[resource_name]' or a Chef::Resource object" end end diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb index af9a71b246..739a463ad5 100644 --- a/lib/chef/util/dsc/configuration_generator.rb +++ b/lib/chef/util/dsc/configuration_generator.rb @@ -68,7 +68,7 @@ class Chef::Util::DSC end def get_merged_configuration_flags!(configuration_flags, configuration_name) - merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) } + merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) } if configuration_flags configuration_flags.map do |switch, value| if merged_configuration_flags.key?(switch.to_s.downcase.to_sym) diff --git a/lib/chef/win32/api.rb b/lib/chef/win32/api.rb index ad65b087cc..64db9d2b63 100644 --- a/lib/chef/win32/api.rb +++ b/lib/chef/win32/api.rb @@ -67,7 +67,7 @@ class Chef # BaseTsd.h: #ifdef (_WIN64) host.typedef int HALF_PTR; #else host.typedef short HALF_PTR; host.typedef :ulong, :HACCEL # (L) Handle to an accelerator table. WinDef.h: #host.typedef HANDLE HACCEL; # See http://msdn.microsoft.com/en-us/library/ms645526%28VS.85%29.aspx - host.typedef :size_t, :HANDLE # (L) Handle to an object. WinNT.h: #host.typedef PVOID HANDLE; + host.typedef :size_t, :HANDLE # (L) Handle to an object. WinNT.h: #host.typedef PVOID HANDLE; # todo: Platform-dependent! Need to change to :uint64 for Win64 host.typedef :ulong, :HBITMAP # (L) Handle to a bitmap: http://msdn.microsoft.com/en-us/library/dd183377%28VS.85%29.aspx host.typedef :ulong, :HBRUSH # (L) Handle to a brush. http://msdn.microsoft.com/en-us/library/dd183394%28VS.85%29.aspx diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb index 7a7f7a2ded..af345b0ea4 100644 --- a/spec/functional/resource/powershell_script_spec.rb +++ b/spec/functional/resource/powershell_script_spec.rb @@ -458,7 +458,7 @@ configuration LCM end it "evaluates a successful cmdlet exit status for not_if as true" do - resource.not_if "cd ." + resource.not_if "cd ." expect(resource.should_skip?(:run)).to be_truthy end diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index fe2abdb12a..ab324ee907 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -43,7 +43,7 @@ describe Shell do end if Time.new - start > TIMEOUT raise "did not read expected value `#{expected_value}' within #{TIMEOUT}s\n" + - "Buffer so far: `#{buffer}'" + "Buffer so far: `#{buffer}'" end end buffer diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb index 53fce39491..e8b0fa7af2 100644 --- a/spec/functional/win32/versions_spec.rb +++ b/spec/functional/win32/versions_spec.rb @@ -107,7 +107,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on if os_version_components.length < 2 raise "WMI returned a Windows version from Win32_OperatingSystem.Version " + - "with an unexpected format. The Windows version could not be determined." + "with an unexpected format. The Windows version could not be determined." end # Windows 6.0 is Windows Server 2008, so test the major and diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb index 8e6b5bfa89..d6ba709c77 100644 --- a/spec/support/shared/functional/http.rb +++ b/spec/support/shared/functional/http.rb @@ -81,7 +81,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length.png", 200, nil, { - "Content-Length" => nyan_uncompressed_size.to_s + "Content-Length" => nyan_uncompressed_size.to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -109,7 +109,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated.png", 200, nil, { - "Content-Length" => (nyan_uncompressed_size + 1).to_s + "Content-Length" => (nyan_uncompressed_size + 1).to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb index 32ce402e19..abd034833c 100644 --- a/spec/unit/knife/core/node_editor_spec.rb +++ b/spec/unit/knife/core/node_editor_spec.rb @@ -43,7 +43,7 @@ describe Chef::Knife::NodeEditor do describe '#view' do it "returns a Hash with only the name, chef_environment, normal, " + - "policy_name, policy_group, and run_list properties" do + "policy_name, policy_group, and run_list properties" do expected = node_data.select do |key,| %w{ name chef_environment normal policy_name policy_group run_list }.include?(key) @@ -74,7 +74,7 @@ describe Chef::Knife::NodeEditor do expect(ui).to have_received(:warn) .with "Changing the name of a node results in a new node being " + - "created, test_node will not be modified or removed." + "created, test_node will not be modified or removed." expect(ui).to have_received(:confirm) .with("Proceed with creation of new node") @@ -123,7 +123,7 @@ describe Chef::Knife::NodeEditor do "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } }, "policy_name" => "mypolicy", "policy_group" => "prod", - "run_list" => %w{role[drama] recipe[mystery]}, + "run_list" => %w{role[drama] recipe[mystery]}, ) end @@ -159,7 +159,7 @@ describe Chef::Knife::NodeEditor do "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } }, "policy_name" => "mypolicy", "policy_group" => "prod", - "run_list" => %w{role[drama] recipe[mystery]}, + "run_list" => %w{role[drama] recipe[mystery]}, ) end @@ -189,7 +189,7 @@ describe Chef::Knife::NodeEditor do end it 'returns an array of property names that doesn\'t include ' + - "the non-editable properties" do + "the non-editable properties" do expect(subject.updated?).to eql %w{ normal policy_name policy_group run_list } end end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 37974821d7..eacca2af2e 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -352,19 +352,19 @@ EOM end it "should return multiple attributes" do - input = { "gi" => "go", "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "gi" => "go", "hi" => "ho", "id" => "sample-data-bag-item" } @ui.config[:attribute] = %w{gi hi} expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi" => "ho" } }) end it "should handle attributes named the same as methods" do - input = { "keys" => "values", "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "keys" => "values", "hi" => "ho", "id" => "sample-data-bag-item" } @ui.config[:attribute] = "keys" expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "keys" => "values" } }) end it "should handle nested attributes named the same as methods" do - input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } @ui.config[:attribute] = "keys.keys" expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "keys.keys" => "values" } }) end @@ -377,7 +377,7 @@ EOM end it "returns nil when given an attribute path that isn't a name or attribute" do - input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } non_existing_path = "nope.nada.nothingtoseehere" @ui.config[:attribute] = non_existing_path expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { non_existing_path => nil } }) diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb index b3fc78c954..2f684b27f4 100644 --- a/spec/unit/knife/node_show_spec.rb +++ b/spec/unit/knife/node_show_spec.rb @@ -34,7 +34,7 @@ describe Chef::Knife::NodeShow do end before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" end describe "run" do diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 7170f62efb..aaca47d951 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -28,114 +28,114 @@ describe Chef::Node::Attribute do "platform_version" => "10.5.7", "platform" => "mac_os_x", "ipaddress" => "192.168.0.117", - "network" => { "default_interface" => "en1", - "interfaces" => { "vmnet1" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "1", - "addresses" => { "00:50:56:c0:00:01" => { "family" => "lladdr" }, - "192.168.110.1" => { "broadcast" => "192.168.110.255", - "netmask" => "255.255.255.0", - "family" => "inet" } }, - "mtu" => "1500", - "type" => "vmnet", - "arp" => { "192.168.110.255" => "ff:ff:ff:ff:ff:ff" }, - "encapsulation" => "Ethernet" }, - "stf0" => { "flags" => [], - "number" => "0", - "addresses" => {}, - "mtu" => "1280", - "type" => "stf", - "encapsulation" => "6to4" }, - "lo0" => { "flags" => %w{UP LOOPBACK RUNNING MULTICAST}, - "number" => "0", - "addresses" => { "::1" => { "scope" => "Node", "prefixlen" => "128", "family" => "inet6" }, - "127.0.0.1" => { "netmask" => "255.0.0.0", "family" => "inet" }, - "fe80::1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, - "mtu" => "16384", - "type" => "lo", - "encapsulation" => "Loopback" }, - "gif0" => { "flags" => %w{POINTOPOINT MULTICAST}, - "number" => "0", - "addresses" => {}, - "mtu" => "1280", - "type" => "gif", - "encapsulation" => "IPIP" }, - "vmnet8" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "8", - "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255", - "netmask" => "255.255.255.0", - "family" => "inet" }, - "00:50:56:c0:00:08" => { "family" => "lladdr" } }, - "mtu" => "1500", - "type" => "vmnet", - "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" }, - "encapsulation" => "Ethernet" }, - "en0" => { "status" => "inactive", - "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "0", - "addresses" => { "00:23:32:b0:32:f2" => { "family" => "lladdr" } }, - "mtu" => "1500", - "media" => { "supported" => { "autoselect" => { "options" => [] }, - "none" => { "options" => [] }, - "1000baseT" => { "options" => ["full-duplex", "flow-control", "hw-loopback"] }, - "10baseT/UTP" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] }, - "100baseTX" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] } }, - "selected" => { "autoselect" => { "options" => [] } } }, - "type" => "en", - "encapsulation" => "Ethernet" }, - "en1" => { "status" => "active", - "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "1", - "addresses" => { "fe80::223:6cff:fe7f:676c" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" }, - "00:23:6c:7f:67:6c" => { "family" => "lladdr" }, - "192.168.0.117" => { "broadcast" => "192.168.0.255", - "netmask" => "255.255.255.0", - "family" => "inet" } }, - "mtu" => "1500", - "media" => { "supported" => { "autoselect" => { "options" => [] } }, - "selected" => { "autoselect" => { "options" => [] } } }, - "type" => "en", - "arp" => { "192.168.0.72" => "0:f:ea:39:fa:d5", - "192.168.0.1" => "0:1c:fb:fc:6f:20", - "192.168.0.255" => "ff:ff:ff:ff:ff:ff", - "192.168.0.3" => "0:1f:33:ea:26:9b", - "192.168.0.77" => "0:23:12:70:f8:cf", - "192.168.0.152" => "0:26:8:7d:2:4c" }, - "encapsulation" => "Ethernet" }, - "en2" => { "status" => "active", - "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "2", - "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", - "netmask" => "255.255.0.0", - "family" => "inet" }, - "00:1c:42:00:00:01" => { "family" => "lladdr" }, - "fe80::21c:42ff:fe00:1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, - "mtu" => "1500", - "media" => { "supported" => { "autoselect" => { "options" => [] } }, - "selected" => { "autoselect" => { "options" => [] } } }, - "type" => "en", - "encapsulation" => "Ethernet" }, - "fw0" => { "status" => "inactive", - "flags" => %w{BROADCAST SIMPLEX MULTICAST}, - "number" => "0", - "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } }, - "mtu" => "4078", - "media" => { "supported" => { "autoselect" => { "options" => ["full-duplex"] } }, - "selected" => { "autoselect" => { "options" => ["full-duplex"] } } }, - "type" => "fw", - "encapsulation" => "1394" }, - "en3" => { "status" => "active", - "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, - "number" => "3", - "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", - "netmask" => "255.255.0.0", - "family" => "inet" }, - "00:1c:42:00:00:00" => { "family" => "lladdr" }, - "fe80::21c:42ff:fe00:0" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, - "mtu" => "1500", - "media" => { "supported" => { "autoselect" => { "options" => [] } }, - "selected" => { "autoselect" => { "options" => [] } } }, - "type" => "en", - "encapsulation" => "Ethernet" } } }, + "network" => { "default_interface" => "en1", + "interfaces" => { "vmnet1" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "1", + "addresses" => { "00:50:56:c0:00:01" => { "family" => "lladdr" }, + "192.168.110.1" => { "broadcast" => "192.168.110.255", + "netmask" => "255.255.255.0", + "family" => "inet" } }, + "mtu" => "1500", + "type" => "vmnet", + "arp" => { "192.168.110.255" => "ff:ff:ff:ff:ff:ff" }, + "encapsulation" => "Ethernet" }, + "stf0" => { "flags" => [], + "number" => "0", + "addresses" => {}, + "mtu" => "1280", + "type" => "stf", + "encapsulation" => "6to4" }, + "lo0" => { "flags" => %w{UP LOOPBACK RUNNING MULTICAST}, + "number" => "0", + "addresses" => { "::1" => { "scope" => "Node", "prefixlen" => "128", "family" => "inet6" }, + "127.0.0.1" => { "netmask" => "255.0.0.0", "family" => "inet" }, + "fe80::1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, + "mtu" => "16384", + "type" => "lo", + "encapsulation" => "Loopback" }, + "gif0" => { "flags" => %w{POINTOPOINT MULTICAST}, + "number" => "0", + "addresses" => {}, + "mtu" => "1280", + "type" => "gif", + "encapsulation" => "IPIP" }, + "vmnet8" => { "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "8", + "addresses" => { "192.168.4.1" => { "broadcast" => "192.168.4.255", + "netmask" => "255.255.255.0", + "family" => "inet" }, + "00:50:56:c0:00:08" => { "family" => "lladdr" } }, + "mtu" => "1500", + "type" => "vmnet", + "arp" => { "192.168.4.255" => "ff:ff:ff:ff:ff:ff" }, + "encapsulation" => "Ethernet" }, + "en0" => { "status" => "inactive", + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "0", + "addresses" => { "00:23:32:b0:32:f2" => { "family" => "lladdr" } }, + "mtu" => "1500", + "media" => { "supported" => { "autoselect" => { "options" => [] }, + "none" => { "options" => [] }, + "1000baseT" => { "options" => ["full-duplex", "flow-control", "hw-loopback"] }, + "10baseT/UTP" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] }, + "100baseTX" => { "options" => ["half-duplex", "full-duplex", "flow-control", "hw-loopback"] } }, + "selected" => { "autoselect" => { "options" => [] } } }, + "type" => "en", + "encapsulation" => "Ethernet" }, + "en1" => { "status" => "active", + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "1", + "addresses" => { "fe80::223:6cff:fe7f:676c" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" }, + "00:23:6c:7f:67:6c" => { "family" => "lladdr" }, + "192.168.0.117" => { "broadcast" => "192.168.0.255", + "netmask" => "255.255.255.0", + "family" => "inet" } }, + "mtu" => "1500", + "media" => { "supported" => { "autoselect" => { "options" => [] } }, + "selected" => { "autoselect" => { "options" => [] } } }, + "type" => "en", + "arp" => { "192.168.0.72" => "0:f:ea:39:fa:d5", + "192.168.0.1" => "0:1c:fb:fc:6f:20", + "192.168.0.255" => "ff:ff:ff:ff:ff:ff", + "192.168.0.3" => "0:1f:33:ea:26:9b", + "192.168.0.77" => "0:23:12:70:f8:cf", + "192.168.0.152" => "0:26:8:7d:2:4c" }, + "encapsulation" => "Ethernet" }, + "en2" => { "status" => "active", + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "2", + "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", + "netmask" => "255.255.0.0", + "family" => "inet" }, + "00:1c:42:00:00:01" => { "family" => "lladdr" }, + "fe80::21c:42ff:fe00:1" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, + "mtu" => "1500", + "media" => { "supported" => { "autoselect" => { "options" => [] } }, + "selected" => { "autoselect" => { "options" => [] } } }, + "type" => "en", + "encapsulation" => "Ethernet" }, + "fw0" => { "status" => "inactive", + "flags" => %w{BROADCAST SIMPLEX MULTICAST}, + "number" => "0", + "addresses" => { "00:23:32:ff:fe:b0:32:f2" => { "family" => "lladdr" } }, + "mtu" => "4078", + "media" => { "supported" => { "autoselect" => { "options" => ["full-duplex"] } }, + "selected" => { "autoselect" => { "options" => ["full-duplex"] } } }, + "type" => "fw", + "encapsulation" => "1394" }, + "en3" => { "status" => "active", + "flags" => %w{UP BROADCAST SMART RUNNING SIMPLEX MULTICAST}, + "number" => "3", + "addresses" => { "169.254.206.152" => { "broadcast" => "169.254.255.255", + "netmask" => "255.255.0.0", + "family" => "inet" }, + "00:1c:42:00:00:00" => { "family" => "lladdr" }, + "fe80::21c:42ff:fe00:0" => { "scope" => "Link", "prefixlen" => "64", "family" => "inet6" } }, + "mtu" => "1500", + "media" => { "supported" => { "autoselect" => { "options" => [] } }, + "selected" => { "autoselect" => { "options" => [] } } }, + "type" => "en", + "encapsulation" => "Ethernet" } } }, "fqdn" => "latte.local", "ohai_time" => 1249065590.90391, "domain" => "local", @@ -551,11 +551,11 @@ describe Chef::Node::Attribute do "place" => {}, }, { - "one" => { "four" => "five" }, + "one" => { "four" => "five" }, "snakes" => "on a plane", }, { - "one" => { "six" => "seven" }, + "one" => { "six" => "seven" }, "snack" => "cookies", }, {}, diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index 260204f98b..f11fce49db 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -29,30 +29,30 @@ describe Chef::Provider::OsxProfile do let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) } let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } let(:all_profiles) do - { "_computerlevel" => [{ "ProfileDisplayName" => "Finder Settings", - "ProfileIdentifier" => "com.apple.finder", - "ProfileInstallDate" => "2015-11-08 23:15:21 +0000", - "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.finder" => { "Forced" => [{ "mcx_preference_settings" => { "ShowExternalHardDrivesOnDesktop" => false } }] } } }, - "PayloadDisplayName" => "Custom: (com.apple.finder)", - "PayloadIdentifier" => "com.apple.finder", - "PayloadType" => "com.apple.ManagedClient.preferences", - "PayloadUUID" => "a017048f-684b-4e81-baa3-43afe316d739", - "PayloadVersion" => 1 }], - "ProfileOrganization" => "Chef", - "ProfileRemovalDisallowed" => "false", - "ProfileType" => "Configuration", - "ProfileUUID" => "e2e09bef-e673-44a6-bcbe-ecb5f1c1b740", - "ProfileVerificationState" => "unsigned", - "ProfileVersion" => 1 }, + { "_computerlevel" => [{ "ProfileDisplayName" => "Finder Settings", + "ProfileIdentifier" => "com.apple.finder", + "ProfileInstallDate" => "2015-11-08 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.finder" => { "Forced" => [{ "mcx_preference_settings" => { "ShowExternalHardDrivesOnDesktop" => false } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.finder)", + "PayloadIdentifier" => "com.apple.finder", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "a017048f-684b-4e81-baa3-43afe316d739", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "e2e09bef-e673-44a6-bcbe-ecb5f1c1b740", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }, { "ProfileDisplayName" => "ScreenSaver Settings", "ProfileIdentifier" => "com.testprofile.screensaver", "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", - "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, - "PayloadDisplayName" => "Custom: (com.apple.screensaver)", - "PayloadIdentifier" => "com.apple.screensaver", - "PayloadType" => "com.apple.ManagedClient.preferences", - "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", - "PayloadVersion" => 1 }], + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", + "PayloadVersion" => 1 }], "ProfileOrganization" => "Chef", "ProfileRemovalDisallowed" => "false", "ProfileType" => "Configuration", @@ -185,30 +185,30 @@ describe Chef::Provider::OsxProfile do let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } let(:current_resource) { Chef::Resource::OsxProfile.new("Profile Test") } let(:all_profiles) do - { "_computerlevel" => [{ "ProfileDisplayName" => "ScreenSaver Settings", - "ProfileIdentifier" => "com.apple.screensaver", - "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", - "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, - "PayloadDisplayName" => "Custom: (com.apple.screensaver)", - "PayloadIdentifier" => "com.apple.screensaver", - "PayloadType" => "com.apple.ManagedClient.preferences", - "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108", - "PayloadVersion" => 1 }], - "ProfileOrganization" => "Chef", - "ProfileRemovalDisallowed" => "false", - "ProfileType" => "Configuration", - "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc", - "ProfileVerificationState" => "unsigned", - "ProfileVersion" => 1 }, + { "_computerlevel" => [{ "ProfileDisplayName" => "ScreenSaver Settings", + "ProfileIdentifier" => "com.apple.screensaver", + "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108", + "PayloadVersion" => 1 }], + "ProfileOrganization" => "Chef", + "ProfileRemovalDisallowed" => "false", + "ProfileType" => "Configuration", + "ProfileUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc", + "ProfileVerificationState" => "unsigned", + "ProfileVersion" => 1 }, { "ProfileDisplayName" => "ScreenSaver Settings", "ProfileIdentifier" => "com.testprofile.screensaver", "ProfileInstallDate" => "2015-10-05 23:15:21 +0000", - "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, - "PayloadDisplayName" => "Custom: (com.apple.screensaver)", - "PayloadIdentifier" => "com.apple.screensaver", - "PayloadType" => "com.apple.ManagedClient.preferences", - "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", - "PayloadVersion" => 1 }], + "ProfileItems" => [{ "PayloadContent" => { "PayloadContentManagedPreferences" => { "com.apple.screensaver" => { "Forced" => [{ "mcx_preference_settings" => { "idleTime" => 0 } }] } } }, + "PayloadDisplayName" => "Custom: (com.apple.screensaver)", + "PayloadIdentifier" => "com.apple.screensaver", + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c110", + "PayloadVersion" => 1 }], "ProfileOrganization" => "Chef", "ProfileRemovalDisallowed" => "false", "ProfileType" => "Configuration", diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb index 9e99a3e32f..ea3bd88023 100644 --- a/spec/unit/rest_spec.rb +++ b/spec/unit/rest_spec.rb @@ -327,7 +327,7 @@ describe Chef::REST do context "when configured to disable compression" do let(:rest) do allow(Net::HTTP).to receive(:new).and_return(http_client) - Chef::REST.new(base_url, nil, nil, :disable_gzip => true) + Chef::REST.new(base_url, nil, nil, :disable_gzip => true) end it "does not accept encoding gzip" do |