Created
March 21, 2018 16:28
-
-
Save bolshakov/48a48a34efa48d8c947d90fb1c80fc16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define :be_identical_docx_file_to do |expected_docx_file| | |
match do |actual_docx_file| | |
expected_file = extract_zip_file(expected_docx_file) | |
actual_file = extract_zip_file(actual_docx_file) | |
expected_file == actual_file | |
end | |
# @param path [String] path to docx file | |
# @return [{String => String}] maps file names to file content | |
private def extract_zip_file(path) | |
Zip::File.open(path) do |zip_file| | |
zip_file.each_with_object({}) do |entry, files| | |
files[entry.name] = entry.get_input_stream.read | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment