前提・実現したいこと
railsチュートリアルの10章最後の統合テストが通らず、躓いております。
リンク内容
<delete> expected but was <User 19>.. の意味がまったくもってわかりません。
(User 19)のページが無いということかと思いましたが、よくわかりません。
エラーを解消するにはどのようにすればよろしいでしょうか?
発生している問題・エラーメッセージ
$ rails test Running via Spring preloader in process 8756 Started with run options --seed 46978 FAIL["test_index_as_admin_including_pagination_and_delete_links", UsersIndexTest, 1.1899467500006722] test_index_as_admin_including_pagination_and_delete_links#UsersIndexTest (1.19s) <delete> expected but was <User 19>.. Expected 0 to be >= 1. test/integration/users_index_test.rb:19:in `block (2 levels) in <class:UsersIndexTest>' test/integration/users_index_test.rb:16:in `block in <class:UsersIndexTest>'
users_index_test.rb
require 'test_helper' class UsersIndexTest < ActionDispatch::IntegrationTest def setup @admin = users(:michael) @non_admin = users(:archer) end test "index as admin including pagination and delete links" do log_in_as(@admin) get users_path assert_template 'users/index' assert_select 'div.pagination' first_page_of_users = User.paginate(page: 1) first_page_of_users.each do |user| assert_select 'a[href=?]', user_path(user), text: user.name unless user == @admin assert_select 'a[href=?]', user_path(user), text: 'delete' end end assert_difference 'User.count', -1 do delete user_path(@non_admin) end end test "index as non-admin" do log_in_as(@non_admin) get users_path assert_select 'a', text: 'delete', count: 0 end end
index.html.erb
<% provide(:title, 'All users') %> <h1>All users</h1> <%= will_paginate %> <ul class="users"> <% @users.each do |user| %> <%= render @users %> <% end %> </ul> <%= will_paginate %>
_user.html.erb
<li> <%= gravatar_for user, size: 50 %> <%= link_to user.name, user %> </li>
補足情報(FW/ツールのバージョンなど)
AWS Cloud9
Google Chrome
回答1件
あなたの回答
tips
プレビュー