小编RBe*_*rgs的帖子

为什么我的RSpec测试失败,但我的应用程序正在运行?

我刚刚完成了Ruby on Rails教程的第10章,添加了编辑/更新,索引和销毁用户的功能.在我的应用程序中,一切似乎都正常工作,但是当我运行RSpec时,我的许多测试都失败了.

我设置的users_controller_spec与书的设置完全相同,我的应用程序代码也是一样的.一个问题可能是我使用Rails 3.1.1而不是他在书中使用的Rails 3.0?它对于以前的测试来说并不是一个问题,只是偶尔会出现几行不同的代码.在我开始第10.2.1节之后,问题就开始出现了.

以下是我看到的错误列表,如果您需要更多信息,请告诉我.谢谢!

1) UsersController GET 'index' for signed-in users should be successful
 Failure/Error: response.should be_success
   expected success? to return true, got false
 # ./spec/controllers/users_controller_spec.rb:31:in `block (4 levels) in <top (required)>'

2) UsersController GET 'index' for signed-in users should have the right title
 Failure/Error: response.should have_selector("title", :content => "All users")
   expected following output to contain a <title>All users</title> tag:
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
   <html><body>You are being <a href="http://test.host/signin">redirected</a>.</body></html> …
Run Code Online (Sandbox Code Playgroud)

ruby testing rspec railstutorial.org ruby-on-rails-3.1

9
推荐指数
1
解决办法
8210
查看次数