我正在運行Rails 3.0.1和Rspec 2.0.1。我正在關注M. Hartl的Ruby on Rails教程,並對第5課中的失敗測試存在問題:填充佈局。Rails 3 + Rspec 2.0.1自動測試失敗:Ruby on Rails教程作者:M. Hartl
當我運行自動測試,並不斷得到這個錯誤並且似乎無法figoure爲什麼:
Failures:
1) UsersController GET 'new' should have the right title
Failure/Error: response.should have_selector('title', :content => "Sign Up")
expected following output to contain a <title>Sign Up</title> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Ruby on Rails Tutorial Sample App | Sign up</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js""></script>
<![endif]--><link href="/stylesheets/blueprint/screen.css?1313951692" media="screen" rel="stylesheet" type="text/css">
<link href="/stylesheets/blueprint/print.css?1313951692" media="media" rel="stylesheet" type="text/css">
<!--[if lt IE 8]><link href="/stylesheets/blueprint/ie.css?1313951692" media="screen" rel="stylesheet" type="text/css" /><[endif]--><link href="/stylesheets/custom.css?1319319986" media="screen" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<nav class="round"><ul>
<li><a href="/">Home</a></li>
<li><a href="/help">Help</a></li>
<li><a href="#">Sign in</a></li>
</ul></nav></header><section class="round"><h1>Users#new</h1>
<p>Find me in app/views/users/new.html.erb</p>
</section><footer><nav class="round"><ul>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="http://news.railstutorial.org">News</a></li>
<li><a href="http://railstutorial.org">Rails Tutorial</a></li>
</ul></nav></footer>
</div>
</body>
</html>
# ./spec/controllers/users_controller_spec.rb:14:in `block (3 levels) in <top (required)>'
多麼疏忽...感謝諾亞! – TomK
@TomKim是的,我們都這樣做。不久之前(不到一週前),我在教程中做了完全相同的事情。另外,我看到你是新來的。我的答案旁邊有一個灰色複選標記,如果我提供了正確的解決方案,則應檢查它是否顯示此問題具有可接受的答案。如果您在未來提出問題,如果您的答案百分比很高,則更有可能得到更好的答覆。 –