2015-10-20 35 views
0

我有2个下拉列表和第一个预先填充第二个下拉列表(这是在骨干中完成)的变化。更改事件没有得到触发与poltergeist

events: -> 
    'change #client_id': 'selectedClientChange' 

    selectedClientChange: (ev) -> 
    @populateGroups $(ev.target.selectedOptions).val() 

与骚灵,但变化事件同一份书面水豚的规格是没有得到触发某些原因和规格是越来越失败。

scenario 'it should populate the groups automatically', js: true, speed: :slow do 
    click_link 'New Item' 
    find('#name').set('Sample Item') 
    page.execute_script("$('#client_id').val('testing').trigger('change')") 
    select "#{client.name}", from: "client_id" 
    groups = find('#group_id').all('option').collect(&:text) 
    expect(groups.count).to eq 1 
    expect(groups).to include pg.name 
end 

有人可以告诉我如何解决这个问题。

+0

你得到了什么错误(以及场景的哪一步)? –

回答

0

没有关于你得到的错误的细节大多是猜测 - 你可能在select事件发生之前得到这些组实际更新它们。你会更好使用have_select匹配,因为它会重试了一段时间,看看是否领域的变化相匹配的要求

select "#{client.name}", from: "client_id" 
expect(page).to have_select('group_id', options: [pg.name])