test/test_latex_document.rb in pdfmult-1.3.0 vs test/test_latex_document.rb in pdfmult-1.3.1
- old
+ new
@@ -1,18 +1,39 @@
-#!/usr/bin/ruby -w
# test_latex_document.rb: Unit tests for the pdfmult script.
#
-# Copyright (C) 2011-2012 Marcus Stollsteimer
+# Copyright (C) 2011-2013 Marcus Stollsteimer
require 'minitest/spec'
require 'minitest/autorun'
require 'pdfmult'
describe Pdfmult::LaTeXDocument do
- it 'should return the expected LaTeX code' do
- document = Pdfmult::LaTeXDocument.new('sample.pdf', 8, 3)
- document.to_s.split(/\n/)[0].must_equal "\\documentclass[a4paper,landscape]{article}"
- document.to_s.split(/\n/)[-2].must_equal "\\includepdf[pages={3,3,3,3,3,3,3,3},nup=4x2]{sample.pdf}%"
+ before do
+ @layout_class = Pdfmult::Layout
+ end
+
+ it 'should return the expected LaTeX code for 4 pages' do
+ args = {
+ :pdffile => 'sample.pdf',
+ :layout => @layout_class.new(4),
+ :page_count => 3
+ }
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
+ document_lines[0].must_equal '\documentclass[a4paper]{article}'
+ document_lines[-2].must_equal '\includepdf[pages={3,3,3,3},nup=2x2]{sample.pdf}%'
+ document_lines.grep(/includepdf/).size.must_equal args[:page_count]
+ end
+
+ it 'should return the expected LaTeX code for 8 pages' do
+ args = {
+ :pdffile => 'sample.pdf',
+ :layout => @layout_class.new(8),
+ :page_count => 5
+ }
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
+ document_lines[0].must_equal '\documentclass[a4paper,landscape]{article}'
+ document_lines[-2].must_equal '\includepdf[pages={5,5,5,5,5,5,5,5},nup=4x2]{sample.pdf}%'
+ document_lines.grep(/includepdf/).size.must_equal args[:page_count]
end
end