Created
September 23, 2015 15:53
-
-
Save fotinakis/a5a6515b5099335ac9a6 to your computer and use it in GitHub Desktop.
Percy wait_for_animation for JavaScript animations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.feature :homepage, js: true do | |
def finished_all_animations? | |
page.evaluate_script('$(":animated").length') == 0 | |
end | |
def wait_for_animation | |
Timeout.timeout(Capybara.default_wait_time) do | |
sleep 0.1 until finished_all_animations? | |
end | |
end | |
scenario 'user clicks toggle and section appears' do | |
visit '/' | |
find('#toggle-post-dialog').click | |
wait_for_animation | |
expect(page).to have_content('Share') | |
Percy::Capybara.snapshot(page, name: 'homepage with input') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment