2015-05-23 81 views
0

我在我的模型中有一个叫做状态的类,在我的页面中有一个状态选择(组合框)。我需要创建步骤定义,将数据库中的值与组合框中的值进行比较。如何将选择选项与数据库值进行比较?

我已经能够通过它的ID找到组合框,但我无法找到比较每个选项的方法。

expect(page.find_by_id('patient_state_id')) 

我该怎么做?

回答

0

我已经能够用下面的代码来解决这个问题:

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 
相关问题