Module: Sablon::Test::Assertions

Defined in:
lib/sablon/test/assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_docx_equal(expected_path, actual_path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/sablon/test/assertions.rb', line 4

def assert_docx_equal(expected_path, actual_path)
  if get_document_xml(expected_path) != get_document_xml(actual_path)
    msg = <<-error
The generated document does not match the sample. Please investigate.

If the generated document is correct, the sample needs to be updated:
\t cp #{actual_path} #{expected_path}
error
    fail msg
  end
end

#get_document_xml(path) ⇒ Object



16
17
18
19
# File 'lib/sablon/test/assertions.rb', line 16

def get_document_xml(path)
  document_xml_entry = Zip::File.open(path).get_entry("word/document.xml")
  document_xml_entry.get_input_stream.read
end