Welcome to the Treehouse Community
Looking to learn something new?
I am stuck on the 4th minute of the "Write Our First Tests" module in Ruby on Rails.
Hello, I am trying to make it through the ruby on rails module and I keep getting stuck on my first tests. My errors start at 4:42 of the "Write Our First Tests" module in Ruby on Rails.. I've tried to restart the module by deleting the ODOT folder from the projects file and restarting the course. The problems start at the 4:42 when he runs his test (rspec ./spec/features/todo_lists/create_spec.rb)and gets 1 example, zero errors. When I run mine I get
(1 example, 1 failure
rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on success)
Can anyone tell me what this error is referring me to? I am very new to this . Thanks
David Gross19,443 Points
It is saying your todo_list_create_spec feature is not redirecting to the todo list index after creating a new todo list. You need to get really comfortable with MVC and CRUD.
So your test is explaining whats expected to happen when you create a todo list and there is a failure with redirecting to the todo list index.
When you first testing try and understand these three phases.
1.Setup - You need to setup how are you going to test the problem.
it "redirects to the todo list index page on success" do visit "/todo_lists" click_link "New Todo list" expect(page).to have_content("New todo_list") fill_in "Title", with: "My todo list" fill_in "Description", with: "This is what I'm doing today." end
- Exercise- in this case it is the click_button "Save" - when click save is executed what happens, what is executed? Where is the user redirected to? The home page, the todo_lists_index or the todo_lists show?
- Verify- it is expected to have the content "My todo list" after the button "Save" has been clicked.
expect(page).to have_content("My todo list")
The "My todo list" which is your title you just created should now be on the todo_lists_index page but its not. Your index page is being controlled by your todo_lists_controller. Go into your Todo_list_ controller and try and figure out why this isnt working.