Sha256: 92ae9707e23b04747f28f0586b1f76f62a60cc7270510e0cbe5ce0e5ca8ac8af

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'helper'
require 'rails-latex/erb_latex'
require 'ostruct'

Rails=OpenStruct.new(:root => TMP_DIR=File.expand_path("../tmp",__FILE__))

class TestLatexToPdf < Test::Unit::TestCase
  def test_escape
    assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\textasciicircum{} \\textasciitilde{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
    LatexToPdf.instance_eval{@latex_escaper=nil}
    require 'redcloth'
    assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\^{} \\~{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
  end

  def test_generate_pdf
    FileUtils.mkdir_p(TMP_DIR)
    pdf_file=File.join(TMP_DIR,'out.pdf')
    File.delete(pdf_file) if File.exist?(pdf_file)
    File.open(pdf_file,'wb') do |wio|
      wio.write(LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{}))
    end
    assert_equal "hello world\n\n1\n\n\f", `pdftotext #{pdf_file} -`

    assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-latex-1.0.7 test/test_latex_to_pdf.rb