wedding-planner/spec/models/guest_spec.rb
Manuel Bustillo 9035df5178
All checks were successful
Add copyright notice / copyright_notice (pull_request) Successful in 1m18s
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m28s
Run unit tests / unit_tests (pull_request) Successful in 1m0s
Install shoulda matchers, improve guests specs and change enum syntax
2024-11-09 17:45:23 +01:00

40 lines
1.0 KiB
Ruby

# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Guest, type: :model do
it do
should define_enum_for(:status).with_values(
considered: 0,
invited: 10,
confirmed: 20,
declined: 30,
tentative: 40
)
end
it { should belong_to(:group) }
describe 'scopes' do
describe '.potential' do
it 'returns guests that are not declined or considered' do
_declined_guest = create(:guest, status: :declined)
_considered_guest = create(:guest, status: :considered)
invited_guest = create(:guest, status: :invited)
confirmed_guest = create(:guest, status: :confirmed)
tentative_guest = create(:guest, status: :tentative)
expect(Guest.potential).to match_array([invited_guest, confirmed_guest, tentative_guest])
end
end
end
describe '#full_name' do
it 'returns the full name of the guest' do
guest = create(:guest, first_name: 'John', last_name: 'Doe')
expect(guest.full_name).to eq('John Doe')
end
end
end