我有一个显示一些内容的应用程序,然后选择一个随机记录并显示它
我该如何测试?
Then /^I Should see the associated "([^']*)" "([^']*)"$/ do |type, elements|
elements.split(', ').each do |element|
page.should have_content element
end
end
显然失败了,因为它没有找到每条记录。如何验证仅存在一条记录??
谢谢
最佳答案
使用以下内容:
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
关于ruby-on-rails - cucumber 和 rails : testing for the presence of a random record,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14224025/