Skip to content

Instantly share code, notes, and snippets.

@linko
Created December 27, 2013 12:38
Show Gist options
  • Save linko/8146446 to your computer and use it in GitHub Desktop.
Save linko/8146446 to your computer and use it in GitHub Desktop.
Mailer test example
describe 'SomethingMailer' do
include Rails.application.routes.url_helpers
let(:something) { create :something }
describe 'accepted' do
let(:mail) { SomethingMailer.accepted(something) }
it 'renders the subject' do
mail.subject.should == 'Subject Accepted'
end
#ensure that the receiver is correct
it 'renders the receiver email' do
mail.to.should == [something.email]
end
#ensure that the sender is correct
it 'renders the sender email' do
mail.from.should == [AppConfig['something_mail']]
end
#ensure that the @name variable appears in the email body
it 'assigns {{name}}' do
mail.body.encoded.should match("Hello #{something.name}!")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment