我肯定这很容易,但目前我无法判断我的邮件测试有什么问题。
我有一个基本的测试,我正在运行。
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 =>.这是我在运行测试时收到的错误:

如您所见,我的变量不是格式化的。为什么它们没有格式化?我一直在跟踪敏捷Web开发4作为参考,我的这个设置类似于书中的内容。
我还尝试将text.erb文件中的变量封装在大括号中,如下所示。"#{@user.name}等,但它仍然不能工作。这真烦人。有什么想法吗?另一双眼睛将是非常感谢的。谢谢。
发布于 2015-01-09 20:20:01
请将您的text.erb文件替换为以下文件。
Hello <%= @user.name %>, your post has been successfully created for <%= @post.topic.title %>.
我想这会有帮助的
https://stackoverflow.com/questions/27868230
复制相似问题