require 'spec_helper' describe Medivo::PdfGroup do it "can call read on the pdf after creating it" do path = medivo_fixture_path "result_faq.pdf" pdf_group = Medivo::PdfGroup.create do static_pdf(path) end expect { pdf_group.read }.should_not raise_error end it "#variable_fields" do name = "Duderoni" o = OpenStruct.new(:name=>name) path = medivo_fixture_path "negative_results.pdf" pdf_group = Medivo::PdfGroup.create do variable_fields(path, {:patient_name=>o.name}) end text = pdf_to_text(pdf_group.pdf) text.should match name end it "#lab_requisition" do requisition_id = 170420 stub_order_requisition(requisition_id, "lc_order_with_requisition.xml") pdf_group = Medivo::PdfGroup.create do lab_requisition(requisition_id) end text = pdf_to_text(pdf_group.pdf) text.should match "Account #:111111111 Req\/Control #:#{requisition_id}" end it "#lab_result" do requisition_id = 170420 stub_order_result(requisition_id, "lc_order_with_positive_results.xml") pdf_group = Medivo::PdfGroup.create do lab_result(requisition_id) end text = pdf_to_text(pdf_group.pdf) text.should match "COLLECTED:2011-09-06 RECEIVED:2011-09-06 REPORTED:2011-09-06" end it "#static_pdf" do path = medivo_fixture_path "result_faq.pdf" pdf_group = Medivo::PdfGroup.create do static_pdf(path) end text = pdf_to_text(pdf_group.pdf) text.should match "Q: What does a positive result mean" end it "handles a combination of pdfs" do name = "Duderoni" cover_letter_path = medivo_fixture_path "negative_results.pdf" requisition_id = 170420 stub_order_requisition(requisition_id, "lc_order_with_requisition.xml") faq_path = medivo_fixture_path "result_faq.pdf" pdf_group = Medivo::PdfGroup.create do variable_fields(cover_letter_path, {:patient_name=>name}) lab_requisition(requisition_id) static_pdf(faq_path) end text = pdf_to_text(pdf_group.pdf) text.should match name text.should match "Account #:111111111 Req\/Control #:#{requisition_id}" text.should match "Q: What does a positive result mean" end end