Sha256: 762b8b913f180f0957534d37766070812d5788940db970c317ef64baf715962d

Contents?: true

Size: 971 Bytes

Versions: 34

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

34 entries across 34 versions & 1 rubygems

Version Path
quby-5.6.6 spec/support/feature_helpers.rb
quby-5.6.5 spec/support/feature_helpers.rb
quby-5.6.3 spec/support/feature_helpers.rb
quby-5.6.2 spec/support/feature_helpers.rb
quby-5.6.1 spec/support/feature_helpers.rb
quby-5.6.0 spec/support/feature_helpers.rb
quby-5.5.0 spec/support/feature_helpers.rb
quby-5.4.0 spec/support/feature_helpers.rb
quby-5.3.1 spec/support/feature_helpers.rb
quby-5.3.0 spec/support/feature_helpers.rb
quby-5.2.0 spec/support/feature_helpers.rb
quby-5.1.3 spec/support/feature_helpers.rb
quby-5.1.2 spec/support/feature_helpers.rb
quby-5.1.1 spec/support/feature_helpers.rb
quby-5.1.0 spec/support/feature_helpers.rb
quby-5.0.5 spec/support/feature_helpers.rb
quby-5.0.4 spec/support/feature_helpers.rb
quby-5.0.3 spec/support/feature_helpers.rb
quby-5.0.2 spec/support/feature_helpers.rb
quby-5.0.1 spec/support/feature_helpers.rb