back to

Ruby on Rails To-do List

ARCHIVED

Archived: This project has been archived. Cards can no longer be completed.

Editing To-do Lists

Stefy
Stefy completed this card.
Writing tests for editing our todo list:

1. Create a file:
touch spec/features/todo_lists/edit_spec.rb (instead of create spec = edit spec). 

Creating a file for a new test


2. >views > todo_list > index
Give each table row an ID corresponding to the todo list:
We use a method called dom id, and send in the item that we want:

<tr id="<%= dom_id(todo_list) %>">

This will assign an id to it, called "todo_list" and then an underscore and the id of the todo_list (in our database). 


See the todo_list_1 under table row. It already contains the id


We can tell capybara to pass this on a certain id:

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

3. Remember to define the todo_list variable

todo_list = options[:todo_lists]

4. Run the test

5. We'll need a todo_list object so we'll use this feature. This will create the todo_list for me for each of the tests, and then assign it to a variable.

let!(:todo_list) {TodoList.create(title: "Groceries", description: "Grocery list.")}