我在使用 Michael Hartl 的 Ruby on Rails 教程时遇到了一些问题。我在第 10 章结束时遇到了大量失败的测试。我已经将我的代码与 Michael 放在一起的 github repo 进行了比较,它们排成一行。这是失败的测试报告:
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 的新手,我真的不知道在失败的测试中要寻找什么。如果有人能指出我正确的方向,那将非常感激。
先谢谢了。