-
Notifications
You must be signed in to change notification settings - Fork 0
/
06_patient_spec.rb
60 lines (51 loc) · 2 KB
/
06_patient_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'spec_helper'
describe 'Patient' do
describe '#new' do
it 'initializes with a name' do
expect { Patient.new('Devin') }.to_not raise_error
end
end
describe '#new_appointment' do
it 'given a doctor and date, creates a new appointment belonging to that patient' do
doctor_who = Doctor.new('The Doctor')
hevydevy = Patient.new('Devin Townsend')
appointment = hevydevy.new_appointment(doctor_who, 'Friday, January 32nd')
expect(hevydevy.appointments).to include(appointment)
expect(appointment.patient).to eq(hevydevy)
end
end
describe '.all' do
it 'knows about all patients' do
zero = Patient.new('Zero')
good = Patient.new('Good')
expect(Patient.all).to include(zero)
expect(Patient.all).to include(good)
end
end
describe '#appointments' do
it 'returns all appointments associated with this Patient' do
doctor_who = Doctor.new('The Doctor')
doctor_smith = Doctor.new('Matt Smith')
steve = Patient.new('Steve')
mike = Patient.new('Mike')
appointment = Appointment.new(steve, doctor_who, 'Friday, January 32nd')
appointment_2 = Appointment.new(steve, doctor_smith, 'Saturday, January 33rd')
appointment_3 = Appointment.new(mike, doctor_who, "Sunday, January 34th")
expect(steve.appointments).to include(appointment)
expect(steve.appointments).to include(appointment_2)
expect(steve.appointments).to_not include(appointment_3)
expect(mike.appointments).to include(appointment_3)
end
end
describe '#doctors' do
it 'has many doctors through appointments' do
doctor_who = Doctor.new('The Doctor')
doctor_what = Doctor.new('Das Doktor')
hevydevy = Patient.new('Devin Townsend')
hevydevy.new_appointment(doctor_who, 'Friday, January 32nd')
hevydevy.new_appointment(doctor_what, 'Saturday, January 32nd')
expect(hevydevy.doctors).to include(doctor_who)
expect(hevydevy.doctors).to include(doctor_what)
end
end
end