summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-07-13 13:44:20 -0700
committerPete Higgins <pete@peterhiggins.org>2020-07-13 13:44:20 -0700
commit5a4b11abacfd3e50107f048e6a9910fc11bdb1ef (patch)
treec0b6275838bd9e68f0d0d3dd9d1519661ed427b6
parent04eac6a86e51d71cdbfbe163ebb70a887c1c9ddb (diff)
downloadchef-5a4b11abacfd3e50107f048e6a9910fc11bdb1ef.tar.gz
Fix two warnings in tests.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--spec/unit/win32/security_spec.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/spec/unit/win32/security_spec.rb b/spec/unit/win32/security_spec.rb
index d90951c3e2..ed4c033aa3 100644
--- a/spec/unit/win32/security_spec.rb
+++ b/spec/unit/win32/security_spec.rb
@@ -81,9 +81,10 @@ describe "Chef::Win32::Security", :windows_only do
context "when the user has admin privileges" do
it "returns true" do
- allow(Chef::ReservedNames::Win32::Security).to receive(:open_current_process_token)
- token = Chef::ReservedNames::Win32::Security.open_current_process_token
+ token = double(:process_token)
allow(token).to receive_message_chain(:handle, :handle)
+
+ allow(Chef::ReservedNames::Win32::Security).to receive(:open_current_process_token).and_return(token)
allow(Chef::ReservedNames::Win32::Security).to receive(:get_token_information_elevation_type)
allow(Chef::ReservedNames::Win32::Security).to receive(:GetTokenInformation).and_return(true)
allow_any_instance_of(FFI::Buffer).to receive(:read_ulong).and_return(1)
@@ -128,7 +129,7 @@ describe "Chef::Win32::Security", :windows_only do
context "when FFI::LastError.error result is not ERROR_INSUFFICIENT_BUFFER and not NO_ERROR" do
it "raises Chef::ReservedNames::Win32::Error.raise! exception" do
expect(FFI::LastError).to receive(:error).and_return(123).at_least(:once)
- expect { security_class.lookup_account_name "system" }.to raise_error
+ expect { security_class.lookup_account_name "system" }.to raise_error(Chef::Exceptions::Win32APIError)
end
end
end