15 Apr '13, 5am

TIL: How to stub a Rails3 mailer

I'm in the process of migrating from Rails 2 with rspec 1 to Rails 3 with rspec 2, the process has been going pretty well, however, today I came across an issue that I wanted to share. I have a controller that sends out an email through a mailer. Rails 2 code: CurriculumCommentMailer.deliver_comment_update(@curriculum_comment, "created") Rails 3 code: CurriculumCommentMailer.comment_update(@curriculum_comment, "created").deliver In my controller spec, I test to see if the email was sent out. Rspec 1 it "emails the comment" do CurriculumCommentMailer.should_receive(:deliver_comment_update) post :create, :curriculum_comment => @curriculum_comment.attributes end Rspec 2 In my opinion, I expected the following code to work it "emails the comment" do CurriculumCommentMailer.should_receive(:comment_update) post :create, :curriculum_comment => @curriculum_comment.attributes end H...

Full article: http://www.ruby-forum.com/topic/2230882

Tweets