spec/lib/pdf_generator_spec.rb in medivo-0.1.7 vs spec/lib/pdf_generator_spec.rb in medivo-0.1.8

- old
+ new

@@ -1,12 +1,37 @@ require 'spec_helper' describe Medivo::PdfGenerator do it "#variable_fields generates pdf by filling in the variables" do - name = "Duderoni" - path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf" - pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name}) - text = pdf_to_text(pdf_file.read) - text.should =~ /#{name}/ + #name = "Duderoni" + name = <<-MD + Catherine E. Palmier, M.D. + Chief Medical Officer, + UnitedHealthcare Clinical Services + Southeast Region +MD + path = "#{ENGINE_PATH}/spec/fixtures/uhc_requisition_cover_letter.pdf" + #path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf" + pdf_file = Medivo::PdfGenerator.variable_fields(path, {'director_name'=>name}) + #pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name}) + text = pdf_to_text(pdf_file) + text.should match name + end + + it "#variable_fields accepts image param and stamps image onto pdf" do + md = <<-MD + Catherine E. Palmier, M.D. + Chief Medical Officer, + UnitedHealthcare Clinical Services + Southeast Region + MD + + path = "#{ENGINE_PATH}/spec/fixtures/uhc_requisition_cover_letter.pdf" + img_path = "#{ENGINE_PATH}/spec/fixtures/Southeast.jpg" + pdf_file = Medivo::PdfGenerator.variable_fields(path, {'director_name'=>md}) + #pdf_file = Medivo::PdfGenerator.variable_fields_with_images(path, {:director_name=>md}, [{:path=> img_path, :at=> [0, 120]}]) + #open('/tmp/test.pdf', 'wb+') { |f| f.write pdf.read } + text = pdf_to_text(pdf_file) + text.should match md end end