I'm trying to get the syntax just right. I think I'm close but I'm trying to make a test to show that my admin can destroy a user. The error I get right now is :
Ambiguous match, found 2 elements matching link or button "delete
and I totally understand that. That means I get to the users index page and I see the delete button for a regular user and the admin. How do I exactly specify which user I want to click the delete button on so I can delete them in the test.
here is my users.yml file
user:
name: user
email: user@examle.com
admin: false
password_digest: <%= BCrypt::Password.create('password') %>
admin:
name: admin
email: admin@admin.com
admin: true
password_digest: <%= BCrypt::Password.create('password') %>
here is my admin_test.rb file
require "test_helper"
feature "as a blog owner I want a working user delete so I can remove trolls" do
scenario 'admin can delete profile' do
visit new_session_path
fill_in 'Email', with: users(:admin).email
fill_in 'password', with: 'password'
click_on 'Log In'
visit users_path(:admin)
click_on 'delete'
click_on 'OK'
page.must_have_content "User deleted"
end
end
I think the problem is caused on the line
click_on 'delete'
anyone know what the right syntax is or what I'm messing up?