Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails指南测试邮件程序的示例?_Ruby On Rails_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby on 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',

测试邮件程序的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',
                                     '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自动执行的操作

你可以在

你是印度人吗?:-)上阅读关于这个非常具体的话题的整个讨论我也是:-)