0

我一直在尝试执行 bundle exec rspec spec/requests/static_pages_spec.rb 但每次我尝试这样做时都会收到以下 9 个错误:

no DRb server is running. Running in local process instead ...
FFFFFFFFF

Failures:

  1) Static pages Home page should have the h1 'Sample App'
     Failure/Error: visit root_path
     NameError:
       undefined local variable or method `root_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x1047a1cc8>
     # ./spec/requests/static_pages_spec.rb:8

  2) Static pages Home page should have the base title
     Failure/Error: visit root_path
     NameError:
       undefined local variable or method `root_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x1047858e8>
     # ./spec/requests/static_pages_spec.rb:13

  3) Static pages Home page should not have a custom page title
     Failure/Error: visit root_path
     NameError:
       undefined local variable or method `root_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x10477f448>
     # ./spec/requests/static_pages_spec.rb:18

  4) Static pages Help page should have the h1 'Help'
     Failure/Error: visit help_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x1069a0bf8>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:26

  5) Static pages Help page should have the title 'Help'
     Failure/Error: visit help_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x10692e508>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:31

  6) Static pages About page should have the h1 'About Us'
     Failure/Error: visit about_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x1068fb928>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:39

  7) Static pages About page should have the title 'About Us'
     Failure/Error: visit about_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x1068bc3e0>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:44

  8) Static pages Contact page should have the content 'Contact'
     Failure/Error: visit contact_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x106b095a8>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:52

  9) Static pages Contact page should have the title 'Contact'
     Failure/Error: visit contact_path
     ActionView::Template::Error:
       undefined method `full_title' for #<#<Class:0x1069a3e98>:0x106abb740>
     # ./app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___963741010_2202798760'
     # ./spec/requests/static_pages_spec.rb:57

我重新启动了 spork 服务器并删除了 public/index.html 文件,但仍然出现错误。以下是我的 rake 路线的结果:

static_pages_home     /static_pages/home(.:format)    static_pages#home
                help GET /help(.:format)                 static_pages#help
               about GET /about(.:format)                static_pages#about
             contact GET /contact(.:format)              static_pages#contact
                     GET /static_pages/home(.:format)    static_pages#home
   static_pages_help GET /static_pages/help(.:format)    static_pages#help
  static_pages_about GET /static_pages/about(.:format)   static_pages#about
static_pages_contact GET /static_pages/contact(.:format) static_pages#contact
4

1 回答 1

0

root_path错误是因为您没有定义“根”路由。您需要共享代码以分析full_title未定义的原因。如果您正在学习 Hartl 的教程,您可能需要为此添加一个标签。

于 2013-07-26T16:46:51.360 回答