Skip to content

Commit

Permalink
Add test to ensure directory is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Dec 5, 2023
1 parent cda8e62 commit 92dc5c7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/lib/ruby_smb/smb2/tree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@
let(:create_res) { double('create response') }
let(:query_dir_req) { RubySMB::SMB2::Packet::QueryDirectoryRequest.new }
let(:query_dir_res) { RubySMB::SMB2::Packet::QueryDirectoryResponse.new }
let(:open_dir) { instance_double(RubySMB::SMB2::File) }

before :example do
allow(tree).to receive(:open_directory).and_return(create_res)
allow(create_res).to receive(:file_id)
allow(RubySMB::SMB2::File).to receive(:new).and_return(open_dir)
allow(open_dir).to receive(:close)
allow(create_res).to receive(:file_attributes)
allow(RubySMB::SMB2::Packet::QueryDirectoryRequest).to receive(:new).and_return(query_dir_req)
allow(client).to receive(:send_recv)
allow(RubySMB::SMB2::Packet::QueryDirectoryResponse).to receive(:read).and_return(query_dir_res)
Expand All @@ -180,6 +184,7 @@
dir = '/dir'
expect(tree).to receive(:open_directory).with(directory: dir).and_return(create_res)
tree.list(directory: dir)
expect(open_dir).to have_received(:close)
end

it 'uses the File ID from the create response' do
Expand Down

0 comments on commit 92dc5c7

Please sign in to comment.