2016-09-16 129 views
2

試圖在railstutorial.org上執行Rails教程。我目前正在教程的測試部分,並且在執行測試時,我一直在收到錯誤。我用'生成StaticPages控制器'命令創建的測試文件是一樣的,我根本沒有修改它。當我在命令中輸入「軌道測試」我得到這個錯誤:Rails測試將無法正常工作

/Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:152:in `rescue in block in modules_for_helpers': Missing helper file helpers//users/user/programming/odin/rails/sample_app/app/helpers/application_helper.rb_helper.rb (AbstractController::Helpers::MissingHelperError)

這裏是追溯:

from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:149:in block in modules_for_helpers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:145:in map!' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:145:in modules_for_helpers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/helpers.rb:93:in modules_for_helpers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/helpers.rb:109:in helper' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/railties/helpers.rb:17:in inherited' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:11:in <class:TestCase>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:10:in ' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/test_case.rb:8:in <top (required)>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in block in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in load_dependency' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/rails-controller-testing-0.1.1/lib/rails-controller-testing.rb:16:in block in ' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:in instance_eval' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:in execute_hook' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in each' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:215:in ' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:139:in <module:ActionView>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.1/lib/action_view/base.rb:10:in ' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in block in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in load_dependency' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/debug_exceptions.rb:5:in <top (required)>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in block in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in load_dependency' from /Users/user/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:48:in block in build_stack' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:13:in tap' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/default_middleware_stack.rb:13:in build_stack' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:504:in default_middleware_stack' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:506:in block in app' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:504:in synchronize' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:504:in app' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:37:in block in <module:Finisher>' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in instance_exec' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in run' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in block in tsort_each' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in each_strongly_connected_component_from' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in block in each_strongly_connected_component' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in each' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in call' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in each_strongly_connected_component' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in tsort_each' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in tsort_each' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in run_initializers' from /Users/user/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in initialize!' from /Users/user/Programming/Odin/rails/sample_app/config/environment.rb:5:in ' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:92:in require' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:92:in preload' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:in serve' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in block in run' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in loop' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in run' from /Users/user/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in <top (required)>' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /Users/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from -e:1:in '

如果被格式化,並imporperly詢問或什麼不是我道歉,任何幫助將不勝感激我絕對難住。 這裏是GitHub庫:https://github.com/JDjedi/sample_app

Rails的版本是5.0和Ruby版本是2.3.0p0

回答

0

application_helper.rb_helper.rb - 這就是你怎麼稱呼你的助手? .rb是一個擴展。因此,您可以將幫助文件的名稱更改爲application_helper.rb並查看是否有效?

編輯:

你看這個問題嗎? Rails: AbstractController::Helpers::MissingHelperError - Missing helper file application_helper.rb_helper.rb

這裏似乎是一個工作的答案:https://stackoverflow.com/a/28269245/1010826

根文件夾只需重命名同名。不知道爲什麼這會工作,雖然:)

+0

在目錄中它被寫爲'application_helper.rb'。我將在原始文章中提供對github回購的擴展。 – JCD

+0

@JCD更新回答 – Magnuss

+0

原諒我的無知,但我仍然不明白 – JCD

相關問題