我有一个应用程序显示一些内容,然后选择一个随机记录并显示它
我该如何测试?
Then /^I Should see the associated "([^']*)" "([^']*)"$/ do |type, elements|
elements.split(', ').each do |element|
page.should have_content element
end
end
显然失败了,因为它找不到每条记录。如何验证仅存在一条记录?
由于
答案 0 :(得分:1)
使用以下内容:
Then /^I should see the associated "([^"]*)" "([^"]*)"$/ do |type, elements|
found = false
elements.split(', ').each do |element|
found = true if page.has_content? element
end
found.should == true
end