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 Write Our First Tests

Ana Takakuwa
Ana Takakuwa
2,640 Points

Ran the first test and get a 1 failure even though the test runs fine on the local server. Redirecting to the index page

  1. File was created

require 'spec_helper'

describe "Creating todo lists" do

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")

    end

end

  1. If you need more of the backtrace for any of these deprecations to identify where to make the necessary changes, you can configure config.raise_errors_for_deprecations!, and it will turn the deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.271 seconds 1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:5 # Creating todo lists redirects to the todo list index page on success

Randomized with seed 9925

2 Answers

Daniel Cunningham
Daniel Cunningham
21,109 Points

What is the rest of the error? Is it "Expected to have content 'New todo_list'"? or is it something about not being able to find the link "New Todo list". Bear in mind that these commands are case sensitive, so if you mislabel "New Todo list" or needed a capital letter in ('New todo_list'), it will fail.

Ben Michel
Ben Michel
3,170 Points

If it's a syntax error due to a mislabeling like Daniel mentioned, you should have a failure logged similar to this:

Failures:

  1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: expect(page).to have_content("New todo_list")
       expected to find text "New todo_list" in "New Todo List Title Description Back"
     # ./spec/features/todo_lists/create_spec.rb:7:in `block (2 levels) in <top (required)>'

I had this problem while following along with the video because I labeled the page content (which is the header) "New Todo List" rather than "New todo_list" like they did.

If this is your case, back in create_spec.rb try changing the line:

expect(page).to have_content("New todo_list")

–To exactly what you labeled the text that's rendered as the header on the /todo_lists/new page (http://localhost:3000/todo_lists/new).

In my case, I labeled it "New Todo List"–so adjusting accordingly fixed the problem:

expect(page).to have_content("New Todo List")