1
  Error Message:PageController GET 'contact' should have the right title....

我想向更有经验的 Rubists 寻求建议。我正在关注 Michael Hartl 的 Rails 教程 3,就在第 3 章结束之前,我附上了错误消息。

我真的不知道要改什么,因为我检查了几次,我的文件和教科书里的一样。

我的代码在 Github 上可用: https ://github.com/maro9/sample_app

预先感谢您的任何帮助。

错误信息打印屏幕:http: //s11.postimage.org/pcz9us1tv/rspec_error.jpg

4

2 回答 2

1

Change this:

response.should have_selector("title",
                :content => "Ruby on Rails Tutorial Sample App|Home")  

to this:

response.should have_selector("title",
                :content => "Ruby on Rails Tutorial Sample App | Home")  

in your pages_controller_spec.rb: https://github.com/maro9/sample_app/blob/master/spec/controllers/pages_controller_spec.rb#L15

于 2012-10-07T17:54:36.580 回答
0

在您的代码中,内容中的“应用程序”是小写的,但您正在测试大写字母。

你创造了什么

"Ruby on Rails Tutorial Sample app | About"

你断言你创造了什么

"Ruby on Rails Tutorial Sample App | About"

app/views/layouts/application.html.erb 应该改变:

-            <title>Ruby on Rails Tutorial Sample app | <%= @title %></title>
+            <title>Ruby on Rails Tutorial Sample App | <%= @title %></title>
于 2012-10-07T19:29:48.840 回答