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

Dylan Cairns
Dylan Cairns
11,191 Points

Edit with no content still passing

I am getting this error ith no content Failure/Error: expect(page).to_not have_content("Saved todo list item.") expected not to find text "Saved todo list item." in "Saved todo list item. Grocery list Edit New Todo Item"

here is my project on github https://github.com/SpookyCorridor/odot

Daniel Cunningham
Daniel Cunningham
21,109 Points

What is the exact text of the error? Which file is it? Which line?

Dylan Cairns
Dylan Cairns
11,191 Points
Failures:

  1) Editing todo items is unsuccessful with no content
     Failure/Error: expect(page).to_not have_content("Saved todo list item.")
       expected not to find text "Saved todo list item." in "Saved todo list item. Grocery list Edit New Todo Item"
     # ./spec/features/todo_items/edit_spec.rb:34:in `block (2 levels) in <top (required)>'

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I deployed it locally, works fine. I'm getting 4 different errors when running RSpec, but none of them is what you mentioned above.

Dylan Cairns
Dylan Cairns
11,191 Points

I think I forgot to push my latest changes to the repo. Everything is updated now to the point of where I am getting the one error

edit: I was apparently linking to the wrong thing entirely....someone else's ODOT I was trying to compare to, whoops.

Daniel Cunningham
Daniel Cunningham
21,109 Points

The reason your test is failing is because you haven't written the validation to ensure that a todo_item has content.

app/models/todo_item.rb

the text is as follows:

class TodoItem < ActiveRecord::Base
  belongs_to :todo_list
end

Because of this, the error you are receiving is to be expected until a validation is written to force the test to 'fail'. You need to add a "presence: true" validation, and probably a length minimum validation as well. This is the same process you used in your todo_list controller in which you wrote the following:

class TodoList < ActiveRecord::Base

    has_many :todo_items 


    validates :title, presence: true
    validates :title, length: { minimum: 3 }
    validates :description, presence: true 
    validates :description, length: { minimum: 5 }
end

Rails can be really frustrating at times to follow because your errors can very often be found in files outside of the one you are looking at. I would suggest that you do your best to "muscle" through the todo list module and get to the ActiveRecord Basics course that follows it. It gives you a lot more depth on the connections behind all the code we are writing in each of the rails applications. Hope that helps! Good luck!