module Capybara::Lockstep::Helper

Constants

JS
JS_PATH

Public Instance Methods

capybara_lockstep(options = {}) click to toggle source
# File lib/capybara-lockstep/helper.rb, line 12
def capybara_lockstep(options = {})
  tag_options = {}

  # Add a CSRF nonce if supported by our Rails version
  if Rails.version >= '5'
    tag_options[:nonce] = options.fetch(:nonce, true)
  end

  js = capybara_lockstep_js + capybara_lockstep_config_js(options)
  javascript_tag(js, tag_options)
end
capybara_lockstep_config_js(options = {}) click to toggle source
# File lib/capybara-lockstep/helper.rb, line 24
def capybara_lockstep_config_js(options = {})
  js = ''

  if (debug = options.fetch(:debug, Lockstep.debug?))
    js += "\nCapybaraLockstep.debug = #{debug.to_json}"
  end

  if (wait_tasks = options.fetch(:wait_tasks, Lockstep.wait_tasks))
    js += "\nCapybaraLockstep.waitTasks = #{wait_tasks.to_json}"
  end

  js
end
capybara_lockstep_js() click to toggle source
# File lib/capybara-lockstep/helper.rb, line 8
def capybara_lockstep_js
  JS
end