Skip to content

Instantly share code, notes, and snippets.

@sugarfree1
Last active July 12, 2016 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugarfree1/0f2f4d054e7ce83468daa71ed722f5f9 to your computer and use it in GitHub Desktop.
Save sugarfree1/0f2f4d054e7ce83468daa71ed722f5f9 to your computer and use it in GitHub Desktop.
##################### 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