small medium large xlarge

Generic-user-small
24 Nov 2015, 19:03
Patrick Karjala (4 posts)

When working on the final tests for Chapter 11 around page 156 of the PDF, I was still getting an error on my test, as follows:

1) Failure:
LineItemsControllerTest#test_should_create_line_item_via_ajax [.../work/depot/test/controllers/line_items_controller_test.rb:36]:
No JQuery call matches [:html, "#cart"]

I was having a difficult time finding the fix for this, as it is not readily apparent from the error message.

However, I finally came across this github bug:

https://github.com/rails/jquery-rails/issues/188

It states that the problem, directly related to this exercise in fact, is that spaces cannot be in the initial .html() declaration.

In our case, depot/app/views/line_items/create.js.erb cannot have any space outside of the quotes in the following line:

$( '#cart' ).html( "<%= escape_javascript render(@cart) %>" );

which had to be changed to:

$('#cart').html("<%= escape_javascript render(@cart) %>");

or else it will throw the aforementioned error. Removing the whitespace fixed the problem.

You must be logged in to comment