`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
Rails: How to Check If a Column Has a Value
In Ruby or Rails, Why Is "Include" Sometimes Inside the Class and Sometimes Outside the Class
Exception_Notification for Delayed_Job
How Can One Set Property Values When Initializing an Object in Ruby
Log Doesn't Work in Production with Delayed Job
Ruby: How to Check If a String Contains Multiple Items
Rails Routes: Get Without Param :Id
Ruby Scope of Data After _End_
How to Get a List of Gems That Are Installed That Have Native Extensions
Is It a Good Idea to Purge Old Rails Migration Files
Clicking a Button with Ruby Mechanize
How to Add "Somewhere" a 'Before(:Each)' Hook So That All Spec File Can Run It
Specifying Content Type in Rspec
Rails Script Segmentation Fault with Rvm
What Is the Purpose of Redo and Retry Statements in Ruby
Ruby: What Is the Order of Keys/Values Returned by Hash.Keys and Hash.Values Methods