Created
February 5, 2013 03:38
-
-
Save fnando/4711967 to your computer and use it in GitHub Desktop.
This file contains 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 "action_mailer" | |
require "qe" | |
class Mailer < ActionMailer::Base | |
def welcome(options) | |
@options = options | |
mail :to => options[:email] | |
end | |
end | |
class MailerWorker | |
include Qe::Worker | |
def mail | |
Mailer.welcome(options) | |
end | |
def perform | |
mail.deliver | |
end | |
end | |
describe MailerWorker do | |
subject(:worker) { | |
MailerWorker.new(:name => "NAME", :email => "EMAIL") | |
} | |
describe "#mail" do | |
it "initializes mail" do | |
Mailer | |
.should_receive(:welcome) | |
.with(worker.options) | |
worker.mail | |
end | |
end | |
describe "#perform" do | |
let(:mail) { mock } | |
before { worker.stub :mail => mail } | |
it "delivers email" do | |
mail.should_receive(:deliver) | |
worker.perform | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment