summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-07-13 13:44:20 -0700
committerTim Smith <tsmith84@gmail.com>2020-07-15 12:34:34 -0700
commit64d867010e369b753c59ce61be72e0d16729c427 (patch)
treef8419bd109e21608d1abd89ada4bd7cc49e71125
parent36effc24d23675e2daef95d35140b0ee293ac6fa (diff)
downloadchef-64d867010e369b753c59ce61be72e0d16729c427.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