Files
news.gitea.happylizard.me/bin/gems/pdf-reader-2.14.1/examples/rspec.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

35 lines
732 B
Ruby

#!/usr/bin/env ruby
# coding: utf-8
# typed: ignore
# Basic RSpec of a generated PDF
#
# USAGE: rspec -c examples/rspec.rb
require 'rubygems'
require 'pdf/reader'
require 'rspec'
require 'prawn'
require 'stringio'
describe "My generated PDF" do
it "should have the correct text on 2 pages" do
# generate our PDF
pdf = Prawn::Document.new
pdf.text "Chunky"
pdf.start_new_page
pdf.text "Bacon"
io = StringIO.new(pdf.render)
# process the PDF
PDF::Reader.open(io) do |reader|
reader.page_count.should eql(2) # correct page count
reader.page(1).text.should eql("Chunky") # correct content
reader.page(2).text.should eql("Bacon") # correct content
end
end
end