gpt4 book ai didi

ruby-on-rails - Rake 测试失败 assert_match

转载 作者:数据小太阳 更新时间:2023-10-29 08:00:25 25 4
gpt4 key购买 nike

我正在关注 Agile Web Developement with rails4在抽成测试中我失败了。我不知道出了什么问题...我知道这会导致问题
assert_match /<td>1&times;<\/td>\s*<td>Programming Ruby 1.9<\/td>/,
mail.body.encoded

我的order_notifier_test , 我的 shipped.text.erb在 app/views/order_notifier 下

失败
OrderNotifierTest#test_shipped [Work/depot/test/mailers/order_notifier_test.rb:17]:<br/>
Expected /<td>1&times;<\/td>\s*<td>Programming Ruby 1.9<\/td>/ to match "<h3>Pragmatic Order Shipped</h3>\r\n<p>\r\n This is just to let you know that we've shipped your recent order:\r\n</p>\r\n \r\n<table>\r\n <tr><th colspan=\"2\">Qty</th><th>Description</th></tr>\r\n 1 x Programming Ruby 1.9\r\n\r\n</table>\r\n".

请随意浏览存储库以获取更多信息(我的系统也在 README.md 下)

最佳答案

failed assertion :

assert_match /<td>1&times;<\/td>\s*<td>Programming Ruby 1.9<\/td>/, mail.body.encoded

期待 HTML 格式的呈现 View (line_items/_line_item.html.erb)。

但是,由于邮件程序 View 是文本格式 (order_notifier/shipped.text.erb),因此其中的部分内容也以文本格式呈现 (line_items/_line_item.text。 erb).

因此,您可能希望将断言更改为:

assert_match /1 x Programming Ruby 1.9/, mail.body.encoded

(就像之前接收订单通知器测试中的那个一样。)

关于ruby-on-rails - Rake 测试失败 assert_match,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17421097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com