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

Version Path
agilibox-1.6.1 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.6.0 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.13 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.12 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.11 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.10 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.9 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.8 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.7 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.6 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.5 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.4 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.3 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.2 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.1 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.5.0 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.4.4 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.4.3 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.4.2 lib/agilibox/cucumber_helpers/turbolinks.rb
agilibox-1.4.1 lib/agilibox/cucumber_helpers/turbolinks.rb