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 trialUnsubscribed User
11,042 PointsWhy 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?
1 Answer
Unsubscribed User
11,042 PointsNo, I was just saying.. If we have just one todo list, we don't need the "within" thing... :-)
Rachelle Wood
15,362 PointsRachelle Wood
15,362 PointsIf 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.