Created
December 12, 2012 15:42
-
-
Save anonymous/4268812 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
class RegistrationMailer < ActionMailer::Base | |
MAILER_API_KEY = ENV['MAILGUN_API_KEY'] || 'key-####' | |
MAILER_API_URL = "https://api:#{MAILER_API_KEY}@api.mailgun.net/v2/####.mailgun.org/" | |
def registration_confirmation(registration) | |
RestClient.post MAILER_API_URL + "messages", | |
from: "no-reply@p3ople4u.com", | |
to: "#{registration.full_name} <#{registration.email}>", | |
subject: "Welcome to Aeneid", | |
text: "We will be posting back something <b>exciting</b> soon!" | |
end | |
end | |
-------------------- | |
require "spec_helper" | |
describe RegistrationMailer do | |
let!(:registration) { FactoryGirl.create(:registration) } | |
let(:mail) { RegistrationMailer.registration_confirmation(registration) } | |
it "sends confirmation email" do | |
mail.to.should == registration.email | |
mail.from.should == "admin@aeneid.com" | |
mail.subject.should == "Welcome to Aeneid" | |
end | |
end | |
---------------------- | |
FactoryGirl.define do | |
factory :registration do | |
sequence(:email) { |n| "test#{n}@test.com"} | |
sequence(:last_name) { |n| "#{n}"} | |
first_name "Juan" | |
fave_color "Red" | |
end | |
end | |
--------------------- | |
1) RegistrationMailer sends confirmation email | |
Failure/Error: mail.to.should == registration.email | |
expected: "test1@test.com" | |
got: nil (using ==) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment