您如何在ActionMailer规范中测试这些行?
default 'HEADER' => Proc.new { "information" },
:cc => "asdf@asdf.com",
:from => "asdf@asdf.com",
:to => "asdf@asdf.com"
答案 0 :(得分:1)
类似的东西:
# 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
这就是Ryan Bates(=整个buncha人)的做法。