javascript - Rails capybara visiting unrelated page causes test to fail -
i've got got page ajax code i'm trying build spec using capybara. test works:
context 'from jobspec#index page' scenario 'clicks run link' visit job_specs_path within( find('tr', text: @job_spec.name) ) { click_link 'run_now' } visit current_path expect(find('tr', text: @job_spec.name)).to have_content(/(running|success)/) end end
after clicking link 'run_now', job launched , user redirected launched_jobs_path
, has datatable uses ajax pull running jobs. test passes. however, wanted add together test check create sure job wasn't running before clicking 'run_now' button (which give me false positive). started playing around it, noticed putting visit launched_jobs_path
before visit job_specs_path
cause test fail error
failure/error: expect(find('tr', text: @job_spec.name)).to have_content(/(running|success)/) capybara::elementnotfound: unable find css "tr" text "job_spec_collection-1"
i'm issue javascript not running @ right time, don't quite know how resolve it. ideas? rails 4.1 capybara 2.4, , capybara-webkit 1.3.
thanks!
update
in parent context of spec, have :js => true
feature 'user runs jobspec now', :js => true before capybara.current_driver = :webkit @job_spec = factorygirl.create(:job_spec, :with_client_spaces) end after { capybara.use_default_driver } context 'from jobspec#index page' ... end end
i think might simple adding :js => true scenario header knows launch webkit / selenium test js / ajax.
scenario 'clicks run link', :js => true
hope helps!
update
well here's 1 more idea. seek adding 'rails_helper' or 'spec_helper' file set :js driver.
capybara.javascript_driver = :webkit
do have other :js tests working :webkit? have tried using save_and_open_page see if element looking on page , capybara isn't finding it?
javascript jquery ruby-on-rails ajax capybara
No comments:
Post a Comment