3
如何在ActionMailer规范中测试这些行?在Rails中测试默认设置ActionMailer
default 'HEADER' => Proc.new { "information" },
:cc => "[email protected]",
:from => "[email protected]",
:to => "[email protected]"
如何在ActionMailer规范中测试这些行?在Rails中测试默认设置ActionMailer
default 'HEADER' => Proc.new { "information" },
:cc => "[email protected]",
:from => "[email protected]",
:to => "[email protected]"
类似的东西:
# notifier_spec.rb
require "spec_helper"
describe Notifier do
describe "welcome" do
let(:user) { Factory :user }
let(:mail) { Notifier.welcome(user) }
it "renders the headers" do
mail.content_type.should eq('text/plain; charset=UTF-8')
mail.subject.should eq("Welcome")
mail.cc.should eq(["[email protected]"])
mail.from.should eq(["[email protected]"])
mail.to.should eq([user.email])
end
it "renders the body" do
mail.body.encoded.should match("Hi")
end
end
end
这是Ryan Bates(=全buncha人)是如何做的。
我不担心测试默认标题和电子邮件字段,我会检查actionmailer测试覆盖这些。如果你正在添加头文件,我认为你可以在控制器测试中检查头文件哈希,或者你可以在'--head'中使用curl并检查原始输出。 –