-
Notifications
You must be signed in to change notification settings - Fork 0
/
secret_santa_spec.rb
43 lines (37 loc) · 1.5 KB
/
secret_santa_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
require 'mail'
require_relative './secret_santa'
describe 'GifteeList' do
it 'assigns everyone a giftee without sub-loops' do
list = GifteeListAssigner.new([
{ name: 'Sandrine', email: '[email protected]' },
{ name: 'Ella', email: '[email protected]' },
{ name: 'Nicole', email: '[email protected]' },
{ name: 'Sean', email: '[email protected]' }
])
allow(list)
.to receive(:shuffle)
.and_return([
{ name: 'Sean', email: '[email protected]' },
{ name: 'Sandrine', email: '[email protected]' },
{ name: 'Ella', email: '[email protected]' },
{ name: 'Nicole', email: '[email protected]' }
])
list.assign_giftees!
expect(list.giftee_of('Sandrine')).to eq 'Ella'
expect(list.giftee_of('Ella')).to eq 'Nicole'
expect(list.giftee_of('Nicole')).to eq 'Sean'
expect(list.giftee_of('Sean')).to eq 'Sandrine'
end
end
describe 'Mailer' do
it 'sends an email to each santa about their giftee' do
assignments = [
{ name: 'Denise', email: '[email protected]', giftee: 'Spike' },
{ name: 'Spike', email: '[email protected]', giftee: 'Denise' }
]
assigner = Mailer.new(assignments, '[email protected]')
allow(assigner).to receive(:mail_to)
expect(assigner).to receive(:mail_to).twice
assigner.send!
end
end