ruby - Why is spec failing? -


i have 2 specs. 1 written using defaults (i think selenium default?) , other using webkit. same, 1 fails other doesn't

spec

let(:admin) {create(:user, :admin)}   let(:programme) { create(:programme, :full_payment_scheme) }    before(:each)     login_as(admin)     visit edit_programme_path(programme)   end    scenario 'adding payment_scheme', js: true       new_payment_scheme = create(:payment_scheme)       visit edit_programme_path(programme)       click_link 'add payment scheme'       select new_payment_scheme.name, from: all('select[id*="programme_programme_payment_schemes_attributes"][id*="payment_scheme_id"]').last[:id]       fill_in all('input[id*="programme_programme_payment_schemes_attributes"][id*="markup"]').last[:id], with: 50       fill_in all('input[id*="programme_payment_scheme_allocations_attributes"][id*="interval_weeks"]').last[:id], with: 10       fill_in all('input[id*="programme_payment_scheme_allocations_attributes"][id*="allocation"]').last[:id], with: 100        expect {click_button "save"}.to change{programmepaymentscheme.count}.by(1)   end 

the javascript in spec above happens on click_link 'add payment scheme'. adds controls payment scheme page , these filled in. note know ids strange, when use nested attributes , add controls dynamically page id has random part in (usually calculated of date). can't use direct id. have use funky css selector.

results default

programme edit page   editing payment_scheme     adding payment_scheme  finished in 8.57 seconds (files took 1.25 seconds load) 1 example, 0 failures  top 1 slowest examples (7.6 seconds, 88.7% of total time):   programme edit page editing payment_scheme adding payment_scheme     7.6 seconds ./spec/features/programmes/programme_edit_spec.rb:48 ryanme@ryan-mes-macbook-pro ~/sites/phoenix ±20487304354485⚡ »  rspec spec/features/programmes/programme_edit_spec.rb 

results webkit

programme edit page   editing payment_scheme     adding payment_scheme (failed - 1)  failures:    1) programme edit page editing payment_scheme adding payment_scheme      failure/error: expect {click_button "save"}.to change{programmepaymentscheme.count}.by(1)        expected result have changed 1, changed 0      # ./spec/features/programmes/programme_edit_spec.rb:57:in `block (3 levels) in <top (required)>'      # -e:1:in `<main>'  finished in 3.8 seconds (files took 0.53482 seconds load) 1 example, 1 failure  failed examples:  rspec ./spec/features/programmes/programme_edit_spec.rb:48 # programme edit page editing payment_scheme adding payment_scheme  top 1 slowest examples (3.48 seconds, 91.5% of total time):   programme edit page editing payment_scheme adding payment_scheme     3.48 seconds ./spec/features/programmes/programme_edit_spec.rb:48 

when save , open page using launchy, see reason it's not filling in payment scheme fields. functionality works fine using selenium. have tried reworking test, no luck there.

i think everything. input appreciated.

it couple of things

the obvious having async problems because you're using capybara. capybara/test thread tells browser click button , continues on. doesn't wait else happen, browser still working on js , sending out request application example. solve sleep or trigger listen for.

it js button click or code handling js request not doing should be.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -