Rspec'应该有标题'测试失败与Haml

时间:2011-05-06 11:05:33

标签: haml

我已经完成了教程,现在又重新开始使用Haml。 RSpec pages_controller_spec.rb "should be successful"测试所有工作。 "should have the right title"测试不起作用。 (参考教程3.3.2)在任何复制修复或refractoring之前...只重复标题。网站工作正常......只是标题测试失败了。在Rspec和Haml的各种论坛上找不到任何问题?另外,RSpec失败消息是否正常,而不是Haml?

PagesController GET 'home' should have the right title
 Failure/Error: response.should have_selector("title",
   expected following output to contain a <title>Bartel Sample App | Home</title> tag:
   <!DOCTYPE html>
   <html>
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
   <title>Bartel's Sample App | Home</title>
   </head>
   <body>
   <h1>Sample App</h1>
   <p>
   This is the home page for the
   <a href="http://growing-stream-430.heroku.com/">Bartel Sample Application.</a>
   </p>
   </body>
   </html>
 # ./spec/controllers/pages_controller_spec.rb:14:in `block (3 levels) in <top (required)>'

1 个答案:

答案 0 :(得分:0)

认为这是你的问题:

看起来您的测试正在寻找一个名为“Bartel Sample App | Home”的标题,但您的实际标题是“Bartel的Sample App | Home”。取下撇号(或将其添加到测试中),你应该是绿色的。

您应该在HTML / ERB中获取错误,而不是HAML,因为Ruby解释器不使用HAML。这只是为了您的阅读乐趣。它在运行时由HAML解释器转换为ERB / HTML。

相关问题