Skip to content

Instantly share code, notes, and snippets.

@fnando
Created February 5, 2013 03:38
Show Gist options
  • Save fnando/4711967 to your computer and use it in GitHub Desktop.
Save fnando/4711967 to your computer and use it in GitHub Desktop.
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