Sha256: 4de9039e898a70fbe230860011cee236d2859c4b5126ab745d085a456f4549e0

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

require "test_helper"

module Latexpdf
  class PdfGeneratorTest < Minitest::Test
    def teardown
      subject.cleanup
    end

    def test_generate_pdf
      subject.generate
      assert File.file?(pdf_file)
      assert_match (/Test latex document/), pdf_reader.pages.first.text
    end

    def test_fail_on_invalid_tex
      invalid_tex_file = File.join(data_path, "invalid_tex.tex")
      @subject = PdfGenerator.new(invalid_tex_file)
      e = assert_raises LatexpdfError do
        subject.generate
      end
      assert_match (/Missing \\begin\{document\}/), e.message
    end

    private

    def subject
      minimal_tex_file = File.join(data_path, "minimal.tex")
      @subject ||= PdfGenerator.new(File.read(minimal_tex_file))
    end

    def pdf_file
      subject.pdf_file
    end

    def pdf_reader
      PDF::Reader.new(pdf_file)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
latexpdf-0.4.3 test/latexpdf/pdf_generator_test.rb
latexpdf-0.4.2 test/latexpdf/pdf_generator_test.rb
latexpdf-0.4.1 test/latexpdf/pdf_generator_test.rb