我的模型中有一个叫做State的类,而页面中有一个state选择(组合框)。我需要创建将数据库中的值与组合框中的值进行比较的步骤定义。
我已经能够通过其ID找到组合框,但是我找不到一种比较每个选项的方法。
expect(page.find_by_id('patient_state_id'))
我怎样才能做到这一点?
我已经可以使用以下代码解决此问题:
Given(/^I am an application user$/) do
end
When(/^I display the patient registration form$/) do
visit('/patients/new')
end
Then(/^I should be able see the list of registered states$/) do
states = State.pluck(:description)
page.find_by_id('patient_state_id').all('option').each do |el|
expect(states).to include(el.text)
end
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句