8

似乎 cuke 没有显示完整的错误消息(至少在模板中出现问题时),这使得很难找到问题。

这是它在某些错误时输出的内容:

 
...
    我在结帐页面# features/step_definitions/webrat_steps.rb:6
      当你没想到时,你有一个 nil 对象!
      评估 nil.items 时发生错误 (ActionView::TemplateError)
      features/manage_orders.feature:9:in `我在结帐页面上'
...

这是在浏览器中重现相同问题时 rails 显示的内容:

Showing app/views/cart/show.erb where line #46 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.items

Extracted source (around line #46):

43: </script>
44: 
45: <% ths = %w{th_title th_price th_subtotal th_quantity}.collect {|th| t th.intern} %>
46: <% table(@cart.items, ths) do |cart_item, style| -%>
47:   <tr class="<%= style %>">
48:       <td width="60%"><%=h cart_item.title %></td>
49:       <td width="20%"><%=number_to_currency cart_item.price %></td>

前者有点太简洁了。cucumber.log 中也不例外。而且我的模板很少有部分和布局。没有任何线索,相当调查。

是否有任何秘密插件可以让黄瓜显示完整错误?

4

3 回答 3

10

正确答案(感谢 cuke google group)--backtrace在运行黄瓜时使用选项。

于 2009-07-01T21:30:10.760 回答
1

您可以在 features/support.env 中注释掉以下行以使用 Rails 错误处理。

Cucumber::Rails.bypass_rescue

您还可以使用 tail -f log/test.log 来关注日志。

于 2009-07-25T08:49:56.550 回答
-1

也许没有太大帮助,但 @cart 对象似乎没有被实例化。检查您的控制器是否如此。

于 2009-06-29T22:12:30.163 回答