I have the following test in a request spec:
page.should have_link('Edit user', :href => edit_users_path(@user))
This checks that a specific user in an index view has an edit link. I would like to click the same link, with something like:
click_link('Edit user', :href => edit_users_path(@user))
Unfortunately click_link doesn't accept options.
Is there a good way to do this, it seems like a fairly obvious use case?
Should I be including an #id in the table <tr>
or <td>
and doing something like:
within(#user_id)
click_link 'Edit user'
end
I'd prefer not to tinker with the view just to get the tests to work.
you can use find find(:xpath, "//a[@href='/foo']").click