【发布时间】:2015-03-17 20:26:15
【问题描述】:
我已经坚持了将近 4 个小时。在本章中,我们被要求第一次运行测试。它正在输出两个错误,我不明白它们是什么。
这些是错误:
Finished in 0.097197s, 20.5768 runs/s, 0.0000 assertions/s.
1) Error:
StaticPagesControllerTest#test_should_get_help:
AbstractController::Helpers::MissingHelperError: Missing helper file helpers//users/kevinmulhern/documents/the_odin_project/ruby_on_rails/sample_app/app/helpers/application_helper.rb_helper.rb
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/static_pages_controller.rb:1:in `<top (required)>'
2) Error:
StaticPagesControllerTest#test_should_get_home:
ActionView::MissingTemplate: Missing template static_pages/home, application/home with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/kevinmulhern/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates"
* "/Users/kevinmulhern/documents/the_odin_project/ruby_on_rails/sample_app/app/views"
* "/Users/kevinmulhern/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0.beta3/app/views"
test/controllers/static_pages_controller_test.rb:5:in `block in <class:StaticPagesControllerTest>'
2 runs, 0 assertions, 0 failures, 2 errors, 0 skips
我最终抓取了该应用程序,因为无论如何我并没有深入了解它,然后复制并粘贴到我卡住的部分,我不认为这可能是导致这种情况的错字。
这是静态页面的控制器
class StaticPagesController < ApplicationController
def home
end
def help
end
end
最后是测试文件:
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
end
test "should get help" do
get :help
assert_response :success
end
end
任何帮助都将不胜感激。
删除助手后更新错误:
1) Error:
StaticPagesControllerTest#test_should_get_home:
ActionView::MissingTemplate: Missing template static_pages/home, application/home with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/kevinmulhern/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates"
* "/Users/kevinmulhern/documents/the_odin_project/ruby_on_rails/sample_app/app/views"
* "/Users/kevinmulhern/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0.beta3/app/views"
test/controllers/static_pages_controller_test.rb:5:in `block in <class:StaticPagesControllerTest>
更新
我将项目移动到我的主目录,这解决了问题。我的目录结构一定有问题。
【问题讨论】:
标签: ruby-on-rails ruby