Ruby on rails 在Rails ActionMailer中测试默认值
您如何在ActionMailer规范中测试这些行Ruby on rails 在Rails ActionMailer中测试默认值,ruby-on-rails,ruby-on-rails-3,rspec,rspec2,actionmailer,Ruby On Rails,Ruby On Rails 3,Rspec,Rspec2,Actionmailer,您如何在ActionMailer规范中测试这些行 default 'HEADER' => Proc.new { "information" }, :cc => "asdf@asdf.com", :from => "asdf@asdf.com", :to => "asdf@asdf.com" 诸如此类: # notifier_spec.rb require "spec_helper" describe Notifier do describe "welc
default 'HEADER' => Proc.new { "information" },
:cc => "asdf@asdf.com",
:from => "asdf@asdf.com",
:to => "asdf@asdf.com"
诸如此类:
# 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(["zombie@example.com"])
mail.from.should eq(["zombie@example.com"])
mail.to.should eq([user.email])
end
it "renders the body" do
mail.body.encoded.should match("Hi")
end
end
end
这就是(=整个buncha人)如何做到的。我不会担心测试默认的标题和电子邮件字段,我会检查actionmailer测试覆盖范围。如果要添加头,我认为可以在控制器测试中检查头哈希,或者可以使用curl和
--head
并检查原始输出。