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 Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Editing Todo Lists

Generating error in todo_list application, in edit_spec.rb

Hello Rails Rescuers,

In this lesson, the file is supposed to fail on the first run of edit_spec.rb. I managed to get mine to fail earlier than it was supposed to fail.

Mine fails at line 5, the start of the " it " statement. The error message is; rspec ./spec/features/todo_lists/edit_spec.rb:5 # Editing todo lists updates a todo list successfully with correct information

I am running through the treehouse VM.

My code is below. Thanks for any help you can provide.

require 'spec_helper'

describe "Editing todo lists" do 

    it "updates a todo list successfully with correct information" do
        todo_list = TodoList.create(title: "Groceries", description: "Grocery list.")
        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do
            click_link "Edit"
        end 

        fill_in "Title", with: "New Title"
        fill_in "Description", with: "Spiffy New Description"
        click_button "Update Todo list"

        todo_list.reload

        expect(page).to_have_content("Todo list was successfully updated")
        expect(todo_list.title).to eq("New Title")
        expect(todo_list.description).to eq("Spiffy New Description")


    end

end 
Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

This is not your full error message. Please paste all of it. It will tell us exactly why it failed. scroll up and down the terminal to find the exact error, along with expectation and what rspec got instead.

Doh! You are correct. The error I was missing was:

 1) Editing todo lists updates a todo list successfully with correct information
     Failure/Error: expect(page).to_have_content("Todo list was successfully updated")
     NoMethodError:
       undefined method `to_have_content' for #<RSpec::Expectations::ExpectationTarget:0xb8c12d58>
     # ./spec/features/todo_lists/edit_spec.rb:19:in `block (2 levels) in <top (required)>'

I had the extra underscore in expect(page) method. Thanks for your help.

Sir Czuchnowski,

I didn't see a check-box for me to select your answer as best. When I do, I will be happy to check it. :-)

Thanks again.

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

It was a comment, so it can't be selected as the best answer ;). You can put your own answer there and explain what was going on and then select it as the bets one :)