由于呈现内容不匹配,集成测试失败

时间:2015-03-15 20:50:57

标签: ruby-on-rails ruby ruby-on-rails-4 testing integration-testing

当我登录我的ruby应用程序时,第一页网址为http://localhost:3000/tree_display/list。因此,当我运行测试以断言相同时,我收到此错误。

[user1 project]$  rake test
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
Started

 FAIL["test_login_and_access_bookmarks/managing_bookmarks", BookmarksTest, 0.678676891]
 test_login_and_access_bookmarks/managing_bookmarks#BookmarksTest (0.68s)
        expecting <"tree_display/list"> but rendering with <["content_pages/view", "shared/_header", "shared/_navigation", "auth/_login", "shared/_flash_messages", "shared/_footer_message", "layouts/application"]>
        test/integration/bookmarks_test.rb:15:in `block in <class:BookmarksTest>'

  1/1: [=========================================================================================================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.68149s
1 tests, 2 assertions, 1 failures, 0 errors, 0 skips
[user1 project]$  

正在使用<["content_pages/view", "shared/_header", "shared/_navigation", "auth/_login", "shared/_flash_messages", "shared/_footer_message", "layouts/application"]>进行渲染。当我输入用户名和密码然后我转到http://localhost:3000/tree_display/list

时,这些应该在第一页上

我注意到会话变量包含:@host="www.example.com", 这里有什么问题?为什么不渲染tree_display / list?感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

测试中可能登录失败,或者在测试的前一页断言时需要时间登录。尝试在断言和登录步骤中添加延迟。