"asdf@asdf.com", -6ren">
gpt4 book ai didi

ruby-on-rails - 在Rails ActionMailer中测试默认值

转载 作者:行者123 更新时间:2023-12-01 12:49:27 28 4
gpt4 key购买 nike

您如何在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 "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(等于整个Buna人)的工作方式。

关于ruby-on-rails - 在Rails ActionMailer中测试默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7509078/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com