我正在尝试按照Michal hartl的教程学习ruby。 但仍然是一个快速学习的学生。 但是我坚持第11章关于“梅勒测试”的特定部分。
它给了我以下失败:FAIL["test_account_activation", UserMailerTest, 0.8010926319984719]
test_account_activation#UserMailerTest (0.80s)
Expected /Michael\ Example/ to match # encoding: US-ASCII
"\r\n----==_mimepart_5811b80d754fe_7347fb30ec66649\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nUser#account_activation\r\n\r\n, find me in app/views/user_mailer/account_activation.text.erb\r\n\r\n\r\n----==_mimepart_5811b80d754fe_7347fb30ec66649\r\nContent-Type: text/html;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\n<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n <style>\r\n /* Email styles need to be inline */\r\n </style>\r\n </head>\r\n\r\n <body>\r\n <h1>User#account_activation</h1>\r\n\r\n<p>\r\n , find me in app/views/user_mailer/account_activation.html.erb\r\n</p>\r\n\r\n </body>\r\n</html>\r\n\r\n----==_mimepart_5811b80d754fe_7347fb30ec66649--\r\n".
test/mailers/user_mailer_test.rb:12:in `block in <class:UserMailerTest>'
这是我的user_mailer_test.rb
require 'test_helper'
class UserMailerTest < ActionMailer::TestCase
test "account_activation" do
user = users(:michael)
user.activation_token = User.new_token
mail = UserMailer.account_activation(user)
assert_equal "Account activation", mail.subject
assert_equal [user.email], mail.to
assert_equal ["noreply@example.com"], mail.from
assert_match user.name, mail.body.encoded
assert_match user.activation_token, mail.body.encoded
assert_match CGI.escape(user.email), mail.body.encoded
end
end
希望有人可以帮助并解释我失败的原因吗?
非常感谢
答案 0 :(得分:0)
我已经修好了。 有一些地图结构错误。 相当错误的错误哈哈哈。