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

Why we need "within #todo_list_#{todo_list.id}" if on the test environment we have our database blanked?

In the edit_spec.rb we have

within #todo_list_#{todo_list.id} do
  click_link "Edit"
end

in the edit_spec.rb, but why we need it? If the database is empty when in test environment, we should have just the list we have created before... So why check against it?

Rachelle Wood
Rachelle Wood
15,361 Points

If I understand your question correctly, why are we testing this if the database is blank? It isn't blank though. We put in some todo list items, otherwise we would not be able to edit anything and would have to create them instead. The edit page only works if there is something already present to edit. In order to be able to edit an already extant todo list item, you have to be able to have an edit button for each one, hence why we have the within statement here.

1 Answer

No, I was just saying.. If we have just one todo list, we don't need the "within" thing... :-)