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 trialDavid Forero
5,492 PointsFinal 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
David Forero
5,492 PointsThis is the entire project:
https://github.com/davefogo/todo.git
wil try to do it manually as well.
Thanks
David Forero
5,492 PointsActually tried this on manual and when I try to add a new item it makes a blank item.
2 Answers
Maciej Czuchnowski
36,441 PointsYour 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
36,441 PointsAlso, the todo_item_params method at the end of the controller should look a bit differently.
David Forero
5,492 PointsI 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
36,441 PointsTake 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
5,492 PointsYeah,
Indeed you are right. Sorry buddy!
Thank you!
David McGraw
Courses Plus Student 9,711 PointsHey 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!
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsYou 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.