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

后端 未结 13 747
青春惊慌失措
青春惊慌失措 2020-12-13 03:13

I am trying to run rspec for Ruby on Rails. I am running Rails 4.1.1. I have installed the gem, have established a spec folder with some tests. I have created a directory

13条回答
  •  借酒劲吻你
    2020-12-13 03:51

    I had the same error but there was no reference to rails_helper anywhere and we weren't even using rails.

    However, I eventually found that my ~/.rspec was requiring rails_helper (presumably from creating rails app in the past) which was causing the issue ...

    $ cat ~/.rspec
    --color
    --format documentation
    --require spec_helper
    --require rails_helper
    

    The fix is as simple as removing that line. Hope this helps someone else grappling with the same issue!

提交回复
热议问题