Skip to content

Instantly share code, notes, and snippets.

@lucasrenan
Created February 27, 2012 15:12
Show Gist options
  • Save lucasrenan/1924473 to your computer and use it in GitHub Desktop.
Save lucasrenan/1924473 to your computer and use it in GitHub Desktop.
class DealersMailer < ActionMailer::Base
default from: "[email protected]"
def notify_admin(dealer)
@dealer = dealer
mail :to => "[email protected]", :subject => "novo revendedor cadastrado"
end
def send_confirmation(dealer)
@dealer = dealer
mail :to => @dealer.email, :subject => "seu cadastro foi confirmado"
end
end
############################################################
require "spec_helper"
describe DealersMailer do
describe "notify_admin" do
#aqui poderia mockar o model
let(:dealer) { Factory.create(:dealer) }
let(:mail) { DealersMailer.notify_admin(dealer) }
it "renders the headers" do
mail.subject.should eq("novo revendedor cadastrado")
mail.to.should eq(["[email protected]"])
mail.from.should eq(["[email protected]"])
end
it "renders the body" do
mail.body.encoded.should match(dealer.name)
end
end
describe "send_confirmation" do
#aqui poderia mockar o model
let(:dealer) { Factory.create(:dealer) }
let(:mail) { DealersMailer.send_confirmation(dealer) }
it "renders the headers" do
mail.subject.should eq("seu cadastro foi confirmado")
mail.to.should eq([dealer.email])
mail.from.should eq(["[email protected]"])
end
it "renders the body" do
mail.body.encoded.should match("confirmado")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment