lundi 6 août 2018

rails 5.1.4 assert_select 'li', is only checking for first li

I am working through Agile Web Development in Rails 5.1, I seem to be having issues with testing. The book says if I have markdown like

<ul>
  <li>Home</li>
  <li>etc...</li>
</ul>

<ul>
  <% @cart.line_items.each do |item| %>
     <li>
       <%= item.quantity %> &times; <%= 
           item.product.title %>
     </li>
  <% end %>
</ul>

I should be able to write this text

assert_select 'li', '1 \u00d7 Programming Ruby 1.9'

and have it return :true, but it is only checking for the first li element,

Failure:LineItemsControllerTest#test_should_create_line_item [/Users/coreygibson/Documents/workspace/Depot/test/controllers/line_items_controller_test.rb:27]:
<1 \u00d7 Programming Ruby 1.9> expected but was
<Home>..
Expected 0 to be >= 1.

Is there a setting to fix this? or am I missing something? The book says this should work.

Aucun commentaire:

Enregistrer un commentaire