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

Getting error on rsepc test after adding expect(page) ....

This is the error that I get:

Finished in 0.85588 seconds
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

Randomized with seed 48935

This is my creat_spec.rb file

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

I understand that this is the file / line referenced as the error... but it is what was put in by Jason in the course.... and his test returns no errors.

Any help would be greatly appreciated. Thank you.

Amy Kang
Amy Kang
17,188 Points

Hi is that whole failure message? It's hard to tell what failed because it's not saying what failed. Usually it will say something like "Expected 'NewTodo List' to match 'New Todo list'" or something like that so you know which assertion failed. Also, I can't tell which line number it's referring to because the code is not formatted here. Can you point out which line it is?

There, I got it formatted. That was a typo on my part in the Markdown but now it's displaying.

The error is just saying

Failed examples:

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

The rspec ./spec/features/todo_lists/create_spec.rb:4 < Right there it says the line of the error .... I believe.

As you can see... Everything after the '#' symbol is the part in quotes in the code. "

Line 4 is the line with the 'it' block.

I'm sorry... I didn't notice this ...as I also have a few depreciation warnings (as this course is teaching 4.1 something and we're on 4.2 something...)

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

Deprecation Warnings:

2 Answers

Amy Kang
Amy Kang
17,188 Points

Thanks Brandon. Looks like the test is failing because you're expecting "New Todo list", when in fact on your new todo list page you have "New Todo List". So just change

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

to

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

and it should pass.

That worked, but I'm a bit confused as to why. All other instances of the word "list" or "lists" are lower cased.... including the link on the page itself.

Strange.

Thank you very much for getting me unstuck.

Thanks Amy, your answer helped me out!

Amy Kang
Amy Kang
17,188 Points

It differs based on Rails version. Older versions had different capitalization on page titles.