My rails-app contain rspec-tests using Capybara poltergeist (which uses phantomjs). Frontend is Backbone.js. Some tests are sometimes passed, sometimes not. Debugging shows that the right content is not loaded at the time of inspection. If i add an delay, e.c. sleep (inspection_time = 1), then the test passes.
describe 'Direct visit page / # / desk / page / [ID]' do
before {sign_in user}
it 'should contain page title' do
visit "/#/desk/pages/#{page.id}"
#sleep (inspection_time = 1)
expect (page) .to have_css (". page-detail p.title",: text => page.title)
end
end
js-tests are performed and so long, and yet unreliable delay increases execution time. Is there a good solution for drivers poltergeist (gem 'poltergeist', '1.6.0')?
Might be worth abandon poltergeist in favor of, for example capybara-webkit?