Sha256: 7d002177bdba559fe7a32be4a93a0bb8165e11e86b672b03e56d1cef835b2e76

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe LifenFhir::Patient do

  describe ':create' do

    it 'works' do

      address = LifenFhir::Address.new(
        lines: ["M et Mme Potter", "39 rue d'Aboukir"],
        city:"paris",
        postal_code: "75002"
      )

      patient = LifenFhir::Patient.new(
        first_name: ["Pierre", "Henri"],
        last_name: "Potter",
        birth_date: Date.new(1974, 12, 25),
        address: address
      )

      VCR.use_cassette "patient/create/with_all_information" do
        patient.save
      end

      expect(patient.uuid).to eq("ab7002e2-f017-48a5-ae09-1e232dc7c726")
    end

  end

  describe ':find_by_uuid' do

    it 'works' do
      VCR.use_cassette "patient/find/with_valid_id" do
        @patient = LifenFhir::Patient.find_by_uuid("ab7002e2-f017-48a5-ae09-1e232dc7c726")
      end

      expect(@patient.last_name).to eq("Potter")
      expect(@patient.first_name).to eq(["Pierre", "Henri"])
      expect(@patient.birth_date).to eq(Date.new(1974, 12, 25))

      address = @patient.address

      expect(address.postal_code).to eq("75002")
      expect(address.city).to eq("paris")
      expect(address.lines.size).to eq(2)
    end

    it 'wrong uuid' do

      VCR.use_cassette "patient/find/with_wrong_id" do
        expect {
          @patient = LifenFhir::Patient.find_by_uuid("wrong-uuid")
        }.to raise_error LifenFhir::Error
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lifen_fhir-0.3.0 spec/patient_spec.rb
lifen_fhir-0.2.0 spec/patient_spec.rb