26 Nov 2011, 18:41
Generic-user-small

Taylor Mock (5 posts)

I’m having trouble running the order_notifier_test. It is trying to find the “1 x Programming Ruby 1.9” text in the mail body but it cannot. I know the text comes from the fixtures/products.yml in the :ruby section, but i dont see it linked anyway to this order_notifier_test. Is that my problem? I’m pretty sure my code is correct but here it is for reference:

`
require 'test_helper'

class OrderNotifierTest < ActionMailer::TestCase
  test "received" do
    mail = OrderNotifier.received(orders(:one))
    assert_equal "Pragmatic Store Order Confirmation", mail.subject
    assert_equal ["BLA@yahoo.com"], mail.to
    assert_equal ["BLA@gmail.com"], mail.from
    assert_match /1 x Programming Ruby 1.9/, mail.body.encoded
  end

  test "shipped" do
    mail = OrderNotifier.shipped(orders(:one))
    assert_equal "Pragmatic Store Order Shipped", mail.subject
    assert_equal ["BLA@yahoo.com"], mail.to
    assert_equal ["BLA@gmail.com"], mail.from
    assert_match /1×<\/td>\s*Programming Ruby 1.9<\/td>/, mail.body.encoded
  end
end
`
04 Jan 2012, 05:03
Generic-user-small

Eric Rykwalder (6 posts)

You have to make sure that in your fixtures, you have a line item (:one, or other) that points to the ruby product (:ruby) and the correct order (:one). For instance, I have one:

line_items.yml:

one:
  product: ruby
  order: one
  quantity: 1
  price: 49.50

Note that the price is only included because I did the exploration/playtime.

04 Apr 2013, 08:33
Generic-user-small

Aleks (5 posts)

I’m having the same problem. My line_items.yml is almost the same except for the price line.

Here’s the error I get when I try to run the test:

` 1) Failure: test_shipped(OrderNotifierTest) [/Users/xxx/Sites/depot/test/functional/order_notifier_test.rb:17]:

Expected /<td>1×<\/td>\s*<td>Programming Ruby 1.9<\/td>/ to match “\r\n\r\n—-==_mimepart_515d379580f9_71553ff49e035ad4904de\r\nDate: Thu, 04 Apr 2013 10:19:33 +xxxx\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\nContent-ID: <515d3795a8ed_71553ff49e035ad49059e@xxx.xxxx.xxxxxl>\r\n\r\nOrderNotifier#shipped\r\n\r\n, find me in app/views/app/views/order_notifier/shipped.text.erb\r\n\r\n\r\n\r\n\r\n—-==_mimepart_515d379580f9_71553ff49e035ad4904de\r\nDate: Thu, 04 Apr 2013 10:19:33 +xxxx\r\nMime-Version: 1.0\r\nContent-Type: text/html;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\nContent-ID: <515d3795c1ad_71553ff49e035ad4906f7@xxxxxxxx.xxxxx.xxxxx>\r\n\r\n<h3>Pragmatic Order Shipped</h3>\r\n<p>\r\n\tThis is just to let you know that we’ve shipped your recent order:\r\n</p>\r\n<table>\r\n\t<tr>\r\n\t\t<th colspan="2">Qty</th>\r\n\t\t<th>Description</th>\r\n\t</tr>\r\n\t\r\n<tr>\t\r\n\t<td>1 ×</td>\r\n\t<td>Programming Ruby 1.9</td>\r\n\t<td class="item_price">$49.50</td>\r\n</tr> \r\n</table>\r\n\r\n—-==_mimepart_515d379580f9_71553ff49e035ad4904de–\r\n”. `

04 Apr 2013, 15:39
Samr_small_pragsmall

Sam Ruby (584 posts)

Relevant portions of the output message:

Expected /1&times;/ to match "1 &times;"

Check app/views/line_items/_line_item.html.erb to see if you added any spaces. Either that, or adjust the test to match.

05 Apr 2013, 11:06
Generic-user-small

Aleks (5 posts)

Thank you very much. It solved my problem.

  You must be logged in to comment