我正在编写一些rspec测试,发现访问我的Mailer类时速度变慢。有没有一种方法可以完全模拟ActionMailer::Base类,以便在电子邮件发送之前和之后测试控制器的其他组件?
这是我的Mailer类定义:
class OrganisationMailer < ActionMailer::Base
# code to send emails
end
这是我写的其中一个测试
require 'spec_helper'
describe OrganisationsController do
describe "#email_single" do
context "With email address" do
let(:org) {Organisation.make!}
it "redirects to listing" do
get :email_single, :id => org.id
response.should redirect_to(organisations_path)
end
end
end
end