Sha256: 1219e421907a62d865ca290bedac72c264101932e8641c0d13f1a0e6691fd113

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Medivo::FdfGenerator do
  before(:all) do
    @fields = {
            :patient_name=>'jane',
            :birth_date=> '01/29/2000',
            :result_date=> '12/24/1901',
            :missing=>'dude'
    }
    @fdf = Medivo::FdfGenerator.file(@fields)
  end

  it "generate fdf" do
    fdf = open(@fdf.path, 'r:ascii-8bit').read
    fdf.should == "%FDF-1.2\r%\xE2\xE3\xCF\xD3\r\n1 0 obj\r<< \r/FDF << /Fields [ << /T (patient_name) /V (jane) /ClrF 2 /ClrFf 1 >> << /T (birth_date) /V (01/29/2000) /ClrF 2 /ClrFf 1 >> << /T (result_date) /V (12/24/1901) /ClrF 2 /ClrFf 1 >> << /T (missing) /V (dude) /ClrF 2 /ClrFf 1 >> ] \r>> \r>> \rendobj\rtrailer\r<<\r/Root 1 0 R \r\r>>\r%%EOF\r\n"
  end

  it "fill in pdf form" do
    pdf_path = medivo_fixture_path "hepc_negative_results.pdf"
    pdf_output = `pdftk #{pdf_path} fill_form #{@fdf.path} output - flatten`
    text = pdf_stream_to_text(pdf_output)
    @fields.each do |key,value|
      text.should match value unless key == :missing
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
medivo-0.2.2 spec/lib/fdf_generator_spec.rb
medivo-0.2.1 spec/lib/fdf_generator_spec.rb
medivo-0.2.0 spec/lib/fdf_generator_spec.rb
medivo-0.1.25 spec/lib/fdf_generator_spec.rb
medivo-0.1.24 spec/lib/fdf_generator_spec.rb