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

Michael Jasinski
Michael Jasinski
7,427 Points

bin/rspec spec/features/todo_lists/create_spec.rb 2 failures

Can Anyone Help?

We are instructed to write " bin/rspec spec/features/todo_lists/create_spec.rb " and not get any Failures, but I keep getting two. However, when I test my application it seems to work.

Also the failures keep talking about RSpec 3.

Thank you all for the help.

Below is a list of the failures description.

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.26605 seconds 2 examples, 2 failures

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:18 # Create todo lists displays an error when the todo list has no title rspec ./spec/features/todo_lists/create_spec.rb:4 # Create todo lists redirects to the todo list index page on success

Randomized with seed 11012


Failures:

1) Create todo lists displays an error when the todo list has no title 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:22:in `block (2 levels) in <top (required)>'

2) Create 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)>'

Marie Nipper
Marie Nipper
22,638 Points

What is your create_spec.rb file code?

Michael Jasinski
Michael Jasinski
7,427 Points

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

fill_in "Title", with: "My todo list" fill_in "Description", with: "This is what I'm doing today." click_button "Create todo list"

expect(page).to have_content("My todo list") end

it "displays an error when the todo list has no title" do
    expect(TodoList.count).to eq(0)
    visit "/todo_lists"
    click_link "New Todo list"
    expect(page).to have_content("New Todo list")

fill_in "Title", with: "" fill_in "Description", with: "This is what I'm doing today." click_button "Create todo list"

expect(page).to have_content('error') expect(TodoList.count).to eq(0)

visit "/todo_lists" expect(page).to_not have_content("This is what I'm doing today.") end

it "displays an error when the todo list has less than 3 characters" do expect(TodoList.count).to eq(0) visit "/todo_lists" click_link "New Todo list" expect(page).to have_content("New Todo list")

fill_in "Title", with: "Hi" fill_in "Description", with: "This is what I'm doing today." click_button "Create todo list"

expect(page).to have_content('error') expect(TodoList.count).to eq(0)

visit "/todo_lists" expect(page).to_not have_content("This is what I'm doing today.") end

it "displays an error when the todo list has no description" do
    expect(TodoList.count).to eq(0)
    visit "/todo_lists"
    click_link "New Todo list"
    expect(page).to have_content("New Todo list
        ")

fill_in "Title", with: "Grocery list" fill_in "Description", with: "" click_button "Create todo list"

expect(page).to have_content('error') expect(TodoList.count).to eq(0)

visit "/todo_lists" expect(page).to_not have_content("Grocery list") end

it "displays an error when the todo list has no description" do
    expect(TodoList.count).to eq(0)
    visit "/todo_lists"
    click_link "New Todo list"
    expect(page).to have_content("New Todo list
        ")

fill_in "Title", with: "Grocery list" fill_in "Description", with: "Food" click_button "Create todo list"

expect(page).to have_content('error') expect(TodoList.count).to eq(0)

visit "/todo_lists" expect(page).to_not have_content("Grocery list") end end

TaJuanna Williams
TaJuanna Williams
26,697 Points

Try this code: require 'spec_helper'

describe "Creating todo lists" do it "redirects to the todo list index page on success" do visit "http://localhost:3000/todo_lists" click_link "New Todo list" expect(page).not_to have_content("New todo list")

    fill_in "Title", with: "My todo list"
    fill_in "Description", with: "This is what I'm doing today."
    click_button "Create Todo list"

    expect(page).to have_content("My todo list")
end

it "displays an error when the todo list has no title" do
    expect(TodoList.count).to eq(0)

visit "http://localhost:3000/todo_lists"
    click_link "New Todo list"
    expect(page).not_to have_content("New todo list")

    fill_in "Title", with: ""
    fill_in "Description", with: "This is what I'm doing today."
    click_button "Create Todo list"

    expect(page).to have_content("error")
    expect(TodoList.count).to eq(0)

    visit "/todo_lists"
    expect(page).to_not have_content("This is what I'm doing today.")

end end

2 Answers

Marie Nipper
Marie Nipper
22,638 Points

Okay. At the top you are having the test visit the /todo_lists URI. Then once there, the test is clicking the "New Todo list" link. It is then immediately hoping that the new loaded page (http://localhost:3000/todo_lists/new) has content at the top that reads "New Todo list" (note the lowercase 'l' in list) and the markup is displaying "New Todo List" (note the capital 'L' in list). Tell your test to expect a capital 'L' in List.

When you have a test click a link, a button or expect content, double check all of the spelling. See how far you get with that.

I just had this same issue and came to the same conclusion. Fixing the exact spelling and capitalization made it work.

The problem is that I followed the video exactly, but the video seems to introduce this bug.

Suelen Henderson
Suelen Henderson
34,034 Points

I was getting the same error. I just changed to the spec directory like it: cd spec. Then I created a folder called features like this: mkdir features, after it I changed to the features folder in the prompt (cd features). Then I created another folder called todo_lists. After it I run (touch spec/features/todo_lists/create_spec.rb). This path will create the (create_spec.rb) file in the todo_lists folder. Then every time I want to see if my changes are corrects or not, I just needed to run (rspec spec/features/todo_lists/create_spec.rb) code.