Sha256: 762b8b913f180f0957534d37766070812d5788940db970c317ef64baf715962d

Contents?: true

Size: 971 Bytes

Versions: 35

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

def wait_until_focussed(selector)
  wait_for do
    test = "$(document.activeElement).is('#{selector}')"
    page.driver.evaluate_script(test)
  end
end

# Make ruby wait for some condition to evaluate to true, useful for waiting on capybara
# - Provide a block evaluating a condition returning true when ruby should proceed
# - Wait max optionally overrides the default max wait time
# - Step optionally overrides the wait time for each step
def wait_for(wait_max: 3, step: 0.001, &block)
  stop_at = wait_max.seconds.from_now

  sleep step while !block.call && (@time = Time.now) < stop_at

  fail "Timeout of #{wait_max} seconds exceeded!" unless @time < stop_at
end

def allow_server_side_validation_error(always: false)
  if always || validation_run_location == :server_side
    allow_any_instance_of(Quby::Answers::Services::UpdatesAnswers).to \
      receive(:raise).with(Quby::NoServerSideValidationInTestError, anything)
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
quby-5.0.1 spec/support/feature_helpers.rb
quby-5.0.0 spec/support/feature_helpers.rb
quby-4.0.4 spec/support/feature_helpers.rb
quby-5.0.0.pre4 spec/support/feature_helpers.rb
quby-5.0.0.pre3 spec/support/feature_helpers.rb
quby-5.0.0.pre2 spec/support/feature_helpers.rb
quby-5.0.0.pre1 spec/support/feature_helpers.rb
quby-4.0.3 spec/support/feature_helpers.rb
quby-4.0.2 spec/support/feature_helpers.rb
quby-4.0.1 spec/support/feature_helpers.rb
quby-4.0.0 spec/support/feature_helpers.rb
quby-3.2.2 spec/support/feature_helpers.rb
quby-3.2.1 spec/support/feature_helpers.rb
quby-3.2.0 spec/support/feature_helpers.rb
quby-3.2.0.pre.pre1 spec/support/feature_helpers.rb