我已经四处搜索,没有发现任何遇到过类似问题的人,所以我想在这里发帖。
我的测试全部通过,直到上市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
非常赞赏任何指导。
答案 0 :(得分:2)
清单9.42中引入了失败的示例,而不是代码清单9.40。它们应该作为"index"
示例的一部分插入,但您已将它们作为顶级"User Pages"
示例的一部分插入。
因此,第一个用户是作为管理员用户而不是普通用户创建的,这会破坏您的结果。
如果你忠实地坚持每个缩进两个空格的Ruby缩进惯例,这种问题更容易避免/检测。