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

Chris Sunde
Chris Sunde
10,680 Points

Adding Todo Items

I'm getting the following error message: 1) Adding todo items is successful with valid content Failure/Error: expect(page).to have_content("Milk") expected to find text "Milk" in "" # ./spec/features/todo_items/create_spec.rb:24:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/create_spec.rb:23:inblock (2 levels) in <top (required)>'

 I can't figure out what the blank "" means.  Can anyone please help debug? Below is the create_spec.rb file...

 require 'spec_helper'

RSpec.configure do |c| c.expose_current_running_example_as :example end

describe "Adding todo items" do let!(:todo_list) { TodoList.create(title: "Grocery list", description: "Groceries")}

def visit_todo_list(list)
    visit "/todo_lists" 
    within "#todo_list_#{list.id}" do
        click_link "List Items"
    end
end

it "is successful with valid content" do
    visit_todo_list(todo_list)
    click_link "New Todo Item"
    fill_in "Content", with: "Milk"
    click_button "Save"
    expect(page).to have_content("Added todo list item.")
    within("ul.todo_items") do
        expect(page).to have_content("Milk")
    end
end

end

1 Answer

Daniel Cunningham
Daniel Cunningham
21,109 Points

Are you sure that there is an unordered list being created in your output? My guess is that the code managed to complete everything and could not find ul.todo_items, so it would definitely fail while expecting to find milk.

If you can do the same test while running the localhost server, see what the html code is supposed to look like. Also check your code on the todo_item "show.html.erb" to find out what the output should look like. You could also try "li.todo_items" as Milk would most certainly be output into an li tag within a ordered or unordered list....

Good luck!