Module: Test::Unit::PdfMatcher::Assertions

Defined in:
lib/test/unit/pdf_matcher/assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_match_pdf(expected_pdf, actual_pdf, output_diff_path: nil) ⇒ Object

Passes if PdfMatcher.match?(‘expected_pdf`, `actual_pdf`). See github.com/hidakatsuya/pdf_matcher for details about PdfMatcher.

Examples:

assert_match_pdf pdf1_data, pdf2_data, output_diff_path: '/path/to/diff.pdf'
assert_match_pdf '/path/to/1.pdf', '/path/to/2.pdf'
assert_match_pdf Pathname('/path/to/1.pdf'), Pathname('/path/to/2.pdf')


17
18
19
20
21
22
23
24
# File 'lib/test/unit/pdf_matcher/assertions.rb', line 17

def assert_match_pdf(expected_pdf, actual_pdf, output_diff_path: nil)
  full_messages = ['The PDF contents did not match.'].tap { |msgs|
    msgs << "Check #{output_diff_path} for details of the differences." if output_diff_path
  }
  assert_block(full_messages.join(' ')) do
    ::PdfMatcher.match?(expected_pdf, actual_pdf, output_diff: output_diff_path)
  end
end