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 Editing Todo Lists

Colton Plumley
Colton Plumley
4,468 Points

Expecting "New title", seeing "groceries"

I keep receiving error message:

   expected: "New title"
        got: "Groceries"

   (compared using ==)
 # ./spec/features/todo_lists/edit_spec.rb:17:in `block (2 levels) in <top (required)>'

code I am using is:

require 'spec_helper'

describe "Editing todo lists" do it "updates the todo list through the edit feature" 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: "Hello"
    fill_in "Description", with: "New Description"
    click_button "Update Todo list"

    expect(page).to have_content("Todo list was successfully updated.")
    expect(todo_list.title).to eq("Hello")
end

end

Someone please advise what is going on!!!

2 Answers

Hey Colton, in the video Jason runs the test and it shows the exact same failure. He fixes it by adding todo_list.reload

    fill_in "Title", with: "Hello"
    fill_in "Description", with: "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("New description")
end
Colton Plumley
Colton Plumley
4,468 Points

Ah!! The one time I pause the video and try it on my own haha! Should've kept watching! Thanks!