jam-cloud/ruby/spec/mailers/batch_mailer_spec.rb

27 lines
768 B
Ruby

require "spec_helper"
describe BatchMailer do
describe "should send test emails" do
BatchMailer.deliveries.clear
let (:mail) { BatchMailer.deliveries[0] }
batch = FactoryGirl.create(:email_batch)
batch.update_attribute(:test_emails, "jonathan@jamkazam.com")
batch.send_test_batch
it { BatchMailer.deliveries.length.should == 1 }
it { mail['from'].to_s.should == EmailBatch::DEFAULT_SENDER }
it { mail['to'].to_s.split(',')[0].should == batch.test_emails.split(',')[0] }
it { mail.subject.should == batch.subject }
it { mail.multipart?.should == true } # because we send plain + html
it { mail.text_part.decode_body.should match(/#{Regexp.escape(batch.body)}/) }
it { batch.testing?.should == true }
end
end