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 Adding Todo Items

David Forero
David Forero
5,492 Points

Final Test in Adding Todo Items Fails

In the last step of this video I am getting the following fail error =

 Failures:

  1) Adding todo lists 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:20:in `block (3 levels) in <top (required)>'
     # ./spec/features/todo_items/create_spec.rb:19:in `block (2 levels) in <top (required)>'

I have checked my create_spec file and everything is fine. The only way to have this test pass is if I send in the expect part like this :

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(" ")
        end 

instead of JasonΒ΄s way:

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 

Any idea what might be going on?

Thank you

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

You have to show us more code, like the view and controller (ideally, the whole project on github). Also, do the steps manually in the browser and see if it works as predicted.

David Forero
David Forero
5,492 Points

This is the entire project:

https://github.com/davefogo/todo.git

wil try to do it manually as well.

Thanks

David Forero
David Forero
5,492 Points

Actually tried this on manual and when I try to add a new item it makes a blank item.

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Your create action for todo_items controller is all wrong. Please watch the videos where Jason was writing that controller and/or take a look at mine:

https://github.com/mczuchnowski/odot/blob/master/app/controllers/todo_items_controller.rb

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Also, the todo_item_params method at the end of the controller should look a bit differently.

David Forero
David Forero
5,492 Points

I followed the video ( http://teamtreehouse.com/library/build-a-todo-list-application-with-rails-4/build-a-todo-list-application-with-rails-4/adding-todo-items "Adding todo items minute 8.47 ) step by step and the file looks exactly like mine, could it be that i am using newer settings?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Take a closer look at the second line of Jason's create action in that part of the video. See if that change helps.

David Forero
David Forero
5,492 Points

Yeah,

Indeed you are right. Sorry buddy!

Thank you!

David McGraw
PLUS
David McGraw
Courses Plus Student 9,711 Points

Hey ya'll!

I'm running into the exact same issue, except I get the following error alert:

1) Adding todo items is successful with valid content Failure/Error: expect(page).to have_content("Added todo list item.") expected to find text "Added todo list item." in "Grocery list New Todo Item" # ./spec/features/todo_items/create_spec.rb:18:in `block (2 levels) in <top (required)>'

Finished in 0.6554 seconds 1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_items/create_spec.rb:13 # Adding todo items is successful with valid content

I've reviewed this video a couple of times now, and all the code per files matches the video.

Any ideas of what it could be?

Thanks!