簡體   English   中英

由於未知原因,在Rails Tutorial ch 9結束時失敗的Rspec測試

[英]Failing Rspec tests at the end of Rails Tutorial ch 9 for unknown reason

我已經四處搜索,沒有發現任何遇到類似問題的人,所以我想在這里發布。

我的測試全部通過,直到上市9.40。 我在9.40和9.46之間發布了所有文件輸入,但我相信我正在按照教程准確地進行操作。

錯誤:

 1) User_pages delete links as an admin user 
     Failure/Error: it { should have_link('delete', href: user_path(User.first)) }
       expected #has_link?("delete", {:href=>"/users/211"}) to return true, got false
     # ./spec/requests/user_pages_spec.rb:45:in `block (4 levels) in <top (required)>'

  2) User_pages delete links as an admin user should be able to delete another user
     Failure/Error: click_link('delete', match: :first)
     Capybara::ElementNotFound:
       Unable to find link "delete"
     # ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'
     # ./spec/requests/user_pages_spec.rb:47:in `block (4 levels) in <top (required)>'

Finished in 8.95 seconds
84 examples, 2 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:45 # User_pages delete links as an admin user 
rspec ./spec/requests/user_pages_spec.rb:46 # User_pages delete links as an admin user should be able to delete another user

我的文件:

https://gist.github.com/ephunit/261670a9fbfe0f3ad471

對任何指導都非常贊賞。

清單9.42中引入了失敗的示例,而不是代碼清單9.40。 它們應該作為"index"示例的一部分插入,但是您將它們作為頂級"User Pages"示例的一部分插入。

因此,第一個用戶是作為管理員用戶而不是普通用戶創建的,這會破壞您的結果。

如果你忠實地堅持每個縮進兩個空格的Ruby縮進約定,這種問題更容易避免/檢測。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM