22
9

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 3 years have passed since last update.

Ruby on RailsでAbstractController::Helpers::MissingHelperError:Missing helper file が発生したときの対処法

Posted at

環境

  • macOS Version 10.13.4
  • Rails 5.2.4
  • ruby 2.4

状況

「Railsチュートリアル13.2.1 マイクロポストの描画」で
$ rails generate controller Microposts
によりMicropostコントローラを作成した後、
bin/rspecコマンドを叩くとエラーが発生しました。

エラーメッセージ

$ bin/rspec
Running via Spring preloader in process 83327

An error occurred while loading ./spec/controllers/account_activations_controller_spec.rb.
Failure/Error: require 'rspec/rails'

AbstractController::Helpers::MissingHelperError:
  Missing helper file helpers/microposts_helper.rb
# ./spec/rails_helper.rb:9:in `<main>'
# ./spec/controllers/account_activations_controller_spec.rb:1:in `<main>'
# -e:1:in `<main>'
# ------------------
# --- Caused by: ---
# LoadError:
#   No such file to load -- microposts_helper.rb
#   ./spec/rails_helper.rb:9:in `<main>'

Finished in 0.00036 seconds (files took 0.31848 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

対処法

bundle updateを実行することで解決しました。

補足

エラーについて検索すると、どうやらパス名の関係で発生するバグらしい。
私の場合、bundle updateで解決したが、それだけでは治らない場合もあるらしい。
その場合は下記ページを参考にしてみてください。
Ruby on Railsで'require': No such file to load -- ***_helper.rb(LoadError)と言われるとき

その他参考
RSpecを実行するとMissing helper fileと表示される

22
9
2

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
22
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?