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

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,362 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... :-)