Sha256: 4b43e8dd6a4096801c781167b7844becc3ceb13aac4b6c73924eb120a4b826cf

Contents?: true

Size: 754 Bytes

Versions: 4

Compression:

Stored size: 754 Bytes

Contents

module CucumberWaitTurbolinksRequests
  def wait_turbolinks_requests
    Timeout.timeout(Capybara.default_max_wait_time) do
      sleep 0.1 until all_turbolinks_requests_finished?
    end
  end

  def all_turbolinks_requests_finished?
    have_selector("body.turbolinks-load")
  end
end

World(CucumberWaitTurbolinksRequests)

# Auto wait turbolinks requests between steps
AfterStep do |scenario|
  if page.evaluate_script('typeof Turbolinks') != "undefined"
    evaluate_script %(
      $(document).on("turbolinks:before-visit", function(){
        $("body").addClass("turbolinks-load")
      })

      $(document).on("turbolinks:load", function(){
        $("body").removeClass("turbolinks-load")
      })
    )

    wait_turbolinks_requests
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dorsale-3.1.5 features/support/turbolinks.rb
dorsale-3.1.4 features/support/turbolinks.rb
dorsale-3.1.3 features/support/turbolinks.rb
dorsale-3.1.2 features/support/turbolinks.rb