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

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

Failed examples:

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

1 Answer

David Gross
David Gross
19,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 
  1. 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?
   click_button "Save"
  1. 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.