I wanted to test that my mailer models all had the correct headers:
subject, to and from fields.
I had done this by creating this in my spec_helper.rb:
it “subject” do
it "to email address(es)" do @email.to.should_not be_blank end it "from email address(es)" do @email.from.should_not be_blank end end
I included the above in all my mailer specs, for which there are four,
and called the method ‘test_basic_headers’. This used to work, even
though it looks terribly unDRY.
An example of a mailer spec:
require File.dirname(FILE) + ‘/…/spec_helper’
describe UserMailer do
@user = users(:normal)
@port = ports(:Alexandria)
describe “activation” do
@email = UserMailer.create_activation(@user)
I have two problems.
One, I am now receiving ‘test_basic_headers’ method not found error
after upgrading rspec to 1.1.12. UserMailer is not including
TestMailerHelpers correctly. Can anyone see why?
Problem number two is that I have realised this is do doubt in
inefficient way of doing what I want. Can anyone recommend a better way?