Skip to content

Instantly share code, notes, and snippets.

@seangaffney
Created January 22, 2015 21:18
Show Gist options
  • Save seangaffney/9ed58d843b7f3d24ac4d to your computer and use it in GitHub Desktop.
Save seangaffney/9ed58d843b7f3d24ac4d to your computer and use it in GitHub Desktop.
require "spec_helper"
describe DripCampaign do
let(:user) { build_stubbed :user }
let(:mail_message) { double(deliver!: true) }
before(:each) do
DummyMailer = double().as_null_object
allow(DummyMailer).to receive(:send).and_return(mail_message)
DripCampaign.mailer :dummy_mailer
end
describe ".send_email" do
context "under normal circumstances" do
it "delivers an email to the user" do
binding.pry
DripCampaign.send_email(:template1, user)
expect(mail_message).to have_received(:deliver!).once
end
end
context "if a user is already emailed" do
it "does not deliver an email to the user" do
DripCampaign.send_email(:template1, user)
DripCampaign.send_email(:template2, user)
expect(mail_message).to have_received(:deliver!).once
end
end
end
describe ".run" do
before do
DripCampaign.drip :day1 do
send_email(:template1, FactoryGirl.build_stubbed(:user))
end
end
it "runs a designated drip" do
DripCampaign.run
expect(mail_message).to have_received(:deliver!).once
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment