Sha256: a316101d96690c98f96d567323a4a0f2ac6e363f1a862364bd8f6fa5c164065a

Contents?: true

Size: 874 Bytes

Versions: 2

Compression:

Stored size: 874 Bytes

Contents

require 'minitest/autorun'
require_relative '../lib/pdfium'
require 'pathname'
require 'fastimage'

class MiniTest::Spec

    def load_document(name)
        PDFium::Document.new(pdf_path(name))
    end

    def pdf_path(name)
        Pathname.new(__FILE__).dirname.join('pdfs',name+'.pdf')
    end

    def after_saving(pdf)
        Tempfile.open(['test','.pdf']) do |f|
            pdf.save(f.path)
            yield PDFium::Document.new(f.path)
        end
    end

    def assert_size(size, file)
        ext = File.extname(file).gsub(/^\./,'')
        img_size = FastImage.size(file)
        img_size = img_size ? img_size.join("x") : "0x0"
        assert_match size, img_size, "Expected size to be #{size} but was #{img_size}"
        img_type=FastImage.type(file).to_s
        assert_match ext,  img_type, "Expected type to be #{ext} but was #{img_type}"
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdfium-0.0.2 test/spec_helper.rb
pdfium-0.0.1 test/spec_helper.rb