2013-07-02 82 views
3

我跟隨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是在應用程序/視圖/ order_notifier耙測試失敗assert_match

失敗
OrderNotifierTest#test_shipped [Work/depot/test/mailers/order_notifier_test.rb:17]:
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)

回答

3

The failed assertion

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

正期待HTML格式的呈現視圖(line_items/_line_item.html.erb)。

但是,由於郵件視圖是文本格式(order_notifier/shipped.text.erb),因此其中的部分內容也以文本格式(line_items/_line_item.text.erb)呈現。

因此,你可能要斷言更改爲:

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

(就像一個在之前接收到的訂單通知測試。)

+0

謝謝你的解釋:) – Vasspilka