为什么我的 ActionMailer text.erb 视图文件在测试时呈现不正确? (Rails)

Why does my ActionMailer text.erb view file render incorrectly when testing? (Rails)

我确信这很容易,但目前我无法判断我的一个邮件测试有什么问题。

我有这个基础测试,我运行宁。

test "email should be sent when a post is created" do
  email = PostNotifier.post_creation_notification(@post)
  assert_equal [@user.email], email.to
  assert_equal "ohlohadmins@blackducksoftware.com", email[:from].value
  assert_equal "Post successfully created", email.subject
  assert_match /Hello #{@user.name}, your post has been successfully created for #{@post.topic.title}/, email.body.encoded
end

这是我的 text.erb 文件:

Hello <%= @user.name =>, your post has been successfully created for <%= @post.topic.title =>.

这是我在 运行 我的测试时收到的错误:

如您所见,我的变量没有格式化。为什么他们不格式化?我一直在关注 Agile Web Development 4 作为参考,我的设置与书中的设置类似。

我也试过像这样用花括号将 text.erb 文件中的变量括起来。 "#{@user.name} 等等,它仍然不起作用。这很烦人。有任何想法吗?另一组眼睛将不胜感激。谢谢。

请用以下内容替换您的 text.erb 文件。

Hello <%= @user.name %>, your post has been successfully created for <%= @post.topic.title %>.

我认为这会有所帮助