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

gerald blady
gerald blady
9,052 Points

Random Failure..

Failures:

1) Editing todo lists updates a todo list succesfully with correct info Failure/Error: expect(page).to have_content("Todo list was succesfully updated") expected to find text "Todo list was succesfully updated" in "Todo list was successfully updated. Title: New title Description: New description Edit | Back" # ./spec/features/todo_lists/edit_spec.rb:29:in `block (2 levels) in <top (required)>'

my code:

require 'spec_helper'

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

        todo_list = options[:todo_list]

        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do 
        click_link "Edit"
        end

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

    it "updates a todo list succesfully with correct info" do 
        todo_list = TodoList.create(title: "Groceries", description: "Grocery list.")
        update_todo_list todo_list: todo_list, 
                         title: "New title", 
                         description: "New description"


        todo_list.reload

        expect(page).to have_content("Todo list was succesfully updated")
        expect(todo_list.title).to eq("New title")
        expect(todo_list.description).to eq("New description")
    end
end
<h1>Listing todo_lists</h1>

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Description</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @todo_lists.each do |todo_list| %>
      <tr id="<%= dom_id(todo_list) %>">
        <td><%= todo_list.title %></td>
        <td><%= todo_list.description %></td>
        <td><%= link_to 'Show', todo_list %></td>
        <td><%= link_to 'Edit', edit_todo_list_path(todo_list) %></td>
        <td><%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Todo list', new_todo_list_path %>

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

It's all in the error message. Your expectation and the actual flash message are different by just one character:

Todo list was succesfully updated

Todo list was successfully updated

gerald blady
gerald blady
9,052 Points

thank you as always.. i must have looked over that for the past 20 minutes..

ugh!

:)

gerald blady
gerald blady
9,052 Points

it has to be something simple.. i'm looking at this over and over and can't figure it out.