1. kiyodori

    Posted

    kiyodori
Changes in title
+RSpecを実行するとMissing helper fileと表示される
Changes in tags
Changes in body
Source | HTML | Preview
@@ -0,0 +1,85 @@
+
+## 問題
+RSpecを実行したところ、下記のエラーが表示された。
+
+```
+$ bundle exec rspec spec
+/home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/abstract_controller/helpers.rb:154:in `rescue in block in modules_for_helpers': Missing
+helper file helpers//home/websites/sites/app/helpers/application_helper.rb_helper.rb (AbstractController::Helpers::MissingHelperError)
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/abstract_controller/helpers.rb:151:in `block in modules_for_helpers'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/abstract_controller/helpers.rb:147:in `map!'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/abstract_controller/helpers.rb:147:in `modules_for_helpers'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/abstract_controller/helpers.rb:111:in `helper'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionpack-4.1.5/lib/action_controller/railties/helpers.rb:17:in `inherited'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionview-4.1.5/lib/action_view/test_case.rb:9:in `<class:TestCase>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionview-4.1.5/lib/action_view/test_case.rb:8:in `<module:ActionView>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/actionview-4.1.5/lib/action_view/test_case.rb:6:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails/example/helper_example_group.rb:9:in `<module:HelperExampleGro
+up>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails/example/helper_example_group.rb:6:in `<module:Rails>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails/example/helper_example_group.rb:4:in `<module:RSpec>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails/example/helper_example_group.rb:3:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails/example.rb:4:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.1.0/lib/rspec/rails.rb:8:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
+ from /HOME/websites/sites/spec/rails_helper.rb:12:in `<top (required)>'
+ from /HOME/websites/sites/spec/controllers/admin/messages_controller_spec.rb:1:in `require'
+ from /HOME/websites/sites/spec/controllers/admin/messages_controller_spec.rb:1:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:66:in `rescue in run'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:62:in `run'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/bin/rspec:23:in `load'
+ from /home/websites/sites/vendor/bundle/ruby/2.2.0/bin/rspec:23:in `<main>'F
+```
+
+## 原因
+どうもruby 2.2.0.から発生するバグらしい。
+
+まず、rails consoleでパスを確認する。
+
+```
+$ rails console
+[1] pry(main)> File.expand_path ("./")
+=> "/HOME/websites/sites"
+```
+
+次に、rails consoleを終了してターミナルで現在のパスを調べる。
+
+```
+$ pwd
+/home/websites/sites
+```
+
+なぜかファイル名が違う。active supportの正規表現のバグみたい。
+
+## 解決策
+名前を付け直してやるとエラーが発生しなくなった。
+
+```
+$ mv /home /home1
+$ mv /home1 /home
+```
+
+もしくは、大文字になっているファイルを一度rmして、再度作りなおすのでも大丈夫みたい。
+
+## 参考
+[Strange error in rails - missing helper](http://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper)