From 5ad0ee8ca9634363e9e7a31632c7d0b88988f49e Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 14 Dec 2021 14:18:59 +0100 Subject: [PATCH] fix(spec.flacky): try to use extractor in a more conventional way to extract file content --- spec/services/procedure_archive_service_spec.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/services/procedure_archive_service_spec.rb b/spec/services/procedure_archive_service_spec.rb index 58bd75d34..e66dd1d89 100644 --- a/spec/services/procedure_archive_service_spec.rb +++ b/spec/services/procedure_archive_service_spec.rb @@ -182,7 +182,7 @@ describe ProcedureArchiveService do service.collect_files_archive(archive, instructeur) archive.file.open do |f| - files = ZipTricks::FileReader.read_zip_structure(io: f) + zip_entries = ZipTricks::FileReader.read_zip_structure(io: f) structure = [ "procedure-#{procedure.id}/", "procedure-#{procedure.id}/dossier-#{dossier.id}/", @@ -191,8 +191,14 @@ describe ProcedureArchiveService do "procedure-#{procedure.id}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf", "procedure-#{procedure.id}/LISEZMOI.txt" ] - expect(files.map(&:filename)).to match_array(structure) - expect(extract(f, files.last)).to match(/Impossible de .* .*cni.*png/) + expect(zip_entries.map(&:filename)).to match_array(structure) + zip_entries.map do |entry| + next unless entry.filename == "procedure-#{procedure.id}/LISEZMOI.txt" + extracted_content = "" + extractor = entry.extractor_from(f) + extracted_content << extractor.extract(1024 * 1024) until extractor.eof? + expect(extracted_content).to match(/Impossible de .* .*cni.*png/) + end end end end