Rails Rspec `require': cannot load such file -- rails_helper (LoadError)
For others who find this:
I got this error, 'require': cannot load such file -- rails_helper (LoadError)
, when I had included the rspec-rails gem but hadn't run rails generate rspec:install
which generates the spec/rails_helper.rb
file. So if the other solution doesn't help you, make sure you've done that.
For those that the answers above didn't help:
You just need to add gem 'rexml'
to your Gemfile.rb
, run bundle install
and try again.
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