Skip to content

Instantly share code, notes, and snippets.

@alexmamonchik
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save alexmamonchik/1db0d5c55d5f9d499c88 to your computer and use it in GitHub Desktop.

Select an option

Save alexmamonchik/1db0d5c55d5f9d499c88 to your computer and use it in GitHub Desktop.
Rspec example
# кусок тестируемого класса
class MandrilMailer
def self.deliver_welcome(whom, details={})
template_name = case whom
when :painter then 'Welcome Painter'
when :homeowner then 'Welcome Homeowner'
else :none
end
options = {
email: details[:email],
name: details[:name],
subject: template_name,
vars: [{
name: 'description',
content: "You are receiving this email because you registered as a #{whom.to_s} on EasyPaint."
}]
}
client.messages.send_template template_name, template_content, message(options)
end
# test
require 'spec_helper'
describe MandrilMailer do
describe '.deliver_welcome' do
let(:name_and_email) { { email: 'test@test.pro', name: 'John Doe' } }
# использовать всё это
context 'send Wellcome email' do
subject { MandrilMailer.deliver_welcome(:homeowner, name_and_email) }
its(['status']) { is_expected.to eq('sent') }
end
# или просто это
it 'send email' do
expect(MandrilMailer.deliver_welcome(:homeowner, name_and_email)).to include('status' => 'sent')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment