action_mailer_spec.rb
1.64 KB
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
describe 'initializers/action_mailer' do
def load_initializer
load File.join(Rails.root, 'config', 'initializers', 'action_mailer.rb')
end
after do
ActionMailer::Base.delivery_method = :test
end
describe 'delivery method' do
it 'sets the delivery method to :smtp' do
allow(Errbit::Config).to receive(:email_delivery_method).and_return(:smtp)
load_initializer
expect(ActionMailer::Base.delivery_method).to be(:smtp)
end
it 'sets the delivery method to :sendmail' do
allow(Errbit::Config).to receive(:email_delivery_method).and_return(:sendmail)
load_initializer
expect(ActionMailer::Base.delivery_method).to be(:sendmail)
end
end
describe 'smtp settings' do
it 'lets smtp settings be set' do
allow(Errbit::Config).to receive(:email_delivery_method).and_return(:smtp)
allow(Errbit::Config).to receive(:smtp_address).and_return('smtp.somedomain.com')
allow(Errbit::Config).to receive(:smtp_port).and_return(998)
allow(Errbit::Config).to receive(:smtp_authentication).and_return(:login)
allow(Errbit::Config).to receive(:smtp_user_name).and_return('my-username')
allow(Errbit::Config).to receive(:smtp_password).and_return('my-password')
allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com')
load_initializer
expect(ActionMailer::Base.smtp_settings).to eq(
address: 'smtp.somedomain.com',
port: 998,
authentication: :login,
user_name: 'my-username',
password: 'my-password',
domain: 'someotherdomain.com'
)
end
end
end