Skip to content

Instantly share code, notes, and snippets.

@sugarfree1
Last active Jul 12, 2016
Embed
What would you like to do?
##################### mailers/welcome.rb
class Mailers::Welcome
include Hanami::Mailer
templates
from 'noreply@bookshelf.org'
to 'user@example.com'
subject 'Welcome to Bookshelf'
def greeting
'hello, world'
end
end
##################### mailers/templates/welcome.html.erb
<h2><%= greeting %></h2>
##################### welcome_spec.rb
require 'spec_helper'
# require your mailer here
# require_relative '...'
RSpec.describe Mailers::Welcome do
before do
Hanami::Mailer.deliveries.clear
end
it 'delivers email' do
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