Email templates change very rarely on my project, so I don't mind the usual
approach of matching the body against a few patterns. And, it's easy to do.
Anyway, here's an example spec of a mailer on my current project:
describe Mailer, "job application submitted" do
before(:each) do
@user = stub(:full_name => "Jane Roe", :email_address => "
[EMAIL PROTECTED]")
@applicant = stub(:full_name => "john doe", :user => @user)
@assessment_url = "http://www.example.com"
@email = Mailer.create_job_application_submitted(@applicant,
@assessment_url)
end
it "addresses the email from the support address" do
@email.from.should == ["[EMAIL PROTECTED]"]
end
it "addresses the email to the given user" do
@email.to.should == [EMAIL PROTECTED]
end
it "sets the subject" do
@email.subject.should == "[EMAIL PROTECTED] - Job
application submitted"
end
it "includes the applicant name in the body" do
@email.body.should match(/[EMAIL PROTECTED]/)
end
it "includes the applicant's assessment link in the body" do
@email.body.should match(/[EMAIL PROTECTED]/)
end
end
Hope that helps somehow.
Also, the Rails Guides site has some content on testing mailers:
http://guides.rails.info/testing_rails_applications.html#_testing_your_mailers.
Regards,
Craig
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---