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

Christopher Quinn
Christopher Quinn
9,943 Points

I'm having issues in the early stages of the build a todo list application videos.

I'm following along with the video and I'm running the command

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

and I get this message:

Finished in 0.31636 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

I have it typed exactly as it is in the video. Open to ideas here.

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
Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

This is not the full error message. There has to be more before that. It says exactly what caused the error. Without this we can only guess the reason.

Christopher Quinn
Christopher Quinn
9,943 Points

Well this is what I get for not scrolling up. I guess I should make myself some coffee when I wait for everyone to go to bed before working on this stuff.. Thanks for pointing out that i left information out of this.

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:10:in create_todo_list' # ./spec/features/todo_lists/create_spec.rb:18:inblock (2 levels) in <top (required)>'

require 'spec_helper'

describe "Creating todo lists" do
    def create_todo_list(options={})
        options[:title] ||= "My todo list"
        options[:description] ||= "This is my todo list."

        visit "/todo_lists"
        click_link "New Todo list"
        expect(page).to have_content("New todo_list")

        fill_in "Title", with: options[:title]
        fill_in "Description", with: options[:description]
        click_button "Create Todo list"
    end

  it "redirects to the todo list index page on success" do
    create_todo_list
    expect(page).to have_content("My todo list")
  end

Updated the code, error message won't match original post.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

OK, so in this case you should run the rails server and see for yourself what shows up after clicking that link. If it's what you expected, modify the test expectation from expect(page).to have_content("New todo_list") to expect(page).to have_content("New Todo List") on line 10. You probably modified the header in the new action view at some point. By default it was "New todo_list" and you got "New Todo List". Notice that this error tells you everything. It tells you what string it expected and what was the actual full content of the visited page: in "New Todo List Title Description Back"

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

You can make sure by checking the app/views/todo_list/new.html.erb file.

Christopher Quinn
Christopher Quinn
9,943 Points

Sometimes all it takes is an extra pair of eyes. Thank you!

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

No worries, I've seen a lot of people having many different problems at every single stage of this course. This happens a lot when you're starting :)