Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
##################### mailers/welcome.rb
module MyNamespace::Mailers
class Welcome
include Hanami::Mailer
templates
from 'noreply@bookshelf.org'
to 'user@example.com'
subject 'Welcome to Bookshelf'
def greeting
'hello, world'
end
end
end
##################### mailers/templates/welcome.html.erb
<h2><%= greeting %></h2>
##################### welcome_spec.rb
require 'spec_helper'
# require your mailer here
# require_relative '...'
RSpec.describe MyNamespace::Mailers::Welcome do
before do
Hanami::Mailer.deliveries.clear
end
it 'delivers email' do
MyNamespace::Mailers::Welcome.deliver
mail = Hanami::Mailer.deliveries.last
expect(mail.body.encoded).to include('hello, world')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment