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 Editing Todo Lists

Bahi Hussien
PLUS
Bahi Hussien
Courses Plus Student 13,128 Points

Capybara::ElementNotFound

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"
        end

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

        todo_list.reload

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


    end

end

index.html.erb

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

<h1>Listing Todo Lists</h1>

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Desc</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @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>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

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

Failures:

1) Editing to do lists updates todo lists successfully with corect information
 Failure/Error: within "#todo_list_#{todo_list.id}" do
 Capybara::ElementNotFound:
   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.