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 Viewing Todo Items: Part 2

Uninitialised constant: TodoList::TodoItem

Hey,

I'm trying to run the rspec command after following this videos instructions. But when I run the command I get the error uninitialised constant: TodoList::TodoItem. Does anyone know how to fix this?

Thanks, Fredrik A. Madsen-Malmo

Failures:

  1) Viewing todo items Displays item content when a todo list has content
     Failure/Error: todo_list.todo_items.create(content: "Eggs")
     NameError:
       uninitialized constant TodoList::TodoItem
     # ./spec/features/todo_items/index_spec.rb:26:in `block (2 levels) in <top (required)>'

EDIT: Here is the rspec itself EDIT: I'm pretty new to ruby/rails so I don't really know what you are asking for. I included some files which I thought may be important. Just comment if you want me to paste some more files.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Can you show the code which is tested by this spec?

Added it to the question Maciej Czuchnowski.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

That's just the spec. But what is tested by this spec? I need that code, the answer could be hidden there.

Ah okay, sorry. I will add shortly

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Also, which version of rspec are you using?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I downloaded the app below the video and pasted your spec instead of Jason's spec and this test succeeds, so the bug has to be somewhere else.

I use rspec v3.0.3

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I would suggest switching to 2.14, because rspec went through some changes in version 3. just change the version in Gemfile and run bundle install. Maybe this will fix something. If not - we will keep looking.

Thanks, will try that now. But I think I will have to revert capybara as well then. Do you know which capybarar version is used in the videos?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I think it's 2.1.0, but capybara didn't go through any huge changes as far as I know. With RSpec these were even changes in syntax.

Thanks man, I ended up changing out my entire project with the one from the video. And it seems some of the gems are to old to be used. I get an error message saying nokogiri is missing, and when I try to install that I get an error message saying libxml2 is missing.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Someone else had the sam eproblem on the forum earlier. Lots of problems with nokogiri:

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&es_th=1&ie=UTF-8#q=rails%20nokogiri%20libxml2%20is%20missing

There are many reasons for that and lots of solutions.