# env.rb or spec_helper.rb
Capybara.register_driver :poltergeist do |app|
opts = {
extensions: ["#{Rails.root}/features/support/phantomjs/disable_animations.js"] # or wherever
}
Capybara::Poltergeist::Driver.new(app, opts)
end
Capybara.javascript_driver = :poltergeist
// disable_animations.js
var disableAnimationStyles = '-webkit-transition: none !important;' +
'-moz-transition: none !important;' +
'-ms-transition: none !important;' +
'-o-transition: none !important;' +
'transition: none !important;'
window.onload = function() {
var animationStyles = document.createElement('style');
animationStyles.type = 'text/css';
animationStyles.innerHTML = '* {' + disableAnimationStyles + '}';
document.head.appendChild(animationStyles);
};
This approach looked really good, but only almost worked for me!
What I found is that on at least one failing spec, the onload hook was intermittently running after my spec actions had started (i.e. finding and clicking on things). Any good approaches for making certain that this has run before moving forward in the spec?
Consider at least the cases of:
page.visit
or similar.Also consider that I'd like to not require developers to special case any code on each example, which would really get complicated around (2).