/
email_spec.rb
executable file
·38 lines (33 loc) · 1.16 KB
/
email_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
require 'spec_helper'
require "email_spec"
describe 'misc forklift core' do
describe 'email' do
include EmailSpec::Helpers
include EmailSpec::Matchers
it "can send mail with an email template" do
plan = SpecPlan.new
plan.do! {
email_args = {
to: "YOU@FAKE.com",
from: "Forklift",
subject: "Forklift has moved your database",
}
email_variables = {
total_users_count: 10,
new_users_count: 5,
}
email_template = "#{File.dirname(__FILE__)}/../../template/spec_email_template.erb"
@email = plan.mailer.send_template(email_args, email_template, email_variables).first
}
plan.disconnect!
expect(@email).to deliver_to("YOU@FAKE.com")
expect(@email).to have_subject(/Forklift has moved your database/)
expect(@email).to have_body_text(/Your forklift email/) # base
expect(@email).to have_body_text(/Total Users: 10/) # template
expect(@email).to have_body_text(/New Users: 5/) # template
end
it "can send mail with an attachment" do
skip("how to test email attachments?")
end
end
end