Require': Cannot Load Such File -- Spec_Helper (Loaderror)

`require': cannot load such file -- spec_helper (LoadError)

You're running the specs from the spec folder. This messes up the load path. Run specs from the root of your project: ~/sheetal.

rspec spec/sheetal_spec.rb

Rspec adds the spec and lib folders to the load path automatically. If you're already in the spec folder, rspec is going to add spec/spec to the load path instead.

Assuming that you have your code in the lib folder, you would have to add both . and ../lib to the load path if you want to run your tests in the spec folder.

cannot load such file -- spec_helper.rb

The error means you are requiring the spec_helper and it can't find it.
Try this to start project and see if you have any problems.

$ mkdir test_proj && cd test_proj
$ rspec --init

Now running rspec on the spec directory (inside test_proj) should yield the correct output.

$ rspec spec/

in `require_relative': cannot load such file -- /models/task (LoadError)

There is no need to write require_relative in spec_helper.rb.
Try removing these two lines

require_relative '../models/task'
require_relative '../models/user'

model will get included automatically

Error when trying to run rspec: `require': cannot load such file -- rails_helper (LoadError)

There is some problem with rspec V3. But in your case you are using V2.

change

require 'rails_helper'

to

require 'spec_helper'

Other description find here https://teamtreehouse.com/forum/problem-with-rspec

For V3 :

If someone using rspec V3 then similar error occurs when generator not run. So before trying anything run generator.

rails generate rspec:install

If you are getting a huge list of warning on your console. Then you need to remove --warnings from .rspec file.

Rails Rspec `require': cannot load such file -- rails_helper (LoadError)

You are getting that error because you're trying to call your spec like this...

rspec mytest_spec.rb

You need to call it like this from your app's root folder , not inside the spec folder. So first get in the right folder

cd ~/
cd path_to_your_rails_app

Then call your spec

rspec spec/the_rest_of_the_path_to_your_spec/mytest_spec.rb

for instance

rspec spec/models/mytest_spec.rb


Related Topics



Leave a reply



Submit