require 'spec_helper' module Mork describe SheetPDF do it 'assigns the grid to @grid' do s = SheetPDF.new(some_pdf_content) s.instance_variable_get("@grid").should be_a Grid end it 'creates a grid by loading the specified file' do s = SheetPDF.new(some_pdf_content, 'spec/samples/grid01.yml') s.instance_variable_get('@grid').should be_a Grid end it 'raises an error with an invalid init parameter' do lambda { SheetPDF.new(some_pdf_content, 2) }.should raise_error "Invalid initialization parameter" end it 'assigns an array to @content' do s = SheetPDF.new(some_pdf_content) s.instance_variable_get("@content").should be_an Array end it 'assigns an array of hashes to @content' do s = SheetPDF.new(some_pdf_content) s.instance_variable_get("@content").first.should be_a Hash end it 'creates a basic PDF sheet' do s = SheetPDF.new(some_pdf_content) s.save("tmp/f1.pdf") end it 'creates a PDF sheet with the maximum possible code' do content = { code: 1099511627775, choices: [5] * 120, header: { name: "Bonazza Sara vr354320", title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013", code: "201.48", signature: "Firma" } } s = SheetPDF.new(content) s.save("tmp/f2.pdf") end it "should create a multipage pdf" do content = [ { code: 18446744073, choices: [5] * 100, header: { name: "Bertini Giuseppe VR123456 Bertini Giuseppe VR123456", title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013 Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013", code: "119.27", signature: "Firma" } }, { code: 5512, choices: [5] * 100, header: { name: "Bonazza Sara vr354320", title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013", code: "201.48", signature: "Firma" } } ] s = SheetPDF.new(content) s.save("tmp/p2.pdf") end end end