spec/lib/pdf_generator_spec.rb in medivo-0.1.11 vs spec/lib/pdf_generator_spec.rb in medivo-0.1.12
- old
+ new
@@ -1,51 +1,60 @@
require 'spec_helper'
describe Medivo::PdfGenerator do
- it "#variable_fields generates pdf by filling in the variables" do
- name = "Duderoni"
- path = medivo_fixture_path "negative_results.pdf"
- pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
- text = pdf_to_text(pdf_file)
- text.should match name
- end
+ describe "#variable_fields generates pdf by filling in the variables" do
- it "#variable_fields generates pdf by filling in the variables" do
+ it "for negative results cover letter" do
+ name = "Duderoni"
+ path = medivo_fixture_path "negative_results.pdf"
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
+ text = pdf_to_text(pdf_file)
+ text.should match name
+ pdf_file.unlink
+ end
- fields = {
- :full_name => 'my full name',
- :address => 'my address',
- :first_name => 'me!!!!!',
- :sched_date => 'todays date',
- :app_date => 'my appt date',
- :app_time => 'my appt time',
- :lab_name => 'LabCorp',
- :lab_address => 'the lab address',
- :order_number => 'the lab id'
- }
+ it "for uhc requisition cover letter" do
- path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
- pdf_file = Medivo::PdfGenerator.variable_fields(path, fields)
- text = pdf_to_text(pdf_file)
- fields.values.each do |value|
- text.should match value
+ fields = {
+ :full_name => 'my full name',
+ :address => 'my address',
+ :first_name => 'me!!!!!',
+ :sched_date => 'todays date',
+ :app_date => 'my appt date',
+ :app_time => 'my appt time',
+ :lab_name => 'LabCorp',
+ :lab_address => 'the lab address',
+ :order_number => 'the lab id'
+ }
+
+ path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, fields)
+
+ text = pdf_to_text(pdf_file)
+ fields.values.each do |value|
+ text.should match value
+ end
+ pdf_file.unlink
end
end
-
- it "#variable_fields accepts image param and stamps image onto pdf" do
+ it "#variable_fields_with_images accepts image param and stamps image onto pdf" do
md = <<-MD
- Catherine E. Palmier, M.D.
- Chief Medical Officer,
- UnitedHealthcare Clinical Services
- Southeast Region
+Catherine E. Palmier, M.D.
+Chief Medical Officer,
+UnitedHealthcare Clinical Services
+Southeast Region
MD
path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
img_path = medivo_fixture_path "Southeast.jpg"
- 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_file.read }
+ pdf_file = Medivo::PdfGenerator.variable_fields_with_images(
+ path,
+ {:director_name=>md},
+ [{:path=> img_path, :at=> [30, 120]}]
+ )
+ show_me_the_pdf(pdf_file, '/tmp/test.pdf')
text = pdf_to_text(pdf_file)
text.should match "Catherine E. Palmier, M.D."
pdf_file.unlink
end
end