Ruby on rails Rails指南测试邮件程序的示例?
测试邮件程序的rails指南示例代码如下:Ruby on rails Rails指南测试邮件程序的示例?,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,测试邮件程序的rails指南示例代码如下: require 'test_helper' class UserMailerTest < ActionMailer::TestCase tests UserMailer test "invite" do # Send the email, then test that it got queued email = UserMailer.create_invite('me@example.com',
require 'test_helper'
class UserMailerTest < ActionMailer::TestCase
tests UserMailer
test "invite" do
# Send the email, then test that it got queued
email = UserMailer.create_invite('me@example.com',
'friend@example.com', Time.now).deliver
assert !ActionMailer::Base.deliveries.empty?
# Test the body of the sent email contains what we expect it to
assert_equal ['me@example.com'], email.from
assert_equal ['friend@example.com'], email.to
assert_equal 'You have been invited by me@example.com', email.subject
assert_equal read_fixture('invite').join, email.body.to_s
end
end
需要“测试助手”
类UserMailerTest
此行的目的是什么?我必须在测试中添加它吗?-->
测试用户邮箱请检查
下面是关于测试
您可以使用邮件程序/控制器/帮助程序测试中的测试来定义
您正在测试的邮件程序/控制器/助手,以防无法测试
从测试名称自动猜测。例如,UserMailerTest
自动猜测UserMailer为测试主题,但您可以
明确地说,或者说它与测试的名称不同
方法。因此,在那里排队并不是完全错误的,只是
明确Rails自动执行的操作
你可以在你是印度人吗?:-)上阅读关于这个非常具体的话题的整个讨论我也是:-)