To really test mail delivery one needs to send and then grab via smtp, but i do not want to go this far atm. So i wrote a surprisingly simple test, that satisfies my need for coverage and be done with it!

If you messed around with your environment.rb and are not sure wheter emails are send in test mode, just enter a real email and watch the inbox, before sending mass-emails…

#spec/models/user_mailer_spec.rb
describe UserMailer do
  fixtures :users

  before(:each) do
    ActionMailer::Base.deliveries = []
  end

  it 'should send activation' do
    UserMailer.deliver_activation(users(:quentin))
    sent.first.subject.should =~ /has been activated/#correct subject
    sent.first.body.should =~ /#{CFG[:site]}/#url to our site is there
  end

  def sent
    ActionMailer::Base.deliveries
  end
end