Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Viewing Todo Items: Part 1

JONATHAN PACHA
JONATHAN PACHA
12,039 Points

I am getting failed examples when running my rspec for the new todo_items.rb

This is my failure list:

Failed examples:

rspec ./spec/features/todo_items/index_spec.rb:5 # Viewing todo items displays no items when the todo list is empty

Randomized with seed 39175

treehouse:~/projects/odot (master *) $ bin/rspec spec/features/todo_items/index_spec.rb F

Failures:

1) Viewing todo items displays no items when the todo list is empty Failure/Error: expect(page).to have_content("#TodoItems#index") expected to find text "#TodoItems#index" in "TodoItems#index Find me in app/views/todo_items/index.html.erb" # ./spec/features/todo_items/index_spec.rb:10:in `block (2 levels) in <top (required)>'

here is my code for index.html.erb:

<h1>Listing todo_lists</h1>

<table> <thead> <tr> <th>Title</th> <th>Description</th> <th></th> <th></th> <th></th> </tr> </thead>

<tbody> <% @todo_lists.each do |todo_list| %> <tr id="<%= dom_id(todo_list) %>"> <td><%= todo_list.title %></td> <td><%= todo_list.description %></td> <td> <%= link_to "List Items", todo_list_todo_items_path(todo_list) %> <%= link_to 'Show', todo_list %> <%= link_to 'Edit', edit_todo_list_path(todo_list) %> <%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %> </td> </tr> <% end %> </tbody> </table>

<br>

<%= link_to 'New Todo list', new_todo_list_path %>

here is the code for index_spec.rb:

require 'spec_helper'

describe "Viewing todo items" do let!(:todo_list) { TodoList.create(title: "Grocery list", description: "Groceries") } it "displays no items when the todo list is empty" do visit "/todo_lists" within "#todo_list_#{todo_list.id}" do click_link "List Items" end expect(page).to have_content("#TodoItems#index") end end

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

expected to find text "#TodoItems#index" in "TodoItems#index

Change your expectation OR change the view's content.

JONATHAN PACHA
JONATHAN PACHA
12,039 Points

Thank you very much. I'm an idiot. I cannot believe I spent that much time on that.