我想知道在具有动态ID的迭代表中测试点击link_to
的最佳方法是什么?
scenario 'select customer from the list' do
sign_in_with user
visit customers_path
## and here I would like to fire this action
end
我的表格将被填充
%table.table.table-striped
%thead
%tr
%th
Name
%th
%tbody
- @customers.each do |customer|
%tr
%td
= customer.name
%td
= link_to '', root_path, class: 'glyphicon glyphicon-usd pull-right', id: "customer_#{customer.id}"
= link_to '', customer, class: 'glyphicon glyphicon-zoom-in pull-right', id: "customer_#{customer.id}"
提前致谢
答案 0 :(得分:0)
Capybara会将id与文本相匹配......
@customer = Customer.all.sample
click_link "customer_%d"%@customer.id