Sha256: 99e07954cf5054709277894a66bc0d37abeb3f2fb70a678ccbafc9468585be7e
Contents?: true
Size: 834 Bytes
Versions: 40
Compression:
Stored size: 834 Bytes
Contents
module CapybaraWaitTurbolinksRequests def wait_turbolinks_requests(timeout = Capybara.default_max_wait_time) Timeout.timeout(timeout) do sleep 0.1 until all_turbolinks_requests_finished? end end def all_turbolinks_requests_finished? have_no_selector("html.turbolinks-load") end def turbolinks_defined? page.evaluate_script("typeof Turbolinks") != "undefined" end end World(CapybaraWaitTurbolinksRequests) # Auto wait turbolinks requests between steps AfterStep do |_scenario| if turbolinks_defined? evaluate_script %( $(document).on("turbolinks:before-visit", function(){ $("html").addClass("turbolinks-load") }) $(document).on("turbolinks:load", function(){ $("html").removeClass("turbolinks-load") }) ) wait_turbolinks_requests end end
Version data entries
40 entries across 40 versions & 1 rubygems