20
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-08-11

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が無かったからエラーになっていたみたいです。

参考

20
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?