繁体   English   中英

Ruby on Rails教程第10章帮助-测试失败

[英]Ruby on Rails Tutorial Chapter 10 help- Failing Test

我在Michael Hartl撰写的Ruby on Rails教程中遇到了一些麻烦。 我到了第10章的结尾,并且得到了大量失败的测试。 我已经将我的代码与Michael放在一起的github回购代码进行了比较,它们排列在一起。 这是失败的测试报告:

  1) Authentication signin with valid information 
     Failure/Error: click_button "Sign in"
     ActionView::Template::Error:
       Missing partial shared/stats with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
         * "/Users/bobbysudekum/Documents/Projects/rails/Secondattempt/sample_app_three/app/views"
     # ./app/views/users/show.html.erb:11:in `_app_views_users_show_html_erb___2309319721249673303_70162631795520'
     # (eval):2:in `click_button'
     # ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'

  2) Authentication signin with valid information 
     Failure/Error: click_button "Sign in"
     ActionView::Template::Error:
       Missing partial shared/stats with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
         * "/Users/bobbysudekum/Documents/Projects/rails/Secondattempt/sample_app_three/app/views"
     # ./app/views/users/show.html.erb:11:in `_app_views_users_show_html_erb___2309319721249673303_70162631795520'
     # (eval):2:in `click_button'
     # ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'

  3) Authentication signin with valid information 
     Failure/Error: click_button "Sign in"
     ActionView::Template::Error:
       Missing partial shared/stats with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
         * "/Users/bobbysudekum/Documents/Projects/rails/Secondattempt/sample_app_three/app/views"
     # ./app/views/users/show.html.erb:11:in `_app_views_users_show_html_erb___2309319721249673303_70162631795520'
     # (eval):2:in `click_button'
     # ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'

     # REMOVED 43 more identical errors

从github移植的视图

<% provide(:title, @user.name) %>
<div class="row">
  <aside class="span4">
    <section>
      <h1>
        <%= gravatar_for @user %>
        <%= @user.name %>
      </h1>
    </section>
    <section>
      <%= render 'shared/stats' %>
    </section>
  </aside>
  <div class="span8">
    <%= render 'follow_form' if signed_in? %>
    <% if @user.microposts.any? %>
      <h3>Microposts (<%= @user.microposts.count %>)</h3>
      <ol class="microposts">
        <%= render @microposts %>
      </ol>
      <%= will_paginate @microposts %>
    <% end %>
  </div>
  </div>
</div>

很抱歉,不包含示例代码-超出了字符数限制。 请查阅github- https://github.com/rsudekum/sample_app_three上的其余代码

作为Rails / ruby​​的新手,我真的不知道在失败的测试中要寻找什么。 如果有人可以指出正确的方向,那将是非常有义务的。

提前致谢。

请参阅我的请求请求: https : //github.com/rsudekum/sample_app_three/pull/1

这是我克隆应用程序并调查错误时的注意事项。 请注意,在发布对答案的评论之前 ,我已经开始调查,因此我可能已经注意到您已经知道的事情。 无论如何,所有规格现在都在我的计算机上通过。 在第10章的末尾,我试图使应用程序类似于本教程的状态,但是我从来没有遵循本教程,因此它可能并不完全匹配。

第一次迁移20120711232738_create_users.rb似乎已将其整个文件内容替换为20120714233631_create_microposts.rb的内容。 (意外复制粘贴?)恢复其原始内容可解决迁移问题。

缺少views/shared/_stats.html.erb的部分内容。 既然您说您刚刚完成了第10章,并且直到第11章才介绍此部分,所以我决定注释掉它的引用,而不是更新该部分本身,因为该部分引用了直到第11章才讨论的内容。

同上的follow_form部分。

根据清单10.42和10.47, shared/feedshared/feed_item部分不正确。 我更正了它们以反映这些列表。

您忘记了分配用户object: f.object来自users/edit.html.erb渲染error_messages部分。

您在users/_user.html.erb使用了confirm: "..." 可以,但是已弃用,因此我将其更改为data: { confirm: "..." }

confirm microposts/_microposts.html.erb

您忘记为SessionsController#destroy添加代码。 清单8.29对此进行了介绍。 我加了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM