diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
commit | 7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (patch) | |
tree | 1e390cd535b38368d091cbb33e5d419408d5ce00 /spec | |
parent | 77f8739a4741e2370e40ec39345a92a6ea393a1a (diff) | |
download | chef-7a1a6c8ef26c787e4b6dd1602f3d158b37e81720.tar.gz |
fix Layout/EmptyLineAfterGuardClause
i like this one, gives visual priority to returns or raises that are
buried in the middle of things.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/mixin/user_context_spec.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/cron_spec.rb | 1 | ||||
-rw-r--r-- | spec/functional/run_lock_spec.rb | 1 | ||||
-rw-r--r-- | spec/support/platform_helpers.rb | 6 | ||||
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/shared/unit/file_system_support.rb | 1 | ||||
-rw-r--r-- | spec/unit/mixin/which.rb | 2 | ||||
-rw-r--r-- | spec/unit/property/state_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/property/validation_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/property_spec.rb | 1 |
10 files changed, 17 insertions, 0 deletions
diff --git a/spec/functional/mixin/user_context_spec.rb b/spec/functional/mixin/user_context_spec.rb index 802b1db9f1..5beed18166 100644 --- a/spec/functional/mixin/user_context_spec.rb +++ b/spec/functional/mixin/user_context_spec.rb @@ -36,12 +36,14 @@ describe Chef::Mixin::UserContext, windows_only: true do if succeeded || last_error != Chef::ReservedNames::Win32::API::Error::ERROR_INSUFFICIENT_BUFFER raise Chef::Exceptions::Win32APIError, "Expected ERROR_INSUFFICIENT_BUFFER from GetUserNameA but it returned the following error: #{last_error}" end + user_name = FFI::MemoryPointer.new :char, (name_size.read_long) succeeded = get_user_name_a.call(user_name, name_size) last_error = FFI::LastError.error if succeeded == 0 || last_error != 0 raise Chef::Exceptions::Win32APIError, "GetUserNameA failed with #{lasterror}" end + user_name.read_string end diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index f616b84ce9..16b0d2645c 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -118,6 +118,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do def cron_attribute_should_exists(cron_name, attribute, value) return if %w{aix solaris}.include?(ohai[:platform]) + # Test if the attribute exists on newly created cron cron_should_exists(cron_name, "") expect(shell_out("crontab -l -u #{new_resource.user} | grep '#{attribute.upcase}=\"#{value}\"'").exitstatus).to eq(0) diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index 49972360ef..825f2810d4 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -334,6 +334,7 @@ describe Chef::RunLock do loop do line = readline_nonblock(read_from_process) break if line.nil? + event, time = line.split("@") example.log_event("#{name}.last_event got #{event}") example.log_event("[#{name}] #{event}", time.strip) diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 02f8c28345..509ca6e71e 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -46,6 +46,7 @@ require "wmi-lite/wmi" if windows? def windows_domain_joined? return false unless windows? + wmi = WmiLite::Wmi.new computer_system = wmi.first_of("Win32_ComputerSystem") computer_system["partofdomain"] @@ -53,11 +54,13 @@ end def windows_2012r2? return false unless windows? + (host_version && host_version.start_with?("6.3")) end def windows_gte_10? return false unless windows? + Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(host_version)) end @@ -71,6 +74,7 @@ end def windows_powershell_dsc? return false unless windows? + supports_dsc = false begin wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration") @@ -88,6 +92,7 @@ end def windows_user_right?(right) return false unless windows? + require "chef/win32/security" Chef::ReservedNames::Win32::Security.get_account_right(ENV["USERNAME"]).include?(right) end @@ -217,6 +222,7 @@ end def root? return false if windows? + Process.euid == 0 end diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 5fc9de4de7..6c0eca98be 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -111,6 +111,7 @@ module IntegrationSupport RSpec.shared_context "with a chef repo" do before :each do raise "Can only create one directory per test" if @repository_dir + @repository_dir = Dir.mktmpdir("chef_repo") Chef::Config.chef_repo_path = @repository_dir %w{client cookbook data_bag environment node role user}.each do |object_name| diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb index 32bdb1456e..d27c90a7c3 100644 --- a/spec/support/shared/unit/file_system_support.rb +++ b/spec/support/shared/unit/file_system_support.rb @@ -26,6 +26,7 @@ module FileSystemSupport if !value.is_a?(Hash) raise "memory_fs() must take a Hash" end + dir = Chef::ChefFS::FileSystem::Memory::MemoryRoot.new(pretty_name, cannot_be_in_regex) value.each do |key, child| dir.add_child(memory_fs_value(child, key.to_s, dir)) diff --git a/spec/unit/mixin/which.rb b/spec/unit/mixin/which.rb index 1764b3b89f..c47eaf37ab 100644 --- a/spec/unit/mixin/which.rb +++ b/spec/unit/mixin/which.rb @@ -88,11 +88,13 @@ describe Chef::Mixin::Which do test_which("passes in the filename as the arg", "foo1", finds: "/dir1/foo1") do |f| raise "bad arg to block" unless f == "/dir1/foo1" + true end test_which("arrays with blocks", "foo1", "foo2", finds: "/dir2/foo1", others: [ "/dir1/foo2" ]) do |f| raise "bad arg to block" unless f == "/dir2/foo1" || f == "/dir1/foo2" + true end end diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb index 5c54ec71b2..ca2cd99214 100644 --- a/spec/unit/property/state_spec.rb +++ b/spec/unit/property/state_spec.rb @@ -28,6 +28,7 @@ describe "Chef::Resource#identity and #state" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 + "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index b05d8c4e17..412fc72682 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -55,6 +55,7 @@ describe "Chef::Resource.property validation" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 + "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 56e44fd1d1..7d04e38068 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -51,6 +51,7 @@ describe "Chef::Resource.property" do def self.english_join(values) return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 + "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end |