由于未知原因导致Rails教程ch 9结束的失败Rspec测试
我搜索了四周并且没有发现任何遇到类似问题的人,所以我想在此处发布它。由于未知原因导致Rails教程ch 9结束的失败Rspec测试
我的测试全部结束,直到列表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=>"https://stackoverflow.com/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
大部分apprecitated任何指导。
回答:
在代码9.42中引入了失败的例子,而不是代码清单9.40。它们应该作为"index"
示例的一部分插入,但您已将它们作为顶级"User Pages"
示例的一部分插入。
因此,第一个用户是作为管理员用户而不是普通用户创建的,因此会导致您的结果出现问题。
如果您忠实地遵守Ruby的每个缩进两个空格的缩进约定,则此类问题更容易避免/检测。
以上是 由于未知原因导致Rails教程ch 9结束的失败Rspec测试 的全部内容, 来源链接: utcz.com/qa/261498.html