Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
14
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

rspecを実行した時にcannot load such file -- spec_helper (LoadError)と言われる解決方法

rspecを実行したらspec_helperが無いというエラーがでました。

rspec実行でエラー
bundle exec rspec spec/models/event_spec.rb 

/var/www/html/pugiemonn.com/spec/models/event_spec.rb:23:in `require': cannot load such file -- spec_helper (LoadError)
    from /var/www/html/pugiemonn.com/spec/models/event_spec.rb:23:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'

略

rspec:installを実行します。

generateコマンドを実行
rails generate rspec:install
      create  .rspec
       exist  spec
      create  spec/spec_helper.rb
      create  spec/rails_helper.rb

再度rspecを実行

今度は成功しました。

実際にspec_helper.rbが無かったからエラーになっていたみたいです。

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
14
Help us understand the problem. What are the problem?