2015-10-20 36 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])