Sha256: 686cf7cb45b6dbff15fd1d3f9775bee632193b13043f3e23e4527d0b6f6b4c76
Contents?: true
Size: 1.37 KB
Versions: 6
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require 'spec_helper' module Quby::Answers::Entities describe Patient do describe '#age' do it 'with a birthyear, calculates the age at the given timestamp' do patient = Patient.new(birthyear: 37.years.ago.year) expect(patient.age_at(10.years.ago)).to eq 27 end it 'with a birthdate, calculates the age at the given timestamp' do patient = Patient.new(birthdate: 37.years.ago) expect(patient.age_at(10.years.ago)).to eq 27 end it 'returns nil when the given timestamp is nil' do patient = Patient.new(birthyear: 37.years.ago.year) expect(patient.age_at(nil)).to be_nil end end describe '#gender' do it 'returns the gender' do patient = Patient.new(gender: :male) expect(patient.gender).to eq :male end end describe '#birthdate' do let(:date) { Time.gm(2003, 4, 2) } it 'returns given date' do patient = Patient.new(birthdate: date) expect(patient.birthdate).to eq(date) end it 'returns the first of the year if only year given' do patient = Patient.new(birthyear: 2003) expect(patient.birthdate).to eq(Time.gm(2003, 1, 1)) end it 'returns nil if nothing given' do patient = Patient.new expect(patient.birthdate).to be_nil end end end end
Version data entries
6 entries across 6 versions & 1 rubygems