1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/models/shared_examples/nameable.rb

42 lines
1 KiB
Ruby
Raw Normal View History

2019-03-26 18:06:03 -04:00
# frozen_string_literal: true
RSpec.shared_examples 'nameable' do
it { is_expected.to validate_presence_of :last_name }
it { is_expected.to validate_presence_of :first_name }
2019-03-26 18:06:03 -04:00
it { is_expected.not_to validate_presence_of :middle_name }
it { is_expected.not_to validate_presence_of :sex }
it { is_expected.not_to validate_presence_of :date_of_birth }
it { is_expected.not_to validate_presence_of :place_of_birth }
2019-03-26 18:06:03 -04:00
%i[
last_name
first_name
middle_name
sex
date_of_birth
place_of_birth
].each do |attribute|
describe "##{attribute}" do
context 'when it is empty' do
subject { build :member_person, attribute => '' }
2019-03-26 18:06:03 -04:00
before { subject.validate }
specify do
expect(subject.public_send(attribute)).to eq nil
end
2019-03-26 18:06:03 -04:00
end
context 'when it is blank' do
subject { build :member_person, attribute => ' ' }
before { subject.validate }
2019-03-26 18:06:03 -04:00
specify do
expect(subject.public_send(attribute)).to eq nil
end
2019-03-26 18:06:03 -04:00
end
end
end
end