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

Michelle Cannito
Michelle Cannito
8,992 Points

LOADERROR require cannot load spec_helper

I am using a Windows Command Prompt. Some commands, such as clear, do not work. To run rspec, I need to be in the bin sub-directory.

I put a copy of the create_spec.rb file in the bin sub-directory to get the command rspec create_spec.rb to work (executed from the bin sub-directory prompt).

If I comment out the require 'spec_helper' statement in the create_spec.rb file, the program runs, but the only test, "redirects to the todo list index page on success", fails.

If I leave the require statement in the program file, I get a LOADERROR.

I never updated the custom_require.rb file. The message seems to be saying that when I use the statement require filename, it will check that custom_require file, and if the path isn't in there or something, it won't find the required file.

Please help! It is really frustrating. I think course instructions should be given for both Mac and PC users.

'''Windows Console Window / Command Prompt

C:\Sites\projects\odot\bin>rspec create_spec.rb C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb: 36:in require': cannot load such file -- spec_helper (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo m_require.rb:36:inrequire' from C:/Sites/projects/odot/bin/create_spec.rb:1:in <top (required)>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/configuration.rb:1065:inload' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/configuration.rb:1065:in block in load_spec_files' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/configuration.rb:1065:ineach' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/configuration.rb:1065:in load_spec_files' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/command_line.rb:18:inrun' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/runner.rb:103:in run' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9 9.1/lib/rspec/core/runner.rb:17:inblock in autorun'

C:\Sites\projects\odot\bin> '''

3 Answers

Michelle Cannito
Michelle Cannito
8,992 Points

Happy days are here again, the skies above are clear again, happy, happy, happy... Everything is working! 3 test cases, 3 passing, 0 failures!

I guess there is greater satisfaction to resolving an issue by one's self. Thank you all who took a look.

Guess I will have to mark one of my own answers as "best" to close this discussion.

Now about those deprecation warnings.... maybe another discussion another time.

Michelle Cannito
Michelle Cannito
8,992 Points

I got rid of the LoadError! I'm not exactly sure how. Before, I had to be in the bin subdirectory to run rspec. I now got rspec to run from the odot directory. Maybe it was enough stopping the server, closing and reopening the console windows, restarting the server and so on that did it.

I notice spec_helper has require statements that use a RELATIVE path that assumes starting in the odot directory instead of an ABSOLUTE path starting with the root C directory.

Since rspec can now run from the odot directory, the create_spec.rb file could be run from its intended spec\features\todo_lists sub-directory. And now that the embedded require statement paths were right, the LoadError disappeared.

To run the program from a Windows console, I used this command: rspec 'spec\features\todo_lists\create_spec.rb'

So, of the 3 tests, all except the last one where the title length has to be at least 3 characters. I'll rewatch that section of video and figure it out.

I hope future PC users who get a LOADERROR find this helpful.

Terry Ulery
Terry Ulery
4,054 Points

For a tl;dr version: Just run it from the application's root directory, versus the bin directory. I was able to get it working (from the bin directory) by changing the 'require' statements in the specs to 'require_relative' and giving the path to the spec_helper file, but after reading your answer, I just ran it from the app's root directory, and it works fine. Rake (by itself) to test all of the specs in the app works this way as well.

Michelle Cannito
Michelle Cannito
8,992 Points

I still need help with this! It's two days, and I'm still stuck. There should be instructions for doing this course on a PC.

The problem might be related to having Rails installed in two different places, from following different instructions from different courses.

If I take out the require statement, then method visit is not recognized, so the rspec test fails.

If I leave in the require statement, I can't run rspec, as I get a LOADERROR. Even if I put the full path name for the require statement, and even if I copy/paste the contents of spec_helper in place of the require, I get a LOADERROR.

The main reason for subscribing to teamtreehouse was for support while learning rails, so that I can get into apprentice.io, which requires intermediate rails skills.

Can someone please help? Thank you.