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", match_requests_on: [:method, :uri, :body]) 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