Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Editing Todo Lists

Bahi Hussien
Bahi Hussien
Courses Plus Student 13,128 Points


I have problem with the capybara in testing the todo list with specific id.

here is my code edit_spec.rb

require "spec_helper"

describe "Editing to do lists" do

    it "updates todo lists successfully with corect information" do
        todo_list = TodoList.create(title: "my title", desc: "my desc")

        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do
            click_link "Edit"

        fill_in "Title", with: "new title"
        fill_in "Desc", with: "new desc"
        click_button "Update Todo List"


        expect(page).to have_content("successfully updated")
        expect(todo_list.title).to eq("new title")
        expect(todo_list.desc).to eq("new desc")




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

<h1>Listing Todo Lists</h1>

      <th colspan="3"></th>

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


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


1) Editing to do lists updates todo lists successfully with corect information
 Failure/Error: within "#todo_list_#{todo_list.id}" do
   Unable to find css "#todo_list_"
 # ./spec/features/todo_lists/edit_spec.rb:9:in `block (2 levels) in <top (required)>'

i have checked some of the previous answers for this issue and i couldn't solve it.