spec/lib/pdf_generator_spec.rb in medivo-0.1.18 vs spec/lib/pdf_generator_spec.rb in medivo-0.1.19
- old
+ new
@@ -1,75 +1,66 @@
require 'spec_helper'
describe Medivo::PdfGenerator do
+ MD = <<-MD
+Catherine E. Palmier, M.D.
+Chief Medical Officer,
+UnitedHealthcare Clinical Services
+Southeast Region
+ MD
+ let(:uhc_cover_letter_fields) {
+ { :full_name => 'dude man',
+ :address => '5 willywonka lane',
+ :first_name => 'fdudely',
+ :sched_date => '2/12/2001',
+ :app_date => '2/13/2001',
+ :app_time => '9:00', # small field .. so too much text will break test
+ :lab_name => 'LabCorp',
+ :lab_address => '3 nowhere road',
+ :order_number => '87113',
+ :director_name=>MD }
+ }
+
describe "#variable_fields generates pdf by filling in the variables" do
- it "for negative results cover letter" do
+ it "simple cover letter" do
name = "Duderoni"
- path = medivo_fixture_path "negative_results.pdf"
+ path = medivo_fixture_path "hepc_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
it "for uhc requisition cover letter" do
-
- fields = {
- :full_name => 'my full name',
- :address => 'my address',
- :first_name => 'me!!!!!',
- :sched_date => 'todays date',
- :app_date => 'my appt date',
- :app_time => 'appt time', # small field .. so too much text will break test
- :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)
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, uhc_cover_letter_fields)
text = pdf_to_text(pdf_file)
text = text.strip_space
- fields.values.each do |value|
+ uhc_cover_letter_fields.values.each do |value|
text.should match value.strip_space
end
pdf_file.unlink
end
end
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
- MD
-
- fields = {
- :full_name => 'my full name',
- :address => 'my address',
- :first_name => 'me!!!!!',
- :sched_date => 'todays date',
- :app_date => 'my appt date',
- :app_time => 'appt time', # small field .. so too much text will break test
- :lab_name => 'LabCorp',
- :lab_address => 'the lab address',
- :order_number => 'the lab id',
- :director_name=>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,
- fields,
+ uhc_cover_letter_fields,
[{:path=> img_path, :options=>{:at=> [40, 100], :width=>180, :height=>28}}]
)
+
show_me_the_pdf(pdf_file, '/tmp/test.pdf')
text = pdf_to_text(pdf_file)
+
+ uhc_cover_letter_fields.each do |key, value|
+ text.should match value unless key == :director_name
+ end
text.strip_space.should match "Catherine E. Palmier, M.D.".strip_space
pdf_file.unlink
end
end