views:

492

answers:

3

Seems like cuke doesn't show the full error message (at least when problem occurs in template) which makes it really hard to locate the problem.

Here is what it outputs on some error:

 
...
    And I am on checkout page                                   # features/step_definitions/webrat_steps.rb:6
      You have a nil object when you didn't expect it!
      The error occurred while evaluating nil.items (ActionView::TemplateError)
      features/manage_orders.feature:9:in `And I am on checkout page'
...

And here is what rails shows when the same problem is reproduced in browser:

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>

The former is a bit too neat. No exception in cucumber.log either. And my template has got few partials and a layout. Given no clues, quite an investigation.

Is there any secret plug to pull to get cucumber show full error?

A: 

Maybe not much help but the @cart object does not seem to have been instantiated. Check out your controller so that it is.

Jonas Elfström
The problem is not the bug itself, but the fact that cuke isn't helpful reporting details.
artemave
Sorry about that. Well, you almost got the Rails error and the line number of the test. One might think that the variable name of nil in nil.Items maybe could have been inserted there somehow but otherwise I do not know what more to expect from Cucumber?
Jonas Elfström
+1  A: 

Correct answer (thanks to cuke google group) is using --backtrace option when running cucumber.

artemave
A: 

You could comment out following line in your features/support.env to use Rails error handling.

Cucumber::Rails.bypass_rescue

You could also use tail -f log/test.log to keep an eye on the logs.

Waseem