Repository navigation
Check an app's PDFs from Minitest and RSpec with the oracle's checks - #107
Merged
Merged
Conversation
The comparisons of the oracle move to Gamba::PdfCheck (text and positions by MuPDF, pixels by MuPDF and Poppler, validity by qpdf and Poppler, PDF/A by veraPDF), which the oracle now calls: one implementation. require "gamba/minitest" adds assert_pdf_text (a page, a position), assert_same_pages, assert_valid_pdf and assert_pdf_a; require "gamba/rspec" adds the matching matchers. A missing tool fails with its install command, or skips when Gamba::Testing.missing_tools is :skip. script/capture_pdfs.rb compares two capture directories with the same checks. Assisted-by: Claude [Claude Code]
TruffleRuby leaves Regexp.last_match unset in the block of a scan enumerator, so assert_pdf_text raised NoMethodError there. Assisted-by: Claude [Claude Code]
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An application that renders PDFs has no good way to test them: most suites check that some bytes came out. Gamba's test support already compared text with its position, pixels in two renderers and validity, but none of it shipped in the gem, and the README sent people to our test support to compare their PDFs before switching. Closes #72.
The oracle's checks move into the gem as
Gamba::PdfCheck, which the oracle now calls, and come as assertions and matchers loaded only on request.require "gamba/minitest", tests getassert_pdf_text pdf, "Invoice INV-2026-0001", page: 1, at: [x, y](a String whose spaces match any run of spaces, or a Regexp),assert_same_pages,assert_valid_pdfandassert_pdf_a. A PDF is its bytes or a path.require "gamba/rspec", specs gethave_pdf_text,have_same_pages_as,be_a_valid_pdfandbe_pdf_a, negatable.Gamba::Testing.missing_tools = :skip.Gamba::PdfCheck.script/capture_pdfs.rb PRAWN_DIR GAMBA_DIRcompares two capture directories with the same checks and exits 1 on a difference. The README and the guide show both.Proof
test/testing_test.rbcovers text on any page or a given one, at a position or not; failure messages; same pages, and a glyph moved by 1 pt named with its pixel rows in Poppler; a broken xref reported invalid; paths and Pathnames as well as bytes; a missing qpdf failing with its install command, then skipping when told; the RSpec matchers run byrspecin a subprocess (6 examples, 1 failure, 1 pending, as written); and the compare mode ofcapture_pdfs.rb. The oracle runs onGamba::PdfCheckwith no other change: 265 examples, 0 failures, the encrypted manual examples included.rake test: 1377 runs, 0 failures; RuboCop is clean.Generated by Claude Code