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 Write Our First Tests

Simple problem: Cannot Load File

I think this is a simple question. When I run the test I get and error "cannot load such file --spec_helper". My code for the test is:

require 'spec_helper'

describe "Creating todo lists" do
    it "redirects to the todo list index page on success" do
        visit "/todo_lists"
        click_link "New Todo list"
        expect(page).to have_content("New Todo List")
    end
end

The spec_helper.rb file is in my spec directory. Also when Jason runs files from the odot directory for some reason I am unable to call them. For example he runs the programs like bin/rspec while I have to cd to the bin directory and then run rspec. Is this a problem with how my path is set up? It is very annoying. Sorry I am relatively new to the terminal. Thanks in advance.

2 Answers

Donald McLamb
Donald McLamb
2,867 Points

Hello,

try require relative, require is for gems. if that does not work then it is a directory address issue, its not looking in the right spot.

Thanks! I actually did get it to work using this method but it seems like there must be a better way. I used:

require_relative '../../spec_helper'

And then I had to call rspec from inside the bin directory with the full path of create_spec.rb all the way from the c drive. At least it worked.

I had moved into the directory where create_spec.rb was. When I backed the command prompt out to the odot directory and called rspec with the path to the subdirectory (odot>rspec spec/features/todo_lists/create_spec.rb), the error went away.