Agile Web Development with Rails, Edition 4

8.4 Iteration C4: Functional Testing 8.2 Iteration C2: Add a Page Layout

8.3 Iteration C3: Use a Helper to Format the Price

Expected at least 1 element matching "span.price", found 0.
<0> expected to be
>=
<1>.

Traceback:
  /home/rubys/git/awdwr/edition4/checkdepot.rb:127:in `block in <class:DepotTest>'

Demonstrate helpers.

Format the price using a built-in helper.

edit app/views/store/index.html.erb
<% 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>
    <%= sanitize(product.description) %>
    <div class="price_line">
      <span class="price"><%= number_to_currency(product.price) %></span>
    </div>
  </div>
<% end %>

Show the results.

get /

Getting started

Here’s how to get rolling:

  1. Use bin/rails generate to create your models and controllers

    To see all available options, run it without parameters.

  2. Set up a root route to replace this page

    You're seeing this page because you're running in development mode and you haven't set a root route yet.

    Routes are set up in config/routes.rb.

  3. Configure your database

    If you're not using SQLite (the default), edit config/database.yml with your username and password.

8.4 Iteration C4: Functional Testing 8.2 Iteration C2: Add a Page Layout