08 Jan 2014, 07:31
Generic-user-small

Mathew Snyder (2 posts)

I’ve modified the code according to all of Chapter 8’s iterations. Most of it I copy/pasted after reading through it so I knew what it was doing. As such, it is exactly as what can be found online.

After the fourth iteration (C4) I run the rake test:functionals command and get the following output:

Rack::File headers parameter replaces cache_control after Rack 1.5.
Run options: 

# Running tests:

..[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
.....ignoring attempt to close div with body
  opened at byte 750, line 27
  closed at byte 1507, line 51
  attributes at open: {"class"=>"entry"}
  text around open: "tic Catalog</h1>\n\n  <div class=\"entry\">\n"
  text around close: "    </div>\n  </div>\n</body>\n</html>\n"
ignoring attempt to close div with html
  opened at byte 750, line 27
  closed at byte 1515, line 52
  attributes at open: {"class"=>"entry"}
  text around open: "tic Catalog</h1>\n\n  <div class=\"entry\">\n"
  text around close: "v>\n  </div>\n</body>\n</html>\n"
F

Finished tests in 0.278688s, 28.7060 tests/s, 46.6472 assertions/s.

  1) Failure:
test_should_get_index(StoreControllerTest) [/home/msnyder/bin/ruby/pragprog_rails/depot/test/functional/store_controller_test.rb:8]:
Expected exactly 3 elements matching "#main .entry", found 1.

8 tests, 13 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/usr/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib" "/usr/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/rake_test_loader.rb" "test/functional/**/*_test.rb" ]

Tasks: TOP => test:functionals
(See full trace by running task with --trace)

I’m assuming some of the output is intiated from the application.html.erb file which looks like:

<!DOCTYPE html>
<html>
<head>
  <title>Depot</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body class='<%= controller.controller_name %>'>
  <div id="banner">
    <%= image_tag("logo.png") %>
    <%= @page_title || "Pragmatic Bookshelf" %><!-- <label id="code.depot.e.title"/> -->
  </div>
  <div id="columns">
    <div id="side">
      <ul>
        <li><a href="http://www....">Home</a></li>
        <li><a href="http://www..../faq">Questions</a></li>
        <li><a href="http://www..../news">News</a></li>
        <li><a href="http://www..../contact">Contact</a></li>
      </ul>
    </div>
    <div id="main">
      <%= yield %>
    </div>
  </div>
</body>
</html>

Other bits appear to be from the <%= yield %> portion which is pulling in app/views/store/index.html.erb which contains

<% if notice %>
  <p> id="notice"><%= notice %></p>
<% end %>

<h1>Your Pragmatic Catalog</h1>

<% @products.each do |product| %>
  <div class="entry">
    <%= image_tag(product.image_url) %>
    <h3><%= product.title %></h3>
    <p><%= sanitize(product.description) %></p>
    <div class="price_line">
      <span class="price"><%= number_to_currency(product.price) %></span>
    </div>
<% end %>

Can anyone help me figure out the problem I’m running into?

08 Jan 2014, 15:40
Sb_pragsmall

Sören Blom (1 post)

Hi,

had the same problem, and it seems we also share the same root cause.

Look at the bottom of your last listing:

<% @products.each do |product| %>
  <div class="entry">
    <%= image_tag(product.image_url) %>
    <h3><%= product.title %></h3>
    <p><%= sanitize(product.description) %></p>
    <div class="price_line">
      <span class="price"><%= number_to_currency(product.price) %></span>
    </div>
<% end %>

there is only one closing </div> before the <% end %>. But that only closes the <div class="price_line">. What is missing is another closing </div> to close <div class="entry">.

Otherwise, the entrys become nested and the CSS selector only finds one.

I also copy and pasted everything so I don’t know how that happened. Both the PDF and the online file have two closing </div>.

08 Jan 2014, 20:56
Generic-user-small

Mathew Snyder (2 posts)

Ach! I thought I evaluated all the <div>…</div> entries.

Thanks for catching that. I’ve just fixed it and the rake test:functionals command returned clean.

  You must be logged in to comment